コード例 #1
0
 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");
 }
コード例 #2
0
ファイル: p4a_i18n.php プロジェクト: eliudiaz/p4a
 /**
  * @param string $locale
  */
 public function __construct($locale = P4A_LOCALE)
 {
     $cache = p4a::singleton()->getCache();
     if ($cache !== null) {
         Zend_Locale_Data::setCache($cache);
     }
     $this->setLocale($locale);
 }
コード例 #3
0
ファイル: DataTest.php プロジェクト: jorgenils/zend-framework
 /**
  * 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);
 }
コード例 #4
0
ファイル: Cache.php プロジェクト: GerDner/luck-docker
 /**
  * @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;
 }
コード例 #5
0
ファイル: Base.php プロジェクト: alexukua/opus4
 /**
  * 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;
 }
コード例 #6
0
ファイル: multilingual.php プロジェクト: nveid/concrete5
	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);
	}
コード例 #7
0
ファイル: Locale.php プロジェクト: codercv/urbansurprisedev
 /**
  * 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;
 }
コード例 #8
0
ファイル: Locale.php プロジェクト: arslbbt/mangentovies
 public function __construct($locale = null)
 {
     Zend_Locale_Data::setCache(Mage::app()->getCache());
     $this->setLocale($locale);
 }
コード例 #9
0
ファイル: Cache.php プロジェクト: Gerhard13/pimcore
 /**
  * @param null $cache
  */
 public static function setZendFrameworkCaches($cache = null)
 {
     \Zend_Locale::setCache($cache);
     \Zend_Locale_Data::setCache($cache);
     \Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
 }
コード例 #10
0
ファイル: Date.php プロジェクト: renatosoares/blog-zend1
 /**
  * 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}");
         }
     }
 }
コード例 #11
0
ファイル: Date.php プロジェクト: jorgenils/zend-framework
    /**
     * 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");
            }
        }
    }
コード例 #12
0
ファイル: Form.php プロジェクト: sitengine/sitengine
 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;
 }
コード例 #13
0
 /**
  * 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}");
         }
     }
 }
コード例 #14
0
ファイル: Format.php プロジェクト: jorgenils/zend-framework
    /**
     * 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'");
            }
        }
        return $options;
    }
コード例 #15
0
ファイル: Bootstrap.php プロジェクト: hoalangoc/ftf
 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;
 }
コード例 #16
0
ファイル: Bootstrap.php プロジェクト: nhp/shopware-4
    /**
     * Init cache method
     *
     * @return Zend_Cache_Core
     */
    protected function initCache()
    {
        $config = Shopware()->getOption('cache');

        $cache = Zend_Cache::factory(
            'Core',
            $config['backend'],
            $config['frontendOptions'],
            $config['backendOptions']
        );

        Zend_Locale_Data::setCache($cache);

        return $cache;
    }
コード例 #17
0
ファイル: Locale.php プロジェクト: ronseigel/agent-ohm
 /**
  * Set locale
  *
  * @param   string $locale
  * @return  Mage_Core_Model_Locale
  */
 public function setLocale($locale = null)
 {
     AO::dispatchEvent('core_locale_set_locale', array('locale' => $this));
     Zend_Locale_Data::setCache(AO::app()->getCache());
     if ($locale === null) {
         $locale = $this->_localeCode;
     }
     $this->_locale = new Zend_Locale($locale);
     return $this;
 }
コード例 #18
0
ファイル: Currency.php プロジェクト: ismaelmelus/home
 /**
  * Internal method for checking the options array
  *
  * @param  array $options
  * @return array
  * @throws Zend_Currency_Exception
  */
 private function checkOptions(array $options = array())
 {
     if (count($options) == 0) {
         return $this->_options;
     }
     foreach ($options as $name => $value) {
         $name = strtolower($name);
         if ($name !== 'format') {
             if (gettype($value) === 'string') {
                 $value = strtolower($value);
             }
         }
         if (array_key_exists($name, $this->_options)) {
             switch ($name) {
                 case 'position':
                     if ($value !== self::STANDARD and $value !== self::RIGHT and $value !== self::LEFT) {
                         throw new Zend_Currency_Exception("Unknown position '" . $position . "'");
                     }
                     if ($value === self::STANDARD) {
                         $options['position'] = $this->_updateFormat();
                     }
                     break;
                 case 'format':
                     if (!empty($value) && !Zend_Locale::isLocale($value)) {
                         throw new Zend_Currency_Exception("'" . (gettype($value) === 'object' ? get_class($value) : $value) . "' is not a known locale.");
                     }
                     break;
                 case 'display':
                     if (!is_numeric($value)) {
                     }
                     if (is_numeric($value) and $value !== self::NO_SYMBOL and $value !== self::USE_SYMBOL and $value !== self::USE_SHORTNAME and $value !== self::USE_NAME) {
                         throw new Zend_Currency_Exception("Unknown display '{$display}'");
                         Zend_Locale_Data::setCache($value);
                     }
                     break;
                 case 'precision':
                     if ($value === NULL) {
                         $value = -1;
                     }
                     if ($value < -1 || $value > 30) {
                         throw new Zend_Currency_Exception("'{$value}' precision has to be between -1 and 30.");
                     }
                     break;
                 case 'script':
                     try {
                         Zend_Locale_Format::convertNumerals(0, $options['script']);
                     } catch (Zend_Locale_Exception $e) {
                         throw new Zend_Currency_Exception($e->getMessage());
                     }
                     break;
             }
         } else {
             throw new Zend_Currency_Exception("Unknown option: '{$name}' = '{$value}'");
         }
     }
     return $options;
 }
コード例 #19
0
			
				<tr>
					<td colspan="2"><?php 
    echo t('Language');
    ?>
</td>
				</tr>	
				<tr>
					<td colspan="2">
					<?php 
    array_unshift($languages, 'en_US');
    $locales = array();
    $locales[''] = t('** Default');
    Loader::library('3rdparty/Zend/Locale');
    Loader::library('3rdparty/Zend/Locale/Data');
    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);
    }
    print $form->select('uDefaultLanguage', $locales);
    ?>
					</td>
				</tr>
                
				<?php 
}
?>
                
			</tbody>
		</table>
コード例 #20
0
 /**
  * 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);
             }
         }
         switch ($name) {
             case 'number_format':
                 if ($value == Zend_Locale_Format::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 == Zend_Locale_Format::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 (isset($options['format_type']) === true and $options['format_type'] == 'php' or isset($options['format_type']) === false 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':
                 $options['locale'] = Zend_Locale::findLocale($value);
                 break;
             case 'cache':
                 if ($value instanceof Zend_Cache_Core) {
                     Zend_Locale_Data::setCache($value);
                 }
                 break;
             case 'disablecache':
                 Zend_Locale_Data::disableCache($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;
             default:
                 // require_once 'Zend/Locale/Exception.php';
                 throw new Zend_Locale_Exception("Unknown option: '{$name}' = '{$value}'");
                 break;
         }
     }
     return $options;
 }
コード例 #21
0
ファイル: Locale.php プロジェクト: dalinhuang/popo
 /**
  * Sets a cache
  *
  * @param Zend_Cache_Core $cache
  */
 public static function setCache(Zend_Cache_Core $cache)
 {
     // load class within method for speed
     require_once 'Zend/Locale/Data.php';
     Zend_Locale_Data::setCache($cache);
 }
コード例 #22
0
 /**
  * {@inheritdoc}
  */
 public function getLocale()
 {
     if (!$this->_locale) {
         \Zend_Locale_Data::setCache($this->_cache->getFrontend()->getLowLevelFrontend());
         $this->_locale = $this->_localeFactory->create(array('locale' => $this->getLocaleCode()));
     } elseif ($this->_locale->__toString() != $this->_localeCode) {
         $this->setLocale($this->_localeCode);
     }
     return $this->_locale;
 }
コード例 #23
0
ファイル: localization.php プロジェクト: Zyqsempai/amanet
 /**
  * Get the description of a locale consisting of language and region description
  * e.g. "French (France)"
  * @param string $locale Locale that should be described
  * @param string $displayLocale Language of the description
  * @return string Description of a language
  */
 public static function getLanguageDescription($locale, $displayLocale = null)
 {
     $localeList = Zend_Locale::getLocaleList();
     if (!isset($localeList[$locale])) {
         return $locale;
     }
     if ($displayLocale !== NULL && !isset($localeList[$displayLocale])) {
         $displayLocale = NULL;
     }
     $cacheLibrary = Cache::getLibrary();
     if (is_object($cacheLibrary)) {
         Zend_Locale_Data::setCache($cacheLibrary);
     }
     $displayLocale = $displayLocale ? $displayLocale : $locale;
     $zendLocale = new Zend_Locale($locale);
     $languageName = Zend_Locale::getTranslation($zendLocale->getLanguage(), 'language', $displayLocale);
     $description = $languageName;
     $region = $zendLocale->getRegion();
     if ($region !== false) {
         $regionName = Zend_Locale::getTranslation($region, 'country', $displayLocale);
         if ($regionName !== false) {
             $localeData = Zend_Locale_Data::getList($displayLocale, 'layout');
             if ($localeData['characters'] == "right-to-left") {
                 $description = '(' . $languageName . ' (' . $regionName;
             } else {
                 $description = $languageName . ' (' . $regionName . ")";
             }
         }
     }
     return $description;
 }
コード例 #24
0
ファイル: Pimcore.php プロジェクト: shanky0110/pimcore-custom
 /**
  * @static
  * @throws Exception|Zend_Controller_Router_Exception
  */
 public static function run()
 {
     self::setSystemRequirements();
     // register shutdown function
     Pimcore_Event::register("pimcore.shutdown", array("Pimcore", "shutdown"), array(), 999);
     // detect frontend (website)
     $frontend = Pimcore_Tool::isFrontend();
     // enable the output-buffer, why? see in self::outputBufferStart()
     //if($frontend) {
     self::outputBufferStart();
     //}
     self::initAutoloader();
     self::initConfiguration();
     self::setupFramework();
     // config is loaded now init the real logger
     self::initLogger();
     // set locale data cache, this must be after self::initLogger() since Pimcore_Model_Cache requires the logger
     // to log if there's something wrong with the cache configuration in cache.xml
     Zend_Locale_Data::setCache(Pimcore_Model_Cache::getInstance());
     // load plugins and modules (=core plugins)
     self::initModules();
     self::initPlugins();
     // init front controller
     $front = Zend_Controller_Front::getInstance();
     $conf = Pimcore_Config::getSystemConfig();
     if (!$conf) {
         // redirect to installer if configuration isn't present
         if (!preg_match("/^\\/install.*/", $_SERVER["REQUEST_URI"])) {
             header("Location: /install/");
             exit;
         }
     }
     $front->registerPlugin(new Pimcore_Controller_Plugin_ErrorHandler(), 1);
     $front->registerPlugin(new Pimcore_Controller_Plugin_Maintenance(), 2);
     // register general pimcore plugins for frontend
     if ($frontend) {
         $front->registerPlugin(new Pimcore_Controller_Plugin_Less(), 799);
     }
     if (Pimcore_Tool::useFrontendOutputFilters(new Zend_Controller_Request_Http())) {
         $front->registerPlugin(new Pimcore_Controller_Plugin_Robotstxt(), 795);
         $front->registerPlugin(new Pimcore_Controller_Plugin_WysiwygAttributes(), 796);
         $front->registerPlugin(new Pimcore_Controller_Plugin_Webmastertools(), 797);
         $front->registerPlugin(new Pimcore_Controller_Plugin_Analytics(), 798);
         $front->registerPlugin(new Pimcore_Controller_Plugin_CssMinify(), 800);
         $front->registerPlugin(new Pimcore_Controller_Plugin_JavascriptMinify(), 801);
         $front->registerPlugin(new Pimcore_Controller_Plugin_ImageDataUri(), 803);
         $front->registerPlugin(new Pimcore_Controller_Plugin_TagManagement(), 804);
         $front->registerPlugin(new Pimcore_Controller_Plugin_HttpErrorLog(), 850);
         $front->registerPlugin(new Pimcore_Controller_Plugin_Cache(), 901);
         // for caching
     }
     self::initControllerFront($front);
     // set router
     $router = $front->getRouter();
     $routeAdmin = new Zend_Controller_Router_Route('admin/:controller/:action/*', array('module' => 'admin', "controller" => "index", "action" => "index"));
     $routeInstall = new Zend_Controller_Router_Route('install/:controller/:action/*', array('module' => 'install', "controller" => "index", "action" => "index"));
     $routeUpdate = new Zend_Controller_Router_Route('admin/update/:controller/:action/*', array('module' => 'update', "controller" => "index", "action" => "index"));
     $routePlugins = new Zend_Controller_Router_Route('admin/plugin/:controller/:action/*', array('module' => 'pluginadmin', "controller" => "index", "action" => "index"));
     $routeExtensions = new Zend_Controller_Router_Route('admin/extensionmanager/:controller/:action/*', array('module' => 'extensionmanager', "controller" => "index", "action" => "index"));
     $routeReports = new Zend_Controller_Router_Route('admin/reports/:controller/:action/*', array('module' => 'reports', "controller" => "index", "action" => "index"));
     $routePlugin = new Zend_Controller_Router_Route('plugin/:module/:controller/:action/*', array("controller" => "index", "action" => "index"));
     $routeWebservice = new Zend_Controller_Router_Route('webservice/:controller/:action/*', array("module" => "webservice", "controller" => "index", "action" => "index"));
     $routeSearchAdmin = new Zend_Controller_Router_Route('admin/search/:controller/:action/*', array("module" => "searchadmin", "controller" => "index", "action" => "index"));
     // website route => custom router which check for a suitable document
     $routeFrontend = new Pimcore_Controller_Router_Route_Frontend();
     $router->addRoute('default', $routeFrontend);
     // only do this if not frontend => performance issue
     if (!$frontend) {
         $router->addRoute("install", $routeInstall);
         $router->addRoute('plugin', $routePlugin);
         $router->addRoute('admin', $routeAdmin);
         $router->addRoute('update', $routeUpdate);
         $router->addRoute('plugins', $routePlugins);
         $router->addRoute('extensionmanager', $routeExtensions);
         $router->addRoute('reports', $routeReports);
         $router->addRoute('searchadmin', $routeSearchAdmin);
         if ($conf instanceof Zend_Config and $conf->webservice and $conf->webservice->enabled) {
             $router->addRoute('webservice', $routeWebservice);
         }
     }
     // check if webdav is configured and add router
     if ($conf instanceof Zend_Config) {
         if ($conf->assets->webdav->hostname) {
             $routeWebdav = new Zend_Controller_Router_Route_Hostname($conf->assets->webdav->hostname, array("module" => "admin", 'controller' => 'asset', 'action' => 'webdav'));
             $router->addRoute('webdav', $routeWebdav);
         }
     }
     $front->setRouter($router);
     Pimcore_API_Plugin_Broker::getInstance()->preDispatch();
     // throw exceptions also when in preview or in editmode (documents) to see it immediately when there's a problem with this page
     $throwExceptions = false;
     if (array_key_exists("pimcore_editmode", $_REQUEST) || array_key_exists("pimcore_preview", $_REQUEST) || array_key_exists("pimcore_admin", $_REQUEST)) {
         $user = Pimcore_Tool_Authentication::authenticateSession();
         if ($user instanceof User) {
             $throwExceptions = true;
         }
     }
     // run dispatcher
     if (!PIMCORE_DEBUG && !$throwExceptions && !PIMCORE_DEVMODE) {
         @ini_set("display_errors", "Off");
         @ini_set("display_startup_errors", "Off");
         $front->dispatch();
     } else {
         @ini_set("display_errors", "On");
         @ini_set("display_startup_errors", "On");
         $front->throwExceptions(true);
         try {
             $front->dispatch();
         } catch (Zend_Controller_Router_Exception $e) {
             header("HTTP/1.0 404 Not Found");
             throw new Zend_Controller_Router_Exception("No route, document, custom route or redirect is matching the request: " . $_SERVER["REQUEST_URI"]);
         } catch (Exception $e) {
             header("HTTP/1.0 500 Internal Server Error");
             throw $e;
         }
     }
 }
コード例 #25
0
ファイル: Locale.php プロジェクト: bizanto/Hooked
 /**
  * Sets a cache
  *
  * @param  Zend_Cache_Core $cache Cache to set
  * @return void
  */
 public static function setCache(Zend_Cache_Core $cache)
 {
     require_once 'Zend/Locale/Data.php';
     Zend_Locale_Data::setCache($cache);
 }
コード例 #26
0
ファイル: Pimcore.php プロジェクト: nblackman/pimcore
 /**
  * @static
  *
  */
 public static function setupFramework()
 {
     // try to set tmp directoy into superglobals, ZF and other frameworks (PEAR) sometimes relies on that
     foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
         $_ENV[$key] = PIMCORE_CACHE_DIRECTORY;
         $_SERVER[$key] = PIMCORE_CACHE_DIRECTORY;
     }
     // set custom view renderer
     $pimcoreViewHelper = new Pimcore_Controller_Action_Helper_ViewRenderer();
     Zend_Controller_Action_HelperBroker::addHelper($pimcoreViewHelper);
     // set dummy timezone if no tz is specified / required for example by the logger, ...
     $defaultTimezone = @date_default_timezone_get();
     if (!$defaultTimezone) {
         date_default_timezone_set("Europe/Berlin");
     }
     // set locale data cache
     Zend_Locale_Data::setCache(Pimcore_Model_Cache::getInstance());
 }
コード例 #27
0
 /**
  * Sets a cache for Zend_Currency
  *
  * @param  Zend_Cache_Core $cache Cache to set
  * @return void
  */
 public static function setCache(Zend_Cache_Core $cache)
 {
     Zend_Locale_Data::setCache($cache);
 }
コード例 #28
0
ファイル: Locale.php プロジェクト: netconstructor/Centurion
 /**
  * Sets a cache
  *
  * @param  Zend_Cache_Core $cache Cache to set
  * @return void
  */
 public static function setCache(Zend_Cache_Core $cache)
 {
     //$1 'Zend/Locale/Data.php';
     Zend_Locale_Data::setCache($cache);
 }