2011-04-03 23:34:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-11-27 23:11:29 +01:00
|
|
|
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
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
|
|
|
));
|
|
|
|
|
|
|
|
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
2012-08-29 05:04:55 +02:00
|
|
|
if ($defaultFade == "") {
|
2012-11-02 20:51:36 +01:00
|
|
|
$defaultFade = '0.5';
|
2011-04-03 23:34:44 +02:00
|
|
|
}
|
2011-12-13 12:10:25 +01:00
|
|
|
|
2011-08-19 22:42:46 +02:00
|
|
|
//Station name
|
|
|
|
$this->addElement('text', 'stationName', array(
|
|
|
|
'class' => 'input_text',
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Station Name'),
|
2011-08-19 22:42:46 +02:00
|
|
|
'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
|
|
|
'decorators' => array(
|
|
|
|
'ViewHelper'
|
|
|
|
)
|
|
|
|
));
|
2011-12-13 12:10:25 +01:00
|
|
|
|
2011-04-03 23:34:44 +02:00
|
|
|
//Default station fade
|
|
|
|
$this->addElement('text', 'stationDefaultFade', array(
|
|
|
|
'class' => 'input_text',
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Default Fade (s):'),
|
2012-11-27 23:11:29 +01:00
|
|
|
'required' => true,
|
2011-04-03 23:34:44 +02:00
|
|
|
'filters' => array('StringTrim'),
|
2012-11-27 23:11:29 +01:00
|
|
|
'validators' => array(array($notEmptyValidator, 'regex', false,
|
2012-11-02 20:51:36 +01:00
|
|
|
array('/^[0-9]{1,2}(\.\d{1})?$/',
|
2012-11-15 16:59:06 +01:00
|
|
|
'messages' => _('enter a time in seconds 0{.0}')))),
|
2011-04-03 23:34:44 +02:00
|
|
|
'value' => $defaultFade,
|
|
|
|
'decorators' => array(
|
|
|
|
'ViewHelper'
|
|
|
|
)
|
|
|
|
));
|
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');
|
2012-11-15 16:59:06 +01:00
|
|
|
$third_party_api->setLabel(
|
2012-11-28 22:16:39 +01:00
|
|
|
sprintf(_('Allow Remote Websites To Access "Schedule" Info?%s (Enable this to make front-end widgets work.)'), '<br>'));
|
2012-11-22 23:32:24 +01:00
|
|
|
$third_party_api->setMultiOptions(array(_("Disabled"),
|
|
|
|
_("Enabled")));
|
2011-04-03 23:34:44 +02:00
|
|
|
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
|
|
|
|
$third_party_api->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($third_party_api);
|
2013-01-07 12:41:29 +01:00
|
|
|
|
2012-11-21 18:44:50 +01:00
|
|
|
$locale = new Zend_Form_Element_Select("locale");
|
2013-01-07 12:05:38 +01:00
|
|
|
$locale->setLabel(_("Default Interface Language"));
|
2012-11-30 00:21:03 +01:00
|
|
|
$locale->setMultiOptions(Application_Model_Locale::getLocales());
|
2012-11-21 18:44:50 +01:00
|
|
|
$locale->setValue(Application_Model_Preference::GetLocale());
|
|
|
|
$locale->setDecorators(array('ViewHelper'));
|
|
|
|
$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");
|
2012-11-15 16:59:06 +01:00
|
|
|
$timezone->setLabel(_("Timezone"));
|
2011-08-12 20:14:07 +02:00
|
|
|
$timezone->setMultiOptions($this->getTimezones());
|
|
|
|
$timezone->setValue(Application_Model_Preference::GetTimezone());
|
|
|
|
$timezone->setDecorators(array('ViewHelper'));
|
|
|
|
$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());
|
|
|
|
$week_start_day->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($week_start_day);
|
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 getTimezones()
|
|
|
|
{
|
2011-08-12 20:14:07 +02:00
|
|
|
$regions = array(
|
|
|
|
'Africa' => DateTimeZone::AFRICA,
|
|
|
|
'America' => DateTimeZone::AMERICA,
|
|
|
|
'Antarctica' => DateTimeZone::ANTARCTICA,
|
2012-02-01 03:24:01 +01:00
|
|
|
'Arctic' => DateTimeZone::ARCTIC,
|
2011-08-22 17:37:48 +02:00
|
|
|
'Asia' => DateTimeZone::ASIA,
|
2011-08-12 20:14:07 +02:00
|
|
|
'Atlantic' => DateTimeZone::ATLANTIC,
|
2012-02-01 03:24:01 +01:00
|
|
|
'Australia' => DateTimeZone::AUSTRALIA,
|
2011-08-12 20:14:07 +02:00
|
|
|
'Europe' => DateTimeZone::EUROPE,
|
|
|
|
'Indian' => DateTimeZone::INDIAN,
|
|
|
|
'Pacific' => DateTimeZone::PACIFIC
|
|
|
|
);
|
2011-12-13 12:10:25 +01:00
|
|
|
|
2011-08-12 20:14:07 +02:00
|
|
|
$tzlist = array();
|
2011-12-13 12:10:25 +01:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
foreach ($regions as $name => $mask) {
|
2011-08-12 20:14:07 +02:00
|
|
|
$ids = DateTimeZone::listIdentifiers($mask);
|
2012-08-29 05:04:55 +02:00
|
|
|
foreach ($ids as $id) {
|
2011-08-12 20:14:07 +02:00
|
|
|
$tzlist[$id] = str_replace("_", " ", $id);
|
|
|
|
}
|
|
|
|
}
|
2011-06-17 17:54:36 +02:00
|
|
|
|
2011-08-12 20:14:07 +02:00
|
|
|
return $tzlist;
|
2011-04-03 23:34:44 +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
|
|
|
}
|