public function init() { $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/password-change.phtml')))); $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $stringLengthValidator = Application_Form_Helper_ValidationTypes::overrideStringLengthValidator(6, 80); $this->addElement('password', 'password', array('label' => _('Password'), 'required' => true, 'filters' => array('stringTrim'), 'validators' => array($notEmptyValidator, $stringLengthValidator), 'decorators' => array('ViewHelper'))); $this->addElement('password', 'password_confirm', array('label' => _('Confirm new password'), 'required' => true, 'filters' => array('stringTrim'), 'validators' => array(new Zend_Validate_Callback(function ($value, $context) { return $value == $context['password']; })), 'errorMessages' => array(_("Password confirmation does not match your password.")), 'decorators' => array('ViewHelper'))); $this->addElement('submit', 'submit', array('label' => _('Get new password'), 'ignore' => true, 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center', 'decorators' => array('ViewHelper'))); }
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'))); $bg = $this->getElement('add_show_background_color'); $bg->setDecorators(array(array('ViewScript', array('viewScript' => 'form/add-show-style.phtml', 'class' => 'big')))); $stringLengthValidator = Application_Form_Helper_ValidationTypes::overrideStringLengthValidator(6, 6); $bg->setValidators(array('Hex', $stringLengthValidator)); // Add show color input $this->addElement('text', 'add_show_color', array('label' => _('Text Colour:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); $c = $this->getElement('add_show_color'); $c->setDecorators(array(array('ViewScript', array('viewScript' => 'form/add-show-style.phtml', 'class' => 'big')))); $c->setValidators(array('Hex', $stringLengthValidator)); }
public function init() { $country_list = Application_Model_Preference::GetCountryList(); $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/support-setting.phtml')), 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'), 'validators' => array($notEmptyValidator), '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); //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(sprintf(_("By checking this box, I agree to Sourcefabric's %sprivacy policy%s."), "<a id='link_to_privacy' href='http://www.sourcefabric.org/en/about/policy/' onclick='window.open(this.href); return false;'>", "</a>"))->setDecorators(array('ViewHelper')); $this->addElement($checkboxPrivacy); // submit button $submit = new Zend_Form_Element_Submit("submit"); $submit->class = 'btn right-floated'; $submit->setIgnore(true)->setLabel(_("Save"))->setDecorators(array('ViewHelper')); $this->addElement($submit); }
public function startForm($p_id) { $baseUrl = Application_Common_OsPath::getBaseDir(); // Set the method for the display form to POST $this->setMethod('post'); $this->addElement('hidden', 'file_id', array('value' => $p_id)); // Add title field $this->addElement('text', 'track_title', array('label' => _('Title:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add artist field $this->addElement('text', 'artist_name', array('label' => _('Creator:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add album field $this->addElement('text', 'album_title', array('label' => _('Album:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add track number field $this->addElement('text', 'track_number', array('label' => _('Track:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add genre field $this->addElement('text', 'genre', array('label' => _('Genre:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // 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"))); $this->addElement($year); // Add label field $this->addElement('text', 'label', array('label' => _('Label:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add composer field $this->addElement('text', 'composer', array('label' => _('Composer:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add conductor field $this->addElement('text', 'conductor', array('label' => _('Conductor:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add mood field $this->addElement('text', 'mood', array('label' => _('Mood:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // 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())); $this->addElement($bpm); // Add copyright field $this->addElement('text', 'copyright', array('label' => _('Copyright:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add isrc number field $this->addElement('text', 'isrc_number', array('label' => _('ISRC Number:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add website field $this->addElement('text', 'info_url', array('label' => _('Website:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add language field $this->addElement('text', 'language', array('label' => _('Language:'), 'class' => 'input_text', 'filters' => array('StringTrim'))); // Add the submit button $this->addElement('button', 'editmdsave', array('ignore' => true, 'class' => 'btn', 'label' => _('Save'), 'decorators' => array('ViewHelper'))); // Add the submit button $this->addElement('button', 'editmdcancel', array('ignore' => true, 'class' => 'btn md-cancel', 'label' => _('Cancel'), 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('editmdsave', 'editmdcancel'), 'submitButtons', array('decorators' => array('FormElements', 'DtDdWrapper'))); }
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/add-show-when.phtml')))); $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $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'")); // Add start date element $startDate = new Zend_Form_Element_Text('add_show_start_date'); $startDate->class = 'input_text'; $startDate->setRequired(true)->setLabel(_('Date/Time Start:'))->setValue(date("Y-m-d"))->setFilters(array('StringTrim'))->setValidators(array($notEmptyValidator, $dateValidator))->setDecorators(array('ViewHelper')); $startDate->setAttrib('alt', 'date'); $this->addElement($startDate); // Add start time element $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')); $startTime->setAttrib('alt', 'time'); $this->addElement($startTime); // Add end date element $endDate = new Zend_Form_Element_Text('add_show_end_date_no_repeat'); $endDate->class = 'input_text'; $endDate->setRequired(true)->setLabel(_('Date/Time End:'))->setValue(date("Y-m-d"))->setFilters(array('StringTrim'))->setValidators(array($notEmptyValidator, $dateValidator))->setDecorators(array('ViewHelper')); $endDate->setAttrib('alt', 'date'); $this->addElement($endDate); // Add end time element $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')); $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'))); $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')); $this->addElement($timezone); // Add repeats element $this->addElement('checkbox', 'add_show_repeats', array('label' => _('Repeats?'), 'required' => false, 'decorators' => array('ViewHelper'))); }
public function init() { $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); // retrieves the length limit for each char field // and store to assoc array $maxLens = Application_Model_Show::getMaxLengths(); // 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'))); // Hidden element to indicate the instance id of the show // being edited. $this->addElement('hidden', 'add_show_instance_id', array('decorators' => array('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']))))); // 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 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 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']))))); $descText = $this->getElement('add_show_description'); $descText->setDecorators(array(array('ViewScript', array('viewScript' => 'form/add-show-block.phtml', 'class' => 'block-display')))); }
public function init() { $CC_CONFIG = Config::getConfig(); $isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1; $isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true"; $defaultFade = Application_Model_Preference::GetDefaultTransitionFade(); if ($defaultFade == "") { $defaultFade = '00.000000'; } // 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())->setDecorators(array('ViewHelper')); $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())->setDecorators(array('ViewHelper')); $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('/^[0-9]{1,2}(\\.\\d{1,6})?$/', 'messages' => _('enter a time in seconds 00{.000000}')))->setValue($defaultFade)->setDecorators(array('ViewHelper')); $this->addElement($transition_fade); //Master username $master_username = new Zend_Form_Element_Text('master_username'); $master_username->setAttrib('autocomplete', 'off')->setAllowEmpty(true)->setLabel(_('Master Username'))->setFilters(array('StringTrim'))->setValue(Application_Model_Preference::GetLiveStreamMasterUsername())->setDecorators(array('ViewHelper')); $this->addElement($master_username); //Master password if ($isDemo) { $master_password = new Zend_Form_Element_Text('master_password'); } else { $master_password = new Zend_Form_Element_Password('master_password'); $master_password->setAttrib('renderPassword', 'true'); } $master_password->setAttrib('autocomplete', 'off')->setAttrib('renderPassword', 'true')->setAllowEmpty(true)->setValue(Application_Model_Preference::GetLiveStreamMasterPassword())->setLabel(_('Master Password'))->setFilters(array('StringTrim'))->setDecorators(array('ViewHelper')); $this->addElement($master_password); //Master source connection url $master_dj_connection_url = new Zend_Form_Element_Text('master_dj_connection_url'); $master_dj_connection_url->setAttrib('readonly', true)->setLabel(_('Master Source Connection URL'))->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL())->setDecorators(array('ViewHelper')); $this->addElement($master_dj_connection_url); //Show source connection url $live_dj_connection_url = new Zend_Form_Element_Text('live_dj_connection_url'); $live_dj_connection_url->setAttrib('readonly', true)->setLabel(_('Show Source Connection URL'))->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL())->setDecorators(array('ViewHelper')); $this->addElement($live_dj_connection_url); //liquidsoap harbor.input port $betweenValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(1024, 49151); $m_port = Application_Model_StreamSetting::getMasterLiveStreamPort(); $master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port'); $master_dj_port->setLabel(_("Master Source Port"))->setValue($m_port)->setValidators(array($betweenValidator))->addValidator('regex', false, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => _('Only numbers are allowed.'))))->setDecorators(array('ViewHelper')); $this->addElement($master_dj_port); $m_mount = Application_Model_StreamSetting::getMasterLiveStreamMountPoint(); $master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point'); $master_dj_mount->setLabel(_("Master Source Mount Point"))->setValue($m_mount)->setValidators(array(array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))->setDecorators(array('ViewHelper')); $this->addElement($master_dj_mount); //liquidsoap harbor.input port $l_port = Application_Model_StreamSetting::getDjLiveStreamPort(); $live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port'); $live_dj_port->setLabel(_("Show Source Port"))->setValue($l_port)->setValidators(array($betweenValidator))->addValidator('regex', false, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => _('Only numbers are allowed.'))))->setDecorators(array('ViewHelper')); $this->addElement($live_dj_port); $l_mount = Application_Model_StreamSetting::getDjLiveStreamMountPoint(); $live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point'); $live_dj_mount->setLabel(_("Show Source Mount Point"))->setValue($l_mount)->setValidators(array(array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))->setDecorators(array('ViewHelper')); $this->addElement($live_dj_mount); // demo only code if (!$isStreamConfigable) { $elements = $this->getElements(); foreach ($elements as $element) { if ($element->getType() != 'Zend_Form_Element_Hidden') { $element->setAttrib("disabled", "disabled"); } } } }
public function isValid($data) { $passwordIdenticalValidator = Application_Form_Helper_ValidationTypes::overridePasswordIdenticalValidator($data['cu_password']); $this->getElement('cu_passwordVerify')->addValidator($passwordIdenticalValidator); return parent::isValid($data); }