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


PHP JApplicationCms::set方法代码示例

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


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

示例1: parseRule

 /**
  * Add parse rule to router.
  *
  * @param   JRouter  &$router  JRouter object.
  * @param   JUri     &$uri     JUri object.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function parseRule(&$router, &$uri)
 {
     // Did we find the current and existing language yet?
     $found = false;
     // Are we in SEF mode or not?
     if ($this->mode_sef) {
         $path = $uri->getPath();
         $parts = explode('/', $path);
         $sef = $parts[0];
         // If the default prefix should be removed and the SEF prefix is not among those
         // that we have in our system, its the default language and we "found" the right language
         if ($this->params->get('remove_default_prefix', 0) && !isset($this->sefs[$sef])) {
             $found = true;
             $lang_code = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
         } else {
             // If the language prefix should always be present or it is indeed , we can now look it up in our array
             if (isset($this->sefs[$sef])) {
                 // We found our language
                 $found = true;
                 $lang_code = $this->sefs[$sef]->lang_code;
             }
             // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == JComponentHelper::getParams('com_languages')->get('site', 'en-GB')) {
                 $found = false;
                 array_shift($parts);
                 $path = implode('/', $parts);
             }
             // We have found our language and the first part of our URL is the language prefix
             if ($found) {
                 array_shift($parts);
                 $uri->setPath(implode('/', $parts));
             }
         }
     } else {
         // We are not in SEF mode
         $lang = $uri->getVar('lang');
         if (isset($this->sefs[$lang])) {
             // We found our language
             $found = true;
             $lang_code = $this->sefs[$lang]->lang_code;
         }
     }
     // We are called via POST. We don't care about the language
     // and simply set the default language as our current language.
     if ($this->app->input->getMethod() == "POST" || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) {
         $found = true;
         $lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language'));
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
         }
     }
     // We have not found the language and thus need to redirect
     if (!$found) {
         // Lets find the default language for this user
         if (!isset($lang_code) || !isset($this->lang_codes[$lang_code])) {
             $lang_code = false;
             if ($this->params->get('detect_browser', 1)) {
                 $lang_code = JLanguageHelper::detectLanguage();
                 if (!isset($this->lang_codes[$lang_code])) {
                     $lang_code = false;
                 }
             }
             if (!$lang_code) {
                 $lang_code = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
             }
             // Either we detected the language via the browser or we got it from the cookie. In worst case
             // we fall back to the application setting
             $lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language'), $lang_code);
         }
         if ($this->mode_sef) {
             // Use the current language sef or the default one.
             if (!$this->params->get('remove_default_prefix', 0) || $lang_code != JComponentHelper::getParams('com_languages')->get('site', 'en-GB')) {
                 $path = $this->lang_codes[$lang_code]->sef . '/' . $path;
             }
             $uri->setPath($path);
             if (!$this->app->get('sef_rewrite')) {
                 $uri->setPath('index.php/' . $uri->getPath());
             }
             $this->app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment')));
         } else {
             $uri->setVar('lang', $this->lang_codes[$lang_code]->sef);
             $this->app->redirect($uri->base() . 'index.php?' . $uri->getQuery());
         }
     }
     // We have found our language and now need to set the cookie and the language value in our system
     $array = array('lang' => $lang_code);
     $this->default_lang = $lang_code;
//.........这里部分代码省略.........
开发者ID:educakanchay,项目名称:kanchay,代码行数:101,代码来源:languagefilter.php

示例2: parseRule

 /**
  * Add parse rule to router.
  *
  * @param   JRouter  &$router  JRouter object.
  * @param   JUri     &$uri     JUri object.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function parseRule(&$router, &$uri)
 {
     // Did we find the current and existing language yet?
     $found = false;
     $lang_code = false;
     // Are we in SEF mode or not?
     if ($this->mode_sef) {
         $path = $uri->getPath();
         $parts = explode('/', $path);
         $sef = $parts[0];
         // Do we have a URL Language Code ?
         if (!isset($this->sefs[$sef])) {
             // Check if remove default url language code is set
             if ($this->params->get('remove_default_prefix', 0)) {
                 if ($parts[0]) {
                     // We load a default site language page
                     $lang_code = $this->default_lang;
                 } else {
                     // We check for an existing language cookie
                     $lang_code = $this->getLanguageCookie();
                 }
             } else {
                 $lang_code = $this->getLanguageCookie();
             }
             // No language code. Try using browser settings or default site language
             if (!$lang_code && $this->params->get('detect_browser', 0) == 1) {
                 $lang_code = JLanguageHelper::detectLanguage();
             }
             if (!$lang_code) {
                 $lang_code = $this->default_lang;
             }
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) {
                 $found = true;
             }
         } else {
             // We found our language
             $found = true;
             $lang_code = $this->sefs[$sef]->lang_code;
             // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL.
             // Or we try to change the language back to the default language. We need a redirect to the proper URL for the default language.
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) {
                 // Create a cookie.
                 $this->setLanguageCookie($lang_code);
                 $found = false;
                 array_shift($parts);
                 $path = implode('/', $parts);
             }
             // We have found our language and the first part of our URL is the language prefix
             if ($found) {
                 array_shift($parts);
                 $uri->setPath(implode('/', $parts));
             }
         }
     } else {
         $lang_code = $this->getLanguageCookie();
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = $this->default_lang;
         }
     }
     $lang = $uri->getVar('lang', $lang_code);
     if (isset($this->sefs[$lang])) {
         // We found our language
         $found = true;
         $lang_code = $this->sefs[$lang]->lang_code;
     }
     // We are called via POST. We don't care about the language
     // and simply set the default language as our current language.
     if ($this->app->input->getMethod() == "POST" || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) {
         $found = true;
         if (!isset($lang_code)) {
             $lang_code = $this->getLanguageCookie();
         }
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = $this->default_lang;
         }
     }
     // We have not found the language and thus need to redirect
     if (!$found) {
         // Lets find the default language for this user
         if (!isset($lang_code) || !isset($this->lang_codes[$lang_code])) {
             $lang_code = false;
             if ($this->params->get('detect_browser', 1)) {
                 $lang_code = JLanguageHelper::detectLanguage();
                 if (!isset($this->lang_codes[$lang_code])) {
//.........这里部分代码省略.........
开发者ID:N6REJ,项目名称:joomla-cms,代码行数:101,代码来源:languagefilter.php

示例3: parseRule

 /**
  * Add parse rule to router.
  *
  * @param   JRouter  &$router  JRouter object.
  * @param   JUri     &$uri     JUri object.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function parseRule(&$router, &$uri)
 {
     // Did we find the current and existing language yet?
     $found = false;
     $lang_code = false;
     // Are we in SEF mode or not?
     if ($this->mode_sef) {
         $path = $uri->getPath();
         $parts = explode('/', $path);
         $sef = $parts[0];
         // Do we have a URL Language Code ?
         if (!isset($this->sefs[$sef])) {
             // Check if remove default url language code is set
             if ($this->params->get('remove_default_prefix', 0)) {
                 if ($parts[0]) {
                     // We load a default site language page
                     $lang_code = $this->default_lang;
                 } else {
                     // We check for an existing language cookie
                     $lang_code = $this->getLanguageCookie();
                 }
             } else {
                 $lang_code = $this->getLanguageCookie();
             }
             // No language code. Try using browser settings or default site language
             if (!$lang_code && $this->params->get('detect_browser', 0) == 1) {
                 $lang_code = JLanguageHelper::detectLanguage();
             }
             if (!$lang_code) {
                 $lang_code = $this->default_lang;
             }
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) {
                 $found = true;
             }
         } else {
             // We found our language
             $found = true;
             $lang_code = $this->sefs[$sef]->lang_code;
             // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL.
             // Or we try to change the language back to the default language. We need a redirect to the proper URL for the default language.
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) {
                 // Create a cookie.
                 $this->setLanguageCookie($lang_code);
                 $found = false;
                 array_shift($parts);
                 $path = implode('/', $parts);
             }
             // We have found our language and the first part of our URL is the language prefix
             if ($found) {
                 array_shift($parts);
                 $uri->setPath(implode('/', $parts));
             }
         }
     } else {
         $lang_code = $this->getLanguageCookie();
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = $this->default_lang;
         }
     }
     $lang = $uri->getVar('lang', $lang_code);
     if (isset($this->sefs[$lang])) {
         // We found our language
         $found = true;
         $lang_code = $this->sefs[$lang]->lang_code;
     }
     // We are called via POST. We don't care about the language
     // and simply set the default language as our current language.
     if ($this->app->input->getMethod() == "POST" || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) {
         $found = true;
         if (!isset($lang_code)) {
             $lang_code = $this->getLanguageCookie();
         }
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = $this->default_lang;
         }
     }
     // We have not found the language and thus need to redirect
     if (!$found) {
         // Lets find the default language for this user
         if (!isset($lang_code) || !isset($this->lang_codes[$lang_code])) {
             $lang_code = false;
             if ($this->params->get('detect_browser', 1)) {
                 $lang_code = JLanguageHelper::detectLanguage();
                 if (!isset($this->lang_codes[$lang_code])) {
//.........这里部分代码省略.........
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:101,代码来源:languagefilter.php


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