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


PHP Zend_Validate_Int::setLocale方法代码示例

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


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

示例1: testSettingLocales

 /**
  * Ensures that set/getLocale() works
  */
 public function testSettingLocales()
 {
     $this->_validator->setLocale('de');
     $this->assertEquals('de', $this->_validator->getLocale());
     $this->assertEquals(false, $this->_validator->isValid('10 000'));
     $this->assertEquals(true, $this->_validator->isValid('10.000'));
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:10,代码来源:IntTest.php

示例2: validate

 /**
  * 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);
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:50,代码来源:settings.php

示例3: validate

 /**
  * validates feed input
  *
  * @return Zend_Filter_Input|array validator or error message array
  * @param array $data for validating
  * @param int $validateid (optional) indicates whether id has to be validated
  */
 protected function validate($data, $validateId = false)
 {
     // define filter
     $filterTrim = new Zend_Filter_StringTrim();
     $filter = array('name' => $filterTrim, 'url' => $filterTrim, 'category' => $filterTrim, 'priority' => $filterTrim, 'favicon' => $filterTrim, 'filter' => $filterTrim, 'source' => $filterTrim);
     if (!isset($data['source'])) {
         $data['source'] = '';
     }
     // define validators
     $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);
     $validatorCategoryId = new application_validate_categoryid();
     $validatorCategoryId->setMessage(Zend_Registry::get('language')->translate("category doesn't exists"), application_validate_categoryid::NOT_EXISTS);
     $validatorSource = new application_validate_source();
     $validatorSource->setMessage(Zend_Registry::get('language')->translate("source doesn't exists"), application_validate_source::NOT_EXISTS);
     $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);
     $validatorNum->setMessage(Zend_Registry::get('language')->translate('Only digits allowed'), Zend_Validate_Int::INVALID);
     $validatorDuplicateFeed = new application_validate_duplicatefeed($data['source'], $validateId ? $data['id'] : false);
     $validatorDuplicateFeed->setMessage(Zend_Registry::get('language')->translate("feed already exists"), application_validate_duplicatefeed::ALREADY_EXISTS);
     $validators = array('name' => array($validatorNotEmpty, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED), 'url' => array($validatorDuplicateFeed, Zend_Filter_Input::ALLOW_EMPTY => true, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'category' => array($validatorNum, $validatorCategoryId, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL), 'priority' => array($validatorNum, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED), 'favicon' => array(Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL, Zend_Filter_Input::ALLOW_EMPTY => true), 'filter' => array(Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_OPTIONAL, Zend_Filter_Input::ALLOW_EMPTY => true), 'source' => array($validatorNotEmpty, $validatorSource, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED));
     // read from source whether url is optional or not
     if ($validatorSource->isValid($data['source'])) {
         $plugin = Zend_Controller_Action_HelperBroker::getStaticHelper('pluginloader')->getPlugin($data['source']);
         if (!$plugin->sourceOptional && $plugin->source !== false) {
             $validators['url'] = array($validatorNotEmpty, $validatorDuplicateFeed, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED);
         }
     }
     // insert filter and validate rules for id
     if ($validateId !== false) {
         $validatorFeedId = new application_validate_feedid();
         $validatorFeedId->setMessage(Zend_Registry::get('language')->translate("feed doesn't exists"), application_validate_feedid::NOT_EXISTS);
         $filter['id'] = $filterTrim;
         $validators['id'] = array($validatorNum, $validatorFeedId, Zend_Filter_Input::PRESENCE => Zend_Filter_Input::PRESENCE_REQUIRED);
     }
     // 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);
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:48,代码来源:feeds.php


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