public function init() { $isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled' ? false : true; $this->isSaas = $isSaas; $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/preferences_general.phtml', "isSaas" => $isSaas)))); $defaultFade = Application_Model_Preference::GetDefaultFade(); if ($defaultFade == "") { $defaultFade = '0.500000'; } //Station name $this->addElement('text', 'stationName', array('class' => 'input_text', 'label' => 'Station Name', 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetStationName(), 'decorators' => array('ViewHelper'))); //Default station fade $this->addElement('text', 'stationDefaultFade', array('class' => 'input_text', 'label' => 'Default Fade (s):', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', false, array('/^[0-9]{1,2}(\\.\\d{1,6})?$/', 'messages' => 'enter a time in seconds 0{.000000}'))), 'value' => $defaultFade, 'decorators' => array('ViewHelper'))); $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); $third_party_api->setLabel('Allow Remote Websites To Access "Schedule" Info?<br> (Enable this to make front-end widgets work.)'); $third_party_api->setMultiOptions(array("Disabled", "Enabled")); $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); $third_party_api->setDecorators(array('ViewHelper')); $this->addElement($third_party_api); /* Form Element for setting the Timezone */ $timezone = new Zend_Form_Element_Select("timezone"); $timezone->setLabel("Timezone"); $timezone->setMultiOptions($this->getTimezones()); $timezone->setValue(Application_Model_Preference::GetTimezone()); $timezone->setDecorators(array('ViewHelper')); $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"); $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); }
public function init() { $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')))); $defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn(); $defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut(); //Station name $this->addElement('text', 'stationName', array('class' => 'input_text', 'label' => _('Station Name'), 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetStationName(), 'decorators' => array('ViewHelper'))); //Default station fade in $this->addElement('text', 'stationDefaultCrossfadeDuration', array('class' => 'input_text', 'label' => _('Default Crossfade Duration (s):'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array($rangeValidator, $notEmptyValidator, 'regex', false, array('/^[0-9]{1,2}(\\.\\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}')))), 'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(), 'decorators' => array('ViewHelper'))); //Default station fade in $this->addElement('text', 'stationDefaultFadeIn', array('class' => 'input_text', 'label' => _('Default Fade In (s):'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array($rangeValidator, $notEmptyValidator, 'regex', false, array('/^[0-9]{1,2}(\\.\\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}')))), 'value' => $defaultFadeIn, 'decorators' => array('ViewHelper'))); //Default station fade out $this->addElement('text', 'stationDefaultFadeOut', array('class' => 'input_text', 'label' => _('Default Fade Out (s):'), 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array($rangeValidator, $notEmptyValidator, 'regex', false, array('/^[0-9]{1,2}(\\.\\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}')))), 'value' => $defaultFadeOut, 'decorators' => array('ViewHelper'))); $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); $third_party_api->setLabel(sprintf(_('Allow Remote Websites To Access "Schedule" Info?%s (Enable this to make front-end widgets work.)'), '<br>')); $third_party_api->setMultiOptions(array(_("Disabled"), _("Enabled"))); $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); $third_party_api->setDecorators(array('ViewHelper')); $this->addElement($third_party_api); $locale = new Zend_Form_Element_Select("locale"); $locale->setLabel(_("Default Interface Language")); $locale->setMultiOptions(Application_Model_Locale::getLocales()); $locale->setValue(Application_Model_Preference::GetDefaultLocale()); $locale->setDecorators(array('ViewHelper')); $this->addElement($locale); /* 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()); $timezone->setDecorators(array('ViewHelper')); $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")); $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); }
public function init() { $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/preferences_general.phtml')))); $defaultFade = Application_Model_Preference::GetDefaultFade(); if ($defaultFade == "") { $defaultFade = '00:00:00.000000'; } //Station name $this->addElement('text', 'stationName', array('class' => 'input_text', 'label' => 'Station Name', 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetValue("station_name"), 'decorators' => array('ViewHelper'))); //Default station fade $this->addElement('text', 'stationDefaultFade', array('class' => 'input_text', 'label' => 'Default Fade:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', false, array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\\.\\d{1,6})?$/', 'messages' => 'enter a time 00:00:00{.000000}'))), 'value' => $defaultFade, 'decorators' => array('ViewHelper'))); $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->setValue(Application_Model_Preference::GetStreamLabelFormat()); $stream_format->setDecorators(array('ViewHelper')); $this->addElement($stream_format); $third_party_api = new Zend_Form_Element_Radio('thirdPartyApi'); $third_party_api->setLabel('Allow Remote Websites To Access "Schedule" Info?<br> (Enable this to make front-end widgets work.)'); $third_party_api->setMultiOptions(array("Disabled", "Enabled")); $third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi()); $third_party_api->setDecorators(array('ViewHelper')); $this->addElement($third_party_api); }
public function weekInfoAction() { if (Application_Model_Preference::GetAllow3rdPartyApi()) { // disable the view and the layout $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); //weekStart is in station time. $weekStartDateTime = Application_Common_DateHelper::getWeekStartDateTime(); $dow = array("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday", "nextmonday", "nexttuesday", "nextwednesday", "nextthursday", "nextfriday", "nextsaturday", "nextsunday"); $result = array(); $utcTimezone = new DateTimeZone("UTC"); $stationTimezone = new DateTimeZone(Application_Model_Preference::GetDefaultTimezone()); $weekStartDateTime->setTimezone($utcTimezone); $utcDayStart = $weekStartDateTime->format("Y-m-d H:i:s"); for ($i = 0; $i < 14; $i++) { //have to be in station timezone when adding 1 day for daylight savings. $weekStartDateTime->setTimezone($stationTimezone); $weekStartDateTime->add(new DateInterval('P1D')); //convert back to UTC to get the actual timestamp used for search. $weekStartDateTime->setTimezone($utcTimezone); $utcDayEnd = $weekStartDateTime->format("Y-m-d H:i:s"); $shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd); $utcDayStart = $utcDayEnd; Application_Common_DateHelper::convertTimestamps($shows, array("starts", "ends", "start_timestamp", "end_timestamp"), "station"); $result[$dow[$i]] = $shows; } // XSS exploit prevention foreach ($dow as $d) { foreach ($result[$d] as &$show) { $show["name"] = htmlspecialchars($show["name"]); $show["url"] = htmlspecialchars($show["url"]); } } //used by caller to determine if the airtime they are running or widgets in use is out of date. $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; header("Content-type: text/javascript"); // If a callback is not given, then just provide the raw JSON. echo isset($_GET['callback']) ? $_GET['callback'] . '(' . json_encode($result) . ')' : json_encode($result); } else { header('HTTP/1.0 401 Unauthorized'); print _('You are not allowed to access this resource. '); exit; } }
public function weekInfoAction() { if (Application_Model_Preference::GetAllow3rdPartyApi()) { // disable the view and the layout $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $date = new Application_Common_DateHelper(); $dayStart = $date->getWeekStartDate(); $utcDayStart = Application_Common_DateHelper::ConvertToUtcDateTimeString($dayStart); $dow = array("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"); $result = array(); for ($i = 0; $i < 7; $i++) { $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart); $shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd); $utcDayStart = $utcDayEnd; Application_Model_Show::convertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp")); $result[$dow[$i]] = $shows; } //used by caller to determine if the airtime they are running or widgets in use is out of date. $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; header("Content-type: text/javascript"); // If a callback is not given, then just provide the raw JSON. echo isset($_GET['callback']) ? $_GET['callback'] . '(' . json_encode($result) . ')' : json_encode($result); } else { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource. '; exit; } }
public function weekInfoAction() { if (Application_Model_Preference::GetAllow3rdPartyApi()) { // disable the view and the layout $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $dow = array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"); $result = array(); for ($i = 0; $i < 7; $i++) { $result[$dow[$i]] = Show_DAL::GetShowsByDayOfWeek($i); } header("Content-type: text/javascript"); echo $_GET['callback'] . '(' . json_encode($result) . ')'; } else { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource. '; exit; } }