Added AutoPlaylist Functionality to Show Scheduler enabling shows to have tracks added automatically.

This commit is contained in:
Robb Ebright 2017-02-13 09:35:09 -05:00 committed by Lucas Bickel
parent e3785e25f9
commit 32a1a66378
29 changed files with 1535 additions and 47 deletions

View file

@ -0,0 +1,72 @@
<?php
class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
{
public function init()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/add-show-autoplaylist.phtml'))
));
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
// retrieves the length limit for each char field
// and store to assoc array
$maxLens = Application_Model_Show::getMaxLengths();
// Add autoplaylist checkbox element
$this->addElement('checkbox', 'add_show_has_autoplaylist', array(
'label' => _('Auto Schedule Playlist ?'),
'required' => false,
'class' => 'input_text',
'decorators' => array('ViewHelper')
));
$autoPlaylistSelect = new Zend_Form_Element_Select("add_show_autoplaylist_id");
$autoPlaylistSelect->setLabel(_("Select Playlist"));
$autoPlaylistSelect->setMultiOptions($this->getPlaylistNames());
$autoPlaylistSelect->setValue(null);
$autoPlaylistSelect->setDecorators(array('ViewHelper'));
$this->addElement($autoPlaylistSelect);
}
private function getPlaylistNames()
{
$playlistNames = array(NULL => _("None"));
$playlists = CcPlaylistQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->find();
foreach ($playlists as $playlist) {
$playlistNames[$playlist->getDbId()] = $playlist->getDbName();
}
return $playlistNames;
}
public function disable()
{
$elements = $this->getElements();
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
public function makeReadonly()
{
$elements = $this->getElements();
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('readonly','readonly');
}
}
}
}

View file

@ -27,7 +27,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
'class' => 'input_text',
'required' => true,
'filters' => array('StringTrim'),
'value' => _('Untitled Show'),
'value' => _('New Show'),
'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['name'])))
));
@ -39,7 +39,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
'filters' => array('StringTrim'),
'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['url'])))
));
// Add genre element
$this->addElement('text', 'add_show_genre', array(
'label' => _('Genre:'),
@ -59,6 +59,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
$descText = $this->getElement('add_show_description');
$descText->setDecorators(array(array('ViewScript', array(
'viewScript' => 'form/add-show-block.phtml',
'class' => 'block-display'
@ -73,15 +74,36 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
));
$instanceDesc = $this->getElement('add_show_instance_description');
$instanceDesc->setDecorators(array(array('ViewScript', array(
'viewScript' => 'form/add-show-block.phtml',
'class' => 'block-display'
))));
$instanceDesc->setAttrib('disabled','disabled');
}
private function getPlaylistNames()
{
$playlistNames = array(NULL => _("None"));
/**
$playlists = CcPlaylistQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
->find();
foreach ($playlists as $playlist) {
$playlistNames[$playlist->getDbId()] = $playlist->getDbName();
}
return $playlistNames;
}
/**
* Enable the instance description when editing a show instance
*/
public function enableInstanceDesc()