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


PHP Zend_Validate_Abstract类代码示例

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


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

示例1: replaceMessages

 private function replaceMessages(Zend_Validate_Abstract $validator)
 {
     // replace $phrase to token
     $result = array();
     foreach ($validator->getMessageTemplates() as $token => $phrase) {
         $result[$token] = $token;
     }
     $validator->setMessages($result);
 }
开发者ID:kandy,项目名称:system,代码行数:9,代码来源:Element.php

示例2: _initLanguage

 protected function _initLanguage()
 {
     $locale = new Zend_Locale('de_AT');
     $translator = new Zend_Translate('array', APPLICATION_PATH . '/../resources/languages', 'de', array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     Zend_Locale::setDefault($locale);
 }
开发者ID:ThalerR,项目名称:GEBL,代码行数:7,代码来源:Bootstrap.php

示例3: _initTraslator

 protected function _initTraslator()
 {
     $siteOptions = $this->getOption('site');
     $translator = new Zend_Translate('array', APPLICATION_PATH . DIRECTORY_SEPARATOR . 'languages', $siteOptions['default']['language'], array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     return $translator;
 }
开发者ID:romikring,项目名称:rcalex,代码行数:7,代码来源:Bootstrap.php

示例4: startLocale

 protected function startLocale()
 {
     require_once "Zend/Translate.php";
     // silenciando strict até arrumar zend_locale
     date_default_timezone_set("America/Sao_Paulo");
     $i18n = new Zend_Translate('gettext', $this->config->system->path->base . '/lang/pt_BR.mo', 'pt_BR');
     Zend_Registry::set('i18n', $i18n);
     $translation_files = $this->config->system->path->base . "/lang/";
     foreach (scandir($translation_files) as $filename) {
         // Todos os arquivos .php devem ser classes de descrição de modulos
         if (preg_match("/.*\\.mo\$/", $filename)) {
             $translation_id = basename($filename, '.mo');
             if ($translation_id != "pt_BR") {
                 $i18n->addTranslation($translation_files . "/{$filename}", $translation_id);
             }
         }
     }
     require_once "Zend/Locale.php";
     if (Zend_Locale::isLocale($this->config->system->locale)) {
         $locale = $this->config->system->locale;
     } else {
         $locale = "pt_BR";
     }
     Zend_Registry::set('Zend_Locale', new Zend_Locale($locale));
     Zend_Locale::setDefault($locale);
     Zend_Locale_Format::setOptions(array("locale" => $locale));
     $i18n->setLocale($locale);
     Zend_Registry::set("Zend_Translate", $i18n);
     $zend_validate_translator = new Zend_Translate_Adapter_Array($this->config->system->path->base . "/lang/Zend_Validate/{$locale}/Zend_Validate.php", $locale);
     Zend_Validate_Abstract::setDefaultTranslator($zend_validate_translator);
 }
开发者ID:rootzig,项目名称:SNEP,代码行数:31,代码来源:Bootstrap.php

示例5: _processValidation

 /**
  * Process validation.
  *
  * @param string $validatorName $validatorName Zend validator name
  * @param mixed $input Input data to be validated
  * @param array $options Options to pass to validator
  * @throws iMSCP_Exception
  * @return bool bool TRUE if input data are valid, FALSE otherwise
  */
 protected function _processValidation($validatorName, $input, $options)
 {
     /** @var $validator Zend_Validate_Abstract */
     $validator = self::getZendValidator($validatorName);
     // Override validator default errors message if needed
     if (null != $this->_overrideMessagesFor) {
         if (isset($this->_messages[$this->_overrideMessagesFor])) {
             $defaultMessages = $validator->getMessageTemplates();
             $messages = $this->_messages[$this->_overrideMessagesFor];
             $validator->setMessages($messages);
         } else {
             throw new iMSCP_Exception(sprintf('Custom error messages for the %s validation method are not defined.', __CLASS__ . '::' . $this->_overrideMessagesFor));
         }
     }
     // Getting validator default options
     $defaultOptions = $validator->getOptions();
     // Setup validator options
     $validator->setOptions((array) $options);
     // Process validation
     if (!($retVal = $validator->isValid($input))) {
         $this->_lastValidationErrorMessages = array_merge($this->_lastValidationErrorMessages, $this->_lastValidator->getMessages());
     }
     // Reset default options on validator
     $validator->setOptions($defaultOptions);
     if (isset($defaultMessages)) {
         $validator->setMessages($defaultMessages);
         $this->_overrideMessagesFor = null;
     }
     return $retVal;
 }
开发者ID:svenjantzen,项目名称:imscp,代码行数:39,代码来源:Validate.php

示例6: _initValidateMessages

 protected function _initValidateMessages()
 {
     if (!$this->hasPluginResource('message')) {
         return;
     }
     $this->bootstrap('message');
     Zend_Validate_Abstract::setDefaultTranslator($this->getResource('message'));
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:8,代码来源:Bootstrap.php

示例7: routeShutdown

 /**	@brief Changement de langue.
  * 
  * Exploitation du cache de l'application pour stocker l'instance de Zend_Translate correspondant.
  * Si le cache n'est pas présent, une nouvelle instance est créée, puis stockée dans le cache de Zend_Translate.
  * 
  * @see		Controller/Plugin/Zend_Controller_Plugin_Abstract::routeShutdown()
  * @throws	exception Projet_Exception en cas d'erreur au cours de la requête.
  * @return	void.
  */
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     parent::routeShutdown($request);
     // Récupération du paramètre de langue passée dans l'URL
     $sLocal = $this->getRequest()->getParam('language') ? $this->getRequest()->getParam('language') : self::DEFAULT_LANGUAGE;
     // Récupération du local dans une combinaison du type "fr_FR"
     $aLanguage = explode("_", $sLocal);
     $sLanguage = isset($aLanguage[0]) ? $aLanguage[0] : self::DEFAULT_LANGUAGE;
     # Récupération de "fr"
     $sCountry = isset($aLanguage[1]) ? $aLanguage[1] : self::DEFAULT_COUNTRY;
     # Récupération de "FR"
     // Fonctionnalité réalisée si le fichier de langue n'existe pas
     if (!file_exists(LANGUAGE_PATH . $sLanguage . '.ini')) {
         $sLanguage = self::DEFAULT_LANGUAGE;
     }
     // Récupération du cache de la langue en cours dans le cache de Zend_Translate
     if ((bool) APP_CACHE) {
         $oCacheTranslate = Zend_Translate::getCache();
         $oTranslate = $oCacheTranslate->load($sLanguage);
     } else {
         $oTranslate = null;
     }
     // Fonctionnalité réalisé si
     if (empty($oTranslate)) {
         // Initialisation de la langue
         try {
             // Chargement du Zend_Translate
             $oTranslate = new Zend_Translate(array('adapter' => 'ini', 'content' => LANGUAGE_PATH . $sLanguage . '.ini', 'locale' => $sLocal));
             $sFichier = LANGUAGE_PATH . $sLanguage . '.php';
             if (file_exists($sFichier)) {
                 //traduction des erreurs de formulaires
                 $oTranslate->addTranslation(array('content' => new Zend_Translate('array', $sFichier, $sLanguage)));
             }
             if ((bool) APP_CACHE) {
                 // Enregistrement de la langue dans le cache
                 $oCacheTranslate = Zend_Translate::getCache();
                 $oCacheTranslate->save($oTranslate, $sLanguage);
             }
         } catch (Exception $e) {
             if ((bool) APP_CACHE) {
                 // Suppression du cache
                 $oCacheTranslate->remove($sLanguage);
             }
             // Création d'une exception au niveau du projet
             die($e->getMessage());
             throw new Projet_Exception($e->getMessage(), __METHOD__, $e);
         }
     }
     // Enregistrement du Zend_Translate dans les fonctionnalités de l'application
     Zend_Registry::set("Zend_Locale", $sLocal);
     Zend_Registry::set("Zend_Translate", $oTranslate);
     // Potentiellement inutile vu la ligne précédente...
     Zend_Form::setDefaultTranslator($oTranslate);
     Zend_Validate_Abstract::setDefaultTranslator($oTranslate);
     // Language par défaut pour toutes les routes
     Zend_Controller_Front::getInstance()->getRouter()->setGlobalParam('language', $sLocal);
 }
开发者ID:netixx,项目名称:Stock,代码行数:66,代码来源:Translate.php

示例8: _initTranslate

 public function _initTranslate()
 {
     try {
         $translate = new Zend_Translate('Array', APPLICATION_PATH . '/languages/es/Zend_Validate.php', 'pt_BR');
         Zend_Validate_Abstract::setDefaultTranslator($translate);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
开发者ID:conectapb,项目名称:sysagroweb,代码行数:9,代码来源:Bootstrap.php

示例9: _initTranslation

 protected function _initTranslation()
 {
     $bootstrap = $this->getApplication();
     $bootstrap->bootstrap('translate');
     $translator = $bootstrap->getResource('translate');
     if (method_exists($this, 'connect')) {
         $translator->connect();
     }
     Zend_Validate_Abstract::setDefaultTranslator($translator);
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:10,代码来源:Bootstrap.php

示例10: _initLocale

 protected function _initLocale()
 {
     Zend_Loader::loadClass('Zend_Locale');
     Zend_Locale::setDefault('fr');
     $session = new Zend_Session_Namespace();
     $session->locale = !empty($session->locale) ? $session->locale : DEFAULT_LOCALE;
     $translator = new Zend_Translate(array('adapter' => 'array', 'content' => APPLICATION_PATH . '/languages/' . $session->locale . '.php', 'locale' => $session->locale));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     Zend_Form::setDefaultTranslator($translator);
     Zend_Validate::setDefaultTranslator($translator);
     Zend_Registry::set("Zend_Translate", $translator);
 }
开发者ID:esandre,项目名称:CoeurDeTruffes,代码行数:12,代码来源:Bootstrap.php

示例11: init

 /**
  * Defined by Zend_Application_Resource_Resource
  *
  * @return Zend_View
  */
 public function init()
 {
     // locale Options
     $language = null;
     if (Zend_Registry::isRegistered("Zend_Locale")) {
         $locale = Zend_Registry::get("Zend_Locale");
         $language = $locale->getLanguage() . "_" . $locale->getRegion();
     }
     $options = $this->getOptions();
     if (!is_null($language) and isset($options["translate"])) {
         $options["translate"]["locale"] = $language;
         $translator = new Zend_Translate($options["translate"]);
         Zend_Validate_Abstract::setDefaultTranslator($translator);
     }
     Zend_Validate::addDefaultNamespaces('ZLayer_Validate');
 }
开发者ID:BGCX261,项目名称:zlayer-svn-to-git,代码行数:21,代码来源:Validate.php

示例12: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     $Zrt = new Zend_Session_Namespace('Zrt');
     if (!isset($Zrt->config->lang)) {
         $zl = new Zend_Locale();
         $Zrt->config->lang = $zl->getLanguage();
     }
     if ($Zrt->config->lang !== 'en' && $Zrt->config->lang !== 'de' && $Zrt->config->lang !== 'es' && $Zrt->config->lang !== 'pl') {
         $Zrt->config->lang = 'en';
     }
     if (!isset($Zrt->config->idlang)) {
         $_idioma = new Zrt_Models_Bussines_Idioma();
         $Zrt->config->idlang = $_idioma->getByPrefijo($Zrt->config->lang)->id;
     }
     $translate = new Zend_Translate(Zend_Translate::AN_GETTEXT, APPLICATION_PATH . '/configs/locale/', $Zrt->config->lang, array('scan' => Zend_Translate::LOCALE_FILENAME), $Zrt->config->lang);
     Zend_Registry::set('Zend_Translate', $translate);
     /* translate para Zend_Validate */
     $translator = new Zend_Translate(Zend_Translate::AN_ARRAY, APPLICATION_PATH . '/configs/resources/languages/', $Zrt->config->lang, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     /*         * variables para la vista* */
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     if (null === $viewRenderer->view) {
         $viewRenderer->initView();
     }
     $view = $viewRenderer->view;
     $view->assign('sessionZrt', $Zrt);
     /*         * variables para la vista* */
     /* translate para Zend_Validate */
     /* formulario idioma */
     /* fixme formulario idiomapais */
     //        $data = array( );
     //        if ( isset( $Zrt->config->lang ) )
     //            {
     //            if ( isset( $Zrt->config->idlang ) )
     //                {
     //                $data['idioma'] = $Zrt->config->idlang;
     //                }
     //            if ( isset( $Zrt->config->idpais ) )
     //                {
     //                $data['pais'] = $Zrt->config->idpais;
     //                }
     //            }
     /**/
     /* formulario idioma */
 }
开发者ID:josmel,项目名称:adminwap,代码行数:46,代码来源:LangSelector.php

示例13: _initDoctype

 protected function _initDoctype()
 {
     $this->bootstrap('view');
     $view = $this->getResource('view');
     $view->doctype('XHTML1_STRICT');
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     Zend_Registry::set('config', $config);
     $db = Zend_Db::factory($config->resources->db);
     Zend_Registry::set('db', $db);
     $locale = new Zend_Locale($config->resources->locale->default);
     $translate = new Zend_Translate('array', APPLICATION_PATH . '/../data/locales/' . $locale->getLanguage($config->resources->locale->default) . '.php', $config->resources->locale->default, array('disableNotices' => TRUE));
     $languages = array('en' => 'en_US');
     Zend_Validate_Abstract::setDefaultTranslator($translate);
     Zend_Registry::set('db', $db);
     Zend_Registry::set('languages', $languages);
     Zend_Registry::set('Zend_Translate', $translate);
     Zend_Registry::set('Zend_Locale', $locale);
 }
开发者ID:ankuradhey,项目名称:laundry,代码行数:18,代码来源:Bootstrap.php

示例14: _initTranslate

 /**
  * Referência:
  * http://www.codeforest.net/multilanguage-support-in-zend-framework
  */
 protected function _initTranslate()
 {
     $locale = new Zend_Locale();
     if (!Zend_Locale::isLocale($locale, TRUE, FALSE)) {
         if (!Zend_Locale::isLocale($locale, FALSE, FALSE)) {
             throw new Zend_Locale_Exception("The locale '{$locale}' is no known locale");
         }
         $locale = new Zend_Locale($locale);
     }
     //$locale = "pt_BR";
     $translatorArray = new Zend_Translate(array('adapter' => 'array', 'content' => APPLICATION_PATH . '/../resources/languages', 'locale' => $locale, 'scan' => Zend_Translate::LOCALE_DIRECTORY));
     $translate = new Zend_Translate('gettext', APPLICATION_PATH . "/langs/", $locale, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     $translate->addTranslation($translatorArray);
     $registry = Zend_Registry::getInstance();
     $registry->set('Zend_Translate', $translate);
     Zend_Validate_Abstract::setDefaultTranslator($translate);
     Zend_Form::setDefaultTranslator($translate);
 }
开发者ID:jovanepires,项目名称:sige,代码行数:22,代码来源:Bootstrap.php

示例15: _initValidatorTranslation

    protected function _initValidatorTranslation()
    {
        // traduction des messages d'erreur de validation
        $french = array(
	        'notAlnum' => "'%value%' ne contient pas que des lettres et/ou des chiffres.",
	        'notAlpha' => "'%value%' ne contient pas que des lettres.",
	        'notBetween' => "'%value%' n'est pas compris entre %min% et %max% inclus.",
	        'notBetweenStrict' => "'%value%' n'est pas compris entre %min% et %max% exclus.",
			'notSame' 	=> "Les deux champs ne correspondent pas.",
	        'dateNotYYYY-MM-DD'=> "'%value%' n'est pas une date au format AAAA-MM-JJ (exemple : 2000-12-31).",
	        'dateInvalid' => "'%value%' n'est pas une date valide.",
	        'dateFalseFormat' => "'%value%' n'est pas une date valide au format JJ/MM/AAAA (exemple : 31/12/2000).",
	        'notDigits' => "'%value%' ne contient pas que des chiffres.",
	        'emailAddressInvalid' => "'%value%' n'est pas une adresse mail valide au format adresse@domaine.",
	        'emailAddressInvalidFormat' => "'%value%' n'est pas une adresse mail valide au format adresse@domaine.tld",
	        'emailAddressInvalidHostname' => "'%hostname%' n'est pas un nom d'hôte DNS valide.",
	        'emailAddressInvalidMxRecord' => "'%hostname%' n'accepte pas l'adresse mail '%value%'.",
	        'emailAddressDotAtom' => "'%localPart%' ne respecte pas le format dot-atom.",
	        'emailAddressQuotedString' => "'%localPart%' ne respecte pas le format quoted-string.",
	        'emailAddressInvalidLocalPart' => "'%localPart%' n'est pas une adresse individuelle valide.",
	        'notFloat' => "'%value%' n'est pas un nombre décimal.",
	        'notGreaterThan' => "'%value%' n'est pas strictement supérieur à '%min%'.",
	        'notInt'=> "'%value%' n'est pas un nombre entier.",
	        'notLessThan' => "'%value%' n'est pas strictement inférieur à '%max%'.",
	        'isEmpty' => "Ce champ est vide : vous devez le compléter.",
	        'stringEmpty' => "Ce champ est vide : vous devez le compléter.",
	        'regexNotMatch' => "'%value%' ne respecte pas le format '%pattern%'.",
	        'stringLengthTooShort' => "'%value%' fait moins de %min% caractères.",
	        'stringLengthTooLong' => "'%value%' fait plus de %max% caractères.",
			'postcodeInvalid' => "'%value%' n'est pas du type attendu.",
	        'postcodeNoMatch' => "'%value%' n'est pas un code postal valide.",
			'notPhoneNumber' => "'%value%' ne semble pas être un numéro de téléphone français valide",
			'notIpAddress' => "'%value%' ne semble pas être une addresse IP valide"
        );

        $translate = new Zend_Translate('array', $french, 'fr_FR');
		Zend_Registry::set( 'translator', $translate );
        Zend_Validate_Abstract::setDefaultTranslator($translate);
    }
开发者ID:neotok,项目名称:PROJET1,代码行数:39,代码来源:Bootstrap.php


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