内核更新

bug修复
This commit is contained in:
2016-10-02 11:50:36 +08:00
parent 7608d4d0f7
commit a70c700b04
27 changed files with 201 additions and 141 deletions

View File

@@ -25,6 +25,8 @@ class Lang
protected static $langDetectVar = 'lang';
// 语言Cookie变量
protected static $langCookieVar = 'think_var';
// 语言Cookie的过期时间
protected static $langCookieExpire = 3600;
// 允许语言列表
protected static $allowLangList = [];
@@ -81,10 +83,8 @@ class Lang
// 记录加载信息
App::$debug && Log::record('[ LANG ] ' . $_file, 'info');
$_lang = include $_file;
} else {
$_lang = [];
$lang = array_change_key_case($_lang) + $lang;
}
$lang = array_change_key_case($_lang) + $lang;
}
if (!empty($lang)) {
self::$lang[$range] = $lang + self::$lang[$range];
@@ -157,7 +157,7 @@ class Lang
if (isset($_GET[self::$langDetectVar])) {
// url中设置了语言变量
$langSet = strtolower($_GET[self::$langDetectVar]);
Cookie::set(self::$langCookieVar, $langSet, 3600);
Cookie::set(self::$langCookieVar, $langSet, self::$langCookieExpire);
} elseif (Cookie::get(self::$langCookieVar)) {
// 获取上次用户的选择
$langSet = strtolower(Cookie::get(self::$langCookieVar));
@@ -165,7 +165,7 @@ class Lang
// 自动侦测浏览器语言
preg_match('/^([a-z\d\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);
$langSet = strtolower($matches[1]);
Cookie::set(self::$langCookieVar, $langSet, 3600);
Cookie::set(self::$langCookieVar, $langSet, self::$langCookieExpire);
}
if (empty(self::$allowLangList) || in_array($langSet, self::$allowLangList)) {
// 合法的语言
@@ -197,6 +197,16 @@ class Lang
self::$langCookieVar = $var;
}
/**
* 设置语言的cookie的过期时间
* @param string $expire 过期时间
* @return void
*/
public static function setLangCookieExpire($expire)
{
self::$langCookieExpire = $expire;
}
/**
* 设置允许的语言列表
* @param array $list 语言列表