2011-01-21 00:30:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
|
|
|
{
|
|
|
|
public function init()
|
|
|
|
{
|
2012-11-27 23:11:29 +01:00
|
|
|
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
2012-07-11 00:55:44 +02:00
|
|
|
// retrieves the length limit for each char field
|
|
|
|
// and store to assoc array
|
|
|
|
$maxLens = Application_Model_Show::getMaxLengths();
|
|
|
|
|
2011-04-12 06:14:26 +02:00
|
|
|
// Hidden element to indicate whether the show is new or
|
|
|
|
// whether we are updating an existing show.
|
|
|
|
$this->addElement('hidden', 'add_show_id', array(
|
|
|
|
'decorators' => array('ViewHelper')
|
|
|
|
));
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-04-12 17:54:51 +02:00
|
|
|
// Hidden element to indicate the instance id of the show
|
|
|
|
// being edited.
|
|
|
|
$this->addElement('hidden', 'add_show_instance_id', array(
|
|
|
|
'decorators' => array('ViewHelper')
|
|
|
|
));
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2011-01-21 00:30:53 +01:00
|
|
|
// Add name element
|
|
|
|
$this->addElement('text', 'add_show_name', array(
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Name:'),
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => true,
|
|
|
|
'filters' => array('StringTrim'),
|
2017-02-13 15:35:09 +01:00
|
|
|
'value' => _('New Show'),
|
2012-11-27 23:11:29 +01:00
|
|
|
'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['name'])))
|
2011-01-21 00:30:53 +01:00
|
|
|
));
|
|
|
|
|
2011-03-17 23:23:05 +01:00
|
|
|
// Add URL element
|
|
|
|
$this->addElement('text', 'add_show_url', array(
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('URL:'),
|
2011-03-17 23:23:05 +01:00
|
|
|
'class' => 'input_text',
|
|
|
|
'required' => false,
|
|
|
|
'filters' => array('StringTrim'),
|
2012-11-27 23:11:29 +01:00
|
|
|
'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['url'])))
|
2011-04-02 23:09:37 +02:00
|
|
|
));
|
2017-02-13 15:35:09 +01:00
|
|
|
|
2011-04-02 23:09:37 +02:00
|
|
|
// Add genre element
|
|
|
|
$this->addElement('text', 'add_show_genre', array(
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Genre:'),
|
2011-04-02 23:09:37 +02:00
|
|
|
'class' => 'input_text',
|
|
|
|
'required' => false,
|
2011-10-24 19:27:53 +02:00
|
|
|
'filters' => array('StringTrim'),
|
2012-07-11 00:55:44 +02:00
|
|
|
'validators' => array(array('StringLength', false, array(0, $maxLens['genre'])))
|
2011-04-04 19:50:51 +02:00
|
|
|
));
|
2011-01-28 23:37:31 +01:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
// Add the description element
|
2011-01-21 00:30:53 +01:00
|
|
|
$this->addElement('textarea', 'add_show_description', array(
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Description:'),
|
2011-01-21 00:30:53 +01:00
|
|
|
'required' => false,
|
2011-10-24 19:27:53 +02:00
|
|
|
'class' => 'input_text_area',
|
2012-07-11 00:55:44 +02:00
|
|
|
'validators' => array(array('StringLength', false, array(0, $maxLens['description'])))
|
|
|
|
));
|
2011-01-21 00:30:53 +01:00
|
|
|
|
2011-01-31 02:11:18 +01:00
|
|
|
$descText = $this->getElement('add_show_description');
|
|
|
|
|
2017-02-13 15:35:09 +01:00
|
|
|
|
2011-01-31 02:11:18 +01:00
|
|
|
$descText->setDecorators(array(array('ViewScript', array(
|
|
|
|
'viewScript' => 'form/add-show-block.phtml',
|
|
|
|
'class' => 'block-display'
|
|
|
|
))));
|
2014-09-19 18:55:02 +02:00
|
|
|
|
|
|
|
// Add the instance description
|
|
|
|
$this->addElement('textarea', 'add_show_instance_description', array(
|
|
|
|
'label' => _('Instance Description:'),
|
|
|
|
'required' => false,
|
|
|
|
'class' => 'input_text_area',
|
|
|
|
'validators' => array(array('StringLength', false, array(0, $maxLens['description'])))
|
|
|
|
));
|
|
|
|
|
|
|
|
$instanceDesc = $this->getElement('add_show_instance_description');
|
2017-02-13 15:35:09 +01:00
|
|
|
|
2014-09-19 18:55:02 +02:00
|
|
|
$instanceDesc->setDecorators(array(array('ViewScript', array(
|
|
|
|
'viewScript' => 'form/add-show-block.phtml',
|
|
|
|
'class' => 'block-display'
|
|
|
|
))));
|
|
|
|
$instanceDesc->setAttrib('disabled','disabled');
|
2017-02-13 15:35:09 +01:00
|
|
|
|
2014-09-19 18:55:02 +02:00
|
|
|
}
|
2017-02-13 15:35:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
private function getPlaylistNames()
|
|
|
|
{
|
|
|
|
$playlistNames = array(NULL => _("None"));
|
2014-09-19 18:55:02 +02:00
|
|
|
|
2017-02-13 15:35:09 +01:00
|
|
|
|
|
|
|
$playlists = CcPlaylistQuery::create()
|
|
|
|
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
|
|
|
->find();
|
|
|
|
|
|
|
|
foreach ($playlists as $playlist) {
|
|
|
|
|
|
|
|
$playlistNames[$playlist->getDbId()] = $playlist->getDbName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $playlistNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2014-09-19 18:55:02 +02:00
|
|
|
* Enable the instance description when editing a show instance
|
|
|
|
*/
|
|
|
|
public function enableInstanceDesc()
|
|
|
|
{
|
|
|
|
$el = $this->getElement('add_show_instance_description');
|
|
|
|
Logging::info($el);
|
|
|
|
$el->setAttrib('disabled', null);
|
|
|
|
$el->setAttrib('readonly', null);
|
2011-01-21 00:30:53 +01:00
|
|
|
}
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function disable()
|
|
|
|
{
|
2012-03-30 21:11:24 +02:00
|
|
|
$elements = $this->getElements();
|
2012-08-29 05:04:55 +02:00
|
|
|
foreach ($elements as $element) {
|
|
|
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
2012-04-05 22:01:27 +02:00
|
|
|
$element->setAttrib('disabled','disabled');
|
2012-03-30 21:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-13 18:13:58 +01:00
|
|
|
|
|
|
|
public function makeReadonly()
|
|
|
|
{
|
|
|
|
$elements = $this->getElements();
|
|
|
|
foreach ($elements as $element) {
|
|
|
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
|
|
|
$element->setAttrib('readonly','readonly');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
}
|