Work on adding image upload to add-show form
This commit is contained in:
parent
cc3ddb40ea
commit
cb80423fdd
|
@ -1,2 +1,8 @@
|
|||
.*
|
||||
*.pyc
|
||||
*~$
|
||||
*log.*
|
||||
**/airtime_analyzer.egg-info/*
|
||||
**/build/*
|
||||
**/dist/*
|
||||
*~
|
||||
|
|
|
@ -580,6 +580,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$log_vars["params"]["form_data"] = $data;
|
||||
Logging::info($log_vars);
|
||||
|
||||
$request = $this->getRequest();
|
||||
Logging::info($request);
|
||||
|
||||
$forms = $this->createShowFormAction();
|
||||
|
||||
$this->view->addNewShow = true;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once 'customfilters/ImageSize.php';
|
||||
|
||||
class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
|
@ -41,6 +43,46 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
|||
$c->setValidators(array(
|
||||
'Hex', $stringLengthValidator
|
||||
));
|
||||
|
||||
// Add show image input
|
||||
$fileCountValidator = Application_Form_Helper_ValidationTypes::overrideFileCountValidator(1);
|
||||
$fileSizeValidator = Application_Form_Helper_ValidationTypes::overrideFileSizeValidator(array('max' => '5120000'));
|
||||
$fileExtensionValidator = Application_Form_Helper_ValidationTypes::overrideFileExtensionValidator('jpg,png,gif');
|
||||
|
||||
$upload = new Zend_Form_Element_File('upload');
|
||||
|
||||
$upload->setLabel(_('Show Image:'))
|
||||
->setRequired(false)
|
||||
->setDecorators(array('File', array('ViewScript', array(
|
||||
'viewScript' => 'form/add-show-style.phtml',
|
||||
'class' => 'big',
|
||||
'placement' => false
|
||||
))))
|
||||
->addValidator('Count', false, 1)
|
||||
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
|
||||
->addFilter('ImageSize');
|
||||
$this->addElement($upload);
|
||||
|
||||
// $this->addElement('file', 'add_show_image', array(
|
||||
// 'disableLoadDefaultDecorators' => true,
|
||||
// 'decorators' => array('File', array('ViewScript', array(
|
||||
// 'viewScript' => 'form/add-show-style.phtml',
|
||||
// 'class' => 'big',
|
||||
// 'placement' => false
|
||||
// ))),
|
||||
// 'label' => _('Show Image:'),
|
||||
// 'class' => 'input_file',
|
||||
// 'required' => false,
|
||||
// 'validators' => array(
|
||||
// $fileCountValidator,
|
||||
// $fileSizeValidator,
|
||||
// $fileExtensionValidator),
|
||||
// 'destination' => '../public/images/upload',
|
||||
// 'method' => 'post'
|
||||
// ));
|
||||
|
||||
// Change form enctype to accommodate file upload
|
||||
$this->setEnctype(Zend_Form::ENCTYPE_MULTIPART);
|
||||
}
|
||||
|
||||
public function disable()
|
||||
|
|
|
@ -93,4 +93,41 @@ Class Application_Form_Helper_ValidationTypes {
|
|||
return $validator;
|
||||
}
|
||||
|
||||
public static function overrideFileCountValidator($p_fileCount)
|
||||
{
|
||||
$validator = new Zend_Validate_File_Count($p_fileCount);
|
||||
|
||||
$validator->setMessage(
|
||||
_("Please limit the upload to one file"),
|
||||
Zend_Validate_File_Count::TOO_MANY
|
||||
);
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
public static function overrideFileSizeValidator($p_fileSize)
|
||||
{
|
||||
$validator = new Zend_Validate_File_Size($p_fileSize);
|
||||
|
||||
$validator->setMessage(
|
||||
_("The uploaded file is too large. Please limit your upload to '%max%'"),
|
||||
Zend_Validate_File_Size::TOO_BIG
|
||||
);
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
public static function overrideFileExtensionValidator($p_fileExtensions)
|
||||
{
|
||||
$validator = new Zend_Validate_File_Extension($p_fileExtensions);
|
||||
$validator->setExtension($p_fileExtensions);
|
||||
|
||||
$validator->setMessage(
|
||||
_("'%value%' is not a valid file format"),
|
||||
Zend_Validate_File_Extension::FALSE_EXTENSION
|
||||
);
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
}
|
|
@ -129,45 +129,49 @@ class Application_Model_RabbitMq
|
|||
|
||||
}
|
||||
|
||||
public static function SendMessageToHaproxyConfigDaemon($md){
|
||||
$config = parse_ini_file("/etc/airtime-saas/rabbitmq.ini", true);
|
||||
$conn = new AMQPConnection($config["rabbitmq"]["host"],
|
||||
$config["rabbitmq"]["port"],
|
||||
$config["rabbitmq"]["user"],
|
||||
$config["rabbitmq"]["password"],
|
||||
$config["rabbitmq"]["vhost"]);
|
||||
|
||||
$exchange = $config["rabbitmq"]["queue"];
|
||||
$queue = $config["rabbitmq"]["queue"];
|
||||
|
||||
$ch = $conn->channel();
|
||||
|
||||
|
||||
/*
|
||||
name: $queue
|
||||
passive: false
|
||||
durable: true // the queue will survive server restarts
|
||||
exclusive: false // the queue can be accessed in other channels
|
||||
auto_delete: false //the queue won't be deleted once the channel is closed.
|
||||
/**
|
||||
* Disabled to prevent warnings about /etc/airtime-saas/rabbitmq.ini
|
||||
*/
|
||||
$ch->queue_declare($queue, false, true, false, false);
|
||||
// public static function SendMessageToHaproxyConfigDaemon($md){
|
||||
// $config = parse_ini_file("/etc/airtime-saas/rabbitmq.ini", true);
|
||||
// $conn = new AMQPConnection($config["rabbitmq"]["host"],
|
||||
// $config["rabbitmq"]["port"],
|
||||
// $config["rabbitmq"]["user"],
|
||||
// $config["rabbitmq"]["password"],
|
||||
// $config["rabbitmq"]["vhost"]);
|
||||
|
||||
/*
|
||||
name: $exchange
|
||||
type: direct
|
||||
passive: false
|
||||
durable: true // the exchange will survive server restarts
|
||||
auto_delete: false //the exchange won't be deleted once the channel is closed.
|
||||
*/
|
||||
// $exchange = $config["rabbitmq"]["queue"];
|
||||
// $queue = $config["rabbitmq"]["queue"];
|
||||
|
||||
$ch->exchange_declare($exchange, 'direct', false, true, false);
|
||||
$ch->queue_bind($queue, $exchange);
|
||||
// $ch = $conn->channel();
|
||||
|
||||
$data = json_encode($md).PHP_EOL;
|
||||
$msg = new AMQPMessage($data, array('content_type' => 'application/json'));
|
||||
|
||||
$ch->basic_publish($msg, $exchange);
|
||||
$ch->close();
|
||||
$conn->close();
|
||||
}
|
||||
// /*
|
||||
// name: $queue
|
||||
// passive: false
|
||||
// durable: true // the queue will survive server restarts
|
||||
// exclusive: false // the queue can be accessed in other channels
|
||||
// auto_delete: false //the queue won't be deleted once the channel is closed.
|
||||
// */
|
||||
// $ch->queue_declare($queue, false, true, false, false);
|
||||
|
||||
// /*
|
||||
// name: $exchange
|
||||
// type: direct
|
||||
// passive: false
|
||||
// durable: true // the exchange will survive server restarts
|
||||
// auto_delete: false //the exchange won't be deleted once the channel is closed.
|
||||
// */
|
||||
|
||||
// $ch->exchange_declare($exchange, 'direct', false, true, false);
|
||||
// $ch->queue_bind($queue, $exchange);
|
||||
|
||||
// $data = json_encode($md).PHP_EOL;
|
||||
// $msg = new AMQPMessage($data, array('content_type' => 'application/json'));
|
||||
|
||||
// $ch->basic_publish($msg, $exchange);
|
||||
// $ch->close();
|
||||
// $conn->close();
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -478,12 +478,8 @@ class Application_Service_ShowFormService
|
|||
}
|
||||
}
|
||||
|
||||
if ($what && $live && $record && $who && $style && $when &&
|
||||
$repeats && $absRebroadcast && $rebroadcast) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return ($what && $live && $record && $who && $style && $when &&
|
||||
$repeats && $absRebroadcast && $rebroadcast);
|
||||
}
|
||||
|
||||
public function calculateDuration($start, $end, $timezone)
|
||||
|
|
|
@ -8,6 +8,8 @@ function openAddShowForm() {
|
|||
if($("#add-show-form").length == 1) {
|
||||
if( ($("#add-show-form").css('display')=='none')) {
|
||||
$("#add-show-form").show();
|
||||
$("#add-show-form").prop("enctype", "multipart/form-data");
|
||||
|
||||
/*
|
||||
var windowWidth = $(window).width();
|
||||
// margin on showform are 16 px on each side
|
||||
|
@ -579,7 +581,7 @@ function setAddShowEvents(form) {
|
|||
}
|
||||
})
|
||||
|
||||
form.find("#schedule-show-style input").ColorPicker({
|
||||
form.find("#schedule-show-style input .input_text").ColorPicker({
|
||||
onChange: function (hsb, hex, rgb, el) {
|
||||
$(el).val(hex);
|
||||
},
|
||||
|
|
|
@ -29,6 +29,8 @@ echo "----------------------------------------------------"
|
|||
|
||||
dist=`lsb_release -is`
|
||||
code=`lsb_release -cs`
|
||||
apache2 -v | grep "2\.4" > /dev/null
|
||||
apacheversion=$?
|
||||
|
||||
#enable squeeze backports to get lame packages
|
||||
if [ "$dist" = "Debian" -a "$code" = "squeeze" ]; then
|
||||
|
@ -130,16 +132,17 @@ else
|
|||
echo "----------------------------------------------------"
|
||||
echo "2.1 Apache Config File"
|
||||
echo "----------------------------------------------------"
|
||||
if [ ! -f /etc/apache2/sites-available/airtime ]; then
|
||||
if [ "$apacheversion" != "1" ]; then
|
||||
airtimeconfigfile="airtime.conf"
|
||||
else
|
||||
airtimeconfigfile="airtime"
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/apache2/sites-available/$airtimeconfigfile ]; then
|
||||
echo "Creating Apache config for Airtime..."
|
||||
|
||||
if [ "$dist" = "Ubuntu" -a "$code" = "saucy" ]; then
|
||||
cp $SCRIPTPATH/../apache/airtime-vhost /etc/apache2/sites-available/airtime.conf
|
||||
cp $SCRIPTPATH/../apache/airtime-vhost /etc/apache2/sites-available/$airtimeconfigfile
|
||||
a2dissite 000-default
|
||||
else
|
||||
cp $SCRIPTPATH/../apache/airtime-vhost /etc/apache2/sites-available/airtime
|
||||
a2dissite default
|
||||
fi
|
||||
a2ensite airtime
|
||||
else
|
||||
echo "Apache config for Airtime already exists..."
|
||||
|
|
Loading…
Reference in New Issue