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() { $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 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() { /* $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); }
public function init() { /* $this->addElementPrefixPath('Application_Validate', '../application/validate', 'validate'); * */ $notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator(); $emailValidator = Application_Form_Helper_ValidationTypes::overrideEmailAddressValidator(); $notDemoValidator = new Application_Validate_NotDemoValidate(); $this->setAttrib('id', 'user_form'); $hidden = new Zend_Form_Element_Hidden('user_id'); $hidden->setDecorators(array('ViewHelper')); $this->addElement($hidden); $login = new Zend_Form_Element_Text('login'); $login->setLabel(_('Username:'******'class', 'input_text'); $login->setRequired(true); $login->addValidator($notEmptyValidator); $login->addFilter('StringTrim'); //$login->addValidator('UserNameValidate'); $this->addElement($login); $password = new Zend_Form_Element_Password('password'); $password->setLabel(_('Password:'******'class', 'input_text'); $password->setRequired(true); $password->addFilter('StringTrim'); $password->addValidator($notEmptyValidator); $this->addElement($password); $passwordVerify = new Zend_Form_Element_Password('passwordVerify'); $passwordVerify->setLabel(_('Verify Password:'******'class', 'input_text'); $passwordVerify->setRequired(true); $passwordVerify->addFilter('StringTrim'); $passwordVerify->addValidator($notEmptyValidator); $passwordVerify->addValidator($notDemoValidator); $this->addElement($passwordVerify); $firstName = new Zend_Form_Element_Text('first_name'); $firstName->setLabel(_('Firstname:')); $firstName->setAttrib('class', 'input_text'); $firstName->addFilter('StringTrim'); $this->addElement($firstName); $lastName = new Zend_Form_Element_Text('last_name'); $lastName->setLabel(_('Lastname:')); $lastName->setAttrib('class', 'input_text'); $lastName->addFilter('StringTrim'); $this->addElement($lastName); $email = new Zend_Form_Element_Text('email'); $email->setLabel(_('Email:')); $email->setAttrib('class', 'input_text'); $email->addFilter('StringTrim'); $email->setRequired(true); $email->addValidator($notEmptyValidator); $email->addValidator($emailValidator); $this->addElement($email); $cellPhone = new Zend_Form_Element_Text('cell_phone'); $cellPhone->setLabel(_('Mobile Phone:')); $cellPhone->setAttrib('class', 'input_text'); $cellPhone->addFilter('StringTrim'); $this->addElement($cellPhone); $skype = new Zend_Form_Element_Text('skype'); $skype->setLabel(_('Skype:')); $skype->setAttrib('class', 'input_text'); $skype->addFilter('StringTrim'); $this->addElement($skype); $jabber = new Zend_Form_Element_Text('jabber'); $jabber->setLabel(_('Jabber:')); $jabber->setAttrib('class', 'input_text'); $jabber->addFilter('StringTrim'); $jabber->addValidator($emailValidator); $this->addElement($jabber); $select = new Zend_Form_Element_Select('type'); $select->setLabel(_('User Type:')); $select->setAttrib('class', 'input_select'); $select->setAttrib('style', 'width: 40%'); $select->setMultiOptions(array("G" => _("Guest"), "H" => _("DJ"), "P" => _("Program Manager"), "A" => _("Admin"))); $select->setRequired(true); $this->addElement($select); $saveBtn = new Zend_Form_Element_Button('save_user'); $saveBtn->setAttrib('class', 'btn btn-small right-floated'); $saveBtn->setIgnore(true); $saveBtn->setLabel(_('Save')); $this->addElement($saveBtn); }