SimpleSAML_Utilities::getAcceptLanguage PHP 메소드

getAcceptLanguage() 공개 정적인 메소드

사용 중단: This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getAcceptLanguage() instead.
public static getAcceptLanguage ( )
    public static function getAcceptLanguage()
    {
        return \SimpleSAML\Utils\HTTP::getAcceptLanguage();
    }

Usage Example

예제 #1
0
 /**
  * This function gets the prefered language for the user based on the Accept-Language http header.
  *
  * @return The prefered language based on the Accept-Language http header, or NULL if none of the
  *         languages in the header were available.
  */
 private function getHTTPLanguage()
 {
     $languageScore = SimpleSAML_Utilities::getAcceptLanguage();
     /* For now we only use the default language map. We may use a configurable language map
      * in the future.
      */
     $languageMap = self::$defaultLanguageMap;
     /* Find the available language with the best score. */
     $bestLanguage = NULL;
     $bestScore = -1.0;
     foreach ($languageScore as $language => $score) {
         /* Apply the language map to the language code. */
         if (array_key_exists($language, $languageMap)) {
             $language = $languageMap[$language];
         }
         if (!in_array($language, $this->availableLanguages, TRUE)) {
             /* Skip this language - we don't have it. */
             continue;
         }
         /* Some user agents use very limited precicion of the quality value, but order the
          * elements in descending order. Therefore we rely on the order of the output from
          * getAcceptLanguage() matching the order of the languages in the header when two
          * languages have the same quality.
          */
         if ($score > $bestScore) {
             $bestLanguage = $language;
             $bestScore = $score;
         }
     }
     return $bestLanguage;
 }
All Usage Examples Of SimpleSAML_Utilities::getAcceptLanguage