當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Languages::findByPublished方法代碼示例

本文整理匯總了PHP中Languages::findByPublished方法的典型用法代碼示例。如果您正苦於以下問題:PHP Languages::findByPublished方法的具體用法?PHP Languages::findByPublished怎麽用?PHP Languages::findByPublished使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Languages的用法示例。


在下文中一共展示了Languages::findByPublished方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _initLanguages

 protected function _initLanguages()
 {
     $this->languages = \Languages::findByPublished(true);
     if (sizeof($this->languages) < 2) {
         $this->currentLang = $this->languages[0];
         return;
     }
     $currentLangCode = $this->request()->get('lang');
     if (!$currentLangCode) {
         $currentLangCode = Factory::getCookie()->read('lang');
     }
     if (!$currentLangCode) {
         $this->currentLang = \Languages::findOneByDefault(true);
         $currentLangCode = $this->currentLang->getLangCode();
     }
     Factory::getCookie()->write('lang', $currentLangCode);
     if (Factory::getRouter()->getUrl() == '/' && !$this->request()->get('lang')) {
         $this->redirect($currentLangCode);
     }
     if (!$this->currentLang) {
         $this->currentLang = \Languages::findOneByLangCode($currentLangCode);
     }
     $translator = Translator::getInstance();
     $translator->setLocale($currentLangCode);
     Cms::$currentLang = $this->currentLang;
 }
開發者ID:hosivan90,項目名稱:toxotes,代碼行數:26,代碼來源:Controller.php

示例2: route

 public static function route($r)
 {
     $languages = \Languages::findByPublished(true);
     if (sizeof($languages) > 1) {
         $preLang = array();
         foreach ($languages as $lang) {
             $preLang[] = $lang->getLangCode();
         }
         $preLang = '{lang:(' . implode('|', $preLang) . ')}';
         $nr = array();
         foreach ($r as $route => $value) {
             if ('/' == $route) {
                 $nr[$route] = $value;
             }
             $nr[$route] = $value;
             if (strpos($route, '__') !== 0 && strpos($route, $preLang) !== 0) {
                 $nr[$preLang . '/' . ltrim($route, '/')] = $value;
             }
         }
         $r = $nr;
     }
     return $r;
 }
開發者ID:hosivan90,項目名稱:toxotes,代碼行數:23,代碼來源:Cms.php

示例3: begin

 public function begin()
 {
     $this->languages = Languages::findByPublished(1);
 }
開發者ID:hosivan90,項目名稱:toxotes,代碼行數:4,代碼來源:SelectLanguage.php


注:本文中的Languages::findByPublished方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。