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


PHP PMF_Language::language方法代码示例

本文整理汇总了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;
 }
开发者ID:maggiofrancesco,项目名称:phpMyFAQ,代码行数:67,代码来源:Language.php


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