public function init() { $CC_CONFIG = Config::getConfig(); // Set the method for the display form to POST $this->setMethod('post'); $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/login.phtml')))); // Add username element $this->addElement('text', 'username', array('label' => _('Username:'******'class' => 'input_text', 'required' => true, 'value' => isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1 ? 'admin' : '', 'filters' => array('StringTrim'), 'validators' => array('NotEmpty'), 'decorators' => array('ViewHelper'))); // Add password element $this->addElement('password', 'password', array('label' => _('Password:'******'class' => 'input_text', 'required' => true, 'value' => isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1 ? 'admin' : '', 'filters' => array('StringTrim'), 'validators' => array('NotEmpty'), 'decorators' => array('ViewHelper'))); $locale = new Zend_Form_Element_Select("locale"); $locale->setLabel(_("Language:")); $locale->setMultiOptions(Application_Model_Locale::getLocales()); $locale->setDecorators(array('ViewHelper')); $this->addElement($locale); $recaptchaNeeded = false; if (Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3) { $recaptchaNeeded = true; } if ($recaptchaNeeded) { // recaptcha $this->addRecaptcha(); } // Add the submit button $this->addElement('submit', 'submit', array('ignore' => true, 'label' => _('Login'), 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center', 'decorators' => array('ViewHelper'))); }
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->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); }