Format code using php-cs-fixer
This commit is contained in:
parent
43d7dc92cd
commit
d52c6184b9
352 changed files with 17473 additions and 17041 deletions
|
@ -2,30 +2,28 @@
|
|||
|
||||
class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/add-show-rebroadcast-absolute.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/add-show-rebroadcast-absolute.phtml']],
|
||||
]);
|
||||
|
||||
for ($i=1; $i<=10; $i++) {
|
||||
|
||||
$text = new Zend_Form_Element_Text("add_show_rebroadcast_date_absolute_$i");
|
||||
for ($i = 1; $i <= 10; ++$i) {
|
||||
$text = new Zend_Form_Element_Text("add_show_rebroadcast_date_absolute_{$i}");
|
||||
$text->setAttrib('class', 'input_text');
|
||||
$text->addFilter('StringTrim');
|
||||
$text->addValidator('date', false, array('YYYY-MM-DD'));
|
||||
$text->addValidator('date', false, ['YYYY-MM-DD']);
|
||||
$text->setRequired(false);
|
||||
$text->setDecorators(array('ViewHelper'));
|
||||
$text->setDecorators(['ViewHelper']);
|
||||
$this->addElement($text);
|
||||
|
||||
$text = new Zend_Form_Element_Text("add_show_rebroadcast_time_absolute_$i");
|
||||
$text = new Zend_Form_Element_Text("add_show_rebroadcast_time_absolute_{$i}");
|
||||
$text->setAttrib('class', 'input_text');
|
||||
$text->addFilter('StringTrim');
|
||||
$text->addValidator('date', false, array('HH:mm'));
|
||||
$text->addValidator('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')));
|
||||
$text->addValidator('date', false, ['HH:mm']);
|
||||
$text->addValidator('regex', false, ['/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')]);
|
||||
$text->setRequired(false);
|
||||
$text->setDecorators(array('ViewHelper'));
|
||||
$text->setDecorators(['ViewHelper']);
|
||||
$this->addElement($text);
|
||||
}
|
||||
}
|
||||
|
@ -35,63 +33,64 @@ class Application_Form_AddShowAbsoluteRebroadcastDates extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid($formData) {
|
||||
public function isValid($formData)
|
||||
{
|
||||
if (parent::isValid($formData)) {
|
||||
return $this->checkReliantFields($formData);
|
||||
} else {
|
||||
return false;
|
||||
return $this->checkReliantFields($formData);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData)
|
||||
{
|
||||
$noError = true;
|
||||
|
||||
for ($i=1; $i<=10; $i++) {
|
||||
|
||||
for ($i = 1; $i <= 10; ++$i) {
|
||||
$valid = true;
|
||||
$day = $formData['add_show_rebroadcast_date_absolute_'.$i];
|
||||
$time = $formData['add_show_rebroadcast_time_absolute_'.$i];
|
||||
$day = $formData['add_show_rebroadcast_date_absolute_' . $i];
|
||||
$time = $formData['add_show_rebroadcast_time_absolute_' . $i];
|
||||
|
||||
if (trim($day) == "" && trim($time) == "") {
|
||||
if (trim($day) == '' && trim($time) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trim($day) == "") {
|
||||
$this->getElement('add_show_rebroadcast_date_absolute_'.$i)->setErrors(array(_("Day must be specified")));
|
||||
if (trim($day) == '') {
|
||||
$this->getElement('add_show_rebroadcast_date_absolute_' . $i)->setErrors([_('Day must be specified')]);
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
if (trim($time) == "") {
|
||||
$this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array(_("Time must be specified")));
|
||||
if (trim($time) == '') {
|
||||
$this->getElement('add_show_rebroadcast_time_absolute_' . $i)->setErrors([_('Time must be specified')]);
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
if ($valid === false) {
|
||||
$noError = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$show_start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
|
||||
$show_start_time = $formData['add_show_start_date'] . ' ' . $formData['add_show_start_time'];
|
||||
$show_end = new DateTime($show_start_time);
|
||||
|
||||
$duration = $formData['add_show_duration'];
|
||||
$duration = explode(":", $duration);
|
||||
$duration = explode(':', $duration);
|
||||
|
||||
$show_end->add(new DateInterval("PT$duration[0]H"));
|
||||
$show_end->add(new DateInterval("PT$duration[1]M"));
|
||||
$show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast
|
||||
$show_end->add(new DateInterval("PT{$duration[0]}H"));
|
||||
$show_end->add(new DateInterval("PT{$duration[1]}M"));
|
||||
$show_end->add(new DateInterval('PT1H')); //min time to wait until a rebroadcast
|
||||
|
||||
$rebroad_start = $day." ".$formData['add_show_rebroadcast_time_absolute_'.$i];
|
||||
$rebroad_start = $day . ' ' . $formData['add_show_rebroadcast_time_absolute_' . $i];
|
||||
$rebroad_start = new DateTime($rebroad_start);
|
||||
|
||||
if ($rebroad_start < $show_end) {
|
||||
$this->getElement('add_show_rebroadcast_time_absolute_'.$i)->setErrors(array(_("Must wait at least 1 hour to rebroadcast")));
|
||||
$this->getElement('add_show_rebroadcast_time_absolute_' . $i)->setErrors([_('Must wait at least 1 hour to rebroadcast')]);
|
||||
$valid = false;
|
||||
$noError = false;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
|
|||
{
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/add-show-autoplaylist.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/add-show-autoplaylist.phtml']],
|
||||
]);
|
||||
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
// retrieves the length limit for each char field
|
||||
|
@ -14,26 +14,26 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
|
|||
$maxLens = Application_Model_Show::getMaxLengths();
|
||||
|
||||
// Add autoplaylist checkbox element
|
||||
$this->addElement('checkbox', 'add_show_has_autoplaylist', array(
|
||||
'label' => _('Add Autoloading Playlist ?'),
|
||||
'required' => false,
|
||||
'class' => 'input_text',
|
||||
'decorators' => array('ViewHelper')
|
||||
));
|
||||
|
||||
$autoPlaylistSelect = new Zend_Form_Element_Select("add_show_autoplaylist_id");
|
||||
$autoPlaylistSelect->setLabel(_("Select Playlist"));
|
||||
$this->addElement('checkbox', 'add_show_has_autoplaylist', [
|
||||
'label' => _('Add Autoloading Playlist ?'),
|
||||
'required' => false,
|
||||
'class' => 'input_text',
|
||||
'decorators' => ['ViewHelper'],
|
||||
]);
|
||||
|
||||
$autoPlaylistSelect = new Zend_Form_Element_Select('add_show_autoplaylist_id');
|
||||
$autoPlaylistSelect->setLabel(_('Select Playlist'));
|
||||
$autoPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames(true));
|
||||
$autoPlaylistSelect->setValue(null);
|
||||
$autoPlaylistSelect->setDecorators(array('ViewHelper'));
|
||||
$autoPlaylistSelect->setDecorators(['ViewHelper']);
|
||||
$this->addElement($autoPlaylistSelect);
|
||||
// Add autoplaylist checkbox element
|
||||
$this->addElement('checkbox', 'add_show_autoplaylist_repeat', array(
|
||||
'label' => _('Repeat Playlist Until Show is Full ?'),
|
||||
'required' => false,
|
||||
'class' => 'input_text',
|
||||
'decorators' => array('ViewHelper')
|
||||
));
|
||||
$this->addElement('checkbox', 'add_show_autoplaylist_repeat', [
|
||||
'label' => _('Repeat Playlist Until Show is Full ?'),
|
||||
'required' => false,
|
||||
'class' => 'input_text',
|
||||
'decorators' => ['ViewHelper'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function disable()
|
||||
|
@ -41,7 +41,7 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class Application_Form_AddShowAutoPlaylist extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('readonly','readonly');
|
||||
$element->setAttrib('readonly', 'readonly');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,41 +4,44 @@ require_once 'customvalidators/ConditionalNotEmpty.php';
|
|||
|
||||
class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$cb_airtime_auth = new Zend_Form_Element_Checkbox("cb_airtime_auth");
|
||||
$cb_airtime_auth->setLabel(sprintf(_("Use %s Authentication:"), PRODUCT_NAME))
|
||||
->setChecked(true)
|
||||
->setRequired(false);
|
||||
$cb_airtime_auth = new Zend_Form_Element_Checkbox('cb_airtime_auth');
|
||||
$cb_airtime_auth->setLabel(sprintf(_('Use %s Authentication:'), PRODUCT_NAME))
|
||||
->setChecked(true)
|
||||
->setRequired(false)
|
||||
;
|
||||
$this->addElement($cb_airtime_auth);
|
||||
|
||||
$cb_custom_auth = new Zend_Form_Element_Checkbox("cb_custom_auth");
|
||||
$cb_custom_auth ->setLabel(_("Use Custom Authentication:"))
|
||||
->setRequired(false);
|
||||
$cb_custom_auth = new Zend_Form_Element_Checkbox('cb_custom_auth');
|
||||
$cb_custom_auth->setLabel(_('Use Custom Authentication:'))
|
||||
->setRequired(false)
|
||||
;
|
||||
$this->addElement($cb_custom_auth);
|
||||
|
||||
//custom username
|
||||
$custom_username = new Zend_Form_Element_Text('custom_username');
|
||||
$custom_username->setAttrib('class', 'input_text')
|
||||
->setAttrib('autocomplete', 'off')
|
||||
->setAllowEmpty(true)
|
||||
->setLabel(_('Custom Username'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))));
|
||||
->setAttrib('autocomplete', 'off')
|
||||
->setAllowEmpty(true)
|
||||
->setLabel(_('Custom Username'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new ConditionalNotEmpty(['cb_custom_auth' => '1']), ])
|
||||
;
|
||||
$this->addElement($custom_username);
|
||||
|
||||
//custom password
|
||||
$custom_password = new Zend_Form_Element_Password('custom_password');
|
||||
$custom_password->setAttrib('class', 'input_text')
|
||||
->setAttrib('autocomplete', 'off')
|
||||
->setAttrib('renderPassword','true')
|
||||
->setAllowEmpty(true)
|
||||
->setLabel(_('Custom Password'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new ConditionalNotEmpty(array("cb_custom_auth"=>"1"))));
|
||||
->setAttrib('autocomplete', 'off')
|
||||
->setAttrib('renderPassword', 'true')
|
||||
->setAllowEmpty(true)
|
||||
->setLabel(_('Custom Password'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new ConditionalNotEmpty(['cb_custom_auth' => '1']), ])
|
||||
;
|
||||
$this->addElement($custom_password);
|
||||
|
||||
$showSourceParams = parse_url(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
||||
|
@ -47,25 +50,29 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
|||
$showSourceHost = new Zend_Form_Element_Text('show_source_host');
|
||||
$showSourceHost->setAttrib('readonly', true)
|
||||
->setLabel(_('Host:'))
|
||||
->setValue(isset($showSourceParams["host"])?$showSourceParams["host"]:"");
|
||||
->setValue(isset($showSourceParams['host']) ? $showSourceParams['host'] : '')
|
||||
;
|
||||
$this->addElement($showSourceHost);
|
||||
|
||||
$showSourcePort = new Zend_Form_Element_Text('show_source_port');
|
||||
$showSourcePort->setAttrib('readonly', true)
|
||||
->setLabel(_('Port:'))
|
||||
->setValue(isset($showSourceParams["port"])?$showSourceParams["port"]:"");
|
||||
->setValue(isset($showSourceParams['port']) ? $showSourceParams['port'] : '')
|
||||
;
|
||||
$this->addElement($showSourcePort);
|
||||
|
||||
$showSourceMount = new Zend_Form_Element_Text('show_source_mount');
|
||||
$showSourceMount->setAttrib('readonly', true)
|
||||
->setLabel(_('Mount:'))
|
||||
->setValue(isset($showSourceParams["path"])?$showSourceParams["path"]:"");
|
||||
->setValue(isset($showSourceParams['path']) ? $showSourceParams['path'] : '')
|
||||
;
|
||||
$this->addElement($showSourceMount);
|
||||
|
||||
$this->setDecorators(
|
||||
array(
|
||||
array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml'))
|
||||
));
|
||||
[
|
||||
['ViewScript', ['viewScript' => 'form/add-show-live-stream.phtml']],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function isValid($data)
|
||||
|
@ -74,13 +81,13 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
|||
|
||||
if ($data['cb_custom_auth'] == 1) {
|
||||
if (trim($data['custom_username']) == '') {
|
||||
$element = $this->getElement("custom_username");
|
||||
$element->addError(_("Username field cannot be empty."));
|
||||
$element = $this->getElement('custom_username');
|
||||
$element->addError(_('Username field cannot be empty.'));
|
||||
$isValid = false;
|
||||
}
|
||||
if (trim($data['custom_password']) == '') {
|
||||
$element = $this->getElement("custom_password");
|
||||
$element->addError(_("Password field cannot be empty."));
|
||||
$element = $this->getElement('custom_password');
|
||||
$element->addError(_('Password field cannot be empty.'));
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +100,7 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,19 @@
|
|||
|
||||
class Application_Form_AddShowRR extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
// Add record element
|
||||
$this->addElement('checkbox', 'add_show_record', array(
|
||||
'label' => _('Record from Line In?'),
|
||||
'required' => false,
|
||||
));
|
||||
$this->addElement('checkbox', 'add_show_record', [
|
||||
'label' => _('Record from Line In?'),
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
// Add record element
|
||||
$this->addElement('checkbox', 'add_show_rebroadcast', array(
|
||||
'label' => _('Rebroadcast?'),
|
||||
'required' => false,
|
||||
));
|
||||
$this->addElement('checkbox', 'add_show_rebroadcast', [
|
||||
'label' => _('Rebroadcast?'),
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function disable()
|
||||
|
@ -23,9 +22,8 @@ class Application_Form_AddShowRR extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,35 +2,33 @@
|
|||
|
||||
class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/add-show-rebroadcast.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/add-show-rebroadcast.phtml']],
|
||||
]);
|
||||
|
||||
$relativeDates = array();
|
||||
$relativeDates[""] = "";
|
||||
for ($i=0; $i<=30; $i++) {
|
||||
$relativeDates["$i days"] = "+$i "._("days");
|
||||
$relativeDates = [];
|
||||
$relativeDates[''] = '';
|
||||
for ($i = 0; $i <= 30; ++$i) {
|
||||
$relativeDates["{$i} days"] = "+{$i} " . _('days');
|
||||
}
|
||||
|
||||
for ($i=1; $i<=10; $i++) {
|
||||
|
||||
$select = new Zend_Form_Element_Select("add_show_rebroadcast_date_$i");
|
||||
for ($i = 1; $i <= 10; ++$i) {
|
||||
$select = new Zend_Form_Element_Select("add_show_rebroadcast_date_{$i}");
|
||||
$select->setAttrib('class', 'input_select');
|
||||
$select->setMultiOptions($relativeDates);
|
||||
$select->setRequired(false);
|
||||
$select->setDecorators(array('ViewHelper'));
|
||||
$select->setDecorators(['ViewHelper']);
|
||||
$this->addElement($select);
|
||||
|
||||
$text = new Zend_Form_Element_Text("add_show_rebroadcast_time_$i");
|
||||
$text = new Zend_Form_Element_Text("add_show_rebroadcast_time_{$i}");
|
||||
$text->setAttrib('class', 'input_text');
|
||||
$text->addFilter('StringTrim');
|
||||
$text->addValidator('date', false, array('HH:mm'));
|
||||
$text->addValidator('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')));
|
||||
$text->addValidator('date', false, ['HH:mm']);
|
||||
$text->addValidator('regex', false, ['/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')]);
|
||||
$text->setRequired(false);
|
||||
$text->setDecorators(array('ViewHelper'));
|
||||
$text->setDecorators(['ViewHelper']);
|
||||
$this->addElement($text);
|
||||
}
|
||||
}
|
||||
|
@ -40,67 +38,68 @@ class Application_Form_AddShowRebroadcastDates extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid($formData) {
|
||||
public function isValid($formData)
|
||||
{
|
||||
if (parent::isValid($formData)) {
|
||||
return $this->checkReliantFields($formData);
|
||||
} else {
|
||||
return false;
|
||||
return $this->checkReliantFields($formData);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData)
|
||||
{
|
||||
$noError = true;
|
||||
|
||||
for ($i=1; $i<=10; $i++) {
|
||||
|
||||
for ($i = 1; $i <= 10; ++$i) {
|
||||
$valid = true;
|
||||
$days = $formData['add_show_rebroadcast_date_'.$i];
|
||||
$time = $formData['add_show_rebroadcast_time_'.$i];
|
||||
$days = $formData['add_show_rebroadcast_date_' . $i];
|
||||
$time = $formData['add_show_rebroadcast_time_' . $i];
|
||||
|
||||
if (trim($days) == "" && trim($time) == "") {
|
||||
if (trim($days) == '' && trim($time) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trim($days) == "") {
|
||||
$this->getElement('add_show_rebroadcast_date_'.$i)->setErrors(array(_("Day must be specified")));
|
||||
if (trim($days) == '') {
|
||||
$this->getElement('add_show_rebroadcast_date_' . $i)->setErrors([_('Day must be specified')]);
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
if (trim($time) == "") {
|
||||
$this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array(_("Time must be specified")));
|
||||
if (trim($time) == '') {
|
||||
$this->getElement('add_show_rebroadcast_time_' . $i)->setErrors([_('Time must be specified')]);
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
if ($valid === false) {
|
||||
$noError = false;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$days = explode(" ", $days);
|
||||
$days = explode(' ', $days);
|
||||
$day = $days[0];
|
||||
|
||||
$show_start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
|
||||
$show_start_time = $formData['add_show_start_date'] . ' ' . $formData['add_show_start_time'];
|
||||
$show_end = new DateTime($show_start_time);
|
||||
|
||||
$duration = $formData['add_show_duration'];
|
||||
$duration = explode(":", $duration);
|
||||
$duration = explode(':', $duration);
|
||||
|
||||
$show_end->add(new DateInterval("PT$duration[0]H"));
|
||||
$show_end->add(new DateInterval("PT$duration[1]M"));
|
||||
$show_end->add(new DateInterval("PT1H"));//min time to wait until a rebroadcast
|
||||
$show_end->add(new DateInterval("PT{$duration[0]}H"));
|
||||
$show_end->add(new DateInterval("PT{$duration[1]}M"));
|
||||
$show_end->add(new DateInterval('PT1H')); //min time to wait until a rebroadcast
|
||||
|
||||
$rebroad_start = $formData['add_show_start_date']." ".$formData['add_show_rebroadcast_time_'.$i];
|
||||
$rebroad_start = $formData['add_show_start_date'] . ' ' . $formData['add_show_rebroadcast_time_' . $i];
|
||||
$rebroad_start = new DateTime($rebroad_start);
|
||||
$rebroad_start->add(new DateInterval("P".$day."D"));
|
||||
$rebroad_start->add(new DateInterval('P' . $day . 'D'));
|
||||
|
||||
if ($rebroad_start < $show_end) {
|
||||
$this->getElement('add_show_rebroadcast_time_'.$i)->setErrors(array(_("Must wait at least 1 hour to rebroadcast")));
|
||||
$this->getElement('add_show_rebroadcast_time_' . $i)->setErrors([_('Must wait at least 1 hour to rebroadcast')]);
|
||||
$valid = false;
|
||||
$noError = false;
|
||||
}
|
||||
|
|
|
@ -2,74 +2,75 @@
|
|||
|
||||
class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
$linked = new Zend_Form_Element_Checkbox("add_show_linked");
|
||||
$linked->setLabel(_("Link:"));
|
||||
$linked = new Zend_Form_Element_Checkbox('add_show_linked');
|
||||
$linked->setLabel(_('Link:'));
|
||||
$this->addElement($linked);
|
||||
|
||||
//Add type select
|
||||
$this->addElement('select', 'add_show_repeat_type', array(
|
||||
$this->addElement('select', 'add_show_repeat_type', [
|
||||
'required' => true,
|
||||
'label' => _('Repeat Type:'),
|
||||
'class' => ' input_select',
|
||||
'multiOptions' => array(
|
||||
"0" => _("weekly"),
|
||||
"1" => _("every 2 weeks"),
|
||||
"4" => _("every 3 weeks"),
|
||||
"5" => _("every 4 weeks"),
|
||||
"2" => _("monthly")
|
||||
),
|
||||
));
|
||||
'multiOptions' => [
|
||||
'0' => _('weekly'),
|
||||
'1' => _('every 2 weeks'),
|
||||
'4' => _('every 3 weeks'),
|
||||
'5' => _('every 4 weeks'),
|
||||
'2' => _('monthly'),
|
||||
],
|
||||
]);
|
||||
|
||||
// Add days checkboxes
|
||||
$this->addElement(
|
||||
'multiCheckbox',
|
||||
'add_show_day_check',
|
||||
array(
|
||||
[
|
||||
'label' => _('Select Days:'),
|
||||
'required' => false,
|
||||
'multiOptions' => array(
|
||||
"0" => _("Sun"),
|
||||
"1" => _("Mon"),
|
||||
"2" => _("Tue"),
|
||||
"3" => _("Wed"),
|
||||
"4" => _("Thu"),
|
||||
"5" => _("Fri"),
|
||||
"6" => _("Sat"),
|
||||
),
|
||||
));
|
||||
'multiOptions' => [
|
||||
'0' => _('Sun'),
|
||||
'1' => _('Mon'),
|
||||
'2' => _('Tue'),
|
||||
'3' => _('Wed'),
|
||||
'4' => _('Thu'),
|
||||
'5' => _('Fri'),
|
||||
'6' => _('Sat'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$repeatMonthlyType = new Zend_Form_Element_Radio("add_show_monthly_repeat_type");
|
||||
$repeatMonthlyType
|
||||
->setLabel(_("Repeat By:"))
|
||||
->setRequired(true)
|
||||
->setMultiOptions(
|
||||
array(2 => _("day of the month"), 3 => _("day of the week")))
|
||||
->setValue(2);
|
||||
$this->addElement($repeatMonthlyType);
|
||||
$repeatMonthlyType = new Zend_Form_Element_Radio('add_show_monthly_repeat_type');
|
||||
$repeatMonthlyType
|
||||
->setLabel(_('Repeat By:'))
|
||||
->setRequired(true)
|
||||
->setMultiOptions(
|
||||
[2 => _('day of the month'), 3 => _('day of the week')]
|
||||
)
|
||||
->setValue(2)
|
||||
;
|
||||
$this->addElement($repeatMonthlyType);
|
||||
|
||||
// Add end date element
|
||||
$this->addElement('text', 'add_show_end_date', array(
|
||||
'label' => _('Date End:'),
|
||||
'class' => 'input_text',
|
||||
'value' => date("Y-m-d"),
|
||||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
$this->addElement('text', 'add_show_end_date', [
|
||||
'label' => _('Date End:'),
|
||||
'class' => 'input_text',
|
||||
'value' => date('Y-m-d'),
|
||||
'required' => false,
|
||||
'filters' => ['StringTrim'],
|
||||
'validators' => [
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))
|
||||
)
|
||||
));
|
||||
['date', false, ['YYYY-MM-DD']],
|
||||
],
|
||||
]);
|
||||
|
||||
// Add no end element
|
||||
$this->addElement('checkbox', 'add_show_no_end', array(
|
||||
'label' => _('No End?'),
|
||||
'required' => false,
|
||||
$this->addElement('checkbox', 'add_show_no_end', [
|
||||
'label' => _('No End?'),
|
||||
'required' => false,
|
||||
'checked' => true,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function disable()
|
||||
|
@ -77,17 +78,18 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid($formData) {
|
||||
if (parent::isValid($formData)) {
|
||||
public function isValid($formData)
|
||||
{
|
||||
if (parent::isValid($formData)) {
|
||||
return $this->checkReliantFields($formData);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData)
|
||||
|
@ -96,24 +98,25 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
$start_timestamp = $formData['add_show_start_date'];
|
||||
$end_timestamp = $formData['add_show_end_date'];
|
||||
$showTimeZone = new DateTimeZone($formData['add_show_timezone']);
|
||||
|
||||
|
||||
//We're assuming all data is valid at this point (timezone, etc.).
|
||||
|
||||
|
||||
$startDate = new DateTime($start_timestamp, $showTimeZone);
|
||||
$endDate = new DateTime($end_timestamp, $showTimeZone);
|
||||
|
||||
|
||||
if ($endDate < $startDate) {
|
||||
$this->getElement('add_show_end_date')->setErrors(array(_('End date must be after start date')));
|
||||
$this->getElement('add_show_end_date')->setErrors([_('End date must be after start date')]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isset($formData['add_show_day_check'])) {
|
||||
$this->getElement('add_show_day_check')->setErrors(array(_('Please select a repeat day')));
|
||||
$this->getElement('add_show_day_check')->setErrors([_('Please select a repeat day')]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,102 +4,103 @@ require_once 'customfilters/ImageSize.php';
|
|||
|
||||
class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
// Add show background-color input
|
||||
$this->addElement('text', 'add_show_background_color', array(
|
||||
'label' => _('Background Colour:'),
|
||||
'class' => 'input_text',
|
||||
'filters' => array('StringTrim')
|
||||
));
|
||||
// Add show background-color input
|
||||
$this->addElement('text', 'add_show_background_color', [
|
||||
'label' => _('Background Colour:'),
|
||||
'class' => 'input_text',
|
||||
'filters' => ['StringTrim'],
|
||||
]);
|
||||
|
||||
$bg = $this->getElement('add_show_background_color');
|
||||
|
||||
$bg->setDecorators(array(array('ViewScript', array(
|
||||
$bg->setDecorators([['ViewScript', [
|
||||
'viewScript' => 'form/add-show-style.phtml',
|
||||
'class' => 'big'
|
||||
))));
|
||||
'class' => 'big',
|
||||
]]]);
|
||||
|
||||
$stringLengthValidator = Application_Form_Helper_ValidationTypes::overrideStringLengthValidator(6, 6);
|
||||
$bg->setValidators(array(
|
||||
'Hex', $stringLengthValidator
|
||||
));
|
||||
$bg->setValidators([
|
||||
'Hex', $stringLengthValidator,
|
||||
]);
|
||||
|
||||
// Add show color input
|
||||
$this->addElement('text', 'add_show_color', array(
|
||||
'label' => _('Text Colour:'),
|
||||
'class' => 'input_text',
|
||||
'filters' => array('StringTrim')
|
||||
));
|
||||
// Add show color input
|
||||
$this->addElement('text', 'add_show_color', [
|
||||
'label' => _('Text Colour:'),
|
||||
'class' => 'input_text',
|
||||
'filters' => ['StringTrim'],
|
||||
]);
|
||||
|
||||
$c = $this->getElement('add_show_color');
|
||||
|
||||
$c->setDecorators(array(array('ViewScript', array(
|
||||
$c->setDecorators([['ViewScript', [
|
||||
'viewScript' => 'form/add-show-style.phtml',
|
||||
'class' => 'big'
|
||||
))));
|
||||
'class' => 'big',
|
||||
]]]);
|
||||
|
||||
$c->setValidators([
|
||||
'Hex', $stringLengthValidator,
|
||||
]);
|
||||
|
||||
$c->setValidators(array(
|
||||
'Hex', $stringLengthValidator
|
||||
));
|
||||
|
||||
// Show the current logo
|
||||
$this->addElement('image', 'add_show_logo_current', array(
|
||||
'label' => _('Current Logo:'),
|
||||
));
|
||||
|
||||
$this->addElement('image', 'add_show_logo_current', [
|
||||
'label' => _('Current Logo:'),
|
||||
]);
|
||||
|
||||
$logo = $this->getElement('add_show_logo_current');
|
||||
$logo->setDecorators(array(
|
||||
array('ViewScript', array(
|
||||
'viewScript' => 'form/add-show-style.phtml',
|
||||
'class' => 'big'
|
||||
))
|
||||
));
|
||||
$logo->setDecorators([
|
||||
['ViewScript', [
|
||||
'viewScript' => 'form/add-show-style.phtml',
|
||||
'class' => 'big',
|
||||
]],
|
||||
]);
|
||||
// Since we need to use a Zend_Form_Element_Image proto, disable it
|
||||
$logo->setAttrib('disabled','disabled');
|
||||
|
||||
$logo->setAttrib('disabled', 'disabled');
|
||||
|
||||
// Button to remove the current logo
|
||||
$this->addElement('button', 'add_show_logo_current_remove', array(
|
||||
'label' => '<span class="ui-button-text">' . _('Remove') . '</span>',
|
||||
'class' => 'ui-button ui-state-default ui-button-text-only',
|
||||
'escape' => false
|
||||
));
|
||||
|
||||
$this->addElement('button', 'add_show_logo_current_remove', [
|
||||
'label' => '<span class="ui-button-text">' . _('Remove') . '</span>',
|
||||
'class' => 'ui-button ui-state-default ui-button-text-only',
|
||||
'escape' => false,
|
||||
]);
|
||||
|
||||
// Add show image input
|
||||
$upload = new Zend_Form_Element_File('add_show_logo');
|
||||
|
||||
|
||||
$upload->setLabel(_('Show Logo:'))
|
||||
->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');
|
||||
->setRequired(false)
|
||||
->setDecorators(['File', ['ViewScript', [
|
||||
'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);
|
||||
|
||||
|
||||
// Add image preview
|
||||
$this->addElement('image', 'add_show_logo_preview', array(
|
||||
'label' => _('Logo Preview:'),
|
||||
));
|
||||
|
||||
$this->addElement('image', 'add_show_logo_preview', [
|
||||
'label' => _('Logo Preview:'),
|
||||
]);
|
||||
|
||||
$preview = $this->getElement('add_show_logo_preview');
|
||||
$preview->setDecorators(array(array('ViewScript', array(
|
||||
'viewScript' => 'form/add-show-style.phtml',
|
||||
'class' => 'big'
|
||||
))));
|
||||
$preview->setAttrib('disabled','disabled');
|
||||
$preview->setDecorators([['ViewScript', [
|
||||
'viewScript' => 'form/add-show-style.phtml',
|
||||
'class' => 'big',
|
||||
]]]);
|
||||
$preview->setAttrib('disabled', 'disabled');
|
||||
|
||||
$csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
|
||||
$csrf_element = new Zend_Form_Element_Hidden('csrf');
|
||||
$csrf_element->setValue($csrf_namespace->authtoken)
|
||||
->setRequired('true')
|
||||
->removeDecorator('HtmlTag')
|
||||
->removeDecorator('Label');
|
||||
->removeDecorator('Label')
|
||||
;
|
||||
$this->addElement($csrf_element);
|
||||
}
|
||||
|
||||
|
@ -110,14 +111,14 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
|||
if ($element->getType() != 'Zend_Form_Element_Hidden'
|
||||
// We should still be able to remove the show logo
|
||||
&& $element->getName() != 'add_show_logo_current_remove') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hideShowLogo() {
|
||||
public function hideShowLogo()
|
||||
{
|
||||
$this->removeElement('add_show_logo');
|
||||
$this->removeElement('add_show_logo_preview');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,78 +11,78 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
|||
|
||||
// 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')
|
||||
));
|
||||
$this->addElement('hidden', 'add_show_id', [
|
||||
'decorators' => ['ViewHelper'],
|
||||
]);
|
||||
|
||||
// Hidden element to indicate the instance id of the show
|
||||
// being edited.
|
||||
$this->addElement('hidden', 'add_show_instance_id', array(
|
||||
'decorators' => array('ViewHelper')
|
||||
));
|
||||
$this->addElement('hidden', 'add_show_instance_id', [
|
||||
'decorators' => ['ViewHelper'],
|
||||
]);
|
||||
|
||||
// Add name element
|
||||
$this->addElement('text', 'add_show_name', array(
|
||||
'label' => _('Name:'),
|
||||
'class' => 'input_text',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'value' => _('Untitled Show'),
|
||||
'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['name'])))
|
||||
));
|
||||
$this->addElement('text', 'add_show_name', [
|
||||
'label' => _('Name:'),
|
||||
'class' => 'input_text',
|
||||
'required' => true,
|
||||
'filters' => ['StringTrim'],
|
||||
'value' => _('Untitled Show'),
|
||||
'validators' => [$notEmptyValidator, ['StringLength', false, [0, $maxLens['name']]]],
|
||||
]);
|
||||
|
||||
// Add URL element
|
||||
$this->addElement('text', 'add_show_url', array(
|
||||
'label' => _('URL:'),
|
||||
'class' => 'input_text',
|
||||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array($notEmptyValidator, array('StringLength', false, array(0, $maxLens['url'])))
|
||||
));
|
||||
// Add URL element
|
||||
$this->addElement('text', 'add_show_url', [
|
||||
'label' => _('URL:'),
|
||||
'class' => 'input_text',
|
||||
'required' => false,
|
||||
'filters' => ['StringTrim'],
|
||||
'validators' => [$notEmptyValidator, ['StringLength', false, [0, $maxLens['url']]]],
|
||||
]);
|
||||
|
||||
// Add genre element
|
||||
$this->addElement('text', 'add_show_genre', array(
|
||||
'label' => _('Genre:'),
|
||||
'class' => 'input_text',
|
||||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(array('StringLength', false, array(0, $maxLens['genre'])))
|
||||
));
|
||||
// Add genre element
|
||||
$this->addElement('text', 'add_show_genre', [
|
||||
'label' => _('Genre:'),
|
||||
'class' => 'input_text',
|
||||
'required' => false,
|
||||
'filters' => ['StringTrim'],
|
||||
'validators' => [['StringLength', false, [0, $maxLens['genre']]]],
|
||||
]);
|
||||
|
||||
// Add the description element
|
||||
$this->addElement('textarea', 'add_show_description', array(
|
||||
'label' => _('Description:'),
|
||||
'required' => false,
|
||||
'class' => 'input_text_area',
|
||||
'validators' => array(array('StringLength', false, array(0, $maxLens['description'])))
|
||||
));
|
||||
// Add the description element
|
||||
$this->addElement('textarea', 'add_show_description', [
|
||||
'label' => _('Description:'),
|
||||
'required' => false,
|
||||
'class' => 'input_text_area',
|
||||
'validators' => [['StringLength', false, [0, $maxLens['description']]]],
|
||||
]);
|
||||
|
||||
$descText = $this->getElement('add_show_description');
|
||||
|
||||
$descText->setDecorators(array(array('ViewScript', array(
|
||||
$descText->setDecorators([['ViewScript', [
|
||||
'viewScript' => 'form/add-show-block.phtml',
|
||||
'class' => 'block-display'
|
||||
))));
|
||||
|
||||
'class' => 'block-display',
|
||||
]]]);
|
||||
|
||||
// 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'])))
|
||||
));
|
||||
|
||||
$this->addElement('textarea', 'add_show_instance_description', [
|
||||
'label' => _('Instance Description:'),
|
||||
'required' => false,
|
||||
'class' => 'input_text_area',
|
||||
'validators' => [['StringLength', false, [0, $maxLens['description']]]],
|
||||
]);
|
||||
|
||||
$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');
|
||||
$instanceDesc->setDecorators([['ViewScript', [
|
||||
'viewScript' => 'form/add-show-block.phtml',
|
||||
'class' => 'block-display',
|
||||
]]]);
|
||||
$instanceDesc->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the instance description when editing a show instance
|
||||
* Enable the instance description when editing a show instance.
|
||||
*/
|
||||
public function enableInstanceDesc()
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('readonly','readonly');
|
||||
$element->setAttrib('readonly', 'readonly');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,45 +2,45 @@
|
|||
|
||||
class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/add-show-when.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/add-show-when.phtml']],
|
||||
]);
|
||||
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$dateValidator = Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY-MM-DD");
|
||||
$dateValidator = Application_Form_Helper_ValidationTypes::overrrideDateValidator('YYYY-MM-DD');
|
||||
$regexValidator = Application_Form_Helper_ValidationTypes::overrideRegexValidator(
|
||||
"/^[0-2]?[0-9]:[0-5][0-9]$/",
|
||||
_("'%value%' does not fit the time format 'HH:mm'"));
|
||||
|
||||
'/^[0-2]?[0-9]:[0-5][0-9]$/',
|
||||
_("'%value%' does not fit the time format 'HH:mm'")
|
||||
);
|
||||
|
||||
// Add start date element
|
||||
$startNow = new Zend_Form_Element_Radio('add_show_start_now');
|
||||
$startNow->setRequired(false)
|
||||
->setLabel(_('Start Time:'))
|
||||
->addMultiOptions(array(
|
||||
->addMultiOptions([
|
||||
'now' => _('Now'),
|
||||
'future' => _('In the Future:')
|
||||
))
|
||||
'future' => _('In the Future:'),
|
||||
])
|
||||
->setValue('future')
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
//$startDate->setAttrib('alt', 'date');
|
||||
$this->addElement($startNow);
|
||||
|
||||
|
||||
// Add start date element
|
||||
$startDate = new Zend_Form_Element_Text('add_show_start_date');
|
||||
$startDate->class = 'input_text';
|
||||
$startDate->setRequired(true)
|
||||
->setLabel(_('In the Future:'))
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
$notEmptyValidator,
|
||||
$dateValidator))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setLabel(_('In the Future:'))
|
||||
->setValue(date('Y-m-d'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
$notEmptyValidator,
|
||||
$dateValidator, ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$startDate->setAttrib('alt', 'date');
|
||||
$this->addElement($startDate);
|
||||
|
||||
|
@ -48,12 +48,12 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
$startTime = new Zend_Form_Element_Text('add_show_start_time');
|
||||
$startTime->class = 'input_text';
|
||||
$startTime->setRequired(true)
|
||||
->setValue('00:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
$notEmptyValidator,
|
||||
$regexValidator
|
||||
))->setDecorators(array('ViewHelper'));
|
||||
->setValue('00:00')
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
$notEmptyValidator,
|
||||
$regexValidator,
|
||||
])->setDecorators(['ViewHelper']);
|
||||
$startTime->setAttrib('alt', 'time');
|
||||
$this->addElement($startTime);
|
||||
|
||||
|
@ -61,13 +61,14 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
$endDate = new Zend_Form_Element_Text('add_show_end_date_no_repeat');
|
||||
$endDate->class = 'input_text';
|
||||
$endDate->setRequired(true)
|
||||
->setLabel(_('End Time:'))
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
$notEmptyValidator,
|
||||
$dateValidator))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setLabel(_('End Time:'))
|
||||
->setValue(date('Y-m-d'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
$notEmptyValidator,
|
||||
$dateValidator, ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$endDate->setAttrib('alt', 'date');
|
||||
$this->addElement($endDate);
|
||||
|
||||
|
@ -75,76 +76,87 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
$endTime = new Zend_Form_Element_Text('add_show_end_time');
|
||||
$endTime->class = 'input_text';
|
||||
$endTime->setRequired(true)
|
||||
->setValue('01:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
$notEmptyValidator,
|
||||
$regexValidator))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setValue('01:00')
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
$notEmptyValidator,
|
||||
$regexValidator, ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$endTime->setAttrib('alt', 'time');
|
||||
$this->addElement($endTime);
|
||||
|
||||
// Add duration element
|
||||
$this->addElement('text', 'add_show_duration', array(
|
||||
'label' => _('Duration:'),
|
||||
'class' => 'input_text',
|
||||
'value' => '01h 00m',
|
||||
'readonly' => true,
|
||||
'decorators' => array('ViewHelper')
|
||||
));
|
||||
$this->addElement('text', 'add_show_duration', [
|
||||
'label' => _('Duration:'),
|
||||
'class' => 'input_text',
|
||||
'value' => '01h 00m',
|
||||
'readonly' => true,
|
||||
'decorators' => ['ViewHelper'],
|
||||
]);
|
||||
|
||||
$timezone = new Zend_Form_Element_Select('add_show_timezone');
|
||||
$timezone->setRequired(true)
|
||||
->setLabel(_("Timezone:"))
|
||||
->setMultiOptions(Application_Common_Timezone::getTimezones())
|
||||
->setValue(Application_Model_Preference::GetUserTimezone())
|
||||
->setAttrib('class', 'input_select add_show_input_select')
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setLabel(_('Timezone:'))
|
||||
->setMultiOptions(Application_Common_Timezone::getTimezones())
|
||||
->setValue(Application_Model_Preference::GetUserTimezone())
|
||||
->setAttrib('class', 'input_select add_show_input_select')
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($timezone);
|
||||
|
||||
// Add repeats element
|
||||
$this->addElement('checkbox', 'add_show_repeats', array(
|
||||
'label' => _('Repeats?'),
|
||||
'required' => false,
|
||||
'decorators' => array('ViewHelper')
|
||||
));
|
||||
|
||||
$this->addElement('checkbox', 'add_show_repeats', [
|
||||
'label' => _('Repeats?'),
|
||||
'required' => false,
|
||||
'decorators' => ['ViewHelper'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function isWhenFormValid($formData, $validateStartDate, $originalStartDate,
|
||||
$update, $instanceId) {
|
||||
public function isWhenFormValid(
|
||||
$formData,
|
||||
$validateStartDate,
|
||||
$originalStartDate,
|
||||
$update,
|
||||
$instanceId
|
||||
) {
|
||||
if (parent::isValid($formData)) {
|
||||
return self::checkReliantFields($formData, $validateStartDate,
|
||||
$originalStartDate, $update, $instanceId);
|
||||
} else {
|
||||
return false;
|
||||
return self::checkReliantFields(
|
||||
$formData,
|
||||
$validateStartDate,
|
||||
$originalStartDate,
|
||||
$update,
|
||||
$instanceId
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null)
|
||||
public function checkReliantFields($formData, $validateStartDate, $originalStartDate = null, $update = false, $instanceId = null)
|
||||
{
|
||||
$valid = true;
|
||||
|
||||
$start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
|
||||
$end_time = $formData['add_show_end_date_no_repeat']." ".$formData['add_show_end_time'];
|
||||
$start_time = $formData['add_show_start_date'] . ' ' . $formData['add_show_start_time'];
|
||||
$end_time = $formData['add_show_end_date_no_repeat'] . ' ' . $formData['add_show_end_time'];
|
||||
|
||||
//have to use the timezone the user has entered in the form to check past/present
|
||||
$showTimezone = new DateTimeZone($formData["add_show_timezone"]);
|
||||
$nowDateTime = new DateTime("now", $showTimezone);
|
||||
$showTimezone = new DateTimeZone($formData['add_show_timezone']);
|
||||
$nowDateTime = new DateTime('now', $showTimezone);
|
||||
$showStartDateTime = new DateTime($start_time, $showTimezone);
|
||||
$showEndDateTime = new DateTime($end_time, $showTimezone);
|
||||
|
||||
if ($validateStartDate && ($formData['add_show_start_now'] != "now")) {
|
||||
if ($validateStartDate && ($formData['add_show_start_now'] != 'now')) {
|
||||
if ($showStartDateTime < $nowDateTime) {
|
||||
$this->getElement('add_show_start_time')->setErrors(array(_('Cannot create show in the past')));
|
||||
$this->getElement('add_show_start_time')->setErrors([_('Cannot create show in the past')]);
|
||||
$valid = false;
|
||||
}
|
||||
// if edit action, check if original show start time is in the past. CC-3864
|
||||
if ($originalStartDate) {
|
||||
if ($originalStartDate < $nowDateTime) {
|
||||
$this->getElement('add_show_start_time')->setValue($originalStartDate->format("H:i"));
|
||||
$this->getElement('add_show_start_date')->setValue($originalStartDate->format("Y-m-d"));
|
||||
$this->getElement('add_show_start_time')->setErrors(array(_('Cannot modify start date/time of the show that is already started')));
|
||||
$this->getElement('add_show_start_time')->setValue($originalStartDate->format('H:i'));
|
||||
$this->getElement('add_show_start_date')->setValue($originalStartDate->format('Y-m-d'));
|
||||
$this->getElement('add_show_start_time')->setErrors([_('Cannot modify start date/time of the show that is already started')]);
|
||||
$this->disableStartDateAndTime();
|
||||
$valid = false;
|
||||
}
|
||||
|
@ -153,7 +165,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
|
||||
// if end time is in the past, return error
|
||||
if ($showEndDateTime < $nowDateTime) {
|
||||
$this->getElement('add_show_end_time')->setErrors(array(_('End date/time cannot be in the past')));
|
||||
$this->getElement('add_show_end_time')->setErrors([_('End date/time cannot be in the past')]);
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
|
@ -161,75 +173,71 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
$duration = $showStartDateTime->diff($showEndDateTime);
|
||||
|
||||
if ($showStartDateTime > $showEndDateTime) {
|
||||
$this->getElement('add_show_duration')->setErrors(array(_('Cannot have duration < 0m')));
|
||||
$valid = false;
|
||||
$this->getElement('add_show_duration')->setErrors([_('Cannot have duration < 0m')]);
|
||||
$valid = false;
|
||||
} elseif ($showStartDateTime == $showEndDateTime) {
|
||||
$this->getElement('add_show_duration')->setErrors([_('Cannot have duration 00h 00m')]);
|
||||
$valid = false;
|
||||
} elseif (intval($duration->format('%d')) > 0
|
||||
&& (intval($duration->format('%h')) > 0
|
||||
|| intval($duration->format('%i')) > 0
|
||||
|| intval($duration->format('%s')) > 0)) {
|
||||
$this->getElement('add_show_duration')->setErrors([_('Cannot have duration greater than 24h')]);
|
||||
$valid = false;
|
||||
}
|
||||
else if ($showStartDateTime == $showEndDateTime) {
|
||||
$this->getElement('add_show_duration')->setErrors(array(_('Cannot have duration 00h 00m')));
|
||||
$valid = false;
|
||||
}
|
||||
else if (intval($duration->format('%d')) > 0 &&
|
||||
(intval($duration->format('%h')) > 0
|
||||
|| intval($duration->format('%i')) > 0
|
||||
|| intval($duration->format('%s')) > 0)) {
|
||||
$this->getElement('add_show_duration')->setErrors(array(_('Cannot have duration greater than 24h')));
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
|
||||
/* We need to know the show duration broken down into hours and minutes
|
||||
* They are used for checking overlapping shows and for validating
|
||||
* rebroadcast instances
|
||||
*/
|
||||
$hours = $duration->format("%h");
|
||||
$minutes = $duration->format("%i");
|
||||
$hours = $duration->format('%h');
|
||||
$minutes = $duration->format('%i');
|
||||
|
||||
/* Check if show is overlapping
|
||||
* We will only do this check if the show is valid
|
||||
* upto this point
|
||||
*/
|
||||
if ($valid) {
|
||||
//we need to know the start day of the week in show's local timezome
|
||||
$startDow = $showStartDateTime->format("w");
|
||||
//we need to know the start day of the week in show's local timezome
|
||||
$startDow = $showStartDateTime->format('w');
|
||||
|
||||
$utc = new DateTimeZone('UTC');
|
||||
$showStartDateTime->setTimezone($utc);
|
||||
$showEndDateTime->setTimezone($utc);
|
||||
|
||||
if ($formData["add_show_repeats"]) {
|
||||
|
||||
if ($formData['add_show_repeats']) {
|
||||
//get repeating show end date
|
||||
if ($formData["add_show_no_end"]) {
|
||||
if ($formData['add_show_no_end']) {
|
||||
$date = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||
|
||||
if (is_null($date)) {
|
||||
$populateUntilDateTime = new DateTime("now", $utc);
|
||||
$populateUntilDateTime = new DateTime('now', $utc);
|
||||
Application_Model_Preference::SetShowsPopulatedUntil($populateUntilDateTime);
|
||||
} else {
|
||||
$populateUntilDateTime = clone $date;
|
||||
}
|
||||
|
||||
} elseif (!$formData["add_show_no_end"]) {
|
||||
$popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"];
|
||||
} elseif (!$formData['add_show_no_end']) {
|
||||
$popUntil = $formData['add_show_end_date'] . ' ' . $formData['add_show_end_time'];
|
||||
$populateUntilDateTime = new DateTime($popUntil, $showTimezone);
|
||||
$populateUntilDateTime->setTimezone($utc);
|
||||
}
|
||||
|
||||
//get repeat interval
|
||||
if ($formData["add_show_repeat_type"] == 0) {
|
||||
if ($formData['add_show_repeat_type'] == 0) {
|
||||
$interval = 'P7D';
|
||||
} elseif ($formData["add_show_repeat_type"] == 1) {
|
||||
} elseif ($formData['add_show_repeat_type'] == 1) {
|
||||
$interval = 'P14D';
|
||||
} elseif ($formData["add_show_repeat_type"] == 4) {
|
||||
} elseif ($formData['add_show_repeat_type'] == 4) {
|
||||
$interval = 'P21D';
|
||||
} elseif ($formData["add_show_repeat_type"] == 5) {
|
||||
} elseif ($formData['add_show_repeat_type'] == 5) {
|
||||
$interval = 'P28D';
|
||||
} elseif ($formData["add_show_repeat_type"] == 2 && $formData["add_show_monthly_repeat_type"] == 2) {
|
||||
} elseif ($formData['add_show_repeat_type'] == 2 && $formData['add_show_monthly_repeat_type'] == 2) {
|
||||
$interval = 'P1M';
|
||||
} elseif ($formData["add_show_repeat_type"] == 2 && $formData["add_show_monthly_repeat_type"] == 3) {
|
||||
} elseif ($formData['add_show_repeat_type'] == 2 && $formData['add_show_monthly_repeat_type'] == 3) {
|
||||
list($weekNumberOfMonth, $dayOfWeek) =
|
||||
Application_Service_ShowService::getMonthlyWeeklyRepeatInterval(
|
||||
new DateTime($start_time, $showTimezone));
|
||||
new DateTime($start_time, $showTimezone)
|
||||
);
|
||||
}
|
||||
|
||||
/* Check first show
|
||||
|
@ -237,30 +245,37 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
*/
|
||||
if ($update) {
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||
$showStartDateTime, $showEndDateTime, $update, null, $formData["add_show_id"]);
|
||||
$showStartDateTime,
|
||||
$showEndDateTime,
|
||||
$update,
|
||||
null,
|
||||
$formData['add_show_id']
|
||||
);
|
||||
} else {
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||
$showStartDateTime, $showEndDateTime);
|
||||
$showStartDateTime,
|
||||
$showEndDateTime
|
||||
);
|
||||
}
|
||||
|
||||
/* Check if repeats overlap with previously scheduled shows
|
||||
* Do this for each show day
|
||||
*/
|
||||
if (!$overlapping) {
|
||||
|
||||
if (!isset($formData['add_show_day_check'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($formData["add_show_day_check"] as $day) {
|
||||
foreach ($formData['add_show_day_check'] as $day) {
|
||||
$repeatShowStart = clone $showStartDateTime;
|
||||
$repeatShowEnd = clone $showEndDateTime;
|
||||
$daysAdd=0;
|
||||
$daysAdd = 0;
|
||||
if ($startDow !== $day) {
|
||||
if ($startDow > $day)
|
||||
if ($startDow > $day) {
|
||||
$daysAdd = 6 - $startDow + 1 + $day;
|
||||
else
|
||||
} else {
|
||||
$daysAdd = $day - $startDow;
|
||||
}
|
||||
|
||||
/* In case we are crossing daylights saving time we need
|
||||
* to convert show start and show end to local time before
|
||||
|
@ -268,8 +283,8 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
*/
|
||||
$repeatShowStart->setTimezone($showTimezone);
|
||||
$repeatShowEnd->setTimezone($showTimezone);
|
||||
$repeatShowStart->add(new DateInterval("P".$daysAdd."D"));
|
||||
$repeatShowEnd->add(new DateInterval("P".$daysAdd."D"));
|
||||
$repeatShowStart->add(new DateInterval('P' . $daysAdd . 'D'));
|
||||
$repeatShowEnd->add(new DateInterval('P' . $daysAdd . 'D'));
|
||||
//set back to UTC
|
||||
$repeatShowStart->setTimezone($utc);
|
||||
$repeatShowEnd->setTimezone($utc);
|
||||
|
@ -282,49 +297,58 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
if ($formData['add_show_id'] == -1) {
|
||||
//this is a new show
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||
$repeatShowStart, $repeatShowEnd);
|
||||
$repeatShowStart,
|
||||
$repeatShowEnd
|
||||
);
|
||||
} else {
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||
$repeatShowStart, $repeatShowEnd, $update, null, $formData["add_show_id"]);
|
||||
$repeatShowStart,
|
||||
$repeatShowEnd,
|
||||
$update,
|
||||
null,
|
||||
$formData['add_show_id']
|
||||
);
|
||||
}
|
||||
|
||||
if ($overlapping) {
|
||||
$valid = false;
|
||||
$this->getElement('add_show_duration')->setErrors(array(_('Cannot schedule overlapping shows')));
|
||||
break 1;
|
||||
$this->getElement('add_show_duration')->setErrors([_('Cannot schedule overlapping shows')]);
|
||||
|
||||
break;
|
||||
}
|
||||
if ($formData['add_show_repeat_type'] == 2 && $formData['add_show_monthly_repeat_type'] == 3) {
|
||||
$monthlyWeeklyStart = new DateTime(
|
||||
$repeatShowStart->format('Y-m'),
|
||||
new DateTimeZone('UTC')
|
||||
);
|
||||
$monthlyWeeklyStart->add(new DateInterval('P1M'));
|
||||
$repeatShowStart = clone Application_Service_ShowService::getNextMonthlyWeeklyRepeatDate(
|
||||
$monthlyWeeklyStart,
|
||||
$formData['add_show_timezone'],
|
||||
$formData['add_show_start_time'],
|
||||
$weekNumberOfMonth,
|
||||
$dayOfWeek
|
||||
);
|
||||
$repeatShowEnd = clone $repeatShowStart;
|
||||
$repeatShowEnd->add(new DateInterval('PT' . $hours . 'H' . $minutes . 'M'));
|
||||
} else {
|
||||
if ($formData["add_show_repeat_type"] == 2 && $formData["add_show_monthly_repeat_type"] == 3) {
|
||||
$monthlyWeeklyStart = new DateTime($repeatShowStart->format("Y-m"),
|
||||
new DateTimeZone("UTC"));
|
||||
$monthlyWeeklyStart->add(new DateInterval("P1M"));
|
||||
$repeatShowStart = clone Application_Service_ShowService::getNextMonthlyWeeklyRepeatDate(
|
||||
$monthlyWeeklyStart,
|
||||
$formData["add_show_timezone"],
|
||||
$formData['add_show_start_time'],
|
||||
$weekNumberOfMonth,
|
||||
$dayOfWeek);
|
||||
$repeatShowEnd = clone $repeatShowStart;
|
||||
$repeatShowEnd->add(new DateInterval("PT".$hours."H".$minutes."M"));
|
||||
} else {
|
||||
$repeatShowStart->setTimezone($showTimezone);
|
||||
$repeatShowEnd->setTimezone($showTimezone);
|
||||
$repeatShowStart->add(new DateInterval($interval));
|
||||
$repeatShowEnd->add(new DateInterval($interval));
|
||||
$repeatShowStart->setTimezone($utc);
|
||||
$repeatShowEnd->setTimezone($utc);
|
||||
}
|
||||
$repeatShowStart->setTimezone($showTimezone);
|
||||
$repeatShowEnd->setTimezone($showTimezone);
|
||||
$repeatShowStart->add(new DateInterval($interval));
|
||||
$repeatShowEnd->add(new DateInterval($interval));
|
||||
$repeatShowStart->setTimezone($utc);
|
||||
$repeatShowEnd->setTimezone($utc);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
$this->getElement('add_show_duration')->setErrors(array(_('Cannot schedule overlapping shows')));
|
||||
$this->getElement('add_show_duration')->setErrors([_('Cannot schedule overlapping shows')]);
|
||||
}
|
||||
|
||||
} else {
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows($showStartDateTime, $showEndDateTime, $update, $instanceId);
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows($showStartDateTime, $showEndDateTime, $update, $instanceId);
|
||||
if ($overlapping) {
|
||||
$this->getElement('add_show_duration')->setErrors(array(_('Cannot schedule overlapping shows')));
|
||||
$this->getElement('add_show_duration')->setErrors([_('Cannot schedule overlapping shows')]);
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
@ -333,34 +357,47 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
return $valid;
|
||||
}
|
||||
|
||||
public function checkRebroadcastDates($repeatShowStart, $formData, $hours, $minutes, $showEdit=false) {
|
||||
public function checkRebroadcastDates($repeatShowStart, $formData, $hours, $minutes, $showEdit = false)
|
||||
{
|
||||
$overlapping = false;
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
if (empty($formData["add_show_rebroadcast_date_".$i])) break;
|
||||
for ($i = 1; $i <= 10; ++$i) {
|
||||
if (empty($formData['add_show_rebroadcast_date_' . $i])) {
|
||||
break;
|
||||
}
|
||||
$rebroadcastShowStart = clone $repeatShowStart;
|
||||
/* formData is in local time so we need to set the
|
||||
* show start back to local time
|
||||
*/
|
||||
$rebroadcastShowStart->setTimezone(new DateTimeZone(
|
||||
$formData["add_show_timezone"]));
|
||||
$rebroadcastWhenDays = explode(" ", $formData["add_show_rebroadcast_date_".$i]);
|
||||
$rebroadcastWhenTime = explode(":", $formData["add_show_rebroadcast_time_".$i]);
|
||||
$rebroadcastShowStart->add(new DateInterval("P".$rebroadcastWhenDays[0]."D"));
|
||||
$formData['add_show_timezone']
|
||||
));
|
||||
$rebroadcastWhenDays = explode(' ', $formData['add_show_rebroadcast_date_' . $i]);
|
||||
$rebroadcastWhenTime = explode(':', $formData['add_show_rebroadcast_time_' . $i]);
|
||||
$rebroadcastShowStart->add(new DateInterval('P' . $rebroadcastWhenDays[0] . 'D'));
|
||||
$rebroadcastShowStart->setTime($rebroadcastWhenTime[0], $rebroadcastWhenTime[1]);
|
||||
$rebroadcastShowStart->setTimezone(new DateTimeZone('UTC'));
|
||||
|
||||
$rebroadcastShowEnd = clone $rebroadcastShowStart;
|
||||
$rebroadcastShowEnd->add(new DateInterval("PT".$hours."H".$minutes."M"));
|
||||
$rebroadcastShowEnd->add(new DateInterval('PT' . $hours . 'H' . $minutes . 'M'));
|
||||
|
||||
if ($showEdit) {
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||
$rebroadcastShowStart, $rebroadcastShowEnd, true, null, $formData['add_show_id']);
|
||||
$rebroadcastShowStart,
|
||||
$rebroadcastShowEnd,
|
||||
true,
|
||||
null,
|
||||
$formData['add_show_id']
|
||||
);
|
||||
} else {
|
||||
$overlapping = Application_Model_Schedule::checkOverlappingShows(
|
||||
$rebroadcastShowStart, $rebroadcastShowEnd);
|
||||
$rebroadcastShowStart,
|
||||
$rebroadcastShowEnd
|
||||
);
|
||||
}
|
||||
|
||||
if ($overlapping) break;
|
||||
if ($overlapping) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $overlapping;
|
||||
|
@ -371,7 +408,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -380,16 +417,16 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
{
|
||||
$element = $this->getElement('add_show_repeats');
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
|
||||
public function disableStartDateAndTime()
|
||||
{
|
||||
$elements = array($this->getElement('add_show_start_date'), $this->getElement('add_show_start_time'));
|
||||
$elements = [$this->getElement('add_show_start_date'), $this->getElement('add_show_start_time')];
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,16 @@
|
|||
|
||||
class Application_Form_AddShowWho extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
// Add hosts autocomplete
|
||||
$this->addElement('text', 'add_show_hosts_autocomplete', array(
|
||||
'label' => _('Search Users:'),
|
||||
'class' => 'input_text ui-autocomplete-input',
|
||||
'required' => false
|
||||
));
|
||||
$this->addElement('text', 'add_show_hosts_autocomplete', [
|
||||
'label' => _('Search Users:'),
|
||||
'class' => 'input_text ui-autocomplete-input',
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
$options = array();
|
||||
$options = [];
|
||||
$hosts = Application_Model_User::getHosts();
|
||||
|
||||
foreach ($hosts as $host) {
|
||||
|
@ -22,7 +21,8 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
|
|||
//Add hosts selection
|
||||
$hosts = new Zend_Form_Element_MultiCheckbox('add_show_hosts');
|
||||
$hosts->setLabel(_('DJs:'))
|
||||
->setMultiOptions($options);
|
||||
->setMultiOptions($options)
|
||||
;
|
||||
|
||||
$this->addElement($hosts);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
|
|||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
||||
$element->setAttrib('disabled','disabled');
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class Application_Form_AddTracktype extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
|
@ -10,12 +9,12 @@ class Application_Form_AddTracktype extends Zend_Form
|
|||
$this->setAttrib('id', 'tracktype_form');
|
||||
|
||||
$hidden = new Zend_Form_Element_Hidden('tracktype_id');
|
||||
$hidden->setDecorators(array('ViewHelper'));
|
||||
$hidden->setDecorators(['ViewHelper']);
|
||||
$this->addElement($hidden);
|
||||
|
||||
$this->addElement('hash', 'csrf', array(
|
||||
'salt' => 'unique'
|
||||
));
|
||||
$this->addElement('hash', 'csrf', [
|
||||
'salt' => 'unique',
|
||||
]);
|
||||
|
||||
$typeName = new Zend_Form_Element_Text('type_name');
|
||||
$typeName->setLabel(_('Type Name:'));
|
||||
|
@ -34,10 +33,11 @@ class Application_Form_AddTracktype extends Zend_Form
|
|||
|
||||
$description = new Zend_Form_Element_Textarea('description');
|
||||
$description->setLabel(_('Description:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 200))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 200]),
|
||||
])
|
||||
;
|
||||
$description->setAttrib('class', 'input_text');
|
||||
$description->addFilter('StringTrim');
|
||||
$this->addElement($description);
|
||||
|
@ -46,10 +46,10 @@ class Application_Form_AddTracktype extends Zend_Form
|
|||
$visibility->setLabel(_('Visibility:'));
|
||||
$visibility->setAttrib('class', 'input_select');
|
||||
$visibility->setAttrib('style', 'width: 40%');
|
||||
$visibility->setMultiOptions(array(
|
||||
"0" => _("Disabled"),
|
||||
"1" => _("Enabled")
|
||||
));
|
||||
$visibility->setMultiOptions([
|
||||
'0' => _('Disabled'),
|
||||
'1' => _('Enabled'),
|
||||
]);
|
||||
//$visibility->getValue();
|
||||
$visibility->setRequired(true);
|
||||
$this->addElement($visibility);
|
||||
|
@ -67,7 +67,7 @@ class Application_Form_AddTracktype extends Zend_Form
|
|||
$count = CcTracktypesQuery::create()->filterByDbCode($data['code'])->count();
|
||||
|
||||
if ($count != 0) {
|
||||
$this->getElement('code')->setErrors(array(_("Code is not unique.")));
|
||||
$this->getElement('code')->setErrors([_('Code is not unique.')]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -75,5 +75,4 @@ class Application_Form_AddTracktype extends Zend_Form
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class Application_Form_AddUser extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/*
|
||||
|
@ -13,16 +12,16 @@ class Application_Form_AddUser extends Zend_Form
|
|||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator();
|
||||
$notDemoValidator = new Application_Validate_NotDemoValidate();
|
||||
|
||||
|
||||
$this->setAttrib('id', 'user_form');
|
||||
|
||||
|
||||
$hidden = new Zend_Form_Element_Hidden('user_id');
|
||||
$hidden->setDecorators(array('ViewHelper'));
|
||||
$hidden->setDecorators(['ViewHelper']);
|
||||
$this->addElement($hidden);
|
||||
|
||||
$this->addElement('hash', 'csrf', array(
|
||||
'salt' => 'unique'
|
||||
));
|
||||
$this->addElement('hash', 'csrf', [
|
||||
'salt' => 'unique',
|
||||
]);
|
||||
|
||||
$login = new Zend_Form_Element_Text('login');
|
||||
$login->setLabel(_('Username:'));
|
||||
|
@ -94,12 +93,12 @@ class Application_Form_AddUser extends Zend_Form
|
|||
$select->setLabel(_('User Type:'));
|
||||
$select->setAttrib('class', 'input_select');
|
||||
$select->setAttrib('style', 'width: 40%');
|
||||
$select->setMultiOptions(array(
|
||||
"G" => _("Guest"),
|
||||
"H" => _("DJ"),
|
||||
"P" => _("Program Manager"),
|
||||
"A" => _("Admin"),
|
||||
));
|
||||
$select->setMultiOptions([
|
||||
'G' => _('Guest'),
|
||||
'H' => _('DJ'),
|
||||
'P' => _('Program Manager'),
|
||||
'A' => _('Admin'),
|
||||
]);
|
||||
$select->setRequired(false);
|
||||
$this->addElement($select);
|
||||
|
||||
|
@ -116,7 +115,7 @@ class Application_Form_AddUser extends Zend_Form
|
|||
$count = CcSubjsQuery::create()->filterByDbLogin($data['login'])->count();
|
||||
|
||||
if ($count != 0) {
|
||||
$this->getElement('login')->setErrors(array(_("Login name is not unique.")));
|
||||
$this->getElement('login')->setErrors([_('Login name is not unique.')]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -127,10 +126,13 @@ class Application_Form_AddUser extends Zend_Form
|
|||
|
||||
// We need to add the password identical validator here in case
|
||||
// Zend version is less than 1.10.5
|
||||
public function isValid($data) {
|
||||
public function isValid($data)
|
||||
{
|
||||
$passwordIdenticalValidator = Application_Form_Helper_ValidationTypes::overridePasswordIdenticalValidator(
|
||||
$data['password']);
|
||||
$data['password']
|
||||
);
|
||||
$this->getElement('passwordVerify')->addValidator($passwordIdenticalValidator);
|
||||
|
||||
return parent::isValid($data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_DangerousPreferences extends Zend_Form_SubForm {
|
||||
|
||||
public function init() {
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_danger.phtml'))
|
||||
));
|
||||
class Application_Form_DangerousPreferences extends Zend_Form_SubForm
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/preferences_danger.phtml']],
|
||||
]);
|
||||
|
||||
$clearLibrary = new Zend_Form_Element_Button('clear_library');
|
||||
$clearLibrary->setLabel(_('Delete All Tracks in Library'));
|
||||
//$submit->removeDecorator('Label');
|
||||
$clearLibrary->setAttribs(array('class'=>'btn centered'));
|
||||
$clearLibrary->setAttribs(['class' => 'btn centered']);
|
||||
$clearLibrary->setAttrib('onclick', 'deleteAllFiles();');
|
||||
$clearLibrary->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->addElement($clearLibrary);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
class Application_Form_DateRange extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/daterange.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/daterange.phtml']],
|
||||
]);
|
||||
|
||||
// Add start date element
|
||||
$startDate = new Zend_Form_Element_Text('his_date_start');
|
||||
$startDate->class = 'input_text';
|
||||
$startDate->setRequired(true)
|
||||
->setLabel(_('Date Start:'))
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setLabel(_('Date Start:'))
|
||||
->setValue(date('Y-m-d'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
['date', false, ['YYYY-MM-DD']], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$startDate->setAttrib('alt', 'date');
|
||||
$this->addElement($startDate);
|
||||
|
||||
|
@ -27,13 +27,14 @@ class Application_Form_DateRange extends Zend_Form_SubForm
|
|||
$startTime = new Zend_Form_Element_Text('his_time_start');
|
||||
$startTime->class = 'input_text';
|
||||
$startTime->setRequired(true)
|
||||
->setValue('00:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setValue('00:00')
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
['date', false, ['HH:mm']],
|
||||
['regex', false, ['/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$startTime->setAttrib('alt', 'time');
|
||||
$this->addElement($startTime);
|
||||
|
||||
|
@ -41,13 +42,14 @@ class Application_Form_DateRange extends Zend_Form_SubForm
|
|||
$endDate = new Zend_Form_Element_Text('his_date_end');
|
||||
$endDate->class = 'input_text';
|
||||
$endDate->setRequired(true)
|
||||
->setLabel(_('Date End:'))
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setLabel(_('Date End:'))
|
||||
->setValue(date('Y-m-d'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
['date', false, ['YYYY-MM-DD']], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$endDate->setAttrib('alt', 'date');
|
||||
$this->addElement($endDate);
|
||||
|
||||
|
@ -55,13 +57,14 @@ class Application_Form_DateRange extends Zend_Form_SubForm
|
|||
$endTime = new Zend_Form_Element_Text('his_time_end');
|
||||
$endTime->class = 'input_text';
|
||||
$endTime->setRequired(true)
|
||||
->setValue('01:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setValue('01:00')
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
['date', false, ['HH:mm']],
|
||||
['regex', false, ['/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$endTime->setAttrib('alt', 'time');
|
||||
$this->addElement($endTime);
|
||||
}
|
||||
|
|
|
@ -2,46 +2,48 @@
|
|||
|
||||
class Application_Form_EditAudioMD extends Zend_Form
|
||||
{
|
||||
|
||||
public function init() {}
|
||||
public function init()
|
||||
{
|
||||
}
|
||||
|
||||
public function startForm($p_id)
|
||||
{
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
// Set the method for the display form to POST
|
||||
// Set the method for the display form to POST
|
||||
$this->setMethod('post');
|
||||
|
||||
$file_id = new Zend_Form_Element_Hidden('file_id');
|
||||
$file_id->setValue($p_id);
|
||||
$file_id->addDecorator('HtmlTag', array('tag' => 'div', 'style' => 'display:none'));
|
||||
$file_id->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none']);
|
||||
$file_id->removeDecorator('Label');
|
||||
$file_id->setAttrib('class', 'obj_id');
|
||||
$this->addElement($file_id);
|
||||
|
||||
// Add artwork hidden field
|
||||
$artwork = new Zend_Form_Element_Hidden('artwork');
|
||||
$artwork->class = 'input_text artwork_'. $p_id;
|
||||
$artwork->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 2048))
|
||||
));
|
||||
$file_id->addDecorator('HtmlTag', array('tag' => 'div', 'style' => 'display:none'));
|
||||
$artwork->class = 'input_text artwork_' . $p_id;
|
||||
$artwork->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 2048]),
|
||||
])
|
||||
;
|
||||
$file_id->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none']);
|
||||
$file_id->removeDecorator('Label');
|
||||
$file_id->setAttrib('class', 'artwork');
|
||||
$this->addElement($artwork);
|
||||
|
||||
// Set artwork hidden field
|
||||
$set_artwork = new Zend_Form_Element_Hidden('set_artwork');
|
||||
$set_artwork->class = 'input_text set_artwork_'. $p_id;
|
||||
$file_id->addDecorator('HtmlTag', array('tag' => 'div', 'style' => 'display:none'));
|
||||
$set_artwork->class = 'input_text set_artwork_' . $p_id;
|
||||
$file_id->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none']);
|
||||
$file_id->removeDecorator('Label');
|
||||
$file_id->setAttrib('class', 'set_artwork');
|
||||
$this->addElement($set_artwork);
|
||||
|
||||
// Remove artwork hidden field
|
||||
$remove_artwork = new Zend_Form_Element_Hidden('remove_artwork');
|
||||
$remove_artwork->class = 'input_text remove_artwork_'. $p_id;
|
||||
$file_id->addDecorator('HtmlTag', array('tag' => 'div', 'style' => 'display:none'));
|
||||
$remove_artwork->class = 'input_text remove_artwork_' . $p_id;
|
||||
$file_id->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none']);
|
||||
$file_id->removeDecorator('Label');
|
||||
$file_id->setAttrib('class', 'remove_artwork');
|
||||
$this->addElement($remove_artwork);
|
||||
|
@ -50,35 +52,37 @@ class Application_Form_EditAudioMD extends Zend_Form
|
|||
$track_title = new Zend_Form_Element_Text('track_title');
|
||||
$track_title->class = 'input_text';
|
||||
$track_title->setLabel(_('Title:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($track_title);
|
||||
|
||||
// Add artist field
|
||||
$artist_name = new Zend_Form_Element_Text('artist_name');
|
||||
$artist_name->class = 'input_text';
|
||||
$artist_name->setLabel(_('Creator:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($artist_name);
|
||||
|
||||
// Add album field
|
||||
$album_title = new Zend_Form_Element_Text('album_title');
|
||||
$album_title->class = 'input_text';
|
||||
$album_title->setLabel(_('Album:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($album_title);
|
||||
|
||||
|
||||
// Add album field
|
||||
$user_options = array();
|
||||
$user_options = [];
|
||||
$users = Application_Model_User::getNonGuestUsers();
|
||||
|
||||
foreach ($users as $host) {
|
||||
|
@ -92,14 +96,14 @@ class Application_Form_EditAudioMD extends Zend_Form
|
|||
$this->addelement($owner_id);
|
||||
|
||||
// Add track type dropdown
|
||||
$track_type_options = array();
|
||||
$track_type_options = [];
|
||||
$track_types = Application_Model_Tracktype::getTracktypes();
|
||||
|
||||
array_multisort(array_map(function($element) {
|
||||
|
||||
array_multisort(array_map(function ($element) {
|
||||
return $element['type_name'];
|
||||
}, $track_types), SORT_ASC, $track_types);
|
||||
|
||||
$track_type_options[""] = _('Select a Type');
|
||||
|
||||
$track_type_options[''] = _('Select a Type');
|
||||
foreach ($track_types as $key => $tt) {
|
||||
$track_type_options[$tt['code']] = $tt['type_name'];
|
||||
}
|
||||
|
@ -114,189 +118,204 @@ class Application_Form_EditAudioMD extends Zend_Form
|
|||
$description = new Zend_Form_Element_Textarea('description');
|
||||
$description->class = 'input_text';
|
||||
$description->setLabel(_('Description:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($description);
|
||||
|
||||
// Add track number field
|
||||
$track_number = new Zend_Form_Element('track_number');
|
||||
$track_number->class = 'input_text';
|
||||
$track_number->setLabel('Track Number:')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(new Zend_Validate_Int()));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([new Zend_Validate_Int()])
|
||||
;
|
||||
$this->addElement($track_number);
|
||||
|
||||
// Add genre field
|
||||
$genre = new Zend_Form_Element('genre');
|
||||
$genre->class = 'input_text';
|
||||
$genre->setLabel(_('Genre:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 64))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 64]),
|
||||
])
|
||||
;
|
||||
$this->addElement($genre);
|
||||
|
||||
// Add year field
|
||||
$year = new Zend_Form_Element_Text('year');
|
||||
$year->class = 'input_text';
|
||||
$year->setLabel(_('Year:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 10)),
|
||||
Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY-MM-DD"),
|
||||
Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY-MM"),
|
||||
Application_Form_Helper_ValidationTypes::overrrideDateValidator("YYYY")
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 10]),
|
||||
Application_Form_Helper_ValidationTypes::overrrideDateValidator('YYYY-MM-DD'),
|
||||
Application_Form_Helper_ValidationTypes::overrrideDateValidator('YYYY-MM'),
|
||||
Application_Form_Helper_ValidationTypes::overrrideDateValidator('YYYY'),
|
||||
])
|
||||
;
|
||||
$this->addElement($year);
|
||||
|
||||
// Add label field
|
||||
$label = new Zend_Form_Element('label');
|
||||
$label->class = 'input_text';
|
||||
$label->setLabel(_('Label:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($label);
|
||||
|
||||
// Add composer field
|
||||
$composer = new Zend_Form_Element('composer');
|
||||
$composer->class = 'input_text';
|
||||
$composer->setLabel(_('Composer:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($composer);
|
||||
|
||||
// Add conductor field
|
||||
$conductor = new Zend_Form_Element('conductor');
|
||||
$conductor->class = 'input_text';
|
||||
$conductor->setLabel(_('Conductor:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($conductor);
|
||||
|
||||
// Add mood field
|
||||
$mood = new Zend_Form_Element('mood');
|
||||
$mood->class = 'input_text';
|
||||
$mood->setLabel(_('Mood:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 64))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 64]),
|
||||
])
|
||||
;
|
||||
$this->addElement($mood);
|
||||
|
||||
// Add bmp field
|
||||
$bpm = new Zend_Form_Element_Text('bpm');
|
||||
$bpm->class = 'input_text';
|
||||
$bpm->setLabel(_('BPM:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('min'=>0,'max' => 8)),
|
||||
new Zend_Validate_Digits()));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['min' => 0, 'max' => 8]),
|
||||
new Zend_Validate_Digits(), ])
|
||||
;
|
||||
$this->addElement($bpm);
|
||||
|
||||
// Add copyright field
|
||||
$copyright = new Zend_Form_Element('copyright');
|
||||
$copyright->class = 'input_text';
|
||||
$copyright->setLabel(_('Copyright:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($copyright);
|
||||
|
||||
// Add isrc number field
|
||||
$isrc_number = new Zend_Form_Element('isrc_number');
|
||||
$isrc_number->class = 'input_text';
|
||||
$isrc_number->setLabel(_('ISRC Number:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($isrc_number);
|
||||
|
||||
// Add website field
|
||||
$info_url = new Zend_Form_Element('info_url');
|
||||
$info_url->class = 'input_text';
|
||||
$info_url->setLabel(_('Website:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($info_url);
|
||||
|
||||
// Add language field
|
||||
$language = new Zend_Form_Element('language');
|
||||
$language->class = 'input_text';
|
||||
$language->setLabel(_('Language:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
new Zend_Validate_StringLength(array('max' => 512))
|
||||
));
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
new Zend_Validate_StringLength(['max' => 512]),
|
||||
])
|
||||
;
|
||||
$this->addElement($language);
|
||||
|
||||
$validCuePattern = '/^(?:[0-9]{1,2}:)?(?:[0-9]{1,2}:)?[0-9]{1,6}(\.\d{1,6})?$/';
|
||||
|
||||
$cueIn = new Zend_Form_Element_Text('cuein');
|
||||
$cueIn->class = 'input_text';
|
||||
$cueIn->setLabel("Cue In:");
|
||||
$cueIn->setLabel('Cue In:');
|
||||
$cueInValidator = Application_Form_Helper_ValidationTypes::overrideRegexValidator(
|
||||
$validCuePattern, _(sprintf("Specify cue in time in the format %s", "(hh:mm:)ss(.dddddd)"))
|
||||
$validCuePattern,
|
||||
_(sprintf('Specify cue in time in the format %s', '(hh:mm:)ss(.dddddd)'))
|
||||
);
|
||||
$cueIn->setValidators(array($cueInValidator));
|
||||
$cueIn->setValidators([$cueInValidator]);
|
||||
$this->addElement($cueIn);
|
||||
|
||||
$cueOut = new Zend_Form_Element_Text('cueout');
|
||||
$cueOut->class = 'input_text';
|
||||
$cueOut->setLabel('Cue Out:');
|
||||
$cueOutValidator = Application_Form_Helper_ValidationTypes::overrideRegexValidator(
|
||||
$validCuePattern, _(sprintf("Specify cue out time in the format %s", "(hh:mm:)ss(.dddddd)"))
|
||||
$validCuePattern,
|
||||
_(sprintf('Specify cue out time in the format %s', '(hh:mm:)ss(.dddddd)'))
|
||||
);
|
||||
$cueOut->setValidators(array($cueOutValidator));
|
||||
$cueOut->setValidators([$cueOutValidator]);
|
||||
$this->addElement($cueOut);
|
||||
|
||||
// Add the cancel button
|
||||
$this->addElement('button', 'editmdcancel', array(
|
||||
'ignore' => true,
|
||||
'class' => 'btn md-cancel',
|
||||
'label' => _('Cancel'),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
$this->addElement('button', 'editmdcancel', [
|
||||
'ignore' => true,
|
||||
'class' => 'btn md-cancel',
|
||||
'label' => _('Cancel'),
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
// Add the submit button
|
||||
$this->addElement('button', 'editmdsave', array(
|
||||
'ignore' => true,
|
||||
'class' => 'btn md-save',
|
||||
'label' => _('Save'),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
$this->addElement('button', 'editmdsave', [
|
||||
'ignore' => true,
|
||||
'class' => 'btn md-save',
|
||||
'label' => _('Save'),
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
// Button to open the publish dialog
|
||||
$this->addElement('button', 'publishdialog', array(
|
||||
'ignore' => true,
|
||||
'class' => 'btn md-publish',
|
||||
'label' => _('Publish...'),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
$this->addElement('button', 'publishdialog', [
|
||||
'ignore' => true,
|
||||
'class' => 'btn md-publish',
|
||||
'label' => _('Publish...'),
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->addDisplayGroup(array('publishdialog', 'editmdsave', 'editmdcancel'), 'submitButtons', array(
|
||||
'decorators' => array(
|
||||
$this->addDisplayGroup(['publishdialog', 'editmdsave', 'editmdcancel'], 'submitButtons', [
|
||||
'decorators' => [
|
||||
'FormElements',
|
||||
'DtDdWrapper'
|
||||
)
|
||||
));
|
||||
'DtDdWrapper',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function makeReadOnly()
|
||||
|
@ -306,13 +325,14 @@ class Application_Form_EditAudioMD extends Zend_Form
|
|||
}
|
||||
}
|
||||
|
||||
public function removeOwnerEdit() {
|
||||
public function removeOwnerEdit()
|
||||
{
|
||||
$this->removeElement('owner_id');
|
||||
}
|
||||
|
||||
public function removeActionButtons()
|
||||
{
|
||||
$this->removeElement('editmdsave');
|
||||
$this->removeElement('editmdcancel');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,210 +2,205 @@
|
|||
|
||||
class Application_Form_EditHistory extends Zend_Form
|
||||
{
|
||||
const VALIDATE_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
|
||||
//this is used by the javascript widget, unfortunately h/H is opposite from Zend.
|
||||
const TIMEPICKER_DATETIME_FORMAT = 'yyyy-MM-dd hh:mm:ss';
|
||||
public const VALIDATE_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
|
||||
//this is used by the javascript widget, unfortunately h/H is opposite from Zend.
|
||||
public const TIMEPICKER_DATETIME_FORMAT = 'yyyy-MM-dd hh:mm:ss';
|
||||
|
||||
const VALIDATE_DATE_FORMAT = 'yyyy-MM-dd';
|
||||
const VALIDATE_TIME_FORMAT = 'HH:mm:ss';
|
||||
public const VALIDATE_DATE_FORMAT = 'yyyy-MM-dd';
|
||||
public const VALIDATE_TIME_FORMAT = 'HH:mm:ss';
|
||||
|
||||
const ITEM_TYPE = "type";
|
||||
const ITEM_CLASS = "class";
|
||||
const ITEM_OPTIONS = "options";
|
||||
const ITEM_ID_SUFFIX = "name";
|
||||
public const ITEM_TYPE = 'type';
|
||||
public const ITEM_CLASS = 'class';
|
||||
public const ITEM_OPTIONS = 'options';
|
||||
public const ITEM_ID_SUFFIX = 'name';
|
||||
|
||||
const TEXT_INPUT_CLASS = "input_text";
|
||||
public const TEXT_INPUT_CLASS = 'input_text';
|
||||
|
||||
private $formElTypes = array(
|
||||
TEMPLATE_DATE => array(
|
||||
"class" => "Zend_Form_Element_Text",
|
||||
"attrs" => array(
|
||||
"class" => self::TEXT_INPUT_CLASS
|
||||
),
|
||||
"validators" => array(
|
||||
array(
|
||||
"class" => "Zend_Validate_Date",
|
||||
"params" => array(
|
||||
"format" => self::VALIDATE_DATE_FORMAT
|
||||
)
|
||||
)
|
||||
),
|
||||
"filters" => array(
|
||||
"StringTrim"
|
||||
)
|
||||
),
|
||||
TEMPLATE_TIME => array(
|
||||
"class" => "Zend_Form_Element_Text",
|
||||
"attrs" => array(
|
||||
"class" => self::TEXT_INPUT_CLASS
|
||||
),
|
||||
"validators" => array(
|
||||
array(
|
||||
"class" => "Zend_Validate_Date",
|
||||
"params" => array(
|
||||
"format" => self::VALIDATE_TIME_FORMAT
|
||||
)
|
||||
)
|
||||
),
|
||||
"filters" => array(
|
||||
"StringTrim"
|
||||
)
|
||||
),
|
||||
TEMPLATE_DATETIME => array(
|
||||
"class" => "Zend_Form_Element_Text",
|
||||
"attrs" => array(
|
||||
"class" => self::TEXT_INPUT_CLASS
|
||||
),
|
||||
"validators" => array(
|
||||
array(
|
||||
"class" => "Zend_Validate_Date",
|
||||
"params" => array(
|
||||
"format" => self::VALIDATE_DATETIME_FORMAT
|
||||
)
|
||||
)
|
||||
),
|
||||
"filters" => array(
|
||||
"StringTrim"
|
||||
)
|
||||
),
|
||||
TEMPLATE_STRING => array(
|
||||
"class" => "Zend_Form_Element_Text",
|
||||
"attrs" => array(
|
||||
"class" => self::TEXT_INPUT_CLASS
|
||||
),
|
||||
"filters" => array(
|
||||
"StringTrim"
|
||||
)
|
||||
),
|
||||
TEMPLATE_BOOLEAN => array(
|
||||
"class" => "Zend_Form_Element_Checkbox",
|
||||
"validators" => array(
|
||||
array(
|
||||
"class" => "Zend_Validate_InArray",
|
||||
"options" => array(
|
||||
"haystack" => array(0,1)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
TEMPLATE_INT => array(
|
||||
"class" => "Zend_Form_Element_Text",
|
||||
"validators" => array(
|
||||
array(
|
||||
"class" => "Zend_Validate_Int",
|
||||
)
|
||||
),
|
||||
"attrs" => array(
|
||||
"class" => self::TEXT_INPUT_CLASS
|
||||
)
|
||||
),
|
||||
TEMPLATE_FLOAT => array(
|
||||
"class" => "Zend_Form_Element_Text",
|
||||
"attrs" => array(
|
||||
"class" => self::TEXT_INPUT_CLASS
|
||||
),
|
||||
"validators" => array(
|
||||
array(
|
||||
"class" => "Zend_Validate_Float",
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
private $formElTypes = [
|
||||
TEMPLATE_DATE => [
|
||||
'class' => 'Zend_Form_Element_Text',
|
||||
'attrs' => [
|
||||
'class' => self::TEXT_INPUT_CLASS,
|
||||
],
|
||||
'validators' => [
|
||||
[
|
||||
'class' => 'Zend_Validate_Date',
|
||||
'params' => [
|
||||
'format' => self::VALIDATE_DATE_FORMAT,
|
||||
],
|
||||
],
|
||||
],
|
||||
'filters' => [
|
||||
'StringTrim',
|
||||
],
|
||||
],
|
||||
TEMPLATE_TIME => [
|
||||
'class' => 'Zend_Form_Element_Text',
|
||||
'attrs' => [
|
||||
'class' => self::TEXT_INPUT_CLASS,
|
||||
],
|
||||
'validators' => [
|
||||
[
|
||||
'class' => 'Zend_Validate_Date',
|
||||
'params' => [
|
||||
'format' => self::VALIDATE_TIME_FORMAT,
|
||||
],
|
||||
],
|
||||
],
|
||||
'filters' => [
|
||||
'StringTrim',
|
||||
],
|
||||
],
|
||||
TEMPLATE_DATETIME => [
|
||||
'class' => 'Zend_Form_Element_Text',
|
||||
'attrs' => [
|
||||
'class' => self::TEXT_INPUT_CLASS,
|
||||
],
|
||||
'validators' => [
|
||||
[
|
||||
'class' => 'Zend_Validate_Date',
|
||||
'params' => [
|
||||
'format' => self::VALIDATE_DATETIME_FORMAT,
|
||||
],
|
||||
],
|
||||
],
|
||||
'filters' => [
|
||||
'StringTrim',
|
||||
],
|
||||
],
|
||||
TEMPLATE_STRING => [
|
||||
'class' => 'Zend_Form_Element_Text',
|
||||
'attrs' => [
|
||||
'class' => self::TEXT_INPUT_CLASS,
|
||||
],
|
||||
'filters' => [
|
||||
'StringTrim',
|
||||
],
|
||||
],
|
||||
TEMPLATE_BOOLEAN => [
|
||||
'class' => 'Zend_Form_Element_Checkbox',
|
||||
'validators' => [
|
||||
[
|
||||
'class' => 'Zend_Validate_InArray',
|
||||
'options' => [
|
||||
'haystack' => [0, 1],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
TEMPLATE_INT => [
|
||||
'class' => 'Zend_Form_Element_Text',
|
||||
'validators' => [
|
||||
[
|
||||
'class' => 'Zend_Validate_Int',
|
||||
],
|
||||
],
|
||||
'attrs' => [
|
||||
'class' => self::TEXT_INPUT_CLASS,
|
||||
],
|
||||
],
|
||||
TEMPLATE_FLOAT => [
|
||||
'class' => 'Zend_Form_Element_Text',
|
||||
'attrs' => [
|
||||
'class' => self::TEXT_INPUT_CLASS,
|
||||
],
|
||||
'validators' => [
|
||||
[
|
||||
'class' => 'Zend_Validate_Float',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function init() {
|
||||
|
||||
$history_id = new Zend_Form_Element_Hidden($this::ID_PREFIX.'id');
|
||||
$history_id->setValidators(array(
|
||||
new Zend_Validate_Int()
|
||||
));
|
||||
$history_id->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($history_id);
|
||||
|
||||
$dynamic_attrs = new Zend_Form_SubForm();
|
||||
$this->addSubForm($dynamic_attrs, $this::ID_PREFIX.'template');
|
||||
|
||||
// Add the submit button
|
||||
$this->addElement('button', $this::ID_PREFIX.'save', array(
|
||||
'ignore' => true,
|
||||
'class' => 'btn '.$this::ID_PREFIX.'save',
|
||||
'label' => _('Save'),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
|
||||
// Add the cancel button
|
||||
$this->addElement('button', $this::ID_PREFIX.'cancel', array(
|
||||
'ignore' => true,
|
||||
'class' => 'btn '.$this::ID_PREFIX.'cancel',
|
||||
'label' => _('Cancel'),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
}
|
||||
public function init()
|
||||
{
|
||||
$history_id = new Zend_Form_Element_Hidden($this::ID_PREFIX . 'id');
|
||||
$history_id->setValidators([
|
||||
new Zend_Validate_Int(),
|
||||
]);
|
||||
$history_id->setDecorators(['ViewHelper']);
|
||||
$this->addElement($history_id);
|
||||
|
||||
public function createFromTemplate($template, $required) {
|
||||
$dynamic_attrs = new Zend_Form_SubForm();
|
||||
$this->addSubForm($dynamic_attrs, $this::ID_PREFIX . 'template');
|
||||
|
||||
$templateSubForm = $this->getSubForm($this::ID_PREFIX.'template');
|
||||
// Add the submit button
|
||||
$this->addElement('button', $this::ID_PREFIX . 'save', [
|
||||
'ignore' => true,
|
||||
'class' => 'btn ' . $this::ID_PREFIX . 'save',
|
||||
'label' => _('Save'),
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
for ($i = 0, $len = count($template); $i < $len; $i++) {
|
||||
// Add the cancel button
|
||||
$this->addElement('button', $this::ID_PREFIX . 'cancel', [
|
||||
'ignore' => true,
|
||||
'class' => 'btn ' . $this::ID_PREFIX . 'cancel',
|
||||
'label' => _('Cancel'),
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$item = $template[$i];
|
||||
//don't dynamically add this as it should be included in the
|
||||
//init() function already if it should show up in the UI..
|
||||
if (in_array($item["name"], $required)) {
|
||||
continue;
|
||||
}
|
||||
public function createFromTemplate($template, $required)
|
||||
{
|
||||
$templateSubForm = $this->getSubForm($this::ID_PREFIX . 'template');
|
||||
|
||||
$formElType = $this->formElTypes[$item[self::ITEM_TYPE]];
|
||||
for ($i = 0, $len = count($template); $i < $len; ++$i) {
|
||||
$item = $template[$i];
|
||||
//don't dynamically add this as it should be included in the
|
||||
//init() function already if it should show up in the UI..
|
||||
if (in_array($item['name'], $required)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = $item[self::ITEM_ID_SUFFIX];
|
||||
$id = $this::ID_PREFIX.$label;
|
||||
$el = new $formElType[self::ITEM_CLASS]($id);
|
||||
$el->setLabel($item["label"]);
|
||||
$formElType = $this->formElTypes[$item[self::ITEM_TYPE]];
|
||||
|
||||
if (isset($formElType["attrs"])) {
|
||||
$label = $item[self::ITEM_ID_SUFFIX];
|
||||
$id = $this::ID_PREFIX . $label;
|
||||
$el = new $formElType[self::ITEM_CLASS]($id);
|
||||
$el->setLabel($item['label']);
|
||||
|
||||
$attrs = $formElType["attrs"];
|
||||
if (isset($formElType['attrs'])) {
|
||||
$attrs = $formElType['attrs'];
|
||||
|
||||
foreach ($attrs as $key => $value) {
|
||||
$el->setAttrib($key, $value);
|
||||
}
|
||||
}
|
||||
foreach ($attrs as $key => $value) {
|
||||
$el->setAttrib($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($formElType["filters"])) {
|
||||
if (isset($formElType['filters'])) {
|
||||
$filters = $formElType['filters'];
|
||||
|
||||
$filters = $formElType["filters"];
|
||||
foreach ($filters as $filter) {
|
||||
$el->addFilter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($filters as $filter) {
|
||||
$el->addFilter($filter);
|
||||
}
|
||||
}
|
||||
if (isset($formElType['validators'])) {
|
||||
$validators = $formElType['validators'];
|
||||
|
||||
if (isset($formElType["validators"])) {
|
||||
foreach ($validators as $index => $arr) {
|
||||
$options = isset($arr[self::ITEM_OPTIONS]) ? $arr[self::ITEM_OPTIONS] : null;
|
||||
$validator = new $arr[self::ITEM_CLASS]($options);
|
||||
|
||||
$validators = $formElType["validators"];
|
||||
//extra validator info
|
||||
if (isset($arr['params'])) {
|
||||
foreach ($arr['params'] as $key => $value) {
|
||||
$method = 'set' . ucfirst($key);
|
||||
$validator->{$method}($value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($validators as $index => $arr) {
|
||||
$options = isset($arr[self::ITEM_OPTIONS]) ? $arr[self::ITEM_OPTIONS] : null;
|
||||
$validator = new $arr[self::ITEM_CLASS]($options);
|
||||
$el->addValidator($validator);
|
||||
}
|
||||
}
|
||||
|
||||
//extra validator info
|
||||
if (isset($arr["params"])) {
|
||||
|
||||
foreach ($arr["params"] as $key => $value) {
|
||||
$method = "set".ucfirst($key);
|
||||
$validator->$method($value);
|
||||
}
|
||||
}
|
||||
|
||||
$el->addValidator($validator);
|
||||
}
|
||||
}
|
||||
|
||||
$el->setDecorators(array('ViewHelper'));
|
||||
$templateSubForm->addElement($el);
|
||||
}
|
||||
}
|
||||
}
|
||||
$el->setDecorators(['ViewHelper']);
|
||||
$templateSubForm->addElement($el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
|
||||
class Application_Form_EditHistoryFile extends Application_Form_EditHistory
|
||||
{
|
||||
const ID_PREFIX = "his_file_";
|
||||
|
||||
public function init() {
|
||||
|
||||
parent::init();
|
||||
public const ID_PREFIX = 'his_file_';
|
||||
|
||||
$this->setDecorators(
|
||||
array(
|
||||
array('ViewScript', array('viewScript' => 'form/edit-history-file.phtml'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function createFromTemplate($template, $required) {
|
||||
|
||||
parent::createFromTemplate($template, $required);
|
||||
}
|
||||
}
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->setDecorators(
|
||||
[
|
||||
['ViewScript', ['viewScript' => 'form/edit-history-file.phtml']],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function createFromTemplate($template, $required)
|
||||
{
|
||||
parent::createFromTemplate($template, $required);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,65 +2,65 @@
|
|||
|
||||
class Application_Form_EditHistoryItem extends Application_Form_EditHistory
|
||||
{
|
||||
const ID_PREFIX = "his_item_";
|
||||
public const ID_PREFIX = 'his_item_';
|
||||
|
||||
public function init() {
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
parent::init();
|
||||
$this->setDecorators([
|
||||
'PrepareElements',
|
||||
['ViewScript', ['viewScript' => 'form/edit-history-item.phtml']],
|
||||
]);
|
||||
|
||||
$this->setDecorators(array(
|
||||
'PrepareElements',
|
||||
array('ViewScript', array('viewScript' => 'form/edit-history-item.phtml'))
|
||||
));
|
||||
/*
|
||||
$instance = new Zend_Form_Element_Select("instance_id");
|
||||
$instance->setLabel(_("Choose Show Instance"));
|
||||
$instance->setMultiOptions(array("0" => "-----------"));
|
||||
$instance->setValue(0);
|
||||
$instance->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($instance);
|
||||
*/
|
||||
|
||||
/*
|
||||
$instance = new Zend_Form_Element_Select("instance_id");
|
||||
$instance->setLabel(_("Choose Show Instance"));
|
||||
$instance->setMultiOptions(array("0" => "-----------"));
|
||||
$instance->setValue(0);
|
||||
$instance->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($instance);
|
||||
*/
|
||||
$starts = new Zend_Form_Element_Text(self::ID_PREFIX . 'starts');
|
||||
$starts->setValidators([
|
||||
new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT),
|
||||
]);
|
||||
$starts->setAttrib('class', self::TEXT_INPUT_CLASS . ' datepicker');
|
||||
$starts->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT);
|
||||
$starts->addFilter('StringTrim');
|
||||
$starts->setLabel(_('Start Time'));
|
||||
$starts->setDecorators(['ViewHelper']);
|
||||
$starts->setRequired(true);
|
||||
$this->addElement($starts);
|
||||
|
||||
$starts = new Zend_Form_Element_Text(self::ID_PREFIX.'starts');
|
||||
$starts->setValidators(array(
|
||||
new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT)
|
||||
));
|
||||
$starts->setAttrib('class', self::TEXT_INPUT_CLASS." datepicker");
|
||||
$starts->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT);
|
||||
$starts->addFilter('StringTrim');
|
||||
$starts->setLabel(_('Start Time'));
|
||||
$starts->setDecorators(array('ViewHelper'));
|
||||
$starts->setRequired(true);
|
||||
$this->addElement($starts);
|
||||
$ends = new Zend_Form_Element_Text(self::ID_PREFIX . 'ends');
|
||||
$ends->setValidators([
|
||||
new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT),
|
||||
]);
|
||||
$ends->setAttrib('class', self::TEXT_INPUT_CLASS . ' datepicker');
|
||||
$ends->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT);
|
||||
$ends->addFilter('StringTrim');
|
||||
$ends->setLabel(_('End Time'));
|
||||
$ends->setDecorators(['ViewHelper']);
|
||||
//$ends->setRequired(true);
|
||||
$this->addElement($ends);
|
||||
}
|
||||
|
||||
$ends = new Zend_Form_Element_Text(self::ID_PREFIX.'ends');
|
||||
$ends->setValidators(array(
|
||||
new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT)
|
||||
));
|
||||
$ends->setAttrib('class', self::TEXT_INPUT_CLASS." datepicker");
|
||||
$ends->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT);
|
||||
$ends->addFilter('StringTrim');
|
||||
$ends->setLabel(_('End Time'));
|
||||
$ends->setDecorators(array('ViewHelper'));
|
||||
//$ends->setRequired(true);
|
||||
$this->addElement($ends);
|
||||
}
|
||||
public function createFromTemplate($template, $required)
|
||||
{
|
||||
parent::createFromTemplate($template, $required);
|
||||
}
|
||||
|
||||
public function createFromTemplate($template, $required) {
|
||||
public function populateShowInstances($possibleInstances, $default)
|
||||
{
|
||||
$possibleInstances['0'] = _('No Show');
|
||||
|
||||
parent::createFromTemplate($template, $required);
|
||||
}
|
||||
|
||||
public function populateShowInstances($possibleInstances, $default) {
|
||||
|
||||
$possibleInstances["0"] = _("No Show");
|
||||
|
||||
$instance = new Zend_Form_Element_Select("his_instance_select");
|
||||
//$instance->setLabel(_("Choose Show Instance"));
|
||||
$instance->setMultiOptions($possibleInstances);
|
||||
$instance->setValue($default);
|
||||
$instance->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($instance);
|
||||
}
|
||||
}
|
||||
$instance = new Zend_Form_Element_Select('his_instance_select');
|
||||
//$instance->setLabel(_("Choose Show Instance"));
|
||||
$instance->setMultiOptions($possibleInstances);
|
||||
$instance->setValue($default);
|
||||
$instance->setDecorators(['ViewHelper']);
|
||||
$this->addElement($instance);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class Application_Form_EditUser extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/*
|
||||
|
@ -17,39 +16,39 @@ class Application_Form_EditUser extends Zend_Form
|
|||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator();
|
||||
$notDemoValidator = new Application_Validate_NotDemoValidate();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/edit-user.phtml', "currentUser" => $currentUser->getLogin()))));
|
||||
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/edit-user.phtml', 'currentUser' => $currentUser->getLogin()]], ]);
|
||||
$this->setAttrib('id', 'current-user-form');
|
||||
|
||||
$csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
|
||||
$csrf_element = new Zend_Form_Element_Hidden('csrf');
|
||||
$csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label');
|
||||
$this->addElement($csrf_element);
|
||||
|
||||
|
||||
$hidden = new Zend_Form_Element_Hidden('cu_user_id');
|
||||
$hidden->setDecorators(array('ViewHelper'));
|
||||
$hidden->setValue($userData["id"]);
|
||||
$hidden->setDecorators(['ViewHelper']);
|
||||
$hidden->setValue($userData['id']);
|
||||
$this->addElement($hidden);
|
||||
|
||||
$login = new Zend_Form_Element_Text('cu_login');
|
||||
$login->setLabel(_('Username:'));
|
||||
$login->setValue($userData["login"]);
|
||||
$login->setValue($userData['login']);
|
||||
$login->setAttrib('class', 'input_text');
|
||||
$login->setAttrib('readonly', 'readonly');
|
||||
$login->setRequired(true);
|
||||
$login->addValidator($notEmptyValidator);
|
||||
$login->addFilter('StringTrim');
|
||||
$login->setDecorators(array('viewHelper'));
|
||||
$login->setDecorators(['viewHelper']);
|
||||
$this->addElement($login);
|
||||
|
||||
|
||||
$password = new Zend_Form_Element_Password('cu_password');
|
||||
$password->setLabel(_('Password:'));
|
||||
$password->setAttrib('class', 'input_text');
|
||||
$password->setRequired(true);
|
||||
$password->addFilter('StringTrim');
|
||||
$password->addValidator($notEmptyValidator);
|
||||
$password->setDecorators(array('viewHelper'));
|
||||
$password->setDecorators(['viewHelper']);
|
||||
$this->addElement($password);
|
||||
|
||||
$passwordVerify = new Zend_Form_Element_Password('cu_passwordVerify');
|
||||
|
@ -59,91 +58,94 @@ class Application_Form_EditUser extends Zend_Form
|
|||
$passwordVerify->addFilter('StringTrim');
|
||||
$passwordVerify->addValidator($notEmptyValidator);
|
||||
$passwordVerify->addValidator($notDemoValidator);
|
||||
$passwordVerify->setDecorators(array('viewHelper'));
|
||||
$passwordVerify->setDecorators(['viewHelper']);
|
||||
$this->addElement($passwordVerify);
|
||||
|
||||
$firstName = new Zend_Form_Element_Text('cu_first_name');
|
||||
$firstName->setLabel(_('Firstname:'));
|
||||
$firstName->setValue($userData["first_name"]);
|
||||
$firstName->setValue($userData['first_name']);
|
||||
$firstName->setAttrib('class', 'input_text');
|
||||
$firstName->addFilter('StringTrim');
|
||||
$firstName->setDecorators(array('viewHelper'));
|
||||
$firstName->setDecorators(['viewHelper']);
|
||||
$this->addElement($firstName);
|
||||
|
||||
$lastName = new Zend_Form_Element_Text('cu_last_name');
|
||||
$lastName->setLabel(_('Lastname:'));
|
||||
$lastName->setValue($userData["last_name"]);
|
||||
$lastName->setValue($userData['last_name']);
|
||||
$lastName->setAttrib('class', 'input_text');
|
||||
$lastName->addFilter('StringTrim');
|
||||
$lastName->setDecorators(array('viewHelper'));
|
||||
$lastName->setDecorators(['viewHelper']);
|
||||
$this->addElement($lastName);
|
||||
|
||||
$email = new Zend_Form_Element_Text('cu_email');
|
||||
$email->setLabel(_('Email:'));
|
||||
$email->setValue($userData["email"]);
|
||||
$email->setValue($userData['email']);
|
||||
$email->setAttrib('class', 'input_text');
|
||||
$email->addFilter('StringTrim');
|
||||
$email->setRequired(true);
|
||||
$email->addValidator($notEmptyValidator);
|
||||
$email->addValidator($emailValidator);
|
||||
$email->setDecorators(array('viewHelper'));
|
||||
$email->setDecorators(['viewHelper']);
|
||||
$this->addElement($email);
|
||||
|
||||
$cellPhone = new Zend_Form_Element_Text('cu_cell_phone');
|
||||
$cellPhone->setLabel(_('Mobile Phone:'));
|
||||
$cellPhone->setValue($userData["cell_phone"]);
|
||||
$cellPhone->setValue($userData['cell_phone']);
|
||||
$cellPhone->setAttrib('class', 'input_text');
|
||||
$cellPhone->addFilter('StringTrim');
|
||||
$cellPhone->setDecorators(array('viewHelper'));
|
||||
$cellPhone->setDecorators(['viewHelper']);
|
||||
$this->addElement($cellPhone);
|
||||
|
||||
$skype = new Zend_Form_Element_Text('cu_skype');
|
||||
$skype->setLabel(_('Skype:'));
|
||||
$skype->setValue($userData["skype_contact"]);
|
||||
$skype->setValue($userData['skype_contact']);
|
||||
$skype->setAttrib('class', 'input_text');
|
||||
$skype->addFilter('StringTrim');
|
||||
$skype->setDecorators(array('viewHelper'));
|
||||
$skype->setDecorators(['viewHelper']);
|
||||
$this->addElement($skype);
|
||||
|
||||
$jabber = new Zend_Form_Element_Text('cu_jabber');
|
||||
$jabber->setLabel(_('Jabber:'));
|
||||
$jabber->setValue($userData["jabber_contact"]);
|
||||
$jabber->setValue($userData['jabber_contact']);
|
||||
$jabber->setAttrib('class', 'input_text');
|
||||
$jabber->addFilter('StringTrim');
|
||||
$jabber->addValidator($emailValidator);
|
||||
$jabber->setDecorators(array('viewHelper'));
|
||||
$jabber->setDecorators(['viewHelper']);
|
||||
$this->addElement($jabber);
|
||||
|
||||
$locale = new Zend_Form_Element_Select("cu_locale");
|
||||
$locale->setLabel(_("Language:"));
|
||||
$locale = new Zend_Form_Element_Select('cu_locale');
|
||||
$locale->setLabel(_('Language:'));
|
||||
$locale->setMultiOptions(Application_Model_Locale::getLocales());
|
||||
$locale->setValue(Application_Model_Preference::GetUserLocale());
|
||||
$locale->setDecorators(array('ViewHelper'));
|
||||
$locale->setDecorators(['ViewHelper']);
|
||||
$this->addElement($locale);
|
||||
|
||||
$stationTz = Application_Model_Preference::GetDefaultTimezone();
|
||||
$userTz = Application_Model_Preference::GetUserTimezone();
|
||||
|
||||
$timezone = new Zend_Form_Element_Select("cu_timezone");
|
||||
$timezone->setLabel(_("Interface Timezone:"));
|
||||
$timezone = new Zend_Form_Element_Select('cu_timezone');
|
||||
$timezone->setLabel(_('Interface Timezone:'));
|
||||
$timezone->setMultiOptions(Application_Common_Timezone::getTimezones());
|
||||
$timezone->setValue($userTz == $stationTz ? null : $userTz);
|
||||
$timezone->setDecorators(array('ViewHelper'));
|
||||
$timezone->setDecorators(['ViewHelper']);
|
||||
$this->addElement($timezone);
|
||||
}
|
||||
|
||||
public function validateLogin($p_login, $p_userId) {
|
||||
public function validateLogin($p_login, $p_userId)
|
||||
{
|
||||
$count = CcSubjsQuery::create()
|
||||
->filterByDbLogin($p_login)
|
||||
->filterByDbId($p_userId, Criteria::NOT_EQUAL)
|
||||
->count();
|
||||
->count()
|
||||
;
|
||||
|
||||
if ($count != 0) {
|
||||
$this->getElement('cu_login')->setErrors(array(_("Login name is not unique.")));
|
||||
$this->getElement('cu_login')->setErrors([_('Login name is not unique.')]);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// We need to add the password identical validator here in case
|
||||
|
@ -152,9 +154,11 @@ class Application_Form_EditUser extends Zend_Form
|
|||
{
|
||||
if (isset($data['cu_password'])) {
|
||||
$passwordIdenticalValidator = Application_Form_Helper_ValidationTypes::overridePasswordIdenticalValidator(
|
||||
$data['cu_password']);
|
||||
$data['cu_password']
|
||||
);
|
||||
$this->getElement('cu_passwordVerify')->addValidator($passwordIdenticalValidator);
|
||||
}
|
||||
|
||||
return parent::isValid($data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ require_once 'customfilters/ImageSize.php';
|
|||
|
||||
class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$maxLens = Application_Model_Show::getMaxLengths();
|
||||
|
@ -14,40 +13,41 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$rangeValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(0, 59.9);
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_general.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/preferences_general.phtml']],
|
||||
]);
|
||||
|
||||
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
||||
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
||||
|
||||
//Station name
|
||||
$this->addElement('text', 'stationName', array(
|
||||
$this->addElement('text', 'stationName', [
|
||||
'class' => 'input_text',
|
||||
'label' => _('Station Name'),
|
||||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
'filters' => ['StringTrim'],
|
||||
'value' => Application_Model_Preference::GetStationName(),
|
||||
));
|
||||
]);
|
||||
|
||||
// Station description
|
||||
$stationDescription = new Zend_Form_Element_Textarea("stationDescription");
|
||||
$stationDescription = new Zend_Form_Element_Textarea('stationDescription');
|
||||
$stationDescription->setLabel(_('Station Description'));
|
||||
$stationDescription->setValue(Application_Model_Preference::GetStationDescription());
|
||||
$stationDescription->setRequired(false);
|
||||
$stationDescription->setValidators(array(array('StringLength', false, array(0, $maxLens['description']))));
|
||||
$stationDescription->setValidators([['StringLength', false, [0, $maxLens['description']]]]);
|
||||
$stationDescription->setAttrib('rows', 4);
|
||||
$this->addElement($stationDescription);
|
||||
|
||||
// Station Logo
|
||||
$stationLogoUpload = new Zend_Form_Element_File('stationLogo');
|
||||
$stationLogoUpload->setLabel(_('Station Logo:'))
|
||||
->setDescription(_("Note: Anything larger than 600x600 will be resized."))
|
||||
->setDescription(_('Note: Anything larger than 600x600 will be resized.'))
|
||||
->setRequired(false)
|
||||
->addValidator('Count', false, 1)
|
||||
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
|
||||
->setMaxFileSize(1000000)
|
||||
->addFilter('ImageSize');
|
||||
->addFilter('ImageSize')
|
||||
;
|
||||
$stationLogoUpload->setAttrib('accept', 'image/*');
|
||||
$this->addElement($stationLogoUpload);
|
||||
|
||||
|
@ -59,94 +59,94 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
$this->addElement($stationLogoRemove);
|
||||
|
||||
//Default station crossfade duration
|
||||
$this->addElement('text', 'stationDefaultCrossfadeDuration', array(
|
||||
$this->addElement('text', 'stationDefaultCrossfadeDuration', [
|
||||
'class' => 'input_text',
|
||||
'label' => _('Default Crossfade Duration (s):'),
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
$rangeValidator,
|
||||
$notEmptyValidator,
|
||||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
'filters' => ['StringTrim'],
|
||||
'validators' => [
|
||||
$rangeValidator,
|
||||
$notEmptyValidator,
|
||||
['regex', false, ['/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')]],
|
||||
],
|
||||
'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(),
|
||||
));
|
||||
]);
|
||||
|
||||
//Default station fade in
|
||||
$this->addElement('text', 'stationDefaultFadeIn', array(
|
||||
$this->addElement('text', 'stationDefaultFadeIn', [
|
||||
'class' => 'input_text',
|
||||
'label' => _('Default Fade In (s):'),
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'filters' => ['StringTrim'],
|
||||
'validators' => [
|
||||
$rangeValidator,
|
||||
$notEmptyValidator,
|
||||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
['regex', false, ['/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')]],
|
||||
],
|
||||
'value' => $defaultFadeIn,
|
||||
));
|
||||
]);
|
||||
|
||||
//Default station fade out
|
||||
$this->addElement('text', 'stationDefaultFadeOut', array(
|
||||
$this->addElement('text', 'stationDefaultFadeOut', [
|
||||
'class' => 'input_text',
|
||||
'label' => _('Default Fade Out (s):'),
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'filters' => ['StringTrim'],
|
||||
'validators' => [
|
||||
$rangeValidator,
|
||||
$notEmptyValidator,
|
||||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
['regex', false, ['/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')]],
|
||||
],
|
||||
'value' => $defaultFadeOut,
|
||||
));
|
||||
]);
|
||||
|
||||
$tracktypeDefault = new Zend_Form_Element_Select("tracktypeDefault");
|
||||
$tracktypeDefault->setLabel(_("Track Type Upload Default"));
|
||||
$tracktypeDefault = new Zend_Form_Element_Select('tracktypeDefault');
|
||||
$tracktypeDefault->setLabel(_('Track Type Upload Default'));
|
||||
$tracktypeDefault->setMultiOptions(Application_Model_Library::getTracktypes());
|
||||
$tracktypeDefault->setValue(Application_Model_Preference::GetTrackTypeDefault());
|
||||
$this->addElement($tracktypeDefault);
|
||||
|
||||
// add intro playlist select here
|
||||
$introPlaylistSelect = new Zend_Form_Element_Select("introPlaylistSelect");
|
||||
$introPlaylistSelect->setLabel(_("Intro Autoloading Playlist"));
|
||||
$introPlaylistSelect = new Zend_Form_Element_Select('introPlaylistSelect');
|
||||
$introPlaylistSelect->setLabel(_('Intro Autoloading Playlist'));
|
||||
$introPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames(true));
|
||||
$introPlaylistSelect->setValue(Application_Model_Preference::GetIntroPlaylist());
|
||||
$this->addElement($introPlaylistSelect);
|
||||
|
||||
$outroPlaylistSelect = new Zend_Form_Element_Select("outroPlaylistSelect");
|
||||
$outroPlaylistSelect->setLabel(_("Outro Autoloading Playlist"));
|
||||
$outroPlaylistSelect = new Zend_Form_Element_Select('outroPlaylistSelect');
|
||||
$outroPlaylistSelect->setLabel(_('Outro Autoloading Playlist'));
|
||||
$outroPlaylistSelect->setMultiOptions(Application_Model_Library::getPlaylistNames(true));
|
||||
$outroPlaylistSelect->setValue(Application_Model_Preference::GetOutroPlaylist());
|
||||
$this->addElement($outroPlaylistSelect);
|
||||
|
||||
$podcast_album_override = new Zend_Form_Element_Radio('podcastAlbumOverride');
|
||||
$podcast_album_override->setLabel(_('Overwrite Podcast Episode Metatags'));
|
||||
$podcast_album_override->setMultiOptions(array(
|
||||
_("Disabled"),
|
||||
_("Enabled"),
|
||||
));
|
||||
$podcast_album_override->setMultiOptions([
|
||||
_('Disabled'),
|
||||
_('Enabled'),
|
||||
]);
|
||||
$podcast_album_override->setValue(Application_Model_Preference::GetPodcastAlbumOverride());
|
||||
$podcast_album_override->setDescription(_('Enabling this feature will cause podcast episode tracks to have their Artist, Title, and Album metatags set from podcast feed values. Note that enabling this feature is recommended in order to ensure reliable scheduling of episodes via smartblocks.'));
|
||||
$podcast_album_override->setSeparator(' '); //No <br> between radio buttons
|
||||
$podcast_album_override->addDecorator('HtmlTag', array('tag' => 'dd',
|
||||
'id'=>"podcastAlbumOverride-element",
|
||||
$podcast_album_override->addDecorator('HtmlTag', ['tag' => 'dd',
|
||||
'id' => 'podcastAlbumOverride-element',
|
||||
'class' => 'radio-inline-list',
|
||||
));
|
||||
]);
|
||||
$this->addElement($podcast_album_override);
|
||||
|
||||
$podcast_auto_smartblock = new Zend_Form_Element_Radio('podcastAutoSmartblock');
|
||||
$podcast_auto_smartblock->setLabel(_('Generate a smartblock and a playlist upon creation of a new podcast'));
|
||||
$podcast_auto_smartblock->setMultiOptions(array(
|
||||
_("Disabled"),
|
||||
_("Enabled"),
|
||||
));
|
||||
$podcast_auto_smartblock->setMultiOptions([
|
||||
_('Disabled'),
|
||||
_('Enabled'),
|
||||
]);
|
||||
$podcast_auto_smartblock->setValue(Application_Model_Preference::GetPodcastAutoSmartblock());
|
||||
$podcast_auto_smartblock->setDescription(_('If this option is enabled, a new smartblock and playlist matching the newest track of a podcast will be generated immediately upon creation of a new podcast. Note that the "Overwrite Podcast Episode Metatags" feature must also be enabled in order for smartblocks to reliably find episodes.'));
|
||||
$podcast_auto_smartblock->setSeparator(' '); //No <br> between radio buttons
|
||||
$podcast_auto_smartblock->addDecorator('HtmlTag', array('tag' => 'dd',
|
||||
'id'=>"podcastAutoSmartblock-element",
|
||||
$podcast_auto_smartblock->addDecorator('HtmlTag', ['tag' => 'dd',
|
||||
'id' => 'podcastAutoSmartblock-element',
|
||||
'class' => 'radio-inline-list',
|
||||
));
|
||||
]);
|
||||
$this->addElement($podcast_auto_smartblock);
|
||||
|
||||
//TODO add and insert Podcast Smartblock and Playlist autogenerate options
|
||||
|
@ -154,19 +154,19 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
$third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
|
||||
$third_party_api->setLabel(_('Public LibreTime API'));
|
||||
$third_party_api->setDescription(_('Required for embeddable schedule widget.'));
|
||||
$third_party_api->setMultiOptions(array(
|
||||
_("Disabled"),
|
||||
_("Enabled"),
|
||||
));
|
||||
$third_party_api->setMultiOptions([
|
||||
_('Disabled'),
|
||||
_('Enabled'),
|
||||
]);
|
||||
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
|
||||
$third_party_api->setDescription(_('Enabling this feature will allow LibreTime to provide schedule data
|
||||
to external widgets that can be embedded in your website.'));
|
||||
$third_party_api->setSeparator(' '); //No <br> between radio buttons
|
||||
//$third_party_api->addDecorator(new Zend_Form_Decorator_Label(array('tag' => 'dd', 'class' => 'radio-inline-list')));
|
||||
$third_party_api->addDecorator('HtmlTag', array('tag' => 'dd',
|
||||
'id'=>"thirdPartyApi-element",
|
||||
'class' => 'radio-inline-list',
|
||||
));
|
||||
$third_party_api->addDecorator('HtmlTag', ['tag' => 'dd',
|
||||
'id' => 'thirdPartyApi-element',
|
||||
'class' => 'radio-inline-list',
|
||||
]);
|
||||
$this->addElement($third_party_api);
|
||||
|
||||
$allowedCorsUrlsValue = Application_Model_Preference::GetAllowedCorsUrls();
|
||||
|
@ -176,69 +176,67 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
$allowedCorsUrls->setValue($allowedCorsUrlsValue);
|
||||
$this->addElement($allowedCorsUrls);
|
||||
|
||||
$locale = new Zend_Form_Element_Select("locale");
|
||||
$locale->setLabel(_("Default Language"));
|
||||
$locale = new Zend_Form_Element_Select('locale');
|
||||
$locale->setLabel(_('Default Language'));
|
||||
$locale->setMultiOptions(Application_Model_Locale::getLocales());
|
||||
$locale->setValue(Application_Model_Preference::GetDefaultLocale());
|
||||
$this->addElement($locale);
|
||||
|
||||
/* Form Element for setting the Timezone */
|
||||
$timezone = new Zend_Form_Element_Select("timezone");
|
||||
$timezone->setLabel(_("Station Timezone"));
|
||||
// Form Element for setting the Timezone
|
||||
$timezone = new Zend_Form_Element_Select('timezone');
|
||||
$timezone->setLabel(_('Station Timezone'));
|
||||
$timezone->setMultiOptions(Application_Common_Timezone::getTimezones());
|
||||
$timezone->setValue(Application_Model_Preference::GetDefaultTimezone());
|
||||
$this->addElement($timezone);
|
||||
|
||||
/* Form Element for setting which day is the start of the week */
|
||||
$week_start_day = new Zend_Form_Element_Select("weekStartDay");
|
||||
$week_start_day->setLabel(_("Week Starts On"));
|
||||
// Form Element for setting which day is the start of the week
|
||||
$week_start_day = new Zend_Form_Element_Select('weekStartDay');
|
||||
$week_start_day->setLabel(_('Week Starts On'));
|
||||
$week_start_day->setMultiOptions($this->getWeekStartDays());
|
||||
$week_start_day->setValue(Application_Model_Preference::GetWeekStartDay());
|
||||
$this->addElement($week_start_day);
|
||||
|
||||
$radioPageLoginButton = new Zend_Form_Element_Checkbox("radioPageLoginButton");
|
||||
$radioPageLoginButton->setDecorators(array(
|
||||
$radioPageLoginButton = new Zend_Form_Element_Checkbox('radioPageLoginButton');
|
||||
$radioPageLoginButton->setDecorators([
|
||||
'ViewHelper',
|
||||
'Errors',
|
||||
'Label'
|
||||
));
|
||||
'Label',
|
||||
]);
|
||||
$displayRadioPageLoginButtonValue = Application_Model_Preference::getRadioPageDisplayLoginButton();
|
||||
if ($displayRadioPageLoginButtonValue == "") {
|
||||
if ($displayRadioPageLoginButtonValue == '') {
|
||||
$displayRadioPageLoginButtonValue = true;
|
||||
}
|
||||
$radioPageLoginButton->addDecorator('Label', array("class" => "enable-tunein"));
|
||||
$radioPageLoginButton->setLabel(_("Display login button on your Radio Page?"));
|
||||
$radioPageLoginButton->addDecorator('Label', ['class' => 'enable-tunein']);
|
||||
$radioPageLoginButton->setLabel(_('Display login button on your Radio Page?'));
|
||||
$radioPageLoginButton->setValue($displayRadioPageLoginButtonValue);
|
||||
$this->addElement($radioPageLoginButton);
|
||||
|
||||
$feature_preview_mode = new Zend_Form_Element_Radio('featurePreviewMode');
|
||||
$feature_preview_mode->setLabel(_('Feature Previews'));
|
||||
$feature_preview_mode->setMultiOptions(array(
|
||||
_("Disabled"),
|
||||
_("Enabled"),
|
||||
));
|
||||
$feature_preview_mode->setMultiOptions([
|
||||
_('Disabled'),
|
||||
_('Enabled'),
|
||||
]);
|
||||
$feature_preview_mode->setValue(Application_Model_Preference::GetFeaturePreviewMode());
|
||||
$feature_preview_mode->setDescription(_('Enable this to opt-in to test new features.'));
|
||||
$feature_preview_mode->setSeparator(' '); //No <br> between radio buttons
|
||||
$feature_preview_mode->addDecorator('HtmlTag', array('tag' => 'dd',
|
||||
'id'=>"featurePreviewMode-element",
|
||||
$feature_preview_mode->addDecorator('HtmlTag', ['tag' => 'dd',
|
||||
'id' => 'featurePreviewMode-element',
|
||||
'class' => 'radio-inline-list',
|
||||
));
|
||||
]);
|
||||
$this->addElement($feature_preview_mode);
|
||||
}
|
||||
|
||||
private function getWeekStartDays()
|
||||
{
|
||||
$days = array(
|
||||
return [
|
||||
_('Sunday'),
|
||||
_('Monday'),
|
||||
_('Tuesday'),
|
||||
_('Wednesday'),
|
||||
_('Thursday'),
|
||||
_('Friday'),
|
||||
_('Saturday')
|
||||
);
|
||||
|
||||
return $days;
|
||||
_('Saturday'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
@ -10,29 +9,32 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
|
||||
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml')),
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/preferences_livestream.phtml']],
|
||||
]);
|
||||
|
||||
// automatic trasition on source disconnection
|
||||
$auto_transition = new Zend_Form_Element_Checkbox("auto_transition");
|
||||
$auto_transition->setLabel(_("Auto Switch Off:"))
|
||||
->setValue(Application_Model_Preference::GetAutoTransition());
|
||||
$auto_transition = new Zend_Form_Element_Checkbox('auto_transition');
|
||||
$auto_transition->setLabel(_('Auto Switch Off:'))
|
||||
->setValue(Application_Model_Preference::GetAutoTransition())
|
||||
;
|
||||
$this->addElement($auto_transition);
|
||||
|
||||
// automatic switch on upon source connection
|
||||
$auto_switch = new Zend_Form_Element_Checkbox("auto_switch");
|
||||
$auto_switch->setLabel(_("Auto Switch On:"))
|
||||
->setValue(Application_Model_Preference::GetAutoSwitch());
|
||||
$auto_switch = new Zend_Form_Element_Checkbox('auto_switch');
|
||||
$auto_switch->setLabel(_('Auto Switch On:'))
|
||||
->setValue(Application_Model_Preference::GetAutoSwitch())
|
||||
;
|
||||
$this->addElement($auto_switch);
|
||||
|
||||
// Default transition fade
|
||||
$transition_fade = new Zend_Form_Element_Text("transition_fade");
|
||||
$transition_fade->setLabel(_("Switch Transition Fade (s):"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->addValidator('regex', false, array('/^\d*(\.\d+)?$/',
|
||||
'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
->setValue($defaultFade);
|
||||
$transition_fade = new Zend_Form_Element_Text('transition_fade');
|
||||
$transition_fade->setLabel(_('Switch Transition Fade (s):'))
|
||||
->setFilters(['StringTrim'])
|
||||
->addValidator('regex', false, ['/^\d*(\.\d+)?$/',
|
||||
'messages' => _('Please enter a time in seconds (eg. 0.5)'), ])
|
||||
->setValue($defaultFade)
|
||||
;
|
||||
$this->addElement($transition_fade);
|
||||
|
||||
//Master username
|
||||
|
@ -40,8 +42,9 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$master_username->setAttrib('autocomplete', 'off')
|
||||
->setAllowEmpty(true)
|
||||
->setLabel(_('Username:'))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValue(Application_Model_Preference::GetLiveStreamMasterUsername());
|
||||
->setFilters(['StringTrim'])
|
||||
->setValue(Application_Model_Preference::GetLiveStreamMasterUsername())
|
||||
;
|
||||
$this->addElement($master_username);
|
||||
|
||||
//Master password
|
||||
|
@ -56,7 +59,8 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
->setAllowEmpty(true)
|
||||
->setValue(Application_Model_Preference::GetLiveStreamMasterPassword())
|
||||
->setLabel(_('Password:'))
|
||||
->setFilters(array('StringTrim'));
|
||||
->setFilters(['StringTrim'])
|
||||
;
|
||||
$this->addElement($master_password);
|
||||
|
||||
$masterSourceParams = parse_url(Application_Model_Preference::GetMasterDJSourceConnectionURL());
|
||||
|
@ -65,10 +69,10 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$masterSourceHost = new Zend_Form_Element_Text('master_source_host');
|
||||
$masterSourceHost->setLabel(_('Master Source Host:'))
|
||||
->setAttrib('readonly', true)
|
||||
->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL());
|
||||
->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL())
|
||||
;
|
||||
$this->addElement($masterSourceHost);
|
||||
|
||||
|
||||
//liquidsoap harbor.input port
|
||||
$betweenValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(1024, 49151);
|
||||
|
||||
|
@ -77,19 +81,19 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$masterSourcePort = new Zend_Form_Element_Text('master_source_port');
|
||||
$masterSourcePort->setLabel(_('Master Source Port:'))
|
||||
->setValue($m_port)
|
||||
->setValidators(array($betweenValidator))
|
||||
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.'))));
|
||||
|
||||
$this->addElement($masterSourcePort);
|
||||
|
||||
->setValidators([$betweenValidator])
|
||||
->addValidator('regex', false, ['pattern' => '/^[0-9]+$/', 'messages' => ['regexNotMatch' => _('Only numbers are allowed.')]])
|
||||
;
|
||||
|
||||
$this->addElement($masterSourcePort);
|
||||
|
||||
$m_mount = Application_Model_StreamSetting::getMasterLiveStreamMountPoint();
|
||||
$masterSourceMount = new Zend_Form_Element_Text('master_source_mount');
|
||||
$masterSourceMount->setLabel(_('Master Source Mount:'))
|
||||
->setValue($m_mount)
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))));
|
||||
->setValidators([
|
||||
['regex', false, ['/^[^ &<>]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
;
|
||||
$this->addElement($masterSourceMount);
|
||||
|
||||
$showSourceParams = parse_url(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
||||
|
@ -98,7 +102,8 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$showSourceHost = new Zend_Form_Element_Text('show_source_host');
|
||||
$showSourceHost->setLabel(_('Show Source Host:'))
|
||||
->setAttrib('readonly', true)
|
||||
->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
||||
->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL())
|
||||
;
|
||||
$this->addElement($showSourceHost);
|
||||
|
||||
//liquidsoap harbor.input port
|
||||
|
@ -107,16 +112,18 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$showSourcePort = new Zend_Form_Element_Text('show_source_port');
|
||||
$showSourcePort->setLabel(_('Show Source Port:'))
|
||||
->setValue($l_port)
|
||||
->setValidators(array($betweenValidator))
|
||||
->addValidator('regex', false, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => _('Only numbers are allowed.'))));
|
||||
->setValidators([$betweenValidator])
|
||||
->addValidator('regex', false, ['pattern' => '/^[0-9]+$/', 'messages' => ['regexNotMatch' => _('Only numbers are allowed.')]])
|
||||
;
|
||||
$this->addElement($showSourcePort);
|
||||
|
||||
$l_mount = Application_Model_StreamSetting::getDjLiveStreamMountPoint();
|
||||
$showSourceMount = new Zend_Form_Element_Text('show_source_mount');
|
||||
$showSourceMount->setLabel(_('Show Source Mount:'))
|
||||
->setValue($l_mount)
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))));
|
||||
->setValidators([
|
||||
['regex', false, ['/^[^ &<>]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
;
|
||||
$this->addElement($showSourceMount);
|
||||
}
|
||||
|
||||
|
@ -129,20 +136,20 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$showSourceParams = parse_url(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
||||
|
||||
$this->setDecorators(
|
||||
array(
|
||||
array('ViewScript',
|
||||
array(
|
||||
[
|
||||
['ViewScript',
|
||||
[
|
||||
'viewScript' => 'form/preferences_livestream.phtml',
|
||||
'master_source_host' => isset($masterSourceHost) ? Application_Model_Preference::GetMasterDJSourceConnectionURL() : "",
|
||||
'master_source_port' => isset($masterSourcePort) ? Application_Model_StreamSetting::getMasterLiveStreamPort() : "",
|
||||
'master_source_mount' => isset($masterSourceMount) ? Application_Model_StreamSetting::getMasterLiveStreamMountPoint() : "",
|
||||
'show_source_host' => isset($showSourceHost) ? Application_Model_Preference::GetLiveDJSourceConnectionURL() : "",
|
||||
'show_source_port' => isset($showSourcePort) ? Application_Model_StreamSetting::getDjLiveStreamPort() : "",
|
||||
'show_source_mount' => isset($showSourceMount) ? Application_Model_StreamSetting::getDjLiveStreamMountPoint() : "",
|
||||
'master_source_host' => isset($masterSourceHost) ? Application_Model_Preference::GetMasterDJSourceConnectionURL() : '',
|
||||
'master_source_port' => isset($masterSourcePort) ? Application_Model_StreamSetting::getMasterLiveStreamPort() : '',
|
||||
'master_source_mount' => isset($masterSourceMount) ? Application_Model_StreamSetting::getMasterLiveStreamMountPoint() : '',
|
||||
'show_source_host' => isset($showSourceHost) ? Application_Model_Preference::GetLiveDJSourceConnectionURL() : '',
|
||||
'show_source_port' => isset($showSourcePort) ? Application_Model_StreamSetting::getDjLiveStreamPort() : '',
|
||||
'show_source_mount' => isset($showSourceMount) ? Application_Model_StreamSetting::getDjLiveStreamMountPoint() : '',
|
||||
'isDemo' => $isDemo,
|
||||
)
|
||||
)
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class Application_Form_Login extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
@ -19,73 +18,73 @@ class Application_Form_Login extends Zend_Form
|
|||
foreach (CORSHelper::getAllowedOrigins($request) as $safeOrigin) {
|
||||
if ($this->startsWith($safeOrigin, $refererUrl)) {
|
||||
$originIsSafe = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$originIsSafe) {
|
||||
$this->addElement('hash', 'csrf', array(
|
||||
'salt' => 'unique'
|
||||
));
|
||||
$this->addElement('hash', 'csrf', [
|
||||
'salt' => 'unique',
|
||||
]);
|
||||
}
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/login.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/login.phtml']],
|
||||
]);
|
||||
|
||||
// Add username element
|
||||
$username = new Zend_Form_Element_Text("username");
|
||||
$username = new Zend_Form_Element_Text('username');
|
||||
$username->setLabel(_('Username:'))
|
||||
->setAttribs(array(
|
||||
->setAttribs([
|
||||
'autofocus' => 'true',
|
||||
'class' => 'input_text',
|
||||
'required' => 'true'))
|
||||
->setValue((isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1)?'admin':'')
|
||||
'required' => 'true', ])
|
||||
->setValue((isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1) ? 'admin' : '')
|
||||
->addFilter('StringTrim')
|
||||
->setDecorators(array('ViewHelper'))
|
||||
->setValidators(array('NotEmpty'));
|
||||
->setDecorators(['ViewHelper'])
|
||||
->setValidators(['NotEmpty'])
|
||||
;
|
||||
$this->addElement($username);
|
||||
|
||||
// Add password element
|
||||
$this->addElement('password', 'password', array(
|
||||
'label' => _('Password:'),
|
||||
'class' => 'input_text',
|
||||
'required' => true,
|
||||
'value' => (isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1)?'admin':'',
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
$this->addElement('password', 'password', [
|
||||
'label' => _('Password:'),
|
||||
'class' => 'input_text',
|
||||
'required' => true,
|
||||
'value' => (isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1) ? 'admin' : '',
|
||||
'filters' => ['StringTrim'],
|
||||
'validators' => [
|
||||
'NotEmpty',
|
||||
),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
|
||||
$locale = new Zend_Form_Element_Select("locale");
|
||||
$locale->setLabel(_("Language:"));
|
||||
],
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
$locale = new Zend_Form_Element_Select('locale');
|
||||
$locale->setLabel(_('Language:'));
|
||||
$locale->setMultiOptions(Application_Model_Locale::getLocales());
|
||||
$locale->setDecorators(array('ViewHelper'));
|
||||
$locale->setDecorators(['ViewHelper']);
|
||||
$this->addElement($locale);
|
||||
$this->setDefaults(array(
|
||||
"locale" => Application_Model_Locale::getUserLocale()
|
||||
));
|
||||
$this->setDefaults([
|
||||
'locale' => Application_Model_Locale::getUserLocale(),
|
||||
]);
|
||||
|
||||
// Add the submit button
|
||||
$this->addElement('submit', 'submit', array(
|
||||
'ignore' => true,
|
||||
'label' => _('Login'),
|
||||
'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
|
||||
$this->addElement('submit', 'submit', [
|
||||
'ignore' => true,
|
||||
'label' => _('Login'),
|
||||
'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* tests if a string starts with a given string
|
||||
* tests if a string starts with a given string.
|
||||
*
|
||||
* This method was pinched as is from phing since it was the only line of code
|
||||
* actually used from phing. I'm not 100% convinced why it was deemed necessary
|
||||
|
@ -102,10 +101,10 @@ class Application_Form_Login extends Zend_Form
|
|||
*/
|
||||
private function startsWith($check, $string)
|
||||
{
|
||||
if ($check === "" || $check === $string) {
|
||||
if ($check === '' || $check === $string) {
|
||||
return true;
|
||||
} else {
|
||||
return (strpos($string, $check) === 0) ? true : false;
|
||||
}
|
||||
|
||||
return (strpos($string, $check) === 0) ? true : false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,51 +1,49 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*/
|
||||
class Application_Form_PasswordChange extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/password-change.phtml'))
|
||||
));
|
||||
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/password-change.phtml']],
|
||||
]);
|
||||
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$stringLengthValidator = Application_Form_Helper_ValidationTypes::overrideStringLengthValidator(6, 80);
|
||||
|
||||
$this->addElement('password', 'password', array(
|
||||
$this->addElement('password', 'password', [
|
||||
'label' => _('Password'),
|
||||
'required' => true,
|
||||
'filters' => array('stringTrim'),
|
||||
'validators' => array($notEmptyValidator,
|
||||
$stringLengthValidator),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
'filters' => ['stringTrim'],
|
||||
'validators' => [$notEmptyValidator,
|
||||
$stringLengthValidator, ],
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->addElement('password', 'password_confirm', array(
|
||||
$this->addElement('password', 'password_confirm', [
|
||||
'label' => _('Confirm new password'),
|
||||
'required' => true,
|
||||
'filters' => array('stringTrim'),
|
||||
'validators' => array(
|
||||
'filters' => ['stringTrim'],
|
||||
'validators' => [
|
||||
new Zend_Validate_Callback(function ($value, $context) {
|
||||
return $value == $context['password'];
|
||||
}),
|
||||
),
|
||||
'errorMessages' => array(_("Password confirmation does not match your password.")),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
],
|
||||
'errorMessages' => [_('Password confirmation does not match your password.')],
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->addElement('submit', 'submit', array(
|
||||
$this->addElement('submit', 'submit', [
|
||||
'label' => _('Save'),
|
||||
'ignore' => true,
|
||||
'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +1,51 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*/
|
||||
class Application_Form_PasswordRestore extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/password-restore.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/password-restore.phtml']],
|
||||
]);
|
||||
|
||||
$this->addElement('text', 'email', array(
|
||||
$this->addElement('text', 'email', [
|
||||
'label' => _('Email'),
|
||||
'required' => true,
|
||||
'filters' => array(
|
||||
'filters' => [
|
||||
'stringTrim',
|
||||
),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
],
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->addElement('text', 'username', array(
|
||||
$this->addElement('text', 'username', [
|
||||
'label' => _('Username'),
|
||||
'required' => false,
|
||||
'filters' => array(
|
||||
'filters' => [
|
||||
'stringTrim',
|
||||
),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
],
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->addElement('submit', 'submit', array(
|
||||
$this->addElement('submit', 'submit', [
|
||||
'label' => _('Reset password'),
|
||||
'ignore' => true,
|
||||
'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center',
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
$cancel = new Zend_Form_Element_Button("cancel");
|
||||
$cancel = new Zend_Form_Element_Button('cancel');
|
||||
$cancel->class = 'ui-button ui-widget ui-state-default ui-button-text-only center';
|
||||
$cancel->setLabel(_("Back"))
|
||||
->setIgnore(True)
|
||||
->setAttrib('onclick', 'window.location = ' . Zend_Controller_Front::getInstance()->getBaseUrl('login'))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$cancel->setLabel(_('Back'))
|
||||
->setIgnore(true)
|
||||
->setAttrib('onclick', 'window.location = ' . Zend_Controller_Front::getInstance()->getBaseUrl('login'))
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($cancel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
<?php
|
||||
|
||||
define("OPUS", "opus");
|
||||
define('OPUS', 'opus');
|
||||
|
||||
class Application_Form_Player extends Zend_Form_SubForm
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/player.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/player.phtml']],
|
||||
]);
|
||||
|
||||
$title = new Zend_Form_Element_Text('player_title');
|
||||
$title->setValue(_('Now Playing'));
|
||||
$title->setLabel(_('Title:'));
|
||||
$title->setDecorators(array(
|
||||
$title->setDecorators([
|
||||
'ViewHelper',
|
||||
'Errors',
|
||||
'Label'
|
||||
));
|
||||
$title->addDecorator('Label', array('class' => 'player-title'));
|
||||
'Label',
|
||||
]);
|
||||
$title->addDecorator('Label', ['class' => 'player-title']);
|
||||
$this->addElement($title);
|
||||
|
||||
$streamMode = new Zend_Form_Element_Radio('player_stream_mode');
|
||||
$streamMode->setLabel(_('Select Stream:'));
|
||||
$streamMode->setMultiOptions(
|
||||
array(
|
||||
"auto" => _("Auto detect the most appropriate stream to use."),
|
||||
"manual" => _("Select a stream:")
|
||||
)
|
||||
[
|
||||
'auto' => _('Auto detect the most appropriate stream to use.'),
|
||||
'manual' => _('Select a stream:'),
|
||||
]
|
||||
);
|
||||
$streamMode->setValue("auto");
|
||||
$streamMode->setValue('auto');
|
||||
$this->addElement($streamMode);
|
||||
|
||||
$streamURL = new Zend_Form_Element_Radio('player_stream_url');
|
||||
$opusStreamCount = 0;
|
||||
$urlOptions = Array();
|
||||
foreach(Application_Model_StreamSetting::getEnabledStreamData() as $stream => $data) {
|
||||
$urlOptions[$stream] = strtoupper($data["codec"])." - ".$data["bitrate"]."kbps";
|
||||
if ($data["mobile"]) {
|
||||
$urlOptions[$stream] .= _(" - Mobile friendly");
|
||||
$urlOptions = [];
|
||||
foreach (Application_Model_StreamSetting::getEnabledStreamData() as $stream => $data) {
|
||||
$urlOptions[$stream] = strtoupper($data['codec']) . ' - ' . $data['bitrate'] . 'kbps';
|
||||
if ($data['mobile']) {
|
||||
$urlOptions[$stream] .= _(' - Mobile friendly');
|
||||
}
|
||||
if ($data["codec"] == OPUS) {
|
||||
$opusStreamCount += 1;
|
||||
$urlOptions[$stream] .= _(" - The player does not support Opus streams.");
|
||||
if ($data['codec'] == OPUS) {
|
||||
++$opusStreamCount;
|
||||
$urlOptions[$stream] .= _(' - The player does not support Opus streams.');
|
||||
}
|
||||
}
|
||||
$streamURL->setMultiOptions(
|
||||
|
@ -53,35 +53,35 @@ class Application_Form_Player extends Zend_Form_SubForm
|
|||
foreach ($urlOptions as $o => $v) {
|
||||
if (strpos(strtolower($v), OPUS) !== false) {
|
||||
continue;
|
||||
} else {
|
||||
$streamURL->setValue($o);
|
||||
break;
|
||||
}
|
||||
$streamURL->setValue($o);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$streamURL->setAttrib('numberOfEnabledStreams', sizeof($urlOptions)-$opusStreamCount);
|
||||
$streamURL->setAttrib('numberOfEnabledStreams', sizeof($urlOptions) - $opusStreamCount);
|
||||
$streamURL->removeDecorator('label');
|
||||
$this->addElement($streamURL);
|
||||
|
||||
$embedSrc = new Zend_Form_Element_Textarea('player_embed_src');
|
||||
$embedSrc->setAttrib("readonly", "readonly");
|
||||
$embedSrc->setAttrib("class", "embed-player-text-box");
|
||||
$embedSrc->setAttrib('readonly', 'readonly');
|
||||
$embedSrc->setAttrib('class', 'embed-player-text-box');
|
||||
$embedSrc->setAttrib('cols', '40')
|
||||
->setAttrib('rows', '4');
|
||||
$embedSrc->setLabel(_("Embeddable code:"));
|
||||
->setAttrib('rows', '4')
|
||||
;
|
||||
$embedSrc->setLabel(_('Embeddable code:'));
|
||||
$embedSrc->setDescription(_("Copy this code and paste it into your website's HTML to embed the player in your site."));
|
||||
$embedSrc->setValue('<iframe frameborder="0" width="280" height="216" src="'.Application_Common_HTTPHelper::getStationUrl().'embed/player?stream=auto&title=Now Playing"></iframe>');
|
||||
$embedSrc->setValue('<iframe frameborder="0" width="280" height="216" src="' . Application_Common_HTTPHelper::getStationUrl() . 'embed/player?stream=auto&title=Now Playing"></iframe>');
|
||||
$this->addElement($embedSrc);
|
||||
|
||||
$previewLabel = new Zend_Form_Element_Text('player_preview_label');
|
||||
$previewLabel->setLabel(_("Preview:"));
|
||||
$previewLabel->setDecorators(array(
|
||||
$previewLabel->setLabel(_('Preview:'));
|
||||
$previewLabel->setDecorators([
|
||||
'ViewHelper',
|
||||
'Errors',
|
||||
'Label'
|
||||
));
|
||||
$previewLabel->addDecorator('Label', array('class' => 'preview-label'));
|
||||
'Label',
|
||||
]);
|
||||
$previewLabel->addDecorator('Label', ['class' => 'preview-label']);
|
||||
$this->addElement($previewLabel);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_PodcastPreferences extends Zend_Form_SubForm {
|
||||
|
||||
public function init() {
|
||||
class Application_Form_PodcastPreferences extends Zend_Form_SubForm
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$isPrivate = Application_Model_Preference::getStationPodcastPrivacy();
|
||||
$stationPodcastPrivacy = new Zend_Form_Element_Radio("stationPodcastPrivacy");
|
||||
$stationPodcastPrivacy = new Zend_Form_Element_Radio('stationPodcastPrivacy');
|
||||
$stationPodcastPrivacy->setLabel(_('Feed Privacy'));
|
||||
$stationPodcastPrivacy->setMultiOptions(array(
|
||||
_("Public"),
|
||||
_("Private"),
|
||||
));
|
||||
$stationPodcastPrivacy->setMultiOptions([
|
||||
_('Public'),
|
||||
_('Private'),
|
||||
]);
|
||||
$stationPodcastPrivacy->setSeparator(' ');
|
||||
$stationPodcastPrivacy->addDecorator('HtmlTag', array('tag' => 'dd',
|
||||
'id'=>"stationPodcastPrivacy-element",
|
||||
$stationPodcastPrivacy->addDecorator('HtmlTag', ['tag' => 'dd',
|
||||
'id' => 'stationPodcastPrivacy-element',
|
||||
'class' => 'radio-inline-list',
|
||||
));
|
||||
]);
|
||||
$stationPodcastPrivacy->setValue($isPrivate);
|
||||
$this->addElement($stationPodcastPrivacy);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ class Application_Form_Preferences extends Zend_Form
|
|||
{
|
||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/preferences.phtml']],
|
||||
]);
|
||||
|
||||
$general_pref = new Application_Form_GeneralPreferences();
|
||||
|
||||
|
@ -36,7 +36,7 @@ class Application_Form_Preferences extends Zend_Form
|
|||
$submit = new Zend_Form_Element_Submit('submit');
|
||||
$submit->setLabel(_('Save'));
|
||||
//$submit->removeDecorator('Label');
|
||||
$submit->setAttribs(array('class'=>'btn right-floated'));
|
||||
$submit->setAttribs(['class' => 'btn right-floated']);
|
||||
$submit->removeDecorator('DtDdWrapper');
|
||||
|
||||
$this->addElement($submit);
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
class Application_Form_ScheduleShow extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
/* Form Elements & Other Definitions Here ... */
|
||||
// Form Elements & Other Definitions Here ...
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
class Application_Form_SetupLanguageTimezone extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/setup-lang-timezone.phtml'))));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/setup-lang-timezone.phtml']], ]);
|
||||
|
||||
$csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
|
||||
$csrf_element = new Zend_Form_Element_Hidden('csrf');
|
||||
|
@ -15,14 +13,13 @@ class Application_Form_SetupLanguageTimezone extends Zend_Form_SubForm
|
|||
$this->addElement($csrf_element);
|
||||
|
||||
$language = new Zend_Form_Element_Select('setup_language');
|
||||
$language->setLabel(_("Station Language"));
|
||||
$language->setLabel(_('Station Language'));
|
||||
$language->setMultiOptions(Application_Model_Locale::getLocales());
|
||||
$this->addElement($language);
|
||||
|
||||
$timezone = new Zend_Form_Element_Select('setup_timezone');
|
||||
$timezone->setLabel(_("Station Timezone"));
|
||||
$timezone->setLabel(_('Station Timezone'));
|
||||
$timezone->setMultiOptions(Application_Common_Timezone::getTimezones());
|
||||
$this->addElement($timezone);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,26 +2,26 @@
|
|||
|
||||
class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/showbuilder.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/showbuilder.phtml']],
|
||||
]);
|
||||
|
||||
// Add start date element
|
||||
$startDate = new Zend_Form_Element_Text('sb_date_start');
|
||||
$startDate->class = 'input_text';
|
||||
$startDate->setRequired(true)
|
||||
->setLabel(_('Date Start:'))
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setLabel(_('Date Start:'))
|
||||
->setValue(date('Y-m-d'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
['date', false, ['YYYY-MM-DD']], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$startDate->setAttrib('alt', 'date');
|
||||
$this->addElement($startDate);
|
||||
|
||||
|
@ -29,13 +29,14 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
|||
$startTime = new Zend_Form_Element_Text('sb_time_start');
|
||||
$startTime->class = 'input_text';
|
||||
$startTime->setRequired(true)
|
||||
->setValue('00:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setValue('00:00')
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
['date', false, ['HH:mm']],
|
||||
['regex', false, ['/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$startTime->setAttrib('alt', 'time');
|
||||
$this->addElement($startTime);
|
||||
|
||||
|
@ -43,13 +44,14 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
|||
$endDate = new Zend_Form_Element_Text('sb_date_end');
|
||||
$endDate->class = 'input_text';
|
||||
$endDate->setRequired(true)
|
||||
->setLabel(_('Date End:'))
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setLabel(_('Date End:'))
|
||||
->setValue(date('Y-m-d'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
['date', false, ['YYYY-MM-DD']], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$endDate->setAttrib('alt', 'date');
|
||||
$this->addElement($endDate);
|
||||
|
||||
|
@ -57,28 +59,30 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
|||
$endTime = new Zend_Form_Element_Text('sb_time_end');
|
||||
$endTime->class = 'input_text';
|
||||
$endTime->setRequired(true)
|
||||
->setValue('01:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setValue('01:00')
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
['date', false, ['HH:mm']],
|
||||
['regex', false, ['/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$endTime->setAttrib('alt', 'time');
|
||||
$this->addElement($endTime);
|
||||
|
||||
// add a select to choose a show.
|
||||
$showSelect = new Zend_Form_Element_Select("sb_show_filter");
|
||||
$showSelect->setLabel(_("Filter by Show"));
|
||||
$showSelect = new Zend_Form_Element_Select('sb_show_filter');
|
||||
$showSelect->setLabel(_('Filter by Show'));
|
||||
$showSelect->setMultiOptions($this->getShowNames());
|
||||
$showSelect->setValue(null);
|
||||
$showSelect->setDecorators(array('ViewHelper'));
|
||||
$showSelect->setDecorators(['ViewHelper']);
|
||||
$this->addElement($showSelect);
|
||||
|
||||
if ($user->getType() === 'H') {
|
||||
$myShows = new Zend_Form_Element_Checkbox('sb_my_shows');
|
||||
$myShows->setLabel(_('All My Shows:'))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($myShows);
|
||||
}
|
||||
}
|
||||
|
@ -86,22 +90,21 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
|||
private function getShowNames()
|
||||
{
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
$showNames = array("0" => _("Filter by Show"));
|
||||
$showNames = ['0' => _('Filter by Show')];
|
||||
if ($user->getType() === 'H') {
|
||||
$showNames["-1"] = _("My Shows");
|
||||
$showNames['-1'] = _('My Shows');
|
||||
}
|
||||
|
||||
$shows = CcShowQuery::create()
|
||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||
->orderByDbName()
|
||||
->find();
|
||||
->find()
|
||||
;
|
||||
|
||||
foreach ($shows as $show) {
|
||||
|
||||
$showNames[$show->getDbId()] = $show->getDbName();
|
||||
}
|
||||
|
||||
return $showNames;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
class Application_Form_ShowListenerStat extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/daterange.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/daterange.phtml']],
|
||||
]);
|
||||
|
||||
// Add start date element
|
||||
$startDate = new Zend_Form_Element_Text('his_date_start');
|
||||
$startDate->class = 'input_text';
|
||||
$startDate->setRequired(true)
|
||||
->setLabel(_('Date Start:'))
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
->setValue(date('Y-m-d'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
['date', false, ['YYYY-MM-DD']], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$startDate->setAttrib('alt', 'date');
|
||||
$this->addElement($startDate);
|
||||
|
||||
|
@ -28,12 +28,13 @@ class Application_Form_ShowListenerStat extends Zend_Form_SubForm
|
|||
$startTime->class = 'input_text';
|
||||
$startTime->setRequired(true)
|
||||
->setValue('00:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
['date', false, ['HH:mm']],
|
||||
['regex', false, ['/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$startTime->setAttrib('alt', 'time');
|
||||
$this->addElement($startTime);
|
||||
|
||||
|
@ -42,12 +43,13 @@ class Application_Form_ShowListenerStat extends Zend_Form_SubForm
|
|||
$endDate->class = 'input_text';
|
||||
$endDate->setRequired(true)
|
||||
->setLabel(_('Date End:'))
|
||||
->setValue(date("Y-m-d"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
->setValue(date('Y-m-d'))
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
['date', false, ['YYYY-MM-DD']], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$endDate->setAttrib('alt', 'date');
|
||||
$this->addElement($endDate);
|
||||
|
||||
|
@ -56,12 +58,13 @@ class Application_Form_ShowListenerStat extends Zend_Form_SubForm
|
|||
$endTime->class = 'input_text';
|
||||
$endTime->setRequired(true)
|
||||
->setValue('01:00')
|
||||
->setFilters(array('StringTrim'))
|
||||
->setValidators(array(
|
||||
->setFilters(['StringTrim'])
|
||||
->setValidators([
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm')),
|
||||
array('regex', false, array('/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
['date', false, ['HH:mm']],
|
||||
['regex', false, ['/^[0-2]?[0-9]:[0-5][0-9]$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$endTime->setAttrib('alt', 'time');
|
||||
$this->addElement($endTime);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_StationPodcast extends Zend_Form {
|
||||
|
||||
public function init() {
|
||||
class Application_Form_StationPodcast extends Zend_Form
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
// Station Podcast form
|
||||
$podcastPreferences = new Application_Form_PodcastPreferences();
|
||||
$this->addSubForm($podcastPreferences, 'preferences_podcast');
|
||||
|
@ -12,8 +13,8 @@ class Application_Form_StationPodcast extends Zend_Form {
|
|||
$csrf_element->setValue($csrf_namespace->authtoken)
|
||||
->setRequired('true')
|
||||
->removeDecorator('HtmlTag')
|
||||
->removeDecorator('Label');
|
||||
->removeDecorator('Label')
|
||||
;
|
||||
$this->addElement($csrf_element);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ class Application_Form_StreamSetting extends Zend_Form
|
|||
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function setSetting($setting)
|
||||
|
@ -16,74 +15,80 @@ class Application_Form_StreamSetting extends Zend_Form
|
|||
|
||||
public function startFrom()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'preference/stream-setting.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'preference/stream-setting.phtml']],
|
||||
]);
|
||||
|
||||
$setting = $this->setting;
|
||||
|
||||
$output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device');
|
||||
$output_sound_device->setLabel(_('Hardware Audio Output:'))
|
||||
->setRequired(false)
|
||||
->setValue(($setting['output_sound_device'] == "true")?1:0)
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setRequired(false)
|
||||
->setValue(($setting['output_sound_device'] == 'true') ? 1 : 0)
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($output_sound_device);
|
||||
|
||||
$output_sound_device_type = new Zend_Form_Element_Select('output_sound_device_type');
|
||||
$output_sound_device_type->setLabel(_('Output Type'))
|
||||
->setMultiOptions(array(
|
||||
"ALSA"=>_("ALSA"),
|
||||
"AO"=>_("AO"),
|
||||
"OSS"=>_("OSS"),
|
||||
"Portaudio"=>_("Portaudio"),
|
||||
"Pulseaudio"=>_("Pulseaudio"),
|
||||
"Jack"=>_("Jack")))
|
||||
->setValue(isset($setting['output_sound_device_type'])?$setting['output_sound_device_type']:0)
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setMultiOptions([
|
||||
'ALSA' => _('ALSA'),
|
||||
'AO' => _('AO'),
|
||||
'OSS' => _('OSS'),
|
||||
'Portaudio' => _('Portaudio'),
|
||||
'Pulseaudio' => _('Pulseaudio'),
|
||||
'Jack' => _('Jack'), ])
|
||||
->setValue(isset($setting['output_sound_device_type']) ? $setting['output_sound_device_type'] : 0)
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($output_sound_device_type);
|
||||
|
||||
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
|
||||
$icecast_vorbis_metadata->setLabel(_('Icecast Vorbis Metadata'))
|
||||
->setRequired(false)
|
||||
->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0)
|
||||
->setDecorators(array('ViewHelper'));
|
||||
if (Application_Model_Preference::GetEnableStreamConf() == "false") {
|
||||
$icecast_vorbis_metadata->setAttrib("readonly", true);
|
||||
->setRequired(false)
|
||||
->setValue(($setting['icecast_vorbis_metadata'] == 'true') ? 1 : 0)
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
if (Application_Model_Preference::GetEnableStreamConf() == 'false') {
|
||||
$icecast_vorbis_metadata->setAttrib('readonly', true);
|
||||
}
|
||||
$this->addElement($icecast_vorbis_metadata);
|
||||
|
||||
$stream_format = new Zend_Form_Element_Radio('streamFormat');
|
||||
$stream_format->setLabel(_('Stream Label:'));
|
||||
$stream_format->setMultiOptions(array(_("Artist - Title"),
|
||||
_("Show - Artist - Title"),
|
||||
_("Station name - Show name")));
|
||||
$stream_format->setMultiOptions([_('Artist - Title'),
|
||||
_('Show - Artist - Title'),
|
||||
_('Station name - Show name'), ]);
|
||||
$stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat());
|
||||
$stream_format->setDecorators(array('ViewHelper'));
|
||||
$stream_format->setDecorators(['ViewHelper']);
|
||||
$this->addElement($stream_format);
|
||||
|
||||
|
||||
$offAirMeta = new Zend_Form_Element_Text('offAirMeta');
|
||||
$offAirMeta->setLabel(_('Off Air Metadata'))
|
||||
->setValue(Application_Model_StreamSetting::getOffAirMeta())
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setValue(Application_Model_StreamSetting::getOffAirMeta())
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($offAirMeta);
|
||||
|
||||
$enable_replay_gain = new Zend_Form_Element_Checkbox("enableReplayGain");
|
||||
$enable_replay_gain->setLabel(_("Enable Replay Gain"))
|
||||
->setValue(Application_Model_Preference::GetEnableReplayGain())
|
||||
->setDecorators(array('ViewHelper'));
|
||||
|
||||
$enable_replay_gain = new Zend_Form_Element_Checkbox('enableReplayGain');
|
||||
$enable_replay_gain->setLabel(_('Enable Replay Gain'))
|
||||
->setValue(Application_Model_Preference::GetEnableReplayGain())
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($enable_replay_gain);
|
||||
|
||||
$replay_gain = new Zend_Form_Element_Hidden("replayGainModifier");
|
||||
$replay_gain->setLabel(_("Replay Gain Modifier"))
|
||||
->setValue(Application_Model_Preference::getReplayGainModifier())
|
||||
->setAttribs(array('style' => "border: 0; color: #f6931f; font-weight: bold;"))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
|
||||
$replay_gain = new Zend_Form_Element_Hidden('replayGainModifier');
|
||||
$replay_gain->setLabel(_('Replay Gain Modifier'))
|
||||
->setValue(Application_Model_Preference::getReplayGainModifier())
|
||||
->setAttribs(['style' => 'border: 0; color: #f6931f; font-weight: bold;'])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($replay_gain);
|
||||
|
||||
$custom = Application_Model_Preference::getUsingCustomStreamSettings();
|
||||
$customSettings = new Zend_Form_Element_Radio('customStreamSettings');
|
||||
$customSettings->setLabel(_('Streaming Server:'));
|
||||
$customSettings->setMultiOptions(array(_("Default Streaming"), _("Custom / 3rd Party Streaming")));
|
||||
$customSettings->setMultiOptions([_('Default Streaming'), _('Custom / 3rd Party Streaming')]);
|
||||
$customSettings->setValue(!empty($custom) ? $custom : 0);
|
||||
$this->addElement($customSettings);
|
||||
}
|
||||
|
@ -91,17 +96,16 @@ class Application_Form_StreamSetting extends Zend_Form
|
|||
public function isValid($data)
|
||||
{
|
||||
if (isset($data['output_sound_device'])) {
|
||||
$d = array();
|
||||
$d["output_sound_device"] = $data['output_sound_device'];
|
||||
$d["icecast_vorbis_metadata"] = $data['icecast_vorbis_metadata'];
|
||||
$d = [];
|
||||
$d['output_sound_device'] = $data['output_sound_device'];
|
||||
$d['icecast_vorbis_metadata'] = $data['icecast_vorbis_metadata'];
|
||||
if (isset($data['output_sound_device_type'])) {
|
||||
$d["output_sound_device_type"] = $data['output_sound_device_type'];
|
||||
$d['output_sound_device_type'] = $data['output_sound_device_type'];
|
||||
}
|
||||
$d["streamFormat"] = $data['streamFormat'];
|
||||
$d['streamFormat'] = $data['streamFormat'];
|
||||
$this->populate($d);
|
||||
}
|
||||
$isValid = parent::isValid($data);
|
||||
|
||||
return $isValid;
|
||||
return parent::isValid($data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
|
||||
{
|
||||
private $prefix;
|
||||
|
@ -6,11 +7,10 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
|
|||
private $stream_types;
|
||||
private $stream_bitrates;
|
||||
|
||||
static $customizable;
|
||||
public static $customizable;
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function setPrefix($prefix)
|
||||
|
@ -35,7 +35,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
|
|||
|
||||
public function startForm()
|
||||
{
|
||||
$prefix = "s".$this->prefix;
|
||||
$prefix = 's' . $this->prefix;
|
||||
$stream_number = $this->prefix;
|
||||
$setting = $this->setting;
|
||||
$stream_types = $this->stream_types;
|
||||
|
@ -46,180 +46,196 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
|
|||
$useDefaults = !Application_Model_Preference::getUsingCustomStreamSettings();
|
||||
|
||||
$this->setIsArray(true);
|
||||
$this->setElementsBelongTo($prefix."_data");
|
||||
$this->setElementsBelongTo($prefix . '_data');
|
||||
|
||||
$enable = new Zend_Form_Element_Checkbox('enable');
|
||||
$enable->setLabel(_('Enabled:'))
|
||||
->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0)
|
||||
->setDecorators(array('ViewHelper'));
|
||||
->setValue($setting[$prefix . '_enable'] == 'true' ? 1 : 0)
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($enable);
|
||||
static::$customizable[] = $enable->getName();
|
||||
|
||||
$mobile = new Zend_Form_Element_Checkbox('mobile');
|
||||
$mobile->setLabel(_('Mobile:'));
|
||||
$mobile->setValue($setting[$prefix.'_mobile']);
|
||||
$mobile->setDecorators(array('ViewHelper'));
|
||||
$mobile->setValue($setting[$prefix . '_mobile']);
|
||||
$mobile->setDecorators(['ViewHelper']);
|
||||
$this->addElement($mobile);
|
||||
static::$customizable[] = $mobile->getName();
|
||||
|
||||
$type = new Zend_Form_Element_Select('type');
|
||||
$type->setLabel(_("Stream Type:"))
|
||||
->setMultiOptions($stream_types)
|
||||
->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0)
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$type->setLabel(_('Stream Type:'))
|
||||
->setMultiOptions($stream_types)
|
||||
->setValue(isset($setting[$prefix . '_type']) ? $setting[$prefix . '_type'] : 0)
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($type);
|
||||
static::$customizable[] = $type->getName();
|
||||
|
||||
$bitrate = new Zend_Form_Element_Select('bitrate');
|
||||
$bitrate->setLabel(_("Bit Rate:"))
|
||||
->setMultiOptions($stream_bitrates)
|
||||
->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0)
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$bitrate->setLabel(_('Bit Rate:'))
|
||||
->setMultiOptions($stream_bitrates)
|
||||
->setValue(isset($setting[$prefix . '_bitrate']) ? $setting[$prefix . '_bitrate'] : 0)
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($bitrate);
|
||||
static::$customizable[] = $bitrate->getName();
|
||||
|
||||
$output = new Zend_Form_Element_Select('output');
|
||||
$output->setLabel(_("Service Type:"))
|
||||
->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast"))
|
||||
->setValue($useDefaults ? $streamDefaults['output'] :
|
||||
(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast"))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$output->setLabel(_('Service Type:'))
|
||||
->setMultiOptions(['icecast' => 'Icecast', 'shoutcast' => 'SHOUTcast'])
|
||||
->setValue($useDefaults ? $streamDefaults['output'] :
|
||||
(isset($setting[$prefix . '_output']) ? $setting[$prefix . '_output'] : 'icecast'))
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($output);
|
||||
|
||||
$channels = new Zend_Form_Element_Select('channels');
|
||||
$channels->setLabel(_("Channels:"))
|
||||
->setMultiOptions(array("mono"=>_("1 - Mono"), "stereo"=>_("2 - Stereo")))
|
||||
->setValue(isset($setting[$prefix.'_channels']) ? $setting[$prefix.'_channels'] : "stereo")
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$channels->setLabel(_('Channels:'))
|
||||
->setMultiOptions(['mono' => _('1 - Mono'), 'stereo' => _('2 - Stereo')])
|
||||
->setValue(isset($setting[$prefix . '_channels']) ? $setting[$prefix . '_channels'] : 'stereo')
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($channels);
|
||||
static::$customizable[] = $channels->getName();
|
||||
|
||||
$host = new Zend_Form_Element_Text('host');
|
||||
$host->setLabel(_("Server"))
|
||||
->setValue($useDefaults ? $streamDefaults['host'] :
|
||||
(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:""))
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$host->setLabel(_('Server'))
|
||||
->setValue($useDefaults ? $streamDefaults['host'] :
|
||||
(isset($setting[$prefix . '_host']) ? $setting[$prefix . '_host'] : ''))
|
||||
->setValidators([
|
||||
['regex', false, ['/^[0-9a-zA-Z-_.]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$host->setAttrib('alt', 'domain');
|
||||
$this->addElement($host);
|
||||
|
||||
$port = new Zend_Form_Element_Text('port');
|
||||
$port->setLabel(_("Port"))
|
||||
->setValue($useDefaults ? $streamDefaults['port'] :
|
||||
(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:""))
|
||||
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
|
||||
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$port->setLabel(_('Port'))
|
||||
->setValue($useDefaults ? $streamDefaults['port'] :
|
||||
(isset($setting[$prefix . '_port']) ? $setting[$prefix . '_port'] : ''))
|
||||
->setValidators([new Zend_Validate_Between(['min' => 0, 'max' => 99999])])
|
||||
->addValidator('regex', false, ['pattern' => '/^[0-9]+$/', 'messages' => ['regexNotMatch' => _('Only numbers are allowed.')]])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($port);
|
||||
|
||||
$pass = new Zend_Form_Element_Text('pass');
|
||||
$pass->setLabel(_("Password"))
|
||||
->setValue($useDefaults ? $streamDefaults['pass'] :
|
||||
(isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:""))
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$pass->setLabel(_('Password'))
|
||||
->setValue($useDefaults ? $streamDefaults['pass'] :
|
||||
(isset($setting[$prefix . '_pass']) ? $setting[$prefix . '_pass'] : ''))
|
||||
->setValidators([
|
||||
['regex', false, ['/^[^ &<>]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$pass->setAttrib('alt', 'regular_text');
|
||||
$this->addElement($pass);
|
||||
|
||||
$genre = new Zend_Form_Element_Text('genre');
|
||||
$genre->setLabel(_("Genre"))
|
||||
->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"")
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$genre->setLabel(_('Genre'))
|
||||
->setValue(isset($setting[$prefix . '_genre']) ? $setting[$prefix . '_genre'] : '')
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($genre);
|
||||
|
||||
$url = new Zend_Form_Element_Text('url');
|
||||
$url->setLabel(_("URL"))
|
||||
->setValue(isset($setting[$prefix.'_url'])?$setting[$prefix.'_url']:"")
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$url->setLabel(_('URL'))
|
||||
->setValue(isset($setting[$prefix . '_url']) ? $setting[$prefix . '_url'] : '')
|
||||
->setValidators([
|
||||
['regex', false, ['/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$url->setAttrib('alt', 'url');
|
||||
$this->addElement($url);
|
||||
|
||||
$name = new Zend_Form_Element_Text('name');
|
||||
$name->setLabel(_("Name"))
|
||||
->setValue(isset($setting[$prefix.'_name'])?$setting[$prefix.'_name']:"")
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$name->setLabel(_('Name'))
|
||||
->setValue(isset($setting[$prefix . '_name']) ? $setting[$prefix . '_name'] : '')
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($name);
|
||||
|
||||
$description = new Zend_Form_Element_Text('description');
|
||||
$description->setLabel(_("Description"))
|
||||
->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"")
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$description->setLabel(_('Description'))
|
||||
->setValue(isset($setting[$prefix . '_description']) ? $setting[$prefix . '_description'] : '')
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$this->addElement($description);
|
||||
|
||||
$mount = new Zend_Form_Element_Text('mount');
|
||||
$mount->setLabel(_("Mount Point"))
|
||||
->setValue($useDefaults ? $streamDefaults['mount'] :
|
||||
(isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:""))
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$mount->setLabel(_('Mount Point'))
|
||||
->setValue($useDefaults ? $streamDefaults['mount'] :
|
||||
(isset($setting[$prefix . '_mount']) ? $setting[$prefix . '_mount'] : ''))
|
||||
->setValidators([
|
||||
['regex', false, ['/^[^ &<>]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$mount->setAttrib('alt', 'regular_text');
|
||||
$this->addElement($mount);
|
||||
|
||||
$user = new Zend_Form_Element_Text('user');
|
||||
$user->setLabel(_("Username"))
|
||||
->setValue($useDefaults ? $streamDefaults['user'] :
|
||||
(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:""))
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$user->setLabel(_('Username'))
|
||||
->setValue($useDefaults ? $streamDefaults['user'] :
|
||||
(isset($setting[$prefix . '_user']) ? $setting[$prefix . '_user'] : ''))
|
||||
->setValidators([
|
||||
['regex', false, ['/^[^ &<>]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$user->setAttrib('alt', 'regular_text');
|
||||
$this->addElement($user);
|
||||
|
||||
|
||||
$adminUser = new Zend_Form_Element_Text('admin_user');
|
||||
$adminUser->setLabel(_("Admin User"))
|
||||
->setValue(Application_Model_StreamSetting::getAdminUser($prefix))
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$adminUser->setLabel(_('Admin User'))
|
||||
->setValue(Application_Model_StreamSetting::getAdminUser($prefix))
|
||||
->setValidators([
|
||||
['regex', false, ['/^[^ &<>]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$adminUser->setAttrib('alt', 'regular_text');
|
||||
$this->addElement($adminUser);
|
||||
|
||||
|
||||
$adminPass = new Zend_Form_Element_Password('admin_pass');
|
||||
$adminPass->setLabel(_("Admin Password"))
|
||||
->setValue(Application_Model_StreamSetting::getAdminPass($prefix))
|
||||
->setValidators(array(
|
||||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$adminPass->setLabel(_('Admin Password'))
|
||||
->setValue(Application_Model_StreamSetting::getAdminPass($prefix))
|
||||
->setValidators([
|
||||
['regex', false, ['/^[^ &<>]+$/', 'messages' => _('Invalid character entered')]], ])
|
||||
->setDecorators(['ViewHelper'])
|
||||
;
|
||||
$adminPass->setAttrib('alt', 'regular_text');
|
||||
$this->addElement($adminPass);
|
||||
|
||||
$liquidsoap_error_msg = '<div class="stream-status status-info"><p>'._('Getting information from the server...').'</p></div>';
|
||||
$liquidsoap_error_msg = '<div class="stream-status status-info"><p>' . _('Getting information from the server...') . '</p></div>';
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml',
|
||||
"stream_number"=>$stream_number,
|
||||
"enabled"=>$enable->getValue(),
|
||||
"liquidsoap_error_msg"=>$liquidsoap_error_msg))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/stream-setting-form.phtml',
|
||||
'stream_number' => $stream_number,
|
||||
'enabled' => $enable->getValue(),
|
||||
'liquidsoap_error_msg' => $liquidsoap_error_msg, ]],
|
||||
]);
|
||||
}
|
||||
|
||||
public function isValid ($data)
|
||||
public function isValid($data)
|
||||
{
|
||||
$f_data = $data['s'.$this->prefix."_data"];
|
||||
$f_data = $data['s' . $this->prefix . '_data'];
|
||||
$isValid = parent::isValid($f_data);
|
||||
// XXX: A couple of ugly workarounds here, but I guess that's what you get when you
|
||||
// combine an already-complex POST and GET into a single action...
|
||||
if (Application_Model_Preference::getUsingCustomStreamSettings() && $f_data) {
|
||||
if ($f_data['enable'] == 1 && isset($f_data["host"])) {
|
||||
if ($f_data['enable'] == 1 && isset($f_data['host'])) {
|
||||
if ($f_data['host'] == '') {
|
||||
$element = $this->getElement("host");
|
||||
$element->addError(_("Server cannot be empty."));
|
||||
$element = $this->getElement('host');
|
||||
$element->addError(_('Server cannot be empty.'));
|
||||
$isValid = false;
|
||||
}
|
||||
if ($f_data['port'] == '') {
|
||||
$element = $this->getElement("port");
|
||||
$element->addError(_("Port cannot be empty."));
|
||||
$element = $this->getElement('port');
|
||||
$element->addError(_('Port cannot be empty.'));
|
||||
$isValid = false;
|
||||
}
|
||||
if ($f_data['output'] == 'icecast') {
|
||||
if ($f_data['mount'] == '') {
|
||||
$element = $this->getElement("mount");
|
||||
$element->addError(_("Mount cannot be empty with Icecast server."));
|
||||
$element = $this->getElement('mount');
|
||||
$element->addError(_('Mount cannot be empty with Icecast server.'));
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
|
@ -229,12 +245,13 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
|
|||
return $isValid;
|
||||
}
|
||||
|
||||
public function toggleState() {
|
||||
public function toggleState()
|
||||
{
|
||||
$elements = $this->getElements();
|
||||
foreach ($elements as $element) {
|
||||
if (Application_Model_Preference::getUsingCustomStreamSettings()) {
|
||||
$element->setAttrib('disabled', null);
|
||||
} else if (!(in_array($element->getName(), static::$customizable)
|
||||
} elseif (!(in_array($element->getName(), static::$customizable)
|
||||
|| $element->getType() == 'Zend_Form_Element_Hidden')) {
|
||||
$element->setAttrib('disabled', 'disabled');
|
||||
}
|
||||
|
|
|
@ -6,37 +6,37 @@ class Application_Form_TuneInPreferences extends Zend_Form_SubForm
|
|||
{
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_tunein.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/preferences_tunein.phtml']],
|
||||
]);
|
||||
|
||||
$enableTunein = new Zend_Form_Element_Checkbox("enable_tunein");
|
||||
$enableTunein->setDecorators(array(
|
||||
$enableTunein = new Zend_Form_Element_Checkbox('enable_tunein');
|
||||
$enableTunein->setDecorators([
|
||||
'ViewHelper',
|
||||
'Errors',
|
||||
'Label'
|
||||
));
|
||||
$enableTunein->addDecorator('Label', array('class' => 'enable-tunein'));
|
||||
$enableTunein->setLabel(_("Push metadata to your station on TuneIn?"));
|
||||
'Label',
|
||||
]);
|
||||
$enableTunein->addDecorator('Label', ['class' => 'enable-tunein']);
|
||||
$enableTunein->setLabel(_('Push metadata to your station on TuneIn?'));
|
||||
$enableTunein->setValue(Application_Model_Preference::getTuneinEnabled());
|
||||
$this->addElement($enableTunein);
|
||||
|
||||
$tuneinStationId = new Zend_Form_Element_Text("tunein_station_id");
|
||||
$tuneinStationId->setLabel(_("Station ID:"));
|
||||
$tuneinStationId = new Zend_Form_Element_Text('tunein_station_id');
|
||||
$tuneinStationId->setLabel(_('Station ID:'));
|
||||
$tuneinStationId->setValue(Application_Model_Preference::getTuneinStationId());
|
||||
$tuneinStationId->setAttrib("class", "input_text");
|
||||
$tuneinStationId->setAttrib('class', 'input_text');
|
||||
$this->addElement($tuneinStationId);
|
||||
|
||||
$tuneinPartnerKey = new Zend_Form_Element_Text("tunein_partner_key");
|
||||
$tuneinPartnerKey->setLabel(_("Partner Key:"));
|
||||
$tuneinPartnerKey = new Zend_Form_Element_Text('tunein_partner_key');
|
||||
$tuneinPartnerKey->setLabel(_('Partner Key:'));
|
||||
$tuneinPartnerKey->setValue(Application_Model_Preference::getTuneinPartnerKey());
|
||||
$tuneinPartnerKey->setAttrib("class", "input_text");
|
||||
$tuneinPartnerKey->setAttrib('class', 'input_text');
|
||||
$this->addElement($tuneinPartnerKey);
|
||||
|
||||
$tuneinPartnerId = new Zend_Form_Element_Text("tunein_partner_id");
|
||||
$tuneinPartnerId->setLabel(_("Partner Id:"));
|
||||
$tuneinPartnerId = new Zend_Form_Element_Text('tunein_partner_id');
|
||||
$tuneinPartnerId->setLabel(_('Partner Id:'));
|
||||
$tuneinPartnerId->setValue(Application_Model_Preference::getTuneinPartnerId());
|
||||
$tuneinPartnerId->setAttrib("class", "input_text");
|
||||
$tuneinPartnerId->setAttrib('class', 'input_text');
|
||||
$this->addElement($tuneinPartnerId);
|
||||
}
|
||||
|
||||
|
@ -49,18 +49,18 @@ class Application_Form_TuneInPreferences extends Zend_Form_SubForm
|
|||
// with the commercial flag set to true, which removes the metadata
|
||||
// from the station on TuneIn. After that, and if the test request
|
||||
// succeeds, we will make another request with the real metadata.
|
||||
if ($data["enable_tunein"]) {
|
||||
$credentialsQryStr = "?partnerId=".$data["tunein_partner_id"]."&partnerKey=".$data["tunein_partner_key"]."&id=".$data["tunein_station_id"];
|
||||
$commercialFlagQryStr = "&commercial=true";
|
||||
if ($data['enable_tunein']) {
|
||||
$credentialsQryStr = '?partnerId=' . $data['tunein_partner_id'] . '&partnerKey=' . $data['tunein_partner_key'] . '&id=' . $data['tunein_station_id'];
|
||||
$commercialFlagQryStr = '&commercial=true';
|
||||
|
||||
$metadata = Application_Model_Schedule::getCurrentPlayingTrack();
|
||||
|
||||
if (is_null($metadata)) {
|
||||
$qryStr = $credentialsQryStr . $commercialFlagQryStr;
|
||||
} else {
|
||||
$metadata["artist"] = empty($metadata["artist"]) ? "n/a" : $metadata["artist"];
|
||||
$metadata["title"] = empty($metadata["title"]) ? "n/a" : $metadata["title"];
|
||||
$metadataQryStr = "&artist=" . $metadata["artist"] . "&title=" . $metadata["title"];
|
||||
$metadata['artist'] = empty($metadata['artist']) ? 'n/a' : $metadata['artist'];
|
||||
$metadata['title'] = empty($metadata['title']) ? 'n/a' : $metadata['title'];
|
||||
$metadataQryStr = '&artist=' . $metadata['artist'] . '&title=' . $metadata['title'];
|
||||
|
||||
$qryStr = $credentialsQryStr . $metadataQryStr;
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ class Application_Form_TuneInPreferences extends Zend_Form_SubForm
|
|||
|
||||
$xmlData = curl_exec($ch);
|
||||
if (curl_error($ch)) {
|
||||
Logging::error("Failed to reach TuneIn: ". curl_errno($ch)." - ". curl_error($ch) . " - " . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
|
||||
if (curl_error($ch) == "The requested URL returned error: 403 Forbidden") {
|
||||
$this->getElement("enable_tunein")->setErrors(array(_("Invalid TuneIn Settings. Please ensure your TuneIn settings are correct and try again.")));
|
||||
Logging::error('Failed to reach TuneIn: ' . curl_errno($ch) . ' - ' . curl_error($ch) . ' - ' . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
|
||||
if (curl_error($ch) == 'The requested URL returned error: 403 Forbidden') {
|
||||
$this->getElement('enable_tunein')->setErrors([_('Invalid TuneIn Settings. Please ensure your TuneIn settings are correct and try again.')]);
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
@ -83,10 +83,10 @@ class Application_Form_TuneInPreferences extends Zend_Form_SubForm
|
|||
|
||||
if ($valid) {
|
||||
$xmlObj = new SimpleXMLElement($xmlData);
|
||||
if (!$xmlObj || $xmlObj->head->status != "200") {
|
||||
$this->getElement("enable_tunein")->setErrors(array(_("Invalid TuneIn Settings. Please ensure your TuneIn settings are correct and try again.")));
|
||||
if (!$xmlObj || $xmlObj->head->status != '200') {
|
||||
$this->getElement('enable_tunein')->setErrors([_('Invalid TuneIn Settings. Please ensure your TuneIn settings are correct and try again.')]);
|
||||
$valid = false;
|
||||
} else if ($xmlObj->head->status == "200") {
|
||||
} elseif ($xmlObj->head->status == '200') {
|
||||
Application_Model_Preference::setLastTuneinMetadataUpdate(time());
|
||||
$valid = true;
|
||||
}
|
||||
|
@ -98,10 +98,10 @@ class Application_Form_TuneInPreferences extends Zend_Form_SubForm
|
|||
if (!$valid) {
|
||||
// Set values to what the user entered since the form is invalid so they
|
||||
// don't have to enter in the values again and can see what they entered.
|
||||
$this->getElement("enable_tunein")->setValue($data["enable_tunein"]);
|
||||
$this->getElement("tunein_partner_key")->setValue($data["tunein_partner_key"]);
|
||||
$this->getElement("tunein_partner_id")->setValue($data["tunein_partner_id"]);
|
||||
$this->getElement("tunein_station_id")->setValue($data["tunein_station_id"]);
|
||||
$this->getElement('enable_tunein')->setValue($data['enable_tunein']);
|
||||
$this->getElement('tunein_partner_key')->setValue($data['tunein_partner_key']);
|
||||
$this->getElement('tunein_partner_id')->setValue($data['tunein_partner_id']);
|
||||
$this->getElement('tunein_station_id')->setValue($data['tunein_station_id']);
|
||||
}
|
||||
|
||||
return $valid;
|
||||
|
|
|
@ -2,34 +2,33 @@
|
|||
|
||||
class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_watched_dirs.phtml'))
|
||||
));
|
||||
$this->setDecorators([
|
||||
['ViewScript', ['viewScript' => 'form/preferences_watched_dirs.phtml']],
|
||||
]);
|
||||
|
||||
$this->addElement('text', 'storageFolder', array(
|
||||
'class' => 'input_text',
|
||||
'label' => _('Import Folder:'),
|
||||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
$this->addElement('text', 'storageFolder', [
|
||||
'class' => 'input_text',
|
||||
'label' => _('Import Folder:'),
|
||||
'required' => false,
|
||||
'filters' => ['StringTrim'],
|
||||
'value' => '',
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->addElement('text', 'watchedFolder', array(
|
||||
'class' => 'input_text',
|
||||
'label' => _('Watched Folders:'),
|
||||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
$this->addElement('text', 'watchedFolder', [
|
||||
'class' => 'input_text',
|
||||
'label' => _('Watched Folders:'),
|
||||
'required' => false,
|
||||
'filters' => ['StringTrim'],
|
||||
'value' => '',
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
'decorators' => [
|
||||
'ViewHelper',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function verifyChosenFolder($p_form_element_id)
|
||||
|
@ -37,15 +36,12 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm
|
|||
$element = $this->getElement($p_form_element_id);
|
||||
|
||||
if (!is_dir($element->getValue())) {
|
||||
$element->setErrors(array(_('Not a valid Directory')));
|
||||
$element->setErrors([_('Not a valid Directory')]);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$element->setValue("");
|
||||
|
||||
return true;
|
||||
}
|
||||
$element->setValue('');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* custom filter for image uploads
|
||||
* custom filter for image uploads.
|
||||
*
|
||||
* WARNING: you need to include this file directly when using it, it clashes with the
|
||||
* WARNING: you need to include this file directly when using it, it clashes with the
|
||||
* way zf1 Zend_Loader_PluginLoader expects it to be found. Another way around this
|
||||
* might be to rename the class and have the new name get loaded proper.
|
||||
*
|
||||
* Since this is only getting used in a few places I am re-adding the
|
||||
* require_once there to get this fixed for now.
|
||||
*/
|
||||
|
||||
class Zend_Filter_ImageSize implements Zend_Filter_Interface
|
||||
{
|
||||
public function filter($value)
|
||||
|
@ -37,7 +36,7 @@ class Zend_Filter_ImageSize implements Zend_Filter_Interface
|
|||
imagecopyresampled($resized, $image, 0, 0, 0, 0, $newWidth, $newHeight, $origWidth, $origHeight);
|
||||
|
||||
// determine type and store to disk
|
||||
$explodeResult = explode(".", $value);
|
||||
$explodeResult = explode('.', $value);
|
||||
$type = strtolower($explodeResult[count($explodeResult) - 1]);
|
||||
$writeFunc = 'image' . $type;
|
||||
if ($type == 'jpeg' || $type == 'jpg') {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* Check if a field is empty but only when specific fields have specific values
|
||||
* Check if a field is empty but only when specific fields have specific values.
|
||||
*
|
||||
* WARNING: you need to include this file directly when using it, it clashes with the
|
||||
* WARNING: you need to include this file directly when using it, it clashes with the
|
||||
* way zf1 Zend_Loader_PluginLoader expects it to be found. Another way around this
|
||||
* might be to rename the class and have the new name get loaded proper.
|
||||
*
|
||||
|
@ -11,7 +11,7 @@
|
|||
*/
|
||||
class ConditionalNotEmpty extends Zend_Validate_Abstract
|
||||
{
|
||||
const KEY_IS_EMPTY = 'keyIsEmpty';
|
||||
public const KEY_IS_EMPTY = 'keyIsEmpty';
|
||||
|
||||
protected $_messageTemplates;
|
||||
|
||||
|
@ -21,16 +21,16 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract
|
|||
* Constructs a new ConditionalNotEmpty validator.
|
||||
*
|
||||
* @param array $fieldValues - the names and expected values of the fields we're depending on;
|
||||
* E.g., if we have a field that should only be validated when two other
|
||||
* fields PARENT_1 and PARENT_2 have values of '1' and '0' respectively, then
|
||||
* $fieldValues should contain ('PARENT_1'=>'1', 'PARENT_2'=>'0')
|
||||
* E.g., if we have a field that should only be validated when two other
|
||||
* fields PARENT_1 and PARENT_2 have values of '1' and '0' respectively, then
|
||||
* $fieldValues should contain ('PARENT_1'=>'1', 'PARENT_2'=>'0')
|
||||
*/
|
||||
public function __construct($fieldValues)
|
||||
{
|
||||
$this->_fieldValues = $fieldValues;
|
||||
$this->_messageTemplates = array(
|
||||
self::KEY_IS_EMPTY => _("Value is required and can't be empty")
|
||||
);
|
||||
$this->_messageTemplates = [
|
||||
self::KEY_IS_EMPTY => _("Value is required and can't be empty"),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,18 +39,19 @@ class ConditionalNotEmpty extends Zend_Validate_Abstract
|
|||
* this function returns true if the expected values doesn't match the actual user input,
|
||||
* or if $value is not empty. Returns false otherwise.
|
||||
*
|
||||
* @param String $value - this field's value
|
||||
* @param array $context - names and values of the rest of the fields in this form
|
||||
* @return boolean - true if valid; false otherwise
|
||||
* @param string $value - this field's value
|
||||
* @param array $context - names and values of the rest of the fields in this form
|
||||
*
|
||||
* @return bool - true if valid; false otherwise
|
||||
*/
|
||||
public function isValid($value, $context = null)
|
||||
{
|
||||
if ($value != "") {
|
||||
if ($value != '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_array($context)) {
|
||||
foreach ($this->_fieldValues as $fieldName=>$fieldValue) {
|
||||
foreach ($this->_fieldValues as $fieldName => $fieldValue) {
|
||||
if (!isset($context[$fieldName]) || $context[$fieldName] != $fieldValue) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ class Airtime_Decorator_SuperAdmin_Only extends Zend_Form_Decorator_Abstract
|
|||
$currentUser = Application_Model_User::getCurrentUser();
|
||||
if ($currentUser->isSuperAdmin()) {
|
||||
return $content;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ class Airtime_Decorator_Admin_Only extends Zend_Form_Decorator_Abstract
|
|||
$currentUser = Application_Model_User::getCurrentUser();
|
||||
if ($currentUser->isSuperAdmin() || $currentUser->isAdmin()) {
|
||||
return $content;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
Class Application_Form_Helper_ValidationTypes {
|
||||
|
||||
class Application_Form_Helper_ValidationTypes
|
||||
{
|
||||
public static function overrideNotEmptyValidator()
|
||||
{
|
||||
$validator = new Zend_Validate_NotEmpty();
|
||||
|
@ -11,7 +12,7 @@ Class Application_Form_Helper_ValidationTypes {
|
|||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
|
||||
public static function overrideEmailAddressValidator()
|
||||
{
|
||||
$validator = new Zend_Validate_EmailAddress();
|
||||
|
@ -48,7 +49,7 @@ Class Application_Form_Helper_ValidationTypes {
|
|||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
|
||||
public static function overrideStringLengthValidator($p_min, $p_max)
|
||||
{
|
||||
$validator = new Zend_Validate_StringLength();
|
||||
|
@ -86,11 +87,10 @@ Class Application_Form_Helper_ValidationTypes {
|
|||
$validator->setToken($p_matchAgainst);
|
||||
|
||||
$validator->setMessage(
|
||||
_("Passwords do not match"),
|
||||
_('Passwords do not match'),
|
||||
Zend_Validate_Identical::NOT_SAME
|
||||
);
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue