当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Validate_Regex类代码示例

本文整理汇总了PHP中Zend_Validate_Regex的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Regex类的具体用法?PHP Zend_Validate_Regex怎么用?PHP Zend_Validate_Regex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Validate_Regex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:omusico,项目名称:logica,代码行数:35,代码来源:ChangePasswordForm.php

示例2: _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'));
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:26,代码来源:Form.php

示例3: getPreview

 public static function getPreview($page, $crop = false)
 {
     $websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
     $configHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('config');
     $path = (bool) $crop ? $websiteHelper->getPreviewCrop() : $websiteHelper->getPreview();
     if (is_numeric($page)) {
         $page = Application_Model_Mappers_PageMapper::getInstance()->find(intval($page));
     }
     if ($page instanceof Application_Model_Models_Page) {
         $validator = new Zend_Validate_Regex('~^https?://.*~');
         $preview = $page->getPreviewImage();
         if (!is_null($preview)) {
             if ($validator->isValid($preview)) {
                 return $preview;
             } else {
                 $websiteUrl = $configHelper->getConfig('mediaServers') ? Tools_Content_Tools::applyMediaServers($websiteHelper->getUrl()) : $websiteHelper->getUrl();
                 $previewPath = $websiteHelper->getPath() . $path . $preview;
                 if (is_file($previewPath)) {
                     return $websiteUrl . $path . $preview;
                 }
             }
         }
     }
     return $websiteHelper->getUrl() . self::PLACEHOLDER_NOIMAGE;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:25,代码来源:Tools.php

示例4: 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));
 }
开发者ID:neverstoplwy,项目名称:contrib-webacula,代码行数:60,代码来源:FormRole.php

示例5: 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);
     }
 }
开发者ID:staser,项目名称:webacula,代码行数:34,代码来源:FormLogin.php

示例6: _beforeSave

 /**
  * Processing object before save data
  *
  * @return Mage_Core_Model_Abstract
  */
 protected function _beforeSave()
 {
     //validate attribute_code
     $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^[a-z][a-z_0-9]{1,254}$/'));
     if (!$validatorAttrCode->isValid($this->getAttributeCode())) {
         Mage::throwException(Mage::helper('mep')->__('Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.'));
     }
     return parent::_beforeSave();
 }
开发者ID:tschifftner,项目名称:Magento-MEP,代码行数:14,代码来源:Mapping.php

示例7: isValid

 /**
  * Validate element value
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($value, $context = null)
 {
     $v1 = new Zend_Validate_Regex('/^\\d{4}\\-\\d{2}\\-\\d{2}$/');
     $v2 = new Zend_Validate_Date(array('format' => 'Y-m-d'));
     if (!$v1->isValid($value) || !$v2->isValid($value)) {
         $this->_messages = array(self::INVALID_DATE_FORMAT => $this->_templateMessages[self::INVALID_DATE_FORMAT]);
         return false;
     }
     return true;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:17,代码来源:DateInterval.php

示例8: isValid

 public function isValid($value)
 {
     $validator = new Zend_Validate_Regex(array('pattern' => '~^(http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\'/\\\\+&amp;%\\$#\\=\\~])*[^\\.\\,\\)\\(\\s]$~'));
     $this->_setValue($value);
     if (!$validator->isValid($value)) {
         $this->_error(self::URL);
         return false;
     }
     return true;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:10,代码来源:UrlRegex.php

示例9: _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);
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:11,代码来源:Form.php

示例10: validate

 public function validate($object)
 {
     $validator = new Zend_Validate_Regex(array('pattern' => '/(^\\d+(\\.{0,1}\\d{0,})(;\\d+(\\.{0,1}\\d{0,}))+$)|^$/'));
     $attrCode = $this->getAttribute()->getAttributeCode();
     $value = $object->getData($attrCode);
     $price = $object->getData('price');
     if (!($price > 0)) {
         if (!$validator->isValid($value)) {
             Mage::throwException('Not correct value. Example: 100;200.33;300.56');
         }
     }
 }
开发者ID:bevello,项目名称:bevello,代码行数:12,代码来源:Additionalprice.php

示例11: isValid

 /**
  * Modified function validates input pattern.
  * @param string $value
  * @return boolean - True only if date input is valid for Opus requirements
  */
 public function isValid($value)
 {
     $this->_setValue($value);
     // Check first if input matches expected pattern
     $datePattern = $this->getInputPattern();
     $validator = new Zend_Validate_Regex($datePattern);
     if (!$validator->isValid($value)) {
         $this->_error(Zend_Validate_Date::FALSEFORMAT);
         return false;
     }
     // Perform check in parent class
     return parent::isValid($value);
 }
开发者ID:alexukua,项目名称:opus4,代码行数:18,代码来源:Date.php

示例12: login

 public function login($username, $password)
 {
     // Remove backslashes
     $username = str_replace("\\", "", $username);
     // filter data from the user
     $f = new Zend_Filter_StripTags();
     $this->user = $f->filter($username);
     $this->pwd = $f->filter($password);
     // Validate credentials
     if (empty($username)) {
         throw new Exception('Invalid username');
     }
     if (empty($password)) {
         throw new Exception('Invalid password');
     }
     // Username can be alphanum with dash, underscore, @, periods and apostrophe
     $usernameValidator = new Zend_Validate_Regex('/^([A-Za-z0-9-_@\\.\']+)$/');
     if (!$usernameValidator->isValid($username)) {
         throw new Exception('Please enter a valid username');
     }
     // setup Zend_Auth adapter for a database table
     $this->db->setFetchMode(Zend_Db::FETCH_ASSOC);
     $authAdapter = new Zend_Auth_Adapter_DbTable($this->db);
     $authAdapter->setTableName('ol_admins');
     $authAdapter->setIdentityColumn('user');
     $authAdapter->setCredentialColumn('password');
     // Set the input credential values to authenticate against
     $authAdapter->setIdentity($username);
     $authAdapter->setCredential(md5($password));
     $authAdapter->getDbSelect()->where('active = ?', 1);
     // MUST be an active account
     // do the authentication
     $result = $this->auth->authenticate($authAdapter);
     $this->db->setFetchMode(Zend_Db::FETCH_OBJ);
     if (!$result->isValid()) {
         throw new Exception('Login failed.');
     }
     //var_dump($authAdapter->getResultRowObject()); exit();
     // Update last login date
     $users = new OneLogin_Acl_Users();
     $users->updateLastLoginDate($username);
     // Define object and set auth information
     $objUser = new stdClass();
     $objUser->user_id = $authAdapter->getResultRowObject()->id;
     $objUser->api_user_username = $username;
     $objUser->api_user_password = $password;
     $objUser->active = $authAdapter->getResultRowObject()->active;
     $this->auth->getStorage()->write($objUser);
 }
开发者ID:juliomolinero,项目名称:onelogin-api-php,代码行数:49,代码来源:Login.php

示例13: validate

 private function validate()
 {
     $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^[a-z][a-z_0-9]{1,254}$/'));
     if (!$validatorAttrCode->isValid($this->code)) {
         return false;
     }
     if (empty($this->primaryLabel)) {
         return false;
     }
     /** @var $validatorInputType Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator */
     $validatorInputType = Mage::getModel('eav/adminhtml_system_config_source_inputtype_validator');
     if (!$validatorInputType->isValid($this->inputType)) {
         return false;
     }
     return true;
 }
开发者ID:Vitafy,项目名称:M2E,代码行数:16,代码来源:Builder.php

示例14: testBasic

 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     /**
      * The elements of each array are, in order:
      *      - pattern
      *      - expected validation result
      *      - array of test input values
      */
     $valuesExpected = array(array('/[a-z]/', true, array('abc123', 'foo', 'a', 'z')), array('/[a-z]/', false, array('123', 'A')));
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_Regex($element[0]);
         foreach ($element[2] as $input) {
             $this->assertEquals($element[1], $validator->isValid($input));
         }
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:21,代码来源:RegexTest.php

示例15: isValid

 /**
  * Validate element value
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($value, $context = array())
 {
     // Optional?
     if (empty($value) && $this->_optional) {
         return true;
     }
     $lengthValidator = new Zend_Validate_StringLength(array('min' => 5, 'max' => 62));
     if (!$lengthValidator->isValid($value)) {
         $this->_messages = $lengthValidator->getMessages();
         return false;
     }
     $regexValidator = new Zend_Validate_Regex(array('pattern' => '/^(?!(RAC|LAC|SGSN|RNC|\\.))(\\.?[0-9a-z]+(\\-[0-9a-z]+)*)+(?<!(\\.GPRS$))$/i'));
     if (!$regexValidator->isValid($value)) {
         $this->_messages = $regexValidator->getMessages();
         return false;
     }
     return true;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:25,代码来源:Apn.php


注:本文中的Zend_Validate_Regex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。