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() { /* $this->addElementPrefixPath('Application_Validate', '../application/validate', 'validate'); * */ $currentUser = Application_Model_User::getCurrentUser(); $currentUserId = $currentUser->getId(); $userData = Application_Model_User::GetUserData($currentUserId); $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator(); $notDemoValidator = new Application_Validate_NotDemoValidate(); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/edit-user.phtml', "currentUser" => $currentUser->getLogin())))); $this->setAttrib('id', 'current-user-form'); $hidden = new Zend_Form_Element_Hidden('cu_user_id'); $hidden->setDecorators(array('ViewHelper')); $hidden->setValue($userData["id"]); $this->addElement($hidden); $login = new Zend_Form_Element_Text('cu_login'); $login->setLabel(_('Username:'******'class', 'input_text'); $login->setAttrib('readonly', 'readonly'); $login->setRequired(true); $login->addValidator($notEmptyValidator); $login->addFilter('StringTrim'); $login->setDecorators(array('viewHelper')); $this->addElement($login); $password = new Zend_Form_Element_Password('cu_password'); $password->setLabel(_('Password:'******'class', 'input_text'); $password->setRequired(true); $password->addFilter('StringTrim'); $password->addValidator($notEmptyValidator); $password->setDecorators(array('viewHelper')); $this->addElement($password); $passwordVerify = new Zend_Form_Element_Password('cu_passwordVerify'); $passwordVerify->setLabel(_('Verify Password:'******'class', 'input_text'); $passwordVerify->setRequired(true); $passwordVerify->addFilter('StringTrim'); $passwordVerify->addValidator($notEmptyValidator); $passwordVerify->addValidator($notDemoValidator); $passwordVerify->setDecorators(array('viewHelper')); $this->addElement($passwordVerify); $firstName = new Zend_Form_Element_Text('cu_first_name'); $firstName->setLabel(_('Firstname:')); $firstName->setValue($userData["first_name"]); $firstName->setAttrib('class', 'input_text'); $firstName->addFilter('StringTrim'); $firstName->setDecorators(array('viewHelper')); $this->addElement($firstName); $lastName = new Zend_Form_Element_Text('cu_last_name'); $lastName->setLabel(_('Lastname:')); $lastName->setValue($userData["last_name"]); $lastName->setAttrib('class', 'input_text'); $lastName->addFilter('StringTrim'); $lastName->setDecorators(array('viewHelper')); $this->addElement($lastName); $email = new Zend_Form_Element_Text('cu_email'); $email->setLabel(_('Email:')); $email->setValue($userData["email"]); $email->setAttrib('class', 'input_text'); $email->addFilter('StringTrim'); $email->setRequired(true); $email->addValidator($notEmptyValidator); $email->addValidator($emailValidator); $email->setDecorators(array('viewHelper')); $this->addElement($email); $cellPhone = new Zend_Form_Element_Text('cu_cell_phone'); $cellPhone->setLabel(_('Mobile Phone:')); $cellPhone->setValue($userData["cell_phone"]); $cellPhone->setAttrib('class', 'input_text'); $cellPhone->addFilter('StringTrim'); $cellPhone->setDecorators(array('viewHelper')); $this->addElement($cellPhone); $skype = new Zend_Form_Element_Text('cu_skype'); $skype->setLabel(_('Skype:')); $skype->setValue($userData["skype_contact"]); $skype->setAttrib('class', 'input_text'); $skype->addFilter('StringTrim'); $skype->setDecorators(array('viewHelper')); $this->addElement($skype); $jabber = new Zend_Form_Element_Text('cu_jabber'); $jabber->setLabel(_('Jabber:')); $jabber->setValue($userData["jabber_contact"]); $jabber->setAttrib('class', 'input_text'); $jabber->addFilter('StringTrim'); $jabber->addValidator($emailValidator); $jabber->setDecorators(array('viewHelper')); $this->addElement($jabber); $locale = new Zend_Form_Element_Select("cu_locale"); $locale->setLabel(_("Language:")); $locale->setMultiOptions(Application_Model_Locale::getLocales()); $locale->setValue(Application_Model_Preference::GetUserLocale($currentUserId)); $locale->setDecorators(array('ViewHelper')); $this->addElement($locale); $timezone = new Zend_Form_Element_Select("cu_timezone"); $timezone->setLabel(_("Interface Timezone:")); $timezone->setMultiOptions(Application_Common_Timezone::getTimezones()); $timezone->setValue(Application_Model_Preference::GetUserTimezone($currentUserId)); $timezone->setDecorators(array('ViewHelper')); $this->addElement($timezone); }