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


PHP Pimcore_Tool::isValidLanguage方法代码示例

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


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

示例1: walk_path

 private function walk_path($folder, $options = null, $path = "")
 {
     if (is_null($options)) {
         $options = array();
     }
     if ($folder) {
         $source = $this->_getParam("source_methodname");
         if (Pimcore_Version::getRevision() > 3303) {
             $object_name = "Pimcore\\Model\\Object\\" . ucfirst($this->_getParam("source_classname"));
         } else {
             $object_name = "Object_" . ucfirst($this->_getParam("source_classname"));
         }
         $children = $folder->getChilds();
         $usesI18n = sizeof($children) > 0 && $this->isUsingI18n($children[0], $source);
         $current_lang = $this->_getParam("current_language");
         if (!Pimcore_Tool::isValidLanguage($current_lang)) {
             $languages = Pimcore_Tool::getValidLanguages();
             $current_lang = $languages[0];
             // TODO: Is this sensible?
         }
         foreach ($children as $child) {
             $class = get_class($child);
             switch ($class) {
                 case "Object_Folder":
                     /**
                      * @var Object_Folder $child
                      */
                     $key = $child->getProperty("Taglabel") != "" ? $child->getProperty("Taglabel") : $child->getKey();
                     if ($this->_getParam("source_recursive") == "true") {
                         $options = $this->walk_path($child, $options, $path . $this->separator . $key);
                     }
                     break;
                 case $object_name:
                     $key = $usesI18n ? $child->{$source}($current_lang) : $child->{$source}();
                     $options[] = array("value" => $child->getId(), "key" => ltrim($path . $this->separator . $key, $this->separator));
                     if ($this->_getParam("source_recursive") == "true") {
                         $options = $this->walk_path($child, $options, $path . $this->separator . $key);
                     }
                     break;
             }
         }
     }
     return $options;
 }
开发者ID:weblizards-gmbh,项目名称:dynamicdropdown-plugin,代码行数:44,代码来源:DynamicdropdownController.php

示例2: initTranslation

 protected function initTranslation()
 {
     $translate = null;
     if (Zend_Registry::isRegistered("Zend_Translate")) {
         $t = Zend_Registry::get("Zend_Translate");
         // this check is necessary for the case that a document is rendered within an admin request
         // example: send test newsletter
         if ($t instanceof Pimcore_Translate) {
             $translate = $t;
         }
     }
     if (!$translate) {
         // setup Zend_Translate
         try {
             $locale = Zend_Registry::get("Zend_Locale");
             $translate = new Pimcore_Translate_Website($locale);
             if (Pimcore_Tool::isValidLanguage($locale)) {
                 $translate->setLocale($locale);
             } else {
                 Logger::error("You want to use an invalid language which is not defined in the system settings: " . $locale);
                 // fall back to the first (default) language defined
                 $languages = Pimcore_Tool::getValidLanguages();
                 if ($languages[0]) {
                     Logger::error("Using '" . $languages[0] . "' as a fallback, because the language '" . $locale . "' is not defined in system settings");
                     $translate = new Pimcore_Translate_Website($languages[0]);
                     // reinit with new locale
                     $translate->setLocale($languages[0]);
                 } else {
                     throw new Exception("You have not defined a language in the system settings (Website -> Frontend-Languages), please add at least one language.");
                 }
             }
             // register the translator in Zend_Registry with the key "Zend_Translate" to use the translate helper for Zend_View
             Zend_Registry::set("Zend_Translate", $translate);
         } catch (Exception $e) {
             Logger::error("initialization of Pimcore_Translate failed");
             Logger::error($e);
         }
     }
     return $translate;
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:40,代码来源:AdminOrderController.php

示例3: initTranslation

 public function initTranslation()
 {
     if (Zend_Registry::isRegistered("Zend_Translate")) {
         $translator = Zend_Registry::get("Zend_Translate");
     } else {
         // setup Zend_Translate
         try {
             $locale = Zend_Registry::get("Zend_Locale");
             $cacheKey = "translator_website";
             if (!($translate = Pimcore_Model_Cache::load($cacheKey))) {
                 $translate = new Pimcore_Translate_Website($locale);
                 Pimcore_Model_Cache::save($translate, $cacheKey, array("translator", "translator_website", "translate"), null, 999);
             }
             if (Pimcore_Tool::isValidLanguage($locale)) {
                 $translate->setLocale($locale);
             } else {
                 Logger::error("You want to use an invalid language which is not defined in the system settings: " . $locale);
                 // fall back to the first (default) language defined
                 $languages = Pimcore_Tool::getValidLanguages();
                 if ($languages[0]) {
                     Logger::error("Using '" . $languages[0] . "' as a fallback, because the language '" . $locale . "' is not defined in system settings");
                     $translate->setLocale($languages[0]);
                 } else {
                     throw new Exception("You have not defined a language in the system settings (Website -> Frontend-Languages), please add at least one language.");
                 }
             }
             // register the translator in Zend_Registry with the key "Zend_Translate" to use the translate helper for Zend_View
             Zend_Registry::set("Zend_Translate", $translate);
         } catch (Exception $e) {
             Logger::error("initialization of Pimcore_Translate failed");
             Logger::error($e);
         }
     }
     return $translator;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:35,代码来源:Frontend.php

示例4: createEmptyTranslation

 private function createEmptyTranslation($locale, $messageId)
 {
     // don't create translation if it's just empty
     if (array_key_exists($messageId, $this->_translate[$locale])) {
         return;
     }
     // no translation found create key
     if (Pimcore_Tool::isValidLanguage($locale)) {
         try {
             $t = Translation_Website::getByKey($messageId);
         } catch (Exception $e) {
             $t = new Translation_Website();
             $t->setKey($messageId);
         }
         $t->addTranslation($locale, "");
         $t->save();
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:18,代码来源:Translate.php

示例5: getTableName

 /**
  * @return string
  */
 protected function getTableName()
 {
     if (empty($this->tableName)) {
         // default
         $this->tableName = "object_" . $this->model->getClassId();
         // check for a localized field and if they should be used for this list
         if (property_exists("Object_" . ucfirst($this->model->getClassName()), "localizedfields") && !$this->model->getIgnoreLocalizedFields()) {
             $language = "default";
             if (!$this->model->getIgnoreLocale()) {
                 if ($this->model->getLocale()) {
                     if (Pimcore_Tool::isValidLanguage((string) $this->model->getLocale())) {
                         $language = (string) $this->model->getLocale();
                     }
                 }
                 try {
                     $locale = Zend_Registry::get("Zend_Locale");
                     if (Pimcore_Tool::isValidLanguage((string) $locale) && $language == "default") {
                         $language = (string) $locale;
                     }
                 } catch (Exception $e) {
                 }
             }
             $this->tableName = "object_localized_" . $this->model->getClassId() . "_" . $language;
         }
     }
     return $this->tableName;
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:30,代码来源:Resource.php

示例6: getLanguage

 /**
  * @throws Exception
  * @param null $language
  * @return string
  */
 public function getLanguage($language = null)
 {
     if ($language) {
         return (string) $language;
     }
     // try to get the language from the registry
     try {
         $locale = Zend_Registry::get("Zend_Locale");
         if (Pimcore_Tool::isValidLanguage((string) $locale)) {
             return (string) $locale;
         }
         throw new Exception("Not supported language");
     } catch (Exception $e) {
         // try to get default from system settings
         $conf = Pimcore_Config::getSystemConfig();
         if ($conf->general->validLanguages) {
             $languages = explode(",", $conf->general->validLanguages);
             return $languages[0];
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:26,代码来源:Localizedfield.php


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