本文整理汇总了PHP中PMF_Language::language方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Language::language方法的具体用法?PHP PMF_Language::language怎么用?PHP PMF_Language::language使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Language
的用法示例。
在下文中一共展示了PMF_Language::language方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLanguage
/**
* Sets the current language for phpMyFAQ user session
*
* @param bool $configDetection Configuration detection
* @param string $configLanguage Language from configuration
*
* @return string
*/
public function setLanguage($configDetection, $configLanguage)
{
$_lang = [];
self::_getUserAgentLanguage();
// Get language from: _POST, _GET, _COOKIE, phpMyFAQ configuration and the automatic language detection
$_lang['post'] = PMF_Filter::filterInput(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
if (!is_null($_lang['post']) && !self::isASupportedLanguage($_lang['post'])) {
$_lang['post'] = null;
}
// Get the user language
$_lang['get'] = PMF_Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_STRING);
if (!is_null($_lang['get']) && !self::isASupportedLanguage($_lang['get'])) {
$_lang['get'] = null;
}
// Get the faq record language
$_lang['artget'] = PMF_Filter::filterInput(INPUT_GET, 'artlang', FILTER_SANITIZE_STRING);
if (!is_null($_lang['artget']) && !self::isASupportedLanguage($_lang['artget'])) {
$_lang['artget'] = null;
}
// Get the language from the session
if (isset($_SESSION['pmf_lang']) && self::isASupportedLanguage($_SESSION['pmf_lang'])) {
$_lang['session'] = trim($_SESSION['pmf_lang']);
}
// Get the language from the config
if (isset($configLanguage)) {
$confLangCode = str_replace(array("language_", ".php"), "", $configLanguage);
if (self::isASupportedLanguage($confLangCode)) {
$_lang['config'] = $confLangCode;
}
}
// Detect the browser's language
if (true === $configDetection && self::isASupportedLanguage($this->acceptedLanguage)) {
$_lang['detection'] = strtolower($this->acceptedLanguage);
}
// Select the language
if (isset($_lang['post'])) {
self::$language = $_lang['post'];
$_lang = null;
unset($_lang);
} elseif (isset($_lang['get'])) {
self::$language = $_lang['get'];
} elseif (isset($_lang['session'])) {
self::$language = $_lang['session'];
$_lang = null;
unset($_lang);
} elseif (isset($_lang['detection'])) {
self::$language = $_lang['detection'];
$_lang = null;
unset($_lang);
} elseif (isset($_lang['config'])) {
self::$language = $_lang['config'];
$_lang = null;
unset($_lang);
} else {
self::$language = 'en';
// just a fallback
}
return $_SESSION['pmf_lang'] = self::$language;
}