本文整理汇总了PHP中Zend_Validate_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Abstract类的具体用法?PHP Zend_Validate_Abstract怎么用?PHP Zend_Validate_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Validate_Abstract类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 [email protected]",
'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
示例16: _initTranslate
protected function _initTranslate()
{
// If in development, log untranslated messages
$params = array('scan' => Zend_Translate_Adapter::LOCALE_FILENAME, 'logUntranslated' => true);
$log = new Zend_Log();
if (APPLICATION_ENV == 'development') {
$log = new Zend_Log();
$log->addWriter(new Zend_Log_Writer_Firebug());
} else {
$log->addWriter(new Zend_Log_Writer_Null());
}
$params['log'] = $log;
$translate = new Zend_Translate('Csv', APPLICATION_PATH . '/install/languages', null, $params);
Zend_Registry::set('Zend_Translate', $translate);
Zend_Validate_Abstract::setDefaultTranslator($translate);
Engine_Sanity::setDefaultTranslator($translate);
Zend_Registry::set('Locale', new Zend_Locale());
return $translate;
}
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:19,代码来源:Bootstrap.php
示例17: setMessage
/**
* Sets the validation failure message template for a particular key
* Adds the ability to set messages to the attached hostname validator
*
* @param string $messageString
* @param string $messageKey OPTIONAL
* @return Zend_Validate_Abstract Provides a fluent interface
* @throws Zend_Validate_Exception
*/
public function setMessage($messageString, $messageKey = null)
{
if ($messageKey === null) {
$this->_options['hostname']->setMessage($messageString);
parent::setMessage($messageString);
return $this;
}
if (!isset($this->_messageTemplates[$messageKey])) {
$this->_options['hostname']->setMessage($messageString, $messageKey);
}
$this->_messageTemplates[$messageKey] = $messageString;
return $this;
}
开发者ID:Gradven,项目名称:what3.1.7,代码行数:22,代码来源:EmailAddress.php
示例18: testLocalTranslatorPreferredOverGlobalTranslator
public function testLocalTranslatorPreferredOverGlobalTranslator()
{
$this->testCanSetGlobalDefaultTranslator();
$translator = new Zend_Translate('array', array(), 'en');
$this->validator->setTranslator($translator);
$this->assertNotSame(Zend_Validate_Abstract::getDefaultTranslator(), $this->validator->getTranslator());
}
开发者ID:lortnus,项目名称:zf1,代码行数:7,代码来源:AbstractTest.php
示例19: isValid
/**
* Execute validate
*
* @param mixed $data Input data
* @access public
* @return boolean Result of validation
*/
public function isValid($data = null)
{
if (!is_null($this->_validatorTranslate)) {
Zend_Validate_Abstract::setDefaultTranslator($this->_validatorTranslate);
}
if (is_null($this->_rules)) {
// Set validation rules, which is defined in sub class.
$this->setRules();
}
$this->_validator = new Zend_Filter_Input($this->_filters, $this->_rules);
// If $data is null, use $_request data.
if (is_null($data)) {
$data = $this->_request;
}
$this->_validator->setData($data);
$ret = $this->_validator->isValid();
if ($ret === false) {
$errors = $this->_validator->getInvalid();
$messages = array();
if (is_array($errors)) {
foreach ($errors as $fields) {
foreach ($fields as $key => $val) {
$messages[] = $val;
}
}
}
$this->_errorMessages = $messages;
}
return $ret;
}
开发者ID:heavenshell,项目名称:gene,代码行数:37,代码来源:Validator.php
示例20: setTranslationObject
/**
* Translation object setup
*/
public function setTranslationObject()
{
// set language
if (isset($this->requestLang)) {
$lg = $this->requestLang;
} else {
$lg = $this->config->general->lang;
}
if ($lg == '' || !$lg) {
$lg = 'en';
}
$this->registry->set('language', $lg);
$translate = new Zend_Translate('csv', $this->corePath . '/application/language/en.csv', $this->config->general->lang);
$translate->setLocale($this->config->general->locale);
Zend_Validate_Abstract::setDefaultTranslator($translate);
Zend_Form::setDefaultTranslator($translate);
$this->registry->set('Zend_Translate', $translate);
$path1 = $this->corePath . '/application/language/';
$path2 = Sydney_Tools::getLocalPath() . '/application/language/';
// general global translations
if (is_dir($path1) && file_exists($path1 . $lg . '.csv')) {
$translate->addTranslation($path1 . $lg . '.csv', $lg);
}
if (is_dir($path2) && file_exists($path2 . $lg . '.csv')) {
$translate->addTranslation($path2 . $lg . '.csv', $lg);
}
// Create a log instance
if ($this->debugTranslationsNotFound) {
$writer = new Zend_Log_Writer_Stream(Sydney_Tools_Paths::getLogPath() . '/' . $lg . '-translation-notfound.log');
$log = new Zend_Log($writer);
// Attach it to the translation instance
$translate->setOptions(array('log' => $log, 'logUntranslated' => $this->config->general->env != 'PROD'));
}
}
开发者ID:Cryde,项目名称:sydney-core,代码行数:37,代码来源:Bootstrapper.php
注:本文中的Zend_Validate_Abstract类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论