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


PHP http::getAcceptLanguage方法代碼示例

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


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

示例1: getDefaultLang

 /**
  * Retrouve la langue de l'utilisateur.
  *
  * @return string
  */
 protected function getDefaultLang()
 {
     $sLang = '';
     if (isset($_COOKIE[$this->sCookieLangName])) {
         $sLang = $_COOKIE[$this->sCookieLangName];
     } elseif (($acceptLanguage = http::getAcceptLanguage()) != '') {
         $sLang = $acceptLanguage;
     }
     if ($this->okt->languages->isActive($sLang)) {
         return $sLang;
     } else {
         return $this->okt->config->language;
     }
 }
開發者ID:jewelhuq,項目名稱:okatea,代碼行數:19,代碼來源:class.oktAuth.php

示例2: Copyright

# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------
require dirname(__FILE__) . '/../inc/admin/prepend.php';
# If we have a session cookie, go to index.php
if (isset($_SESSION['sess_user_id'])) {
    $core->adminurl->redirect('admin.home');
}
# Loading locales for detected language
# That's a tricky hack but it works ;)
$dlang = http::getAcceptLanguage();
$dlang = $dlang == '' ? 'en' : $dlang;
if ($dlang != 'en' && preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $dlang)) {
    l10n::lang($dlang);
    l10n::set(dirname(__FILE__) . '/../locales/' . $dlang . '/main');
}
$page_url = http::getHost() . $_SERVER['REQUEST_URI'];
$change_pwd = $core->auth->allowPassChange() && isset($_POST['new_pwd']) && isset($_POST['new_pwd_c']) && isset($_POST['login_data']);
$login_data = !empty($_POST['login_data']) ? html::escapeHTML($_POST['login_data']) : null;
$recover = $core->auth->allowPassChange() && !empty($_REQUEST['recover']);
$safe_mode = !empty($_REQUEST['safe_mode']);
$akey = $core->auth->allowPassChange() && !empty($_GET['akey']) ? $_GET['akey'] : null;
$user_id = $user_pwd = $user_key = $user_email = null;
$err = $msg = null;
# Auto upgrade
if (empty($_GET) && empty($_POST)) {
開發者ID:nikrou,項目名稱:dotclear,代碼行數:31,代碼來源:auth.php

示例3: session_start

}
# start sessions... - ah bon ? - hé oui ! - ah ah !
if (!session_id()) {
    session_start();
}
# Install or update ?
if (!isset($_SESSION['okt_install_process_type'])) {
    $_SESSION['okt_install_process_type'] = 'install';
    if (file_exists(OKT_CONFIG_PATH . '/connexion.php')) {
        $_SESSION['okt_install_process_type'] = 'update';
    }
}
$sOldVersion = !empty($_REQUEST['old_version']) ? trim($_REQUEST['old_version']) : null;
# Initialisation localisation
if (!isset($_SESSION['okt_install_language'])) {
    $sAcceptLanguage = http::getAcceptLanguage();
    if (in_array($sAcceptLanguage, $aAvailablesLocales) && $sAcceptLanguage != $sDefaultLanguage) {
        $_SESSION['okt_install_language'] = $sAcceptLanguage;
    } else {
        $_SESSION['okt_install_language'] = $sDefaultLanguage;
    }
    http::redirect('index.php');
}
if (isset($_REQUEST['switch_language']) && in_array($_REQUEST['switch_language'], $aAvailablesLocales)) {
    $_SESSION['okt_install_language'] = $_REQUEST['switch_language'];
    http::redirect('index.php');
}
# load locales
l10n::init();
l10n::set(OKT_LOCALES_PATH . '/' . $_SESSION['okt_install_language'] . '/main');
l10n::set(OKT_INSTAL_DIR . '/inc/locales/' . $_SESSION['okt_install_language'] . '/install');
開發者ID:jewelhuq,項目名稱:okatea,代碼行數:31,代碼來源:index.php


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