2017-02-20 21:47:53 +01:00
|
|
|
<?php
|
2015-01-15 22:28:18 +01:00
|
|
|
|
2017-03-02 14:29:19 +01:00
|
|
|
// this is not getting loaded by autloading since it has a classname
|
|
|
|
// that makes it clash with how zf1 expects to load plugins.
|
|
|
|
require_once 'customfilters/ImageSize.php';
|
|
|
|
|
2011-04-03 23:34:44 +02:00
|
|
|
class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|
|
|
{
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2011-04-03 23:34:44 +02:00
|
|
|
public function init()
|
|
|
|
{
|
2015-01-14 02:51:46 +01:00
|
|
|
$maxLens = Application_Model_Show::getMaxLengths();
|
2015-01-15 22:28:18 +01:00
|
|
|
$this->setEnctype(Zend_Form::ENCTYPE_MULTIPART);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-11-27 23:11:29 +01:00
|
|
|
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
2013-02-06 21:44:52 +01:00
|
|
|
$rangeValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(0, 59.9);
|
2011-04-03 23:34:44 +02:00
|
|
|
$this->setDecorators(array(
|
2012-11-06 23:10:47 +01:00
|
|
|
array('ViewScript', array('viewScript' => 'form/preferences_general.phtml'))
|
2011-04-03 23:34:44 +02:00
|
|
|
));
|
|
|
|
|
2013-04-29 22:55:08 +02:00
|
|
|
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
|
|
|
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
2015-01-14 02:51:46 +01:00
|
|
|
|
2011-08-19 22:42:46 +02:00
|
|
|
//Station name
|
|
|
|
$this->addElement('text', 'stationName', array(
|
2015-01-14 02:51:46 +01:00
|
|
|
'class' => 'input_text',
|
|
|
|
'label' => _('Station Name'),
|
|
|
|
'required' => false,
|
|
|
|
'filters' => array('StringTrim'),
|
2012-09-14 18:09:40 +02:00
|
|
|
'value' => Application_Model_Preference::GetStationName(),
|
2011-08-19 22:42:46 +02:00
|
|
|
));
|
2015-01-14 02:51:46 +01:00
|
|
|
|
|
|
|
// Station description
|
|
|
|
$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->setAttrib('rows', 4);
|
|
|
|
$this->addElement($stationDescription);
|
|
|
|
|
2015-01-15 22:28:18 +01:00
|
|
|
// Station Logo
|
|
|
|
$stationLogoUpload = new Zend_Form_Element_File('stationLogo');
|
|
|
|
$stationLogoUpload->setLabel(_('Station Logo:'))
|
|
|
|
->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');
|
|
|
|
$stationLogoUpload->setAttrib('accept', 'image/*');
|
|
|
|
$this->addElement($stationLogoUpload);
|
|
|
|
|
2015-02-27 23:19:37 +01:00
|
|
|
$stationLogoRemove = new Zend_Form_Element_Button('stationLogoRemove');
|
|
|
|
$stationLogoRemove->setLabel(_('Remove'));
|
|
|
|
$stationLogoRemove->setAttrib('class', 'btn');
|
|
|
|
$stationLogoRemove->setAttrib('id', 'logo-remove-btn');
|
|
|
|
$stationLogoRemove->setAttrib('onclick', 'removeLogo();');
|
|
|
|
$this->addElement($stationLogoRemove);
|
|
|
|
|
2015-01-14 02:51:46 +01:00
|
|
|
//Default station crossfade duration
|
2013-05-02 22:52:30 +02:00
|
|
|
$this->addElement('text', 'stationDefaultCrossfadeDuration', array(
|
2015-01-14 02:51:46 +01:00
|
|
|
'class' => 'input_text',
|
|
|
|
'label' => _('Default Crossfade Duration (s):'),
|
|
|
|
'required' => true,
|
|
|
|
'filters' => array('StringTrim'),
|
|
|
|
'validators' => array(
|
2015-01-13 18:18:57 +01:00
|
|
|
$rangeValidator,
|
|
|
|
$notEmptyValidator,
|
|
|
|
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
2015-01-14 02:51:46 +01:00
|
|
|
),
|
|
|
|
'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(),
|
2013-05-02 22:15:21 +02:00
|
|
|
));
|
2011-12-13 12:10:25 +01:00
|
|
|
|
2013-04-29 22:55:08 +02:00
|
|
|
//Default station fade in
|
|
|
|
$this->addElement('text', 'stationDefaultFadeIn', array(
|
2015-01-14 02:51:46 +01:00
|
|
|
'class' => 'input_text',
|
|
|
|
'label' => _('Default Fade In (s):'),
|
|
|
|
'required' => true,
|
|
|
|
'filters' => array('StringTrim'),
|
2013-02-06 21:44:52 +01:00
|
|
|
'validators' => array(
|
2015-01-13 18:18:57 +01:00
|
|
|
$rangeValidator,
|
|
|
|
$notEmptyValidator,
|
|
|
|
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
2013-02-06 21:44:52 +01:00
|
|
|
),
|
2013-04-29 22:55:08 +02:00
|
|
|
'value' => $defaultFadeIn,
|
2011-04-03 23:34:44 +02:00
|
|
|
));
|
2015-01-14 02:51:46 +01:00
|
|
|
|
2013-04-29 23:01:08 +02:00
|
|
|
//Default station fade out
|
|
|
|
$this->addElement('text', 'stationDefaultFadeOut', array(
|
2015-01-14 02:51:46 +01:00
|
|
|
'class' => 'input_text',
|
|
|
|
'label' => _('Default Fade Out (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)')))
|
|
|
|
),
|
|
|
|
'value' => $defaultFadeOut,
|
2013-04-29 22:55:08 +02:00
|
|
|
));
|
2011-06-17 17:54:36 +02:00
|
|
|
|
2011-04-03 23:34:44 +02:00
|
|
|
$third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
|
2015-01-14 02:51:46 +01:00
|
|
|
$third_party_api->setLabel(_('Public Airtime API'));
|
|
|
|
$third_party_api->setDescription(_('Required for embeddable schedule widget.'));
|
|
|
|
$third_party_api->setMultiOptions(array(
|
|
|
|
_("Disabled"),
|
|
|
|
_("Enabled"),
|
|
|
|
));
|
2011-04-03 23:34:44 +02:00
|
|
|
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
|
2015-01-14 02:51:46 +01:00
|
|
|
$third_party_api->setDescription(_('Enabling this feature will allow Airtime to provide schedule data
|
2015-07-15 19:47:54 +02:00
|
|
|
to external widgets that can be embedded in your website.'));
|
2015-01-14 02:51:46 +01:00
|
|
|
$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',
|
|
|
|
));
|
2011-04-03 23:34:44 +02:00
|
|
|
$this->addElement($third_party_api);
|
2013-01-07 12:41:29 +01:00
|
|
|
|
2017-03-10 15:10:56 +01:00
|
|
|
$allowedCorsUrlsValue = Application_Model_Preference::GetAllowedCorsUrls();
|
|
|
|
$allowedCorsUrls = new Zend_Form_Element_Textarea('allowedCorsUrls');
|
|
|
|
$allowedCorsUrls->setLabel(_('Allowed CORS URLs'));
|
|
|
|
$allowedCorsUrls->setDescription(_('Remote URLs that are allowed to access this LibreTime instance in a browser. One URL per line.'));
|
|
|
|
$allowedCorsUrls->setValue($allowedCorsUrlsValue);
|
|
|
|
$this->addElement($allowedCorsUrls);
|
|
|
|
|
2012-11-21 18:44:50 +01:00
|
|
|
$locale = new Zend_Form_Element_Select("locale");
|
2015-01-14 02:51:46 +01:00
|
|
|
$locale->setLabel(_("Default Language"));
|
2012-11-30 00:21:03 +01:00
|
|
|
$locale->setMultiOptions(Application_Model_Locale::getLocales());
|
2013-01-08 00:18:40 +01:00
|
|
|
$locale->setValue(Application_Model_Preference::GetDefaultLocale());
|
2012-11-21 18:44:50 +01:00
|
|
|
$this->addElement($locale);
|
2011-12-13 12:10:25 +01:00
|
|
|
|
2011-08-12 20:14:07 +02:00
|
|
|
/* Form Element for setting the Timezone */
|
|
|
|
$timezone = new Zend_Form_Element_Select("timezone");
|
2013-10-07 20:49:52 +02:00
|
|
|
$timezone->setLabel(_("Station Timezone"));
|
2013-01-09 19:38:38 +01:00
|
|
|
$timezone->setMultiOptions(Application_Common_Timezone::getTimezones());
|
|
|
|
$timezone->setValue(Application_Model_Preference::GetDefaultTimezone());
|
2011-08-12 20:14:07 +02:00
|
|
|
$this->addElement($timezone);
|
2011-12-13 12:10:25 +01:00
|
|
|
|
2011-10-19 18:42:22 +02:00
|
|
|
/* Form Element for setting which day is the start of the week */
|
|
|
|
$week_start_day = new Zend_Form_Element_Select("weekStartDay");
|
2012-11-15 16:59:06 +01:00
|
|
|
$week_start_day->setLabel(_("Week Starts On"));
|
2011-10-19 18:42:22 +02:00
|
|
|
$week_start_day->setMultiOptions($this->getWeekStartDays());
|
|
|
|
$week_start_day->setValue(Application_Model_Preference::GetWeekStartDay());
|
|
|
|
$this->addElement($week_start_day);
|
2015-07-09 20:38:44 +02:00
|
|
|
|
|
|
|
$radioPageLoginButton = new Zend_Form_Element_Checkbox("radioPageLoginButton");
|
|
|
|
$radioPageLoginButton->setDecorators(array(
|
|
|
|
'ViewHelper',
|
|
|
|
'Errors',
|
|
|
|
'Label'
|
|
|
|
));
|
2015-07-09 21:16:54 +02:00
|
|
|
$displayRadioPageLoginButtonValue = Application_Model_Preference::getRadioPageDisplayLoginButton();
|
|
|
|
if ($displayRadioPageLoginButtonValue == "") {
|
|
|
|
$displayRadioPageLoginButtonValue = true;
|
|
|
|
}
|
2015-07-09 20:38:44 +02:00
|
|
|
$radioPageLoginButton->addDecorator('Label', array("class" => "enable-tunein"));
|
|
|
|
$radioPageLoginButton->setLabel(_("Display login button on your Radio Page?"));
|
2015-07-09 21:16:54 +02:00
|
|
|
$radioPageLoginButton->setValue($displayRadioPageLoginButtonValue);
|
2015-07-09 20:38:44 +02:00
|
|
|
$this->addElement($radioPageLoginButton);
|
2011-08-12 20:14:07 +02:00
|
|
|
}
|
2011-12-13 12:10:25 +01:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
private function getWeekStartDays()
|
|
|
|
{
|
2012-07-11 00:55:44 +02:00
|
|
|
$days = array(
|
2012-11-22 23:32:24 +01:00
|
|
|
_('Sunday'),
|
|
|
|
_('Monday'),
|
|
|
|
_('Tuesday'),
|
|
|
|
_('Wednesday'),
|
|
|
|
_('Thursday'),
|
|
|
|
_('Friday'),
|
|
|
|
_('Saturday')
|
2012-07-11 00:55:44 +02:00
|
|
|
);
|
2012-08-29 05:04:55 +02:00
|
|
|
|
2012-07-11 00:55:44 +02:00
|
|
|
return $days;
|
2011-10-19 18:42:22 +02:00
|
|
|
}
|
2011-04-03 23:34:44 +02:00
|
|
|
}
|