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


PHP Zend_Locale_Data::setCache方法代码示例

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


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

示例1: on_start

 public function on_start()
 {
     $this->error = Loader::helper('validation/error');
     if (USER_REGISTRATION_WITH_EMAIL_ADDRESS == true) {
         $this->set('uNameLabel', t('Email Address'));
     } else {
         $this->set('uNameLabel', t('Username'));
     }
     $txt = Loader::helper('text');
     if (strlen($_GET['uName'])) {
         // pre-populate the username if supplied, if its an email address with special characters the email needs to be urlencoded first,
         $this->set("uName", trim($txt->email($_GET['uName'])));
     }
     $languages = array();
     $locales = array();
     if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN')) {
         Loader::library('3rdparty/Zend/Locale');
         Loader::library('3rdparty/Zend/Locale/Data');
         $languages = Localization::getAvailableInterfaceLanguages();
         if (count($languages) > 0) {
             array_unshift($languages, 'en_US');
         }
         $locales = array('' => t('** Default'));
         Zend_Locale_Data::setCache(Cache::getLibrary());
         foreach ($languages as $lang) {
             $loc = new Zend_Locale($lang);
             $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', ACTIVE_LOCALE);
         }
     }
     $this->locales = $locales;
     $this->set('locales', $locales);
     $this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
 }
开发者ID:ricardomccerqueira,项目名称:rcerqueira.portfolio,代码行数:33,代码来源:login.php

示例2: __construct

 /**
  * @param string $locale
  */
 public function __construct($locale = P4A_LOCALE)
 {
     $cache = p4a::singleton()->getCache();
     if ($cache !== null) {
         Zend_Locale_Data::setCache($cache);
     }
     $this->setLocale($locale);
 }
开发者ID:eliudiaz,项目名称:p4a,代码行数:11,代码来源:p4a_i18n.php

示例3: setUp

 /**
  * Empty cache
  */
 public function setUp()
 {
     require_once 'Zend/Cache.php';
     $cache = Zend_Cache::factory('Core', 'File',
              array('lifetime' => 1, 'automatic_serialization' => true),
              array('cache_dir' => dirname(__FILE__) . '/_files/'));
     Zend_Locale_Data::setCache($cache);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:11,代码来源:DataTest.php

示例4: factory

 /**
  * @param string $backend
  * @param array  $frontendOptions
  * @param array  $backendOptions
  * @return Zend_Cache_Core
  */
 public function factory($backend, $frontendOptions = [], $backendOptions = [])
 {
     $backend = $this->createBackend($backend, $backendOptions);
     $cacheCore = $this->createCacheCore($frontendOptions);
     $cacheCore->setBackend($backend);
     \Zend_Locale_Data::setCache($cacheCore);
     \Zend_Db_Table_Abstract::setDefaultMetadataCache($cacheCore);
     return $cacheCore;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:15,代码来源:Cache.php

示例5: _initZendCache

 /**
  * Setup zend cache directory.
  *
  * @return void
  */
 protected function _initZendCache()
 {
     $this->bootstrap('Configuration');
     $config = $this->getResource('Configuration');
     $frontendOptions = array('lifetime' => 600, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => $config->workspacePath . '/cache/');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Translate::setCache($cache);
     Zend_Locale::setCache($cache);
     Zend_Locale_Data::setCache($cache);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     return $cache;
 }
开发者ID:alexukua,项目名称:opus4,代码行数:18,代码来源:Base.php

示例6: view

	public function view() {
		Loader::library('3rdparty/Zend/Locale');
		Loader::library('3rdparty/Zend/Locale/Data');
		$languages = Localization::getAvailableInterfaceLanguages();
		if (count($languages) > 0) { 
			array_unshift($languages, 'en_US');
		}
		$locales = array();
		Zend_Locale_Data::setCache(Cache::getLibrary());
		foreach($languages as $lang) {
			$loc = new Zend_Locale($lang);
			$locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', $lang);
		}
		$this->set('LANGUAGE_CHOOSE_ON_LOGIN', Config::get('LANGUAGE_CHOOSE_ON_LOGIN'));
		$this->set('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED', Config::get('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED'));
		$this->set('interfacelocales', $locales);
		$this->set('languages', $languages);
	}
开发者ID:nveid,项目名称:concrete5,代码行数:18,代码来源:multilingual.php

示例7: getLocale

 /**
  * Retrieve locale object
  *
  * @return Zend_Locale
  */
 public function getLocale()
 {
     if (!$this->_locale) {
         Zend_Locale_Data::setCache(Mage::app()->getCache());
         $this->_locale = new Zend_Locale($this->getLocaleCode());
     } elseif ($this->_locale->__toString() != $this->_localeCode) {
         $this->setLocale($this->_localeCode);
     }
     return $this->_locale;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:15,代码来源:Locale.php

示例8: __construct

 public function __construct($locale = null)
 {
     Zend_Locale_Data::setCache(Mage::app()->getCache());
     $this->setLocale($locale);
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:5,代码来源:Locale.php

示例9: setZendFrameworkCaches

 /**
  * @param null $cache
  */
 public static function setZendFrameworkCaches($cache = null)
 {
     \Zend_Locale::setCache($cache);
     \Zend_Locale_Data::setCache($cache);
     \Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:9,代码来源:Cache.php

示例10: setOptions

 /**
  * Sets class wide options, if no option was given, the actual set options will be returned
  *
  * @param  array  $options  Options to set
  * @throws Zend_Date_Exception
  * @return Options array if no option was given
  */
 public static function setOptions(array $options = array())
 {
     if (empty($options)) {
         return self::$_Options;
     }
     foreach ($options as $name => $value) {
         $name = strtolower($name);
         if (isset(self::$_Options[$name])) {
             switch ($name) {
                 case 'format_type':
                     if (strtolower($value) != 'php' && strtolower($value) != 'iso') {
                         throw new Zend_Date_Exception("Unknown format type ({$value}) for dates, only 'iso' and 'php' supported", $value);
                     }
                     break;
                 case 'fix_dst':
                     if (!is_bool($value)) {
                         throw new Zend_Date_Exception("'fix_dst' has to be boolean", $value);
                     }
                     break;
                 case 'extend_month':
                     if (!is_bool($value)) {
                         throw new Zend_Date_Exception("'extend_month' has to be boolean", $value);
                     }
                     break;
                 case 'cache':
                     Zend_Locale_Data::setCache($value);
                     break;
             }
             self::$_Options[$name] = $value;
         } else {
             throw new Zend_Date_Exception("Unknown option: {$name} = {$value}");
         }
     }
 }
开发者ID:renatosoares,项目名称:blog-zend1,代码行数:41,代码来源:Date.php

示例11: setOptions

    /**
     * Sets class wide options, if no option was given, the actual set options will be returned
     *
     * @param  array  $options  Options to set
     * @throws Zend_Date_Exception
     * @return Options array if no option was given
     */
    public static function setOptions(array $options = array())
    {
        if (empty($options)) {
            return self::$_Options;
        }
        foreach ($options as $name => $value) {
            $name  = strtolower($name);

            if (array_key_exists($name, self::$_Options)) {
                switch($name) {
                    case 'format_type' :
                        if ((strtolower($value) != 'php') && (strtolower($value) != 'iso')) {
                            throw new Zend_Date_Exception("Unknown format type ($value) for dates, only 'iso' and 'php' supported", $value);
                        }
                        break;
                    case 'fix_dst' :
                        if (!is_bool($value)) {
                            throw new Zend_Date_Exception("'fix_dst' has to be boolean", $value);
                        }
                        break;
                    case 'extend_month' :
                        if (!is_bool($value)) {
                            throw new Zend_Date_Exception("'extend_month' has to be boolean", $value);
                        }
                        break;
                    case 'cache' :
                        if (!$value instanceof Zend_Cache_Core) {
                            throw new Zend_Date_Exception("Instance of Zend_Cache expected");
                        }
                        parent::$_cache = $value;
                        Zend_Locale_Data::setCache($value);
                        break;
                }
                self::$_Options[$name] = $value;
            }
            else {
                throw new Zend_Date_Exception("Unknown option: $name = $value");
            }
        }
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:47,代码来源:Date.php

示例12: addCountryElement

 public function addCountryElement($default = '')
 {
     require_once 'Zend/Validate/NotEmpty.php';
     $notEmpty = new Zend_Validate_NotEmpty();
     $notEmpty->setMessages(array(Zend_Validate_NotEmpty::IS_EMPTY => $this->getTranslator()->translate('accountFormHintCountryNotEmpty')));
     if ($this->getPermiso()->getEnv()->hasCache()) {
         require_once 'Zend/Locale/Data.php';
         Zend_Locale_Data::setCache($this->getPermiso()->getEnv()->getCache());
     }
     $countries = array();
     require_once 'Zend/Locale/Data.php';
     $territories = Zend_Locale_Data::getList($this->getPermiso()->getEnv()->getLocaleInstance(), 'territory');
     foreach ($territories as $key => $name) {
         if (preg_match('/^[A-Z]{2,2}$/', $key)) {
             # filter out undesired countries
             if (!preg_match('/(ZZ)/', $key)) {
                 $countries[$key] = $name;
             }
         }
     }
     asort($countries);
     $countries = array_merge(array('' => $this->getTranslator()->translate('accountFormFieldvalCountry')), $countries);
     require_once 'Zend/Form/Element/Select.php';
     $element = new Zend_Form_Element_Select($this->getCountryParam());
     $element->clearDecorators()->addDecorator('viewHelper')->addValidator($notEmpty)->setValue($default)->setDisableTranslator(true)->setRequired(true);
     // set options directly for massively enhanced performance
     $element->options = $countries;
     $this->addElement($element);
     return $this;
 }
开发者ID:sitengine,项目名称:sitengine,代码行数:30,代码来源:Form.php

示例13: setOptions

 /**
  * Sets class wide options, if no option was given, the actual set options will be returned
  *
  * @param  array  $options  Options to set
  * @throws Zend_Date_Exception
  * @return Options array if no option was given
  */
 public static function setOptions(array $options = array())
 {
     if (empty($options)) {
         return self::$_options;
     }
     foreach ($options as $name => $value) {
         $name = strtolower($name);
         if (array_key_exists($name, self::$_options)) {
             switch ($name) {
                 case 'format_type':
                     if (strtolower($value) != 'php' && strtolower($value) != 'iso') {
                         require_once 'Zend/Date/Exception.php';
                         throw new Zend_Date_Exception("Unknown format type ({$value}) for dates, only 'iso' and 'php' supported", 0, null, $value);
                     }
                     break;
                 case 'fix_dst':
                     if (!is_bool($value)) {
                         require_once 'Zend/Date/Exception.php';
                         throw new Zend_Date_Exception("'fix_dst' has to be boolean", 0, null, $value);
                     }
                     break;
                 case 'extend_month':
                     if (!is_bool($value)) {
                         require_once 'Zend/Date/Exception.php';
                         throw new Zend_Date_Exception("'extend_month' has to be boolean", 0, null, $value);
                     }
                     break;
                 case 'cache':
                     if ($value === null) {
                         parent::$_cache = null;
                     } else {
                         if (!$value instanceof Zend_Cache_Core) {
                             require_once 'Zend/Date/Exception.php';
                             throw new Zend_Date_Exception("Instance of Zend_Cache expected");
                         }
                         parent::$_cache = $value;
                         parent::$_cacheTags = Zend_Date_DateObject::_getTagSupportForCache();
                         Zend_Locale_Data::setCache($value);
                     }
                     break;
                 case 'timesync':
                     if ($value === null) {
                         parent::$_defaultOffset = 0;
                     } else {
                         if (!$value instanceof Zend_TimeSync_Protocol) {
                             require_once 'Zend/Date/Exception.php';
                             throw new Zend_Date_Exception("Instance of Zend_TimeSync expected");
                         }
                         $date = $value->getInfo();
                         parent::$_defaultOffset = $date['offset'];
                     }
                     break;
             }
             self::$_options[$name] = $value;
         } else {
             require_once 'Zend/Date/Exception.php';
             throw new Zend_Date_Exception("Unknown option: {$name} = {$value}");
         }
     }
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:67,代码来源:Date.php

示例14: checkOptions

    /**
     * Internal function for checking the options array of proper input values
     * See {@link setOptions()} for details.
     *
     * @param  array  $options  Array of options, keyed by option name: format_type = 'iso' | 'php', fix_date = true | false,
     *                          locale = Zend_Locale | locale string, precision = whole number between -1 and 30
     * @throws Zend_Locale_Exception
     * @return Options array if no option was given
     */
    private static function checkOptions(array $options = array())
    {
        if (count($options) == 0) {
            return self::$_Options;
        }
        foreach ($options as $name => $value) {
            $name  = strtolower($name);
            if ($name !== 'locale') {
                if (gettype($value) === 'string') {
                    $value = strtolower($value);
                }
            }

            if (array_key_exists($name, self::$_Options)) {
                switch($name) {
                    case 'number_format' :
                        if ($value == 'standard') {
                            $locale = self::$_Options['locale'];
                            if (isset($options['locale'])) {
                                $locale = $options['locale'];
                            }
                            $options['number_format'] = Zend_Locale_Data::getContent($locale, 'decimalnumber');
                        } else if ((gettype($value) !== 'string') and ($value !== NULL)) {
                            require_once 'Zend/Locale/Exception.php';
                            throw new Zend_Locale_Exception("Unknown number format type '" . gettype($value) . "'. "
                                . "Format '$value' must be a valid number format string.");
                        }
                        break;
                    case 'date_format' :
                        if ($value == 'standard') {
                            $locale = self::$_Options['locale'];
                            if (isset($options['locale'])) {
                                $locale = $options['locale'];
                            }
                            $options['date_format'] = Zend_Locale_Format::getDateFormat($locale);
                        } else if ((gettype($value) !== 'string') and ($value !== NULL)) {
                            require_once 'Zend/Locale/Exception.php';
                            throw new Zend_Locale_Exception("Unknown dateformat type '" . gettype($value) . "'. "
                                . "Format '$value' must be a valid ISO or PHP date format string.");
                        } else {
                            if (((array_key_exists('format_type', $options)) and ($options['format_type'] == 'php')) or
                                ((!array_key_exists('format_type', $options)) and (self::$_Options['format_type'] == 'php'))) {
                                $options['date_format'] = Zend_Locale_Format::convertPhpToIsoFormat($value);
                            }
                        }
                        break;
                    case 'format_type' :
                        if (($value != 'php') && ($value != 'iso')) {
                            require_once 'Zend/Locale/Exception.php';
                            throw new Zend_Locale_Exception("Unknown date format type '$value'. Only 'iso' and 'php'"
                               . " are supported.");
                        }
                        break;
                    case 'fix_date' :
                        if (($value !== true) && ($value !== false)) {
                            require_once 'Zend/Locale/Exception.php';
                            throw new Zend_Locale_Exception("Enabling correction of dates must be either true or false"
                                . "(fix_date='$value').");
                        }
                        break;
                    case 'locale' :
                        if (gettype($value) === 'string' && strtolower($value) == 'standard') {
                            $options['locale'] = new Zend_Locale();
                        } else if (!empty($value) && (!Zend_Locale::isLocale($value))) {
                            require_once 'Zend/Locale/Exception.php';
                            throw new Zend_Locale_Exception("'" .
                                (gettype($value) === 'object' ? get_class($value) : $value)
                                . "' is not a known locale.");
                        }
                        break;
                    case 'cache' :
                        if ($value instanceof Zend_Cache_Core) {
                            Zend_Locale_Data::setCache($value);
                        }
                        break;
                    case 'precision' :
                        if ($value === NULL) {
                            $value = -1;
                        }
                        if (($value < -1) || ($value > 30)) {
                            require_once 'Zend/Locale/Exception.php';
                            throw new Zend_Locale_Exception("'$value' precision is not a whole number less than 30.");
                        }
                        break;
                }
            }
            else {
                require_once 'Zend/Locale/Exception.php';
                throw new Zend_Locale_Exception("Unknown option: '$name' = '$value'");
            }
        }
//.........这里部分代码省略.........
开发者ID:jorgenils,项目名称:zend-framework,代码行数:101,代码来源:Format.php

示例15: _initLocale

 protected function _initLocale()
 {
     // Translate needs to be initialized before Modules, so _initTranslate() could
     // not load the "User" couldn't be initialized then.  Thus, we must assign
     // the language over here if it is a user.
     // Try to pull from various sources
     $viewer = Engine_Api::_()->user()->getViewer();
     $timezone = Engine_Api::_()->getApi('settings', 'core')->core_locale_timezone;
     if ($viewer->getIdentity()) {
         $locale = $viewer->locale;
         $language = $viewer->language;
         $timezone = $viewer->timezone;
     } else {
         if (!empty($_COOKIE['en4_language']) && !empty($_COOKIE['en4_locale'])) {
             $locale = $_COOKIE['en4_locale'];
             $language = $_COOKIE['en4_language'];
         } else {
             if (!empty($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
                 $l = new Zend_Locale(Zend_Locale::BROWSER);
                 $locale = $l->toString();
                 $language = $l->getLanguage();
             } else {
                 $locale = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'auto');
                 $language = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'auto');
             }
         }
     }
     Zend_Registry::set('timezone', $timezone);
     // Make sure it's valid
     try {
         $locale = Zend_Locale::findLocale($locale);
     } catch (Exception $e) {
         $locale = 'en_US';
     }
     $localeObject = new Zend_Locale($locale);
     Zend_Registry::set('Locale', $localeObject);
     // Set in locale and language
     $translate = $this->getContainer()->translate;
     $defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->core_locale_locale;
     $localeLanguage = $localeObject->getLanguage();
     $ls = array($locale, $language, $localeLanguage, $defaultLanguage, 'en');
     foreach ($ls as $l) {
         if ($translate->isAvailable($l)) {
             $translate->setLocale($l);
             break;
         }
     }
     if (!$viewer->getIdentity()) {
         if (empty($_COOKIE['en4_language'])) {
             setcookie('en4_language', $translate->getLocale(), time() + 86400 * 365, '/');
         }
         if (empty($_COOKIE['en4_locale'])) {
             setcookie('en4_locale', $locale, time() + 86400 * 365, '/');
         }
     }
     // Set cache
     Zend_Locale_Data::setCache($this->getContainer()->cache);
     // Get orientation
     $localeData = Zend_Locale_Data::getList($localeObject->__toString(), 'layout');
     $this->getContainer()->layout->orientation = $localeData['characters'];
     return $localeObject;
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:62,代码来源:Bootstrap.php


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