Work on adding image upload to add-show form
This commit is contained in:
parent
cc3ddb40ea
commit
cb80423fdd
|
@ -1,2 +1,8 @@
|
||||||
.*
|
.*
|
||||||
*.pyc
|
*.pyc
|
||||||
|
*~$
|
||||||
|
*log.*
|
||||||
|
**/airtime_analyzer.egg-info/*
|
||||||
|
**/build/*
|
||||||
|
**/dist/*
|
||||||
|
*~
|
||||||
|
|
|
@ -481,7 +481,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->view->addNewShow = true;
|
$this->view->addNewShow = true;
|
||||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||||
} else {
|
} else {
|
||||||
if (!$validateStartDate) {
|
if (!$validateStartDate) {
|
||||||
$this->view->when->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
$this->view->when->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$service_showForm = new Application_Service_ShowFormService(null);
|
$service_showForm = new Application_Service_ShowFormService(null);
|
||||||
//$service_show = new Application_Service_ShowService();
|
//$service_show = new Application_Service_ShowService();
|
||||||
|
|
||||||
$js = $this->_getParam('data');
|
$js = $this->_getParam('data');
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
|
@ -579,21 +579,24 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$log_vars["params"] = array();
|
$log_vars["params"] = array();
|
||||||
$log_vars["params"]["form_data"] = $data;
|
$log_vars["params"]["form_data"] = $data;
|
||||||
Logging::info($log_vars);
|
Logging::info($log_vars);
|
||||||
|
|
||||||
|
$request = $this->getRequest();
|
||||||
|
Logging::info($request);
|
||||||
|
|
||||||
$forms = $this->createShowFormAction();
|
$forms = $this->createShowFormAction();
|
||||||
|
|
||||||
$this->view->addNewShow = true;
|
$this->view->addNewShow = true;
|
||||||
|
|
||||||
if ($service_showForm->validateShowForms($forms, $data)) {
|
if ($service_showForm->validateShowForms($forms, $data)) {
|
||||||
$service_show->addUpdateShow($data);
|
$service_show->addUpdateShow($data);
|
||||||
|
|
||||||
//send new show forms to the user
|
//send new show forms to the user
|
||||||
$this->createShowFormAction(true);
|
$this->createShowFormAction(true);
|
||||||
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
$this->view->newForm = $this->view->render('schedule/add-show-form.phtml');
|
||||||
|
|
||||||
Logging::debug("Show creation succeeded");
|
Logging::debug("Show creation succeeded");
|
||||||
} else {
|
} else {
|
||||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||||
Logging::debug("Show creation failed");
|
Logging::debug("Show creation failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'customfilters/ImageSize.php';
|
||||||
|
|
||||||
class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -24,7 +26,7 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
||||||
'Hex', $stringLengthValidator
|
'Hex', $stringLengthValidator
|
||||||
));
|
));
|
||||||
|
|
||||||
// Add show color input
|
// Add show color input
|
||||||
$this->addElement('text', 'add_show_color', array(
|
$this->addElement('text', 'add_show_color', array(
|
||||||
'label' => _('Text Colour:'),
|
'label' => _('Text Colour:'),
|
||||||
'class' => 'input_text',
|
'class' => 'input_text',
|
||||||
|
@ -41,6 +43,46 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
||||||
$c->setValidators(array(
|
$c->setValidators(array(
|
||||||
'Hex', $stringLengthValidator
|
'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()
|
public function disable()
|
||||||
|
|
|
@ -92,5 +92,42 @@ Class Application_Form_Helper_ValidationTypes {
|
||||||
|
|
||||||
return $validator;
|
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"],
|
* Disabled to prevent warnings about /etc/airtime-saas/rabbitmq.ini
|
||||||
$config["rabbitmq"]["port"],
|
*/
|
||||||
$config["rabbitmq"]["user"],
|
// public static function SendMessageToHaproxyConfigDaemon($md){
|
||||||
$config["rabbitmq"]["password"],
|
// $config = parse_ini_file("/etc/airtime-saas/rabbitmq.ini", true);
|
||||||
$config["rabbitmq"]["vhost"]);
|
// $conn = new AMQPConnection($config["rabbitmq"]["host"],
|
||||||
|
// $config["rabbitmq"]["port"],
|
||||||
|
// $config["rabbitmq"]["user"],
|
||||||
|
// $config["rabbitmq"]["password"],
|
||||||
|
// $config["rabbitmq"]["vhost"]);
|
||||||
|
|
||||||
$exchange = $config["rabbitmq"]["queue"];
|
// $exchange = $config["rabbitmq"]["queue"];
|
||||||
$queue = $config["rabbitmq"]["queue"];
|
// $queue = $config["rabbitmq"]["queue"];
|
||||||
|
|
||||||
$ch = $conn->channel();
|
// $ch = $conn->channel();
|
||||||
|
|
||||||
|
|
||||||
/*
|
// /*
|
||||||
name: $queue
|
// name: $queue
|
||||||
passive: false
|
// passive: false
|
||||||
durable: true // the queue will survive server restarts
|
// durable: true // the queue will survive server restarts
|
||||||
exclusive: false // the queue can be accessed in other channels
|
// exclusive: false // the queue can be accessed in other channels
|
||||||
auto_delete: false //the queue won't be deleted once the channel is closed.
|
// auto_delete: false //the queue won't be deleted once the channel is closed.
|
||||||
*/
|
// */
|
||||||
$ch->queue_declare($queue, false, true, false, false);
|
// $ch->queue_declare($queue, false, true, false, false);
|
||||||
|
|
||||||
/*
|
// /*
|
||||||
name: $exchange
|
// name: $exchange
|
||||||
type: direct
|
// type: direct
|
||||||
passive: false
|
// passive: false
|
||||||
durable: true // the exchange will survive server restarts
|
// durable: true // the exchange will survive server restarts
|
||||||
auto_delete: false //the exchange won't be deleted once the channel is closed.
|
// auto_delete: false //the exchange won't be deleted once the channel is closed.
|
||||||
*/
|
// */
|
||||||
|
|
||||||
$ch->exchange_declare($exchange, 'direct', false, true, false);
|
// $ch->exchange_declare($exchange, 'direct', false, true, false);
|
||||||
$ch->queue_bind($queue, $exchange);
|
// $ch->queue_bind($queue, $exchange);
|
||||||
|
|
||||||
$data = json_encode($md).PHP_EOL;
|
// $data = json_encode($md).PHP_EOL;
|
||||||
$msg = new AMQPMessage($data, array('content_type' => 'application/json'));
|
// $msg = new AMQPMessage($data, array('content_type' => 'application/json'));
|
||||||
|
|
||||||
$ch->basic_publish($msg, $exchange);
|
// $ch->basic_publish($msg, $exchange);
|
||||||
$ch->close();
|
// $ch->close();
|
||||||
$conn->close();
|
// $conn->close();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,12 +478,8 @@ class Application_Service_ShowFormService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($what && $live && $record && $who && $style && $when &&
|
return ($what && $live && $record && $who && $style && $when &&
|
||||||
$repeats && $absRebroadcast && $rebroadcast) {
|
$repeats && $absRebroadcast && $rebroadcast);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculateDuration($start, $end, $timezone)
|
public function calculateDuration($start, $end, $timezone)
|
||||||
|
|
|
@ -8,6 +8,8 @@ function openAddShowForm() {
|
||||||
if($("#add-show-form").length == 1) {
|
if($("#add-show-form").length == 1) {
|
||||||
if( ($("#add-show-form").css('display')=='none')) {
|
if( ($("#add-show-form").css('display')=='none')) {
|
||||||
$("#add-show-form").show();
|
$("#add-show-form").show();
|
||||||
|
$("#add-show-form").prop("enctype", "multipart/form-data");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var windowWidth = $(window).width();
|
var windowWidth = $(window).width();
|
||||||
// margin on showform are 16 px on each side
|
// 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) {
|
onChange: function (hsb, hex, rgb, el) {
|
||||||
$(el).val(hex);
|
$(el).val(hex);
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,6 +29,8 @@ echo "----------------------------------------------------"
|
||||||
|
|
||||||
dist=`lsb_release -is`
|
dist=`lsb_release -is`
|
||||||
code=`lsb_release -cs`
|
code=`lsb_release -cs`
|
||||||
|
apache2 -v | grep "2\.4" > /dev/null
|
||||||
|
apacheversion=$?
|
||||||
|
|
||||||
#enable squeeze backports to get lame packages
|
#enable squeeze backports to get lame packages
|
||||||
if [ "$dist" = "Debian" -a "$code" = "squeeze" ]; then
|
if [ "$dist" = "Debian" -a "$code" = "squeeze" ]; then
|
||||||
|
@ -130,16 +132,17 @@ else
|
||||||
echo "----------------------------------------------------"
|
echo "----------------------------------------------------"
|
||||||
echo "2.1 Apache Config File"
|
echo "2.1 Apache Config File"
|
||||||
echo "----------------------------------------------------"
|
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..."
|
echo "Creating Apache config for Airtime..."
|
||||||
|
|
||||||
if [ "$dist" = "Ubuntu" -a "$code" = "saucy" ]; then
|
cp $SCRIPTPATH/../apache/airtime-vhost /etc/apache2/sites-available/$airtimeconfigfile
|
||||||
cp $SCRIPTPATH/../apache/airtime-vhost /etc/apache2/sites-available/airtime.conf
|
a2dissite 000-default
|
||||||
a2dissite 000-default
|
|
||||||
else
|
|
||||||
cp $SCRIPTPATH/../apache/airtime-vhost /etc/apache2/sites-available/airtime
|
|
||||||
a2dissite default
|
|
||||||
fi
|
|
||||||
a2ensite airtime
|
a2ensite airtime
|
||||||
else
|
else
|
||||||
echo "Apache config for Airtime already exists..."
|
echo "Apache config for Airtime already exists..."
|
||||||
|
@ -205,4 +208,4 @@ echo "----------------------------------------------------"
|
||||||
cd $SCRIPTPATH/../../install_minimal
|
cd $SCRIPTPATH/../../install_minimal
|
||||||
# Restart apache to clear php cache
|
# Restart apache to clear php cache
|
||||||
service apache2 restart
|
service apache2 restart
|
||||||
./airtime-install
|
./airtime-install
|
||||||
|
|
Loading…
Reference in New Issue