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


PHP JApplicationCms::setHeader方法代码示例

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


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

示例1: parseRule


//.........这里部分代码省略.........
             // 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])) {
                     $lang_code = false;
                 }
             }
             if (!$lang_code) {
                 $lang_code = $this->default_lang;
             }
         }
         if ($this->mode_sef) {
             // Use the current language sef or the default one.
             if (!$this->params->get('remove_default_prefix', 0) || $lang_code != $this->default_lang) {
                 $path = $this->lang_codes[$lang_code]->sef . '/' . $path;
             }
             $uri->setPath($path);
             if (!$this->app->get('sef_rewrite')) {
                 $uri->setPath('index.php/' . $uri->getPath());
             }
             $redirectUri = $uri->base() . $uri->toString(array('path', 'query', 'fragment'));
         } else {
             $uri->setVar('lang', $this->lang_codes[$lang_code]->sef);
             $redirectUri = $uri->base() . 'index.php?' . $uri->getQuery();
         }
         // Set redirect HTTP code to "302 Found".
         $redirectHttpCode = 302;
         // If selected language is the default language redirect code is "301 Moved Permanently".
         if ($lang_code === $this->default_lang) {
             $redirectHttpCode = 301;
             // We cannot cache this redirect in browser. 301 is cachable by default so we need to force to not cache it in browsers.
             $this->app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
             $this->app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
             $this->app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
             $this->app->setHeader('Pragma', 'no-cache');
             $this->app->sendHeaders();
         }
         // Redirect to language.
         $this->app->redirect($redirectUri, $redirectHttpCode);
     }
     // 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->current_lang = $lang_code;
     // Set the request var.
     $this->app->input->set('language', $lang_code);
     $this->app->set('language', $lang_code);
     $language = JFactory::getLanguage();
     if ($language->getTag() != $lang_code) {
         $newLang = JLanguage::getInstance($lang_code);
         foreach ($language->getPaths() as $extension => $files) {
             $newLang->load($extension);
         }
         JFactory::$language = $newLang;
         $this->app->loadLanguage($newLang);
     }
     // Create a cookie.
     if ($this->getLanguageCookie() != $lang_code) {
         $this->setLanguageCookie($lang_code);
     }
     return $array;
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:101,代码来源:languagefilter.php

示例2: setHeader

 /**
  * {@inheritdoc}
  */
 public function setHeader($name, $value)
 {
     $this->_app->setHeader($name, $value, true);
 }
开发者ID:JBZoo,项目名称:CrossCMS,代码行数:7,代码来源:Response.php


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