本文整理汇总了PHP中Zend_Validate_Regex::setMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Regex::setMessage方法的具体用法?PHP Zend_Validate_Regex::setMessage怎么用?PHP Zend_Validate_Regex::setMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_Regex
的用法示例。
在下文中一共展示了Zend_Validate_Regex::setMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
Zend_Loader::loadClass('Zend_Validate_Regex');
// translate
$this->translate = Zend_Registry::get('translate');
//Zend_Form::setDefaultTranslator( Zend_Registry::get('translate') );
// login attempt
$defNamespace = new Zend_Session_Namespace('Default');
$use_captcha = $defNamespace->numLoginFails >= self::MAX_LOGIN_ATTEMPT ? TRUE : FALSE;
$this->setMethod('post');
// username
$login = $this->createElement('text', 'login', array('decorators' => $this->elDecorators, 'required' => true, 'label' => $this->translate->_('Username'), 'size' => 25, 'maxlength' => 50));
$login->addDecorator('FormElements', array('tag' => 'div', 'style' => 'width:10em; background-color:#E0F0FF;'));
$login_validator = new Zend_Validate_Regex('/^[a-z0-9\\-_@\\.]+$/i');
$login_validator->setMessage($this->translate->_('Login characters incorrect. Allowed: alphabetical characters, digits, and "- . _ @" characters.'));
$login->addValidator($login_validator)->addValidator('stringLength', false, array(1, 50))->setRequired(true);
// password
$password = $this->createElement('password', 'pwd', array('decorators' => $this->elDecorators, 'required' => true, 'label' => $this->translate->_('Password'), 'size' => 25, 'maxlength' => 50));
$password->addValidator('StringLength', false, array(1, 50))->setRequired(true);
// remember me
$checkbox = $this->createElement('checkbox', 'rememberme', array('decorators' => $this->elDecorators, 'label' => $this->translate->_('Remember me'), 'checked' => 1));
// login
$submit = $this->createElement('submit', 'submit', array('decorators' => array('ViewHelper', 'Errors'), 'class' => 'login-btn', 'id' => 'submit', 'label' => $this->translate->_('Log In')));
// add elements to form
$this->addElement($login)->addElement($password)->addElement($checkbox)->addElement($submit);
if ($use_captcha) {
// create captcha
$captcha = $this->createElement('captcha', 'captcha', array('label' => $this->translate->_('Type the characters:'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 3, 'timeout' => 120)));
// And finally add some CSRF protection
$csrf = $this->createElement('hash', 'csrf', array('ignore' => true));
// add captcha to form
$this->addElement($captcha)->addElement($csrf);
}
}
示例2: init
public function init()
{
Zend_Loader::loadClass('Zend_Validate_Regex');
$this->translate = Zend_Registry::get('translate');
//Zend_Form::setDefaultTranslator( Zend_Registry::get('translate') );
// set method to POST
$this->setMethod('post');
/*
* hidden fields
*/
$acl = $this->addElement('hidden', 'acl', array('decorators' => $this->elDecorators));
$role_id = $this->addElement('hidden', 'role_id', array('decorators' => $this->elDecorators));
/*
* Order role
*/
$order = $this->createElement('text', 'order', array('label' => $this->translate->_('Order') . '*', 'required' => true, 'size' => 3, 'maxlength' => 5));
$order->addValidator('Int')->setRequired(true);
/*
* Name role
*/
$name = $this->createElement('text', 'role_name', array('label' => $this->translate->_('Name') . '*', 'required' => true, 'size' => 30, 'maxlength' => 50));
$name_validator = new Zend_Validate_Regex('/^[a-zA-Z0-9_]+$/');
$name_validator->setMessage($this->translate->_('Role name incorrect. This contains only english alphabetical characters, digits and underscore.'));
$name->addValidator('StringLength', false, array(2, 50))->addValidator($name_validator)->setRequired(true);
/*
* Description role
*/
$description = $this->createElement('textarea', 'description', array('label' => $this->translate->_('Description') . '*', 'required' => true, 'cols' => 50, 'rows' => 3));
$description->setRequired(true);
/*
* Inherited role id
*/
Zend_Loader::loadClass('Wbroles');
$table = new Wbroles();
if ($this->_roleid) {
$where = $table->getAdapter()->quoteInto('id != ?', $this->_roleid);
} else {
$where = null;
}
$rows = $table->fetchAll($where, 'id');
// create element
$inherit_id = $this->createElement('select', 'inherit_id', array('label' => $this->translate->_('Inherited role'), 'class' => 'ui-select', 'size' => 10));
$inherit_id->addMultiOption('', '');
foreach ($rows as $v) {
$inherit_id->addMultiOption($v['id'], $v['name']);
}
unset($table);
/*
* submit button
*/
$submit = new Zend_Form_Element_Submit('submit', array('decorators' => $this->elDecorators, 'id' => 'ok_' . __CLASS__, 'class' => 'prefer_btn', 'label' => $this->translate->_('Submit Form')));
/*
* reset button
*/
$reset = new Zend_Form_Element_Reset('reset', array('decorators' => $this->elDecorators, 'id' => 'reset_' . __CLASS__, 'label' => $this->translate->_('Cancel')));
/*
* add elements to form
*/
$this->addElements(array($order, $name, $description, $inherit_id, $submit, $reset));
}
示例3: _initFields
protected function _initFields()
{
parent::_initFields();
$this->add(new Kwf_Form_Field_TextField('title', trlKwf('Title')))->setAllowBlank(false)->setWidth(500);
$this->add(new Kwf_Form_Field_TextArea('teaser', trlKwf('Teaser')))->setWidth(500)->setHeight(100);
$this->add(new Kwf_Form_Field_DateField('date', trlKwf('Publication')))->setAllowBlank(false);
$this->add(new Kwf_Form_Field_Select('author_id', trlKwf('Author')))->setAllowBlank(false)->setWidth(200)->setValues(Kwf_Model_Abstract::getInstance('Kwc_Articles_Directory_AuthorsModel')->getRows());
$v = new Zend_Validate_Regex('/^[0-9]{4}\\/[0-9]{2}$/');
$v->setMessage(trlKwf('Please use this format -> Year / Month'), Zend_Validate_Regex::NOT_MATCH);
$this->add(new Kwf_Form_Field_TextField('vi_nr', trlKwf('VI-Number')))->setWidth(70)->addValidator($v);
$this->add(Kwc_Abstract_Form::createComponentFormByDbIdTemplate('article_{0}-previewImage', 'previewImage'));
$columns = $this->add(new Kwf_Form_Container_Columns('is_top'));
$col = $columns->add(new Kwf_Form_Container_Column());
$col->setStyle('margin-left: 0px');
$col->add(new Kwf_Form_Field_Checkbox('is_top_checked', trlKwf('Hot-topic')));
$col = $columns->add(new Kwf_Form_Container_Column());
$col->setLabelWidth(50);
$col->add(new Kwf_Form_Field_DateField('is_top_expire', trlKwf('Ends at')));
$this->add(new Kwf_Form_Field_Checkbox('read_required', trlKwf('Required reading')));
$this->add(new Kwf_Form_Field_Checkbox('only_intern', trlKwf('Only intern')));
$priority = array();
for ($i = 1; $i <= 10; $i++) {
$priority[$i] = $i;
}
$this->add(new Kwf_Form_Field_Select('priority', trlKwf('Priority')))->setAllowBlank(false)->setValues($priority)->setWidth(40)->setHelpText(trlKwfStatic('For sorting articles if they have same date'));
}
示例4: init
/**
* 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');
$user = Zend_Auth::getInstance()->getIdentity();
$oldPasswordValidator = new App_Validate_PasswordExists(array('table' => 'backoffice_users', 'field' => 'password', 'treatment' => 'BackofficeUser::hashPassword', 'userPkValue' => $user->id));
$complexityValidator = new Zend_Validate_Regex('/^(?=.*\\d)(?=.*[a-z|A-Z]).{7,}$/');
$complexityValidator->setMessage('The selected password does not meet the required complexity requirements');
$stringLengthValidator = new Zend_Validate_StringLength();
$stringLengthValidator->setMin(7);
$stringLengthValidator->setMessage('Your password must be at least 7 characters long');
$passwordHistoryValidator = new App_Validate_NoPasswordExists(array('table' => 'password_log', 'field' => 'password', 'treatment' => 'BackofficeUser::hashPassword', 'userPkField' => 'user_id', 'userPkValue' => $user->id));
$oldPassword = new Zend_Form_Element_Password('old_password');
$oldPassword->setOptions(array('label' => $this->t('Old password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $oldPasswordValidator)));
$this->addElement($oldPassword);
$password = new Zend_Form_Element_Password('password');
$password->setOptions(array('label' => $this->t('New password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $stringLengthValidator, $complexityValidator, $passwordHistoryValidator)));
$this->addElement($password);
$sameAsValidator = new App_Validate_SameAs($password);
$sameAsValidator->setMessage('The two passwords do not coincide.', App_Validate_SameAs::NOT_THE_SAME);
$retypeNewPassword = new Zend_Form_Element_Password('retype_new_password');
$retypeNewPassword->setOptions(array('label' => $this->t('Retype new password'), 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $sameAsValidator)));
$this->addElement($retypeNewPassword);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setOptions(array('label' => $this->t('Save password'), 'required' => TRUE));
$this->addElement($submit);
}
示例5: _initFields
protected function _initFields()
{
parent::_initFields();
$this->add(new Kwf_Form_Field_ShowField('original_url', trlKwf('Original Url')))->setData(new Kwf_Data_Trl_OriginalComponent('url'));
$fs = $this->add(new Kwf_Form_Container_FieldSet(trlKwf('Own Url')));
$fs->setCheckboxToggle(true);
$fs->setCheckboxName('own_url');
$validator = new Zend_Validate_Regex(array('pattern' => Kwc_Advanced_Youtube_Component::REGEX));
$validator->setMessage(trlKwf('No valid youtube url'), Zend_Validate_Regex::NOT_MATCH);
$fs->add(new Kwf_Form_Field_UrlField('url', trlKwfStatic('URL')))->addValidator($validator)->setAllowBlank(false)->setWidth(400);
}
示例6: init
public function init()
{
Zend_Loader::loadClass('Zend_Validate_Regex');
Zend_Loader::loadClass('Zend_Validate_EmailAddress');
// translate
$this->translate = Zend_Registry::get('translate');
Zend_Form::setDefaultTranslator(Zend_Registry::get('translate'));
$this->setMethod('post');
$this->setDecorators(array(array('ViewScript', array('viewScript' => 'forgot-password.phtml'))));
/*
* username
*/
$login = $this->createElement('text', 'login', array('decorators' => $this->elDecorators, 'required' => true, 'label' => $this->translate->_('Username'), 'size' => 25, 'maxlength' => 50));
$login->addDecorator('FormElements', array('tag' => 'div', 'style' => 'width:10em; background-color:#E0F0FF;'));
$login_validator = new Zend_Validate_Regex('/^[a-z0-9\\-_@\\.]+$/i');
$login_validator->setMessage($this->translate->_('Login characters incorrect. Allowed: alphabetical characters, digits, and "- . _ @" characters.'));
$login->addValidator($login_validator)->addValidator('stringLength', false, array(1, 50))->setRequired(true);
/*
* email
*/
$email = $this->createElement('text', 'email', array('decorators' => $this->elDecorators, 'required' => true, 'label' => $this->translate->_('Email'), 'size' => 25, 'maxlength' => 50));
$email->addDecorator('FormElements', array('tag' => 'div', 'style' => 'width:10em; background-color:#E0F0FF;'));
$email_validator = new Zend_Validate_Regex('/^(.+)@([^@]+)$/');
// $email_validator = new Zend_Validate_EmailAddress();
$email_validator->setMessage($this->translate->_('Email address incorrect.'));
$email->addValidator($email_validator)->setRequired(true);
/*
* submit
*/
$submit = $this->createElement('submit', 'submit', array('decorators' => array('ViewHelper', 'Errors'), 'class' => 'forgot-btn', 'id' => 'submit', 'label' => $this->translate->_('Submit new password')));
/*
* create captcha
*/
$captcha = $this->createElement('captcha', 'captcha', array('label' => $this->translate->_('Type the characters:'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 5, 'timeout' => 120)));
// And finally add some CSRF protection
$csrf = $this->createElement('hash', 'csrf', array('ignore' => true));
// add elements to form
$this->addElement($login)->addElement($email)->addElement($submit)->addElement($captcha)->addElement($csrf);
}
示例7: init
public function init()
{
$formErrors = $this->getView()->getHelper('FormErrors');
$formErrors->setElementStart("<div%s>")->setElementEnd("</div>")->setElementSeparator("<br>");
// required needs following string to be translated
__("Value is required and can't be empty");
// we are less strict than Zend_Validate_Email because we want a user
// with a strange email to be able to still contact us with the form
$emailValidator = new Zend_Validate_Regex('/^[A-Z0-9._-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\\.[A-Z.]{2,6}$/i');
$emailValidator->setMessage(__("Invalid email"), $emailValidator::NOT_MATCH);
$email = array('Text', 'contact_email', array('required' => 'true', 'validators' => array($emailValidator), 'label' => __("Email:")));
$maxSubjLength = 80;
$subjectValidator = new Zend_Validate_StringLength(0, $maxSubjLength);
$subjectValidator->setMessage(__("Subject must be %max% characters long or less", $subjectValidator::TOO_LONG));
$subject = array('Text', 'contact_subject', array('required' => 'true', 'maxlength' => $maxSubjLength, 'validators' => array($subjectValidator), 'label' => __("Subject:")));
$contentFilter = new Zend_Filter_PregReplace('/\\r\\n/', "\n");
$content = array('Textarea', 'contact_content', array('label' => __("Message:"), 'cols' => 40, 'filters' => array($contentFilter), 'required' => 'true', 'rows' => 10));
$submit = array('Submit', 'contact_submit', array('label' => __("Send"), 'decorators' => array('ViewHelper')));
$this->addElements(array($email, $subject, $content, $submit));
// fieldset around form
$this->addDisplayGroup(array_keys($this->_elements), 'main', array('decorators' => array('FormElements', array('fieldset', array('legend' => __("Send a message"))))));
}
示例8: _initFields
protected function _initFields()
{
parent::_initFields();
$validator = new Zend_Validate_Regex(array('pattern' => Kwc_Advanced_Youtube_Component::REGEX));
$validator->setMessage(trlKwf('No valid youtube url'), Zend_Validate_Regex::NOT_MATCH);
$this->add(new Kwf_Form_Field_UrlField('url', trlKwf('URL')))->addValidator($validator)->setAllowBlank(false)->setWidth(400);
if (Kwc_Abstract::getSetting($this->getClass(), 'videoWidth') == Kwc_Advanced_Youtube_Component::USER_SELECT) {
$cards = new Kwf_Form_Container_Cards('size', trlKwf('Size'));
$cards->setDefaultValue('fullWidth');
$cards->setAllowBlank(false);
$card = $cards->add();
$card->setTitle(trlKwfStatic('full width'));
$card->setName('fullWidth');
$card = $cards->add();
$card->setTitle(trlKwfStatic('user-defined'));
$card->setName('custom');
$card->add(new Kwf_Form_Field_TextField('video_width', trlKwf('Width')))->setAllowBlank(false);
$this->add($cards);
}
$this->add(new Kwf_Form_Field_Select('dimensions', trlKwf('Dimension')))->setDefaultValue('16x9')->setValues(array('16x9' => trlStatic('16:9'), '4x3' => trlStatic('4:3')));
$this->add(new Kwf_Form_Field_Checkbox('autoplay', trlKwf('Autoplay')));
}
示例9: __construct
public function __construct($options = null)
{
parent::__construct($options);
$status = $options['status'];
$planedDate = $options['planedDate'];
$planedTime = $options['planedTime'];
$collectionsData = $options['filterList'];
$statusOptions = new Zend_Form_Element_Select('NR_Status');
$statusOptions->setLabel('Action')->setAttrib('class', 'largeSelect');
$statusOptions->addMultiOption('1', 'Terminé (Ne pas envoyer à nouveau)');
$statusOptions->addMultiOption('2', "Envoyez à ceux qui ne l'ont pas reçu");
$statusOptions->addMultiOption('3', 'Envoyez à tous les destinataires');
$this->addElement($statusOptions);
$send = new Zend_Form_Element_Submit('newsletter_send');
$send->setLabel('Envoyer')->setAttrib('class', 'stdButton')->setOrder(2);
$this->addActionButton($send);
$collectionFilters = new Zend_Form_Element_Select('NR_CollectionFiltersID');
$collectionFilters->setLabel($this->getView()->getCibleText('form_label_collection_name'))->setAttrib('class', 'largeSelect');
// $collectionsSelect = new NewsletterFilterCollectionsSet();
// $select = $collectionsSelect->select()
// ->order('NFCS_Name');
// $collectionsData = $collectionsSelect->fetchAll($select);
$collectionFilters->addMultiOption(0, $this->getView()->getCibleText('newsletter_send_filter_selectOne'));
foreach ($collectionsData as $key => $collection) {
$collectionFilters->addMultiOption($key, $collection);
}
$this->addElement($collectionFilters);
// MailingDateScheduled
$datePicker = new Cible_Form_Element_DatePicker('NR_MailingDate', array('jquery.params' => array('changeYear' => true, 'changeMonth' => true)));
$datePicker->setLabel($this->getView()->getCibleText('form_label_releaseDate_planned_date'))->setAttrib('class', 'stdTextInput')->setValue($planedDate)->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator('Date', true, array('messages' => array('dateNotYYYY-MM-DD' => $this->getView()->getCibleText('validation_message_invalid_date'), 'dateInvalid' => $this->getView()->getCibleText('validation_message_invalid_date'), 'dateFalseFormat' => $this->getView()->getCibleText('validation_message_invalid_date'))));
$this->addElement($datePicker);
// MailingTimeScheduled
$regexValidate = new Zend_Validate_Regex('/^([0-1]\\d|2[0-3]):([0-5]\\d)$/');
$regexValidate->setMessage('Temps invalide (HH:MM)', 'regexNotMatch');
$time = new Zend_Form_Element_Text('NR_MailingTime');
$time->setLabel('HH:MM')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setValue($planedTime);
$this->addElement($time);
}
示例10: _getValidationRulesBeforeSave
/**
* Validation rules for store
*
* @return \Zend_Validate_Interface|null
*/
protected function _getValidationRulesBeforeSave()
{
$validator = new \Magento\Framework\Validator\DataObject();
$storeLabelRule = new \Zend_Validate_NotEmpty();
$storeLabelRule->setMessage(__('Name is required'), \Zend_Validate_NotEmpty::IS_EMPTY);
$validator->addRule($storeLabelRule, 'name');
$storeCodeRule = new \Zend_Validate_Regex('/^[a-z]+[a-z0-9_]*$/');
$storeCodeRule->setMessage(__('The store code may contain only letters (a-z), numbers (0-9) or underscore (_),' . ' and the first character must be a letter.'), \Zend_Validate_Regex::NOT_MATCH);
$validator->addRule($storeCodeRule, 'code');
return $validator;
}
示例11: _getValidatorRegex
/**
*
* @param type $pattern
* @param type $messages_prefixed
* @return \Zend_Validate_Regex
*/
protected function _getValidatorRegex($pattern, $messages_prefixed = "")
{
$regex = new Zend_Validate_Regex(array('pattern' => $pattern));
$regex->setMessage(sprintf($this->_translate('ERROR_NOT_MATCH_PATTERN'), $this->_translate($messages_prefixed)), Zend_Validate_Regex::NOT_MATCH);
return $regex;
}
示例12: _addPasswordValidation
/**
* Add validation rules for the password management fields
*
* @param \Magento\Framework\Validator\Object $validator
* @return void
*/
protected function _addPasswordValidation(\Magento\Framework\Validator\Object $validator)
{
$passwordNotEmpty = new \Zend_Validate_NotEmpty();
$passwordNotEmpty->setMessage(__('Password is required field.'), \Zend_Validate_NotEmpty::IS_EMPTY);
$minPassLength = self::MIN_PASSWORD_LENGTH;
$passwordLength = new \Zend_Validate_StringLength(array('min' => $minPassLength, 'encoding' => 'UTF-8'));
$passwordLength->setMessage(__('Your password must be at least %1 characters.', $minPassLength), \Zend_Validate_StringLength::TOO_SHORT);
$passwordChars = new \Zend_Validate_Regex('/[a-z].*\\d|\\d.*[a-z]/iu');
$passwordChars->setMessage(__('Your password must include both numeric and alphabetic characters.'), \Zend_Validate_Regex::NOT_MATCH);
$validator->addRule($passwordNotEmpty, 'password')->addRule($passwordLength, 'password')->addRule($passwordChars, 'password');
if ($this->hasPasswordConfirmation()) {
$passwordConfirmation = new \Zend_Validate_Identical($this->getPasswordConfirmation());
$passwordConfirmation->setMessage(__('Your password confirmation must match your password.'), \Zend_Validate_Identical::NOT_SAME);
$validator->addRule($passwordConfirmation, 'password');
}
}
示例13: _createRegexValidator
protected function _createRegexValidator($pattern, $errorMessage)
{
$mobileRegexValidator = new Zend_Validate_Regex(array('pattern' => $pattern));
$mobileRegexValidator->setMessage($errorMessage, Zend_Validate_Regex::NOT_MATCH);
return $mobileRegexValidator;
}
示例14: overrideRegexValidator
public static function overrideRegexValidator($p_pattern, $p_msg)
{
$validator = new Zend_Validate_Regex($p_pattern);
$validator->setMessage($p_msg, Zend_Validate_Regex::NOT_MATCH);
return $validator;
}
示例15: amount
public function amount($acl = false, $fieldname = 'amount', $label = 'Ilość:', $required = null)
{
$method = $acl ? 'addSupervisedElement' : 'addElement';
$v = new Zend_Validate_Regex('/^[\\d]+(\\.[0-9]{1,2})?$/');
$v->setMessage("Not valid amount", Zend_Validate_Regex::NOT_MATCH);
$this->{$method}('text', $fieldname, array('label' => $label, 'required' => $required !== null ? $required : $this->default_policy, 'filters' => array(array('PregReplace', array('match' => '/,/', 'replace' => '.')))));
$this->getElement($fieldname)->addValidator($v);
$this->notEmpty($fieldname);
}