Example #1
0
 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);
 }
Example #2
0
 public function init()
 {
     $country_list = Application_Model_Preference::GetCountryList();
     $isSass = Application_Model_Preference::GetPlanLevel() == 'disabled' ? false : true;
     $this->isSass = $isSass;
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/support-setting.phtml', "isSaas" => $isSass)), array('File', array('viewScript' => 'form/support-setting.phtml', 'placement' => false))));
     //Station name
     $this->addElement('text', 'stationName', array('class' => 'input_text', 'label' => 'Station Name', 'required' => true, 'filters' => array('StringTrim'), 'validator' => array('NotEmpty'), 'value' => Application_Model_Preference::GetStationName(), 'decorators' => array('ViewHelper')));
     // Phone number
     $this->addElement('text', 'Phone', array('class' => 'input_text', 'label' => 'Phone:', 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetPhone(), 'decorators' => array('ViewHelper')));
     //Email
     $this->addElement('text', 'Email', array('class' => 'input_text', 'label' => 'Email:', 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetEmail(), 'decorators' => array('ViewHelper')));
     // Station Web Site
     $this->addElement('text', 'StationWebSite', array('label' => 'Station Web Site:', 'required' => false, 'class' => 'input_text', 'value' => Application_Model_Preference::GetStationWebSite(), 'decorators' => array('ViewHelper')));
     // county list dropdown
     $this->addElement('select', 'Country', array('label' => 'Country:', 'required' => false, 'value' => Application_Model_Preference::GetStationCountry(), 'multiOptions' => $country_list, 'decorators' => array('ViewHelper')));
     // Station city
     $this->addElement('text', 'City', array('label' => 'City:', 'required' => false, 'class' => 'input_text', 'value' => Application_Model_Preference::GetStationCity(), 'decorators' => array('ViewHelper')));
     // Station Description
     $description = new Zend_Form_Element_Textarea('Description');
     $description->class = 'input_text_area';
     $description->setLabel('Station Description:')->setRequired(false)->setValue(Application_Model_Preference::GetStationDescription())->setDecorators(array('ViewHelper'))->setAttrib('ROWS', '2')->setAttrib('COLS', '58');
     $this->addElement($description);
     // Station Logo
     $upload = new Zend_Form_Element_File('Logo');
     $upload->setLabel('Station Logo:')->setRequired(false)->setDecorators(array('File'))->addValidator('Count', false, 1)->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addFilter('ImageSize');
     $upload->setAttrib('accept', 'image/*');
     $this->addElement($upload);
     if (!$isSass) {
         //enable support feedback
         $this->addElement('checkbox', 'SupportFeedback', array('label' => 'Send support feedback', 'required' => false, 'value' => Application_Model_Preference::GetSupportFeedback(), 'decorators' => array('ViewHelper')));
         // checkbox for publicise
         $checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
         $checkboxPublicise->setLabel('Promote my station on Sourcefabric.org')->setRequired(false)->setDecorators(array('ViewHelper'))->setValue(Application_Model_Preference::GetPublicise());
         if (Application_Model_Preference::GetSupportFeedback() == '0') {
             $checkboxPublicise->setAttrib("disabled", "disabled");
         }
         $this->addElement($checkboxPublicise);
         // text area for sending detail
         $this->addElement('textarea', 'SendInfo', array('class' => 'sending_textarea', 'required' => false, 'filters' => array('StringTrim'), 'readonly' => true, 'cols' => 61, 'rows' => 5, 'value' => Application_Model_Preference::GetSystemInfo(false, true), 'decorators' => array('ViewHelper')));
         // checkbox for privacy policy
         $checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
         $checkboxPrivacy->setLabel("By checking this box, I agree to Sourcefabric's <a id=\"link_to_privacy\" href=\"http://www.sourcefabric.org/en/about/policy/\" onclick=\"window.open(this.href); return false;\">privacy policy</a>.")->setDecorators(array('ViewHelper'));
         $this->addElement($checkboxPrivacy);
     }
     // submit button
     $submit = new Zend_Form_Element_Submit("submit");
     $submit->class = 'ui-button ui-state-default right-floated';
     $submit->setIgnore(true)->setLabel("Save")->setDecorators(array('ViewHelper'));
     $this->addElement($submit);
 }
Example #3
0
 public function init()
 {
     $this->setAction('/Showbuilder');
     $this->setMethod('post');
     $country_list = Application_Model_Preference::GetCountryList();
     $privacyChecked = false;
     if (Application_Model_Preference::GetPrivacyPolicyCheck() == 1) {
         $privacyChecked = true;
     }
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/register-dialog.phtml', 'privacyChecked' => $privacyChecked)), array('File', array('viewScript' => 'form/register-dialog.phtml', 'placement' => false))));
     // Station Name
     $stnName = new Zend_Form_Element_Text("stnName");
     $stnName->setLabel("Station Name")->setRequired(true)->setValue(Application_Model_Preference::GetStationName())->setDecorators(array('ViewHelper'));
     $this->addElement($stnName);
     // Phone number
     $this->addElement('text', 'Phone', array('class' => 'input_text', 'label' => 'Phone:', 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetPhone(), 'decorators' => array('ViewHelper')));
     //Email
     $this->addElement('text', 'Email', array('class' => 'input_text', 'label' => 'Email:', 'required' => false, 'filters' => array('StringTrim'), 'value' => Application_Model_Preference::GetEmail(), 'decorators' => array('ViewHelper')));
     // Station Web Site
     $this->addElement('text', 'StationWebSite', array('label' => 'Station Web Site:', 'required' => false, 'class' => 'input_text', 'value' => Application_Model_Preference::GetStationWebSite(), 'decorators' => array('ViewHelper')));
     // county list dropdown
     $this->addElement('select', 'Country', array('label' => 'Country:', 'required' => false, 'value' => Application_Model_Preference::GetStationCountry(), 'multiOptions' => $country_list, 'decorators' => array('ViewHelper')));
     // Station city
     $this->addElement('text', 'City', array('label' => 'City:', 'required' => false, 'class' => 'input_text', 'value' => Application_Model_Preference::GetStationCity(), 'decorators' => array('ViewHelper')));
     // Station Description
     $description = new Zend_Form_Element_Textarea('Description');
     $description->class = 'input_text_area';
     $description->setLabel('Station Description:')->setRequired(false)->setValue(Application_Model_Preference::GetStationDescription())->setDecorators(array('ViewHelper'))->setAttrib('ROWS', '2')->setAttrib('COLS', '58');
     $this->addElement($description);
     // Station Logo
     $upload = new Zend_Form_Element_File('Logo');
     $upload->setLabel('Station Logo:')->setRequired(false)->setDecorators(array('File'))->addValidator('Count', false, 1)->addValidator('Extension', false, 'jpg,jpeg,png,gif')->addFilter('ImageSize');
     $this->addElement($upload);
     //enable support feedback
     $this->addElement('checkbox', 'SupportFeedback', array('label' => 'Send support feedback', 'required' => false, 'value' => 1, 'decorators' => array('ViewHelper')));
     // checkbox for publicise
     $checkboxPublicise = new Zend_Form_Element_Checkbox("Publicise");
     $checkboxPublicise->setLabel('Promote my station on Sourcefabric.org')->setRequired(false)->setDecorators(array('ViewHelper'))->setValue(Application_Model_Preference::GetPublicise());
     $this->addElement($checkboxPublicise);
     // text area for sending detail
     $this->addElement('textarea', 'SendInfo', array('class' => 'sending_textarea', 'required' => false, 'filters' => array('StringTrim'), 'readonly' => true, 'rows' => 5, 'cols' => 61, 'value' => Application_Model_Preference::GetSystemInfo(false, true), 'decorators' => array('ViewHelper')));
     // checkbox for privacy policy
     $checkboxPrivacy = new Zend_Form_Element_Checkbox("Privacy");
     $checkboxPrivacy->setLabel("By checking this box, I agree to Sourcefabric's <a id=\"link_to_privacy\" href=\"http://www.sourcefabric.org/en/about/policy/\" onclick=\"window.open(this.href); return false;\">privacy policy</a>.")->setDecorators(array('ViewHelper'));
     $this->addElement($checkboxPrivacy);
 }
 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 getBootstrapInfoAction()
 {
     $live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj');
     $master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj');
     $scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play');
     $res = array("live_dj" => $live_dj, "master_dj" => $master_dj, "scheduled_play" => $scheduled_play);
     $this->view->switch_status = $res;
     $this->view->station_name = Application_Model_Preference::GetStationName();
     $this->view->stream_label = Application_Model_Preference::GetStreamLabelFormat();
     $this->view->transition_fade = Application_Model_Preference::GetDefaultTransitionFade();
 }
Example #6
0
 /**
  * Export the schedule in json formatted for pypo (the liquidsoap scheduler)
  *
  * @param string $p_fromDateTime
  *      In the format "YYYY-MM-DD-HH-mm-SS"
  * @param string $p_toDateTime
  *      In the format "YYYY-MM-DD-HH-mm-SS"
  */
 public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null)
 {
     global $CC_CONFIG, $CC_DBC;
     if (is_null($p_fromDateTime)) {
         $t1 = new DateTime();
         $range_start = $t1->format("Y-m-d H:i:s");
     } else {
         $range_start = Schedule::PypoTimeToAirtimeTime($p_fromDateTime);
     }
     if (is_null($p_fromDateTime)) {
         $t2 = new DateTime();
         $t2->add(new DateInterval("PT24H"));
         $range_end = $t2->format("Y-m-d H:i:s");
     } else {
         $range_end = Schedule::PypoTimeToAirtimeTime($p_toDateTime);
     }
     // Scheduler wants everything in a playlist
     $data = Schedule::GetItems($range_start, $range_end, true);
     $playlists = array();
     if (is_array($data)) {
         foreach ($data as $dx) {
             $start = $dx['start'];
             //chop off subseconds
             $start = substr($start, 0, 19);
             //Start time is the array key, needs to be in the format "YYYY-MM-DD-HH-mm-ss"
             $pkey = Schedule::AirtimeTimeToPypoTime($start);
             $timestamp = strtotime($start);
             $playlists[$pkey]['source'] = "PLAYLIST";
             $playlists[$pkey]['x_ident'] = $dx['group_id'];
             //$playlists[$pkey]['subtype'] = '1'; // Just needs to be between 1 and 4 inclusive
             $playlists[$pkey]['timestamp'] = $timestamp;
             $playlists[$pkey]['duration'] = $dx['clip_length'];
             $playlists[$pkey]['played'] = '0';
             $playlists[$pkey]['schedule_id'] = $dx['group_id'];
             $playlists[$pkey]['show_name'] = $dx['show_name'];
             $playlists[$pkey]['show_start'] = Schedule::AirtimeTimeToPypoTime($dx['show_start']);
             $playlists[$pkey]['show_end'] = Schedule::AirtimeTimeToPypoTime($dx['show_end']);
             $playlists[$pkey]['user_id'] = 0;
             $playlists[$pkey]['id'] = $dx['group_id'];
             $playlists[$pkey]['start'] = Schedule::AirtimeTimeToPypoTime($dx["start"]);
             $playlists[$pkey]['end'] = Schedule::AirtimeTimeToPypoTime($dx["end"]);
         }
     }
     foreach ($playlists as &$playlist) {
         $scheduleGroup = new ScheduleGroup($playlist["schedule_id"]);
         $items = $scheduleGroup->getItems();
         $medias = array();
         foreach ($items as $item) {
             $storedFile = StoredFile::Recall($item["file_id"]);
             $uri = $storedFile->getFileUrl();
             $starts = Schedule::AirtimeTimeToPypoTime($item["starts"]);
             $medias[$starts] = array('row_id' => $item["id"], 'id' => $storedFile->getGunid(), 'uri' => $uri, 'fade_in' => Schedule::WallTimeToMillisecs($item["fade_in"]), 'fade_out' => Schedule::WallTimeToMillisecs($item["fade_out"]), 'fade_cross' => 0, 'cue_in' => DateHelper::CalculateLengthInSeconds($item["cue_in"]), 'cue_out' => DateHelper::CalculateLengthInSeconds($item["cue_out"]), 'export_source' => 'scheduler', 'start' => $starts, 'end' => Schedule::AirtimeTimeToPypoTime($item["ends"]));
         }
         $playlist['medias'] = $medias;
     }
     $result = array();
     $result['status'] = array('range' => array('start' => $range_start, 'end' => $range_end), 'version' => AIRTIME_REST_VERSION);
     $result['playlists'] = $playlists;
     $result['check'] = 1;
     $result['stream_metadata'] = array();
     $result['stream_metadata']['format'] = Application_Model_Preference::GetStreamLabelFormat();
     $result['stream_metadata']['station_name'] = Application_Model_Preference::GetStationName();
     $result['server_timezone'] = date('O');
     return $result;
 }
Example #7
0
 public static function GetSystemInfo($returnArray = false)
 {
     exec('/usr/bin/airtime-check-system', $output);
     $output = preg_replace('/\\s+/', ' ', $output);
     $systemInfoArray = array();
     foreach ($output as $key => &$out) {
         $info = explode('=', $out);
         if (isset($info[1])) {
             $key = str_replace(' ', '_', trim($info[0]));
             $key = strtoupper($key);
             $systemInfoArray[$key] = $info[1];
         }
     }
     $outputArray = array();
     $outputArray['STATION_NAME'] = Application_Model_Preference::GetStationName();
     $outputArray['PHONE'] = Application_Model_Preference::GetPhone();
     $outputArray['EMAIL'] = Application_Model_Preference::GetEmail();
     $outputArray['STATION_WEB_SITE'] = Application_Model_Preference::GetStationWebSite();
     $outputArray['STATION_COUNTRY'] = Application_Model_Preference::GetStationCountry();
     $outputArray['STATION_CITY'] = Application_Model_Preference::GetStationCity();
     $outputArray['STATION_DESCRIPTION'] = Application_Model_Preference::GetStationDescription();
     // get web server info
     if (isset($systemInfoArray["AIRTIME_VERSION_URL"])) {
         $url = $systemInfoArray["AIRTIME_VERSION_URL"];
         $index = strpos($url, '/api/');
         $url = substr($url, 0, $index);
         $headerInfo = get_headers(trim($url), 1);
         $outputArray['WEB_SERVER'] = $headerInfo['Server'][0];
     }
     $outputArray['NUM_OF_USERS'] = User::getUserCount();
     $outputArray['NUM_OF_SONGS'] = StoredFile::getFileCount();
     $outputArray['NUM_OF_PLAYLISTS'] = Playlist::getPlaylistCount();
     $outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Schedule::getSchduledPlaylistCount();
     $outputArray['NUM_OF_PAST_SHOWS'] = ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s"));
     $outputArray['UNIQUE_ID'] = Application_Model_Preference::GetUniqueId();
     $outputArray = array_merge($systemInfoArray, $outputArray);
     $outputString = "\n";
     foreach ($outputArray as $key => $out) {
         if ($out != '') {
             $outputString .= $key . ' : ' . $out . "\n";
         }
     }
     if ($returnArray) {
         $outputArray['PROMOTE'] = Application_Model_Preference::GetPublicise();
         $outputArray['LOGOIMG'] = Application_Model_Preference::GetStationLogo();
         return $outputArray;
     } else {
         return $outputString;
     }
 }