本文整理汇总了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;
}
示例2: setHeader
/**
* {@inheritdoc}
*/
public function setHeader($name, $value)
{
$this->_app->setHeader($name, $value, true);
}