예제 #1
0
 /**
  * Configure form
  */
 public function init()
 {
     $this->setAttrib('class', 'ajaxForm formAjaxValidate');
     $registry = MyProject_Registry::getInstance();
     $currentLocale = $registry->registry('locale');
     //
     // Login Information fields
     //
     $this->addElement('info', 'info3', array('label' => __('Login Information'), 'messages' => array(__('Your username and password must both be at least 8 characters long and are case-sensitive. Please do not enter accented characters.'), __('We recommend that your password is not a word you can find in the dictionary, includes both capital and lower case letters, and contains at least one special character (1-9, !, *, _, etc.).'), __('Your password will be encrypted and stored in our system. Due to the encryption, we cannot retrieve your password for you. If you lose or forget your password, we offer the ability to reset it.'))));
     $this->addElement('radio', 'gender', array('helper' => 'formMultiRadio', 'label' => __('Gender:'), 'label_class' => 'compact', 'required' => true, 'multioptions' => array(1 => __('Male'), 2 => __('Female'))));
     $this->getElement('gender')->setAttrib('label_class', 'compact');
     // login
     $this->addElement('text', 'username', array('label' => __('Username:'******'required' => true, 'description' => __('May only contain letters, numbers, and underscore (_) and 8-20 characters long.')));
     $this->getElement('username')->addValidator('StringLength', true, array(8, 20))->addValidator('Regex', false, array('pattern' => '/^[0-9A-Za-z+\\_]*$/', 'messages' => array('regexNotMatch' => __('Invalide Username should only contain letters, numbers, and underscore (_).'))));
     // password
     $this->addElement('password', 'password', array('label' => __('Password:'******'required' => true, 'description' => __('Must be 6-25 characters long.')));
     $this->getElement('password')->addValidator('StringLength', true, array(6, 25));
     $this->addElement('password', 'password_check', array('label' => __('Please re-enter your password:'******'required' => true, 'description' => __('Must match the password you entered just above.')));
     $this->getElement('password_check')->addValidator('StringEquals', true, array('field1' => 'password', 'field2' => 'password_check', 'messages' => array('notMatch' => __("Passwords don't match, please enter them again"))));
     $this->addElement('checkbox', 'remember_me', array('label' => __('Remember Me'), 'description' => __("If you don't want to bother with having to login every time you visit the site, then checking \"Remember Me\" will place a unique identifier only our site can read that we'll use to identify you and log you in automatically each time you visit.")));
     $this->addElement('checkbox', 'therms', array('label' => __('I agree to the bellow terms'), 'required' => true, 'description' => sprintf(__('By checking this, you are indicating that you are agree with the %s Terms of Use %s.'), '<a href="#">', '</a>')));
     $thermsRequired = new Zend_Validate_InArray(array(1));
     $thermsRequired->setMessage('You should accept the Terms of Use');
     $this->getElement('therms')->addValidator($thermsRequired);
     $this->addDisplayGroup(array('info3', 'gender', 'username', 'password', 'password_check', 'remember_me', 'therms'), 'login_information');
     $this->getDisplayGroup('login_information')->setLegend(__('Login Information'));
     // submit and reset buttons
     $this->addElement('reset', 'reset', array('label' => __('Cancel')))->addElement('submit', 'update', array('label' => __('Submit')))->addDisplayGroup(array('reset', 'update'), 'buttons');
     // add class for buttons
     $this->getDisplayGroup('buttons')->setAttrib('class', 'fieldsetButtons');
 }
예제 #2
0
파일: Log.php 프로젝트: rukzuk/rukzuk
 /**
  * @param  string  $format
  * @return boolean
  */
 private function validateFormat($format)
 {
     $formatValidator = new \Zend_Validate_InArray($this->acceptedFormats);
     $formatValidator->setMessage("'%value%' ist kein unterstuetztes Format", \Zend_Validate_InArray::NOT_IN_ARRAY);
     if (!$formatValidator->isValid($format)) {
         $messages = array_values($formatValidator->getMessages());
         $this->addError(new Error('format', $format, $messages));
         return false;
     }
     return true;
 }
예제 #3
0
 public function init()
 {
     parent::init();
     $options = Opus_EnrichmentKey::getAll();
     $values = array();
     $translator = $this->getTranslator();
     $this->setDisableTranslator(true);
     // keys are translated below if possible
     foreach ($options as $index => $option) {
         $keyName = $option->getName();
         $values[] = $keyName;
         $translationKey = 'Enrichment' . $keyName;
         if (!is_null($translator) && $translator->isTranslated($translationKey)) {
             $this->addMultiOption($keyName, $translator->translate($translationKey));
         } else {
             $this->addMultiOption($keyName, $keyName);
         }
     }
     $validator = new Zend_Validate_InArray($values);
     $validator->setMessage('validation_error_unknown_enrichmentkey');
     $this->addValidator($validator);
 }
예제 #4
0
 /**
  * Overrides init() in Zend_Form
  * 
  * @access public
  * @return void
  */
 public function init()
 {
     // init the parent
     parent::init();
     // set the form's method
     $this->setMethod('post');
     $groupModel = new Group();
     $groupsOptions = $groupModel->findPairs();
     $uniqueUsernameValidator = new Zend_Validate_Db_NoRecordExists(array('table' => 'backoffice_users', 'field' => 'username'));
     $uniqueEmailValidator = new Zend_Validate_Db_NoRecordExists(array('table' => 'backoffice_users', 'field' => 'email'));
     $groupsInArrayValidator = new Zend_Validate_InArray(array_keys($groupsOptions));
     $groupsInArrayValidator->setMessage('Please select at least one group. If you are not sure about which group is better, select "member".');
     $username = new Zend_Form_Element_Text('username');
     $username->setOptions(array('label' => 'Username', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $uniqueUsernameValidator)));
     $this->addElement($username);
     $email = new Zend_Form_Element_Text('email');
     $email->setOptions(array('label' => 'Email', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $uniqueEmailValidator)));
     $this->addElement($email);
     $firstname = new Zend_Form_Element_Text('firstname');
     $firstname->setOptions(array('label' => 'First name', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty')));
     $this->addElement($firstname);
     $lastname = new Zend_Form_Element_Text('lastname');
     $lastname->setOptions(array('label' => 'Last name', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty')));
     $this->addElement($lastname);
     $phoneNumber = new Zend_Form_Element_Text('phone_number');
     $phoneNumber->setOptions(array('label' => 'Phone number', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty')));
     $this->addElement($phoneNumber);
     $groups = new Zend_Form_Element_MultiCheckbox('groups');
     $groups->setOptions(array('label' => 'Select the one or more user groups for this user', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $groupsInArrayValidator), 'multiOptions' => $groupsOptions));
     $this->addElement($groups);
     $id = new Zend_Form_Element_Hidden('id');
     $id->setOptions(array('validators' => array(new Zend_Validate_Regex('/^\\d*$/'))));
     $this->addElement($id);
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setOptions(array('label' => 'Save user', 'required' => true, 'order' => 100));
     $this->addElement($submit);
     $this->addDisplayGroup(array('username', 'email', 'firstname', 'lastname', 'phone_number'), 'userdata')->getDisplayGroup('userdata')->setLegend('User details');
     $this->addDisplayGroup(array('groups'), 'usergroups')->getDisplayGroup('usergroups')->setLegend('Groups');
 }
예제 #5
0
 /**
  * returns an validator for settings params or error array
  *
  * @return Zend_Filter_Input|array on success data on error message array
  * @param array $data current data for validation
  */
 public function validate($data)
 {
     // define filter
     $filterTrim = new Zend_Filter_StringTrim();
     $filter = array('deleteItems' => $filterTrim, 'imagesPosition' => $filterTrim, 'imagesHeight' => $filterTrim, 'language' => $filterTrim, 'refresh' => $filterTrim, 'lastrefresh' => $filterTrim, 'view' => $filterTrim, 'offset' => $filterTrim, 'itemsperpage' => $filterTrim, 'selected' => $filterTrim, 'dateFilter' => $filterTrim, 'dateStart' => $filterTrim, 'dateEnd' => $filterTrim, 'search' => $filterTrim, 'unread' => $filterTrim, 'starred' => $filterTrim, 'currentPriorityStart' => $filterTrim, 'currentPriorityEnd' => $filterTrim, 'saveOpenCategories' => $filterTrim, 'openCategories' => $filterTrim, 'firstUnread' => $filterTrim, 'newWindow' => $filterTrim, 'public' => $filterTrim, 'anonymizer' => $filterTrim, 'sort' => $filterTrim, 'openitems' => $filterTrim, 'iconcache' => $filterTrim);
     // define validators
     $validatorType = new Zend_Validate_InArray(array("both", "multimedia", "messages"));
     $validatorType->setMessage(Zend_Registry::get('language')->translate('Only both, multimedia, message allowed'), Zend_Validate_InArray::NOT_IN_ARRAY);
     $validatorNotEmpty = new Zend_Validate_NotEmpty();
     $validatorNotEmpty->setMessage(Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Validate_NotEmpty::IS_EMPTY);
     $validatorNum = new Zend_Validate_Int(Zend_Registry::get('session')->language);
     $validatorNum->setLocale(Zend_Registry::get('session')->language);
     $validatorNum->setMessage(Zend_Registry::get('language')->translate('Only digits allowed'), Zend_Validate_Int::NOT_INT);
     $validatorInArray = new Zend_Validate_InArray(array("top", "bottom"));
     $validatorInArray->setMessage(Zend_Registry::get('language')->translate('Only top or bottom allowed'), Zend_Validate_InArray::NOT_IN_ARRAY);
     $validatorLanguage = new Zend_Validate_InArray(Zend_Registry::get('language')->getList());
     $validatorLanguage->setMessage(Zend_Registry::get('language')->translate('Language is not available'), Zend_Validate_InArray::NOT_IN_ARRAY);
     $validatorDate = new Zend_Validate_Date();
     $validatorDate->setMessage(Zend_Registry::get('language')->translate('No valid date given'), Zend_Validate_Date::INVALID);
     $validatorDate->setMessage(Zend_Registry::get('language')->translate('No valid date given'), Zend_Validate_Date::FALSEFORMAT);
     $validatorBiggerThanZero = new Zend_Validate_GreaterThan(0);
     $validatorBiggerThanZero->setMessage(Zend_Registry::get('language')->translate('Value must be bigger than 0'), Zend_Validate_GreaterThan::NOT_GREATER);
     $validatorBetweenDays = new Zend_Validate_Between(0, 2000);
     $validatorBetweenDays->setMessage(Zend_Registry::get('language')->translate('Please choose a value between 0 and 2000 days'), Zend_Validate_Between::NOT_BETWEEN);
     $validatorBetweenItemsperpage = new Zend_Validate_Between(0, 200);
     $validatorBetweenItemsperpage->setMessage(Zend_Registry::get('language')->translate('Please choose a value between 0 and 200 items per page'), Zend_Validate_Between::NOT_BETWEEN);
     $validatorSort = new Zend_Validate_InArray(array("date", "dateasc", "priority", "priorityasc"));
     $validatorSort->setMessage(Zend_Registry::get('language')->translate('Only date or rating allowed'), Zend_Validate_InArray::NOT_IN_ARRAY);
     $validators = array('deleteItems' => array($validatorNum, $validatorBetweenDays, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'imagesPosition' => array($validatorInArray, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'language' => array($validatorLanguage, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'refresh' => array($validatorNum, $validatorBiggerThanZero, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'lastrefresh' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'view' => array($validatorType, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'offset' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'itemsperpage' => array($validatorNum, $validatorBetweenItemsperpage, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'selected' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'dateFilter' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'search' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'unread' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'starred' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'currentPriorityStart' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'currentPriorityEnd' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'saveOpenCategories' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'openCategories' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'firstUnread' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'newWindow' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'public' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'anonymizer' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'sort' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL, $validatorSort), 'openitems' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'iconcache' => array(Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL));
     // optional check date
     if (isset($data['dateFilter']) && $data['dateFilter'] == 1) {
         $validators['dateStart'] = $validatorDate;
         $validators['dateEnd'] = $validatorDate;
     } else {
         $validators['dateStart'] = array(Zend_Filter_Input::ALLOW_EMPTY => true);
         $validators['dateEnd'] = array(Zend_Filter_Input::ALLOW_EMPTY => true);
         $data['dateStart'] = '';
         $data['dateEnd'] = '';
     }
     // create validation main object
     $validator = new Zend_Filter_Input($filter, $validators, $data, array(Zend_Filter_Input::NOT_EMPTY_MESSAGE => Zend_Registry::get('language')->translate("Value is required and can't be empty"), Zend_Filter_Input::BREAK_CHAIN => false));
     // return filter input object
     return parent::validate($validator);
 }
예제 #6
0
파일: Showcases.php 프로젝트: hartum/basezf
 /**
  * Configure form
  */
 public function init()
 {
     $this->setAttrib('class', 'formAjaxValidate');
     //
     // Personal Information fields
     //
     $this->addElement('info', 'info1', array('label' => __('Personal Information'), 'messages' => array(__('Please enter your name and address as they are listed for your debit card, credit card, or bank account.'))));
     $this->addElement('radio', 'gender', array('label' => __('Gender:'), 'required' => true, 'multioptions' => array(1 => __('Male'), 0 => __('Female'))));
     $this->getElement('gender')->setAttrib('label_class', 'compact');
     $this->addElement('text', 'first_name', array('label' => __('First Name:'), 'required' => true));
     $this->addElement('text', 'last_name', array('label' => __('Last Name:'), 'required' => true));
     // @todo
     $this->addElement('date', 'birthday', array('label' => __('Birthday:'), 'required' => true));
     $this->addElement('text', 'addr1', array('label' => __('Address:')));
     $this->addElement('text', 'addr2', array());
     $this->addElement('select', 'country_id', array('label' => __('Country:'), 'multioptions' => array()));
     $this->addElement('select', 'state_id', array('label' => __('State:'), 'multioptions' => array()));
     $this->addElement('text', 'zipcode', array('label' => __('Zip/Postal Code:')));
     $this->addElement('text', 'city', array('label' => __('City:')));
     $this->addElement('select', 'sexuality_id', array('helper' => 'FormFancySelect', 'label' => __('Sexuality:'), 'notice' => __('Choose from the list'), 'required' => true, 'multioptions' => array('1' => 'Hetero', '2' => 'Bi', '3' => 'Gay')));
     $this->addElement('multiselect', 'lookingfor_id', array('helper' => 'FormFancySelect', 'label' => __('Her for:'), 'multiple' => true, 'show_choice' => true, 'notice' => __('Choose from the list'), 'required' => true, 'multioptions' => array('1' => 'Chatting', '2' => 'Promote Myself', '3' => 'Meeting new people', '4' => 'Flirting', '5' => 'Find the true love')));
     $this->addDisplayGroup(array('info1', 'gender', 'first_name', 'last_name', 'birthday', 'addr1', 'addr2', 'country_id', 'state_id', 'zipcode', 'city', 'sexuality_id', 'lookingfor_id'), 'personal_information');
     $this->getDisplayGroup('personal_information')->setLegend(__('Personal Information'));
     //
     // Contact Information fields
     //
     $this->addElement('info', 'info2', array('label' => __('Contact Information'), 'messages' => array(__('Please enter your full email address, for example, name@domain.com'), __('It is important that you provide a valid, working email address that you have access to as it must be verified before you can use your account.'), __('Please enter a land line number, not a mobile phone number.'), str_replace(array('[link]', '[/link]'), array('<a href="#todo">', '</a>'), __('Your phone number will not be shared or used for telemarketing. Your information is protected by our [link]Privacy Policy[/link].')))));
     $this->addElement('radio', 'how_contact', array('helper' => 'formMultiRadio', 'label' => __('How to Contact You ?'), 'required' => true, 'multioptions' => array(1 => __('Phone'), 0 => __('Email'))));
     $this->getElement('how_contact')->setAttrib('label_class', 'compact');
     $this->addElement('text', 'email', array('label' => __('Email:'), 'required' => true, 'description' => __('We will never sell or disclose your email address to anyone. Once your account is setup, you may add additional email addresses.')));
     $this->getElement('email')->addValidator('EmailAddress', true, array('messages' => array('emailAddressInvalid' => __('This does not appear to be a valid email address'), 'emailAddressInvalidHostname' => __('This does not appear to be a valid email address'), 'emailAddressInvalidMxRecord' => __('This does not appear to be a valid email address'), 'emailAddressDotAtom' => __('This does not appear to be a valid email address'), 'emailAddressQuotedString' => __('This does not appear to be a valid email address'), 'emailAddressInvalidLocalPart' => __('This does not appear to be a valid email address'))));
     $this->addElement('text', 'email_check', array('label' => __('Re-enter Email:'), 'required' => true, 'description' => __('Must match the email address you just entered above.')));
     $this->getElement('email_check')->addValidator('StringEquals', true, array('field1' => 'email', 'field2' => 'email_check', 'messages' => array('notMatch' => __("Emails don't match, please enter them again"))));
     $this->addElement('text', 'phone', array('label' => __('Phone:')));
     $this->addElement('text', 'fax', array('label' => __('Fax:')));
     $this->addElement('radio', 'subject', array('helper' => 'formMultiRadio', 'label' => __('Message Subject:  '), 'multioptions' => array(1 => __('Help, my brother/sister is driving me crazy!'), 1 => __("How can I tell my father/mother, it's time for them to retire?"), 2 => __("I'm exasperated with an awkward partner!"), 3 => __("How do I stop my family members from interfering?"), 4 => __("Other:")), 'container_class' => 'wide'));
     $this->addElement('textarea', 'message', array('label' => __('Your Message:'), 'required' => true, 'description' => __('Must be 250 characters or less.')));
     $this->addElement('textarea', 'message_wide', array('label' => __('Your Message:'), 'required' => true, 'description' => __("We'd love to get your feedback on any of the products or services we offer or on your experience with us."), 'container_class' => 'wide'));
     $this->addElement('text', 'keywords', array('label' => __('Keywords:'), 'required' => true, 'container_class' => 'wide'));
     $this->addElement('multiselect', 'current_availability_id', array('label' => __('What is your current availability?'), 'required' => true, 'description' => __('Use the CTRL key to select more than one.'), 'multioptions' => array(1 => __('Part-time'), 2 => __('Full-time (Days)'), 3 => __('Full-time (Swing)'), 4 => __('Full-time (Graveyard)'), 5 => __('Weekends Only'))));
     $this->addElement('multiCheckbox', 'availability_id', array('label' => __('What is your current availability?'), 'required' => true, 'multioptions' => array(1 => __('Part-time'), 2 => __('Full-time (Days)'), 3 => __('Full-time (Swing)'), 4 => __('Full-time (Graveyard)'), 5 => __('Weekends Only'))));
     $this->addDisplayGroup(array('info2', 'how_contact', 'email', 'email_check', 'phone', 'fax', 'subject', 'message', 'message_wide', 'keywords', 'current_availability_id', 'availability_id'), 'contact_information');
     $this->getDisplayGroup('contact_information')->setLegend(__('Contact Information'));
     //
     // Login Information fields
     //
     $this->addElement('info', 'info3', array('label' => __('Login Information'), 'messages' => array(__('Your username and password must both be at least 8 characters long and are case-sensitive. Please do not enter accented characters.'), __('We recommend that your password is not a word you can find in the dictionary, includes both capital and lower case letters, and contains at least one special character (1-9, !, *, _, etc.).'), __('Your password will be encrypted and stored in our system. Due to the encryption, we cannot retrieve your password for you. If you lose or forget your password, we offer the ability to reset it.'))));
     $this->addElement('text', 'username', array('label' => __('Username:'******'required' => true, 'description' => __('May only contain letters, numbers, and underscore (_) and 8-20 characters long.')));
     $this->addElement('password', 'password', array('label' => __('Password:'******'required' => true, 'description' => __('Must be 6-25 characters long.')));
     $this->addElement('password', 'password_check', array('label' => __('Please re-enter your password:'******'required' => true, 'description' => __('Must match the password you entered just above.')));
     $this->getElement('password_check')->addValidator('StringEquals', true, array('field1' => 'password', 'field2' => 'password_check', 'messages' => array('notMatch' => __("Passwords don't match, please enter them again"))));
     $this->addElement('checkbox', 'remember_me', array('label' => __('Remember Me'), 'description' => __("If you don't want to bother with having to login every time you visit the site, then checking \"Remember Me\" will place a unique identifier only our site can read that we'll use to identify you and log you in automatically each time you visit.")));
     $this->addElement('checkbox', 'therms', array('label' => __('I agree to the bellow terms'), 'required' => true, 'description' => sprintf(__('By checking this, you are indicating that you are agree with the %sTerms of Use%s.'), '<a href="#">', '</a>')));
     $thermsRequired = new Zend_Validate_InArray(array(1));
     $thermsRequired->setMessage('You should accept the Terms of Use');
     $this->getElement('therms')->addValidator($thermsRequired);
     $this->addDisplayGroup(array('info3', 'username', 'password', 'password_check', 'remember_me', 'therms'), 'login_information');
     $this->getDisplayGroup('login_information')->setLegend(__('Login Information'));
     //
     // Avatar
     //
     $this->addElement('info', 'info5', array('label' => __('Avatar Information'), 'messages' => array(__('You can upload a JPG, GIF or PNG file.'), __('File size limit 4 MB. If your upload does not work, try a smaller picture.'))));
     // add synchron upload support
     $this->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);
     $this->addElement('file', 'avatar_file', array('label' => __('Upload your Avatar:'), 'required' => true, 'container_class' => 'wide'));
     $this->addElement('checkbox', 'therms_file', array('label' => __('I certify that I have the right to distribute this picture and that it does not violate the Terms of Use'), 'required' => true, 'container_class' => 'wide'));
     $thermsRequired = new Zend_Validate_InArray(array(1));
     $thermsRequired->setMessage('You should accept the Terms of Use');
     $this->getElement('therms_file')->addValidator($thermsRequired);
     $this->addDisplayGroup(array('info5', 'avatar_file', 'therms_file'), 'avatar');
     $this->getDisplayGroup('avatar')->setLegend(__('Avatar'));
     //
     // Verification fields
     //
     $this->addElement('info', 'info4', array('label' => __('Verification Information'), 'messages' => array(__('Type the characters you see in this picture. This ensures that a person, not an automated program, is creating this account.'))));
     // init ReCaptcha service
     $pubKey = '6Lf59QQAAAAAANrLNTVbBEt4I1TgAIwuQuc22iuN';
     $privKey = '6Lf59QQAAAAAAFaT3xLxeoIHkPNx3OFeTBcv1bXS';
     $recaptcha = new Zend_Service_ReCaptcha($pubKey, $privKey);
     // inir ReCaptcha adapter
     $adapter = new Zend_Captcha_ReCaptcha();
     $adapter->setService($recaptcha);
     // build element
     $this->addElement('captcha', 'captcha', array('captcha' => $adapter));
     $this->addDisplayGroup(array('info4', 'captcha'), 'check_information');
     $this->getDisplayGroup('check_information')->setLegend(__('Verification'));
     // submit and reset buttons
     $this->addElement('reset', 'reset', array('label' => __('Cancel')))->addElement('submit', 'update', array('label' => __('Submit')))->addDisplayGroup(array('reset', 'update'), 'buttons');
     // add class for buttons
     $this->getDisplayGroup('buttons')->setAttrib('class', 'fieldsetButtons');
 }
예제 #7
0
파일: Import.php 프로젝트: rukzuk/rukzuk
 /**
  * @param integer $allowedType
  * @return boolean
  */
 private function validateAllowedType($allowedType, $field)
 {
     $typeValidator = new \Zend_Validate_InArray($this->expectedAllowedTypes);
     $typeValidator->setMessage("'%value%' ist kein unterstuetzter Import-Typ'", \Zend_Validate_InArray::NOT_IN_ARRAY);
     if (!$typeValidator->isValid($allowedType)) {
         $messages = array_values($typeValidator->getMessages());
         $this->addError(new Error($field, $allowedType, $messages));
         return false;
     }
     return true;
 }
예제 #8
0
파일: Media.php 프로젝트: rukzuk/rukzuk
 /**
  * @param string   $direction
  * @return boolean
  */
 private function validateFilterDirection($direction)
 {
     $inArrayValidator = new InArrayValidator(array('ASC', 'DESC', 'asc', 'desc'));
     $allowedDirectionValues = implode(', ', $inArrayValidator->getHaystack());
     $message = "Filter direction '%value%' enthält keinen der folgenden " . "gültigen Werte ({$allowedDirectionValues})";
     $inArrayValidator->setMessage($message, InArrayValidator::NOT_IN_ARRAY);
     if (!$inArrayValidator->isValid($direction)) {
         $messages = array_values($inArrayValidator->getMessages());
         $this->addError(new Error('direction', $direction, $messages));
         return false;
     }
     return true;
 }