# HG changeset patch # User Tom Fredrik "BFG" Klaussen # Date 1349910437 -7200 # Node ID 0f1e08cdfff25f16db1b5a2de7ccd7c742896b99 # Parent 88482c6636c4378e7c968212627dd184e7ddc0c5 Move accept-language to Language to reflect new class name. diff -r 88482c6636c4 -r 0f1e08cdfff2 Language.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Language.inc Thu Oct 11 01:07:17 2012 +0200 @@ -0,0 +1,56 @@ + 0.8 + $langs = array_combine($lang_parse[1], $lang_parse[4]); + + // set default to 1 for any without q factor + foreach ($langs as $lang => $val) { + if ($val === '') $langs[$lang] = 1; + } + + // sort list based on value + arsort($langs, SORT_NUMERIC); + } + } + return $langs; + } + + /** + * From the list of desired languages, pick the best which we can serve. + * + * @param $default what to choose if no match could be found. + */ + static function prefer($default) + { + $language = $default; + $langs = self::accepted(); + if ($langs) { + foreach ($langs as $l => $val) { + if (file_exists($l)) { + $language = $l; + break; + } + } + } + return $language; + } +} +?> \ No newline at end of file diff -r 88482c6636c4 -r 0f1e08cdfff2 accept-language.inc --- a/accept-language.inc Thu Oct 11 01:04:23 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ - 0.8 - $langs = array_combine($lang_parse[1], $lang_parse[4]); - - // set default to 1 for any without q factor - foreach ($langs as $lang => $val) { - if ($val === '') $langs[$lang] = 1; - } - - // sort list based on value - arsort($langs, SORT_NUMERIC); - } - } - return $langs; - } - - /** - * From the list of desired languages, pick the best which we can serve. - * - * @param $default what to choose if no match could be found. - */ - static function prefer($default) - { - $language = $default; - $langs = self::accepted(); - if ($langs) { - foreach ($langs as $l => $val) { - if (file_exists($l)) { - $language = $l; - break; - } - } - } - return $language; - } -} -?> \ No newline at end of file diff -r 88482c6636c4 -r 0f1e08cdfff2 flag.php --- a/flag.php Thu Oct 11 01:04:23 2012 +0200 +++ b/flag.php Thu Oct 11 01:07:17 2012 +0200 @@ -8,7 +8,7 @@ include_once 'CacheTimeCheck.inc'; $cache = CacheTimeCheck::instance(__FILE__); -$cache->includeOnce('accept-language.inc'); +$cache->includeOnce('Language.inc'); $cache->includeOnce('common-functions.inc'); $active = $_GET['active']; diff -r 88482c6636c4 -r 0f1e08cdfff2 index.php --- a/index.php Thu Oct 11 01:04:23 2012 +0200 +++ b/index.php Thu Oct 11 01:07:17 2012 +0200 @@ -12,8 +12,8 @@ $baseDir = dirname(__FILE__); $cache = CacheTimeCheck::instance(__FILE__); +$cache->includeOnce('Language.inc', $baseDir); $cache->includeOnce('Options.inc', $baseDir); -$cache->includeOnce('accept-language.inc', $baseDir); $cache->includeOnce('common-functions.inc', $baseDir); $cache->includeOnce('filters.inc', $baseDir); $cache->includeOnce('inputParser.inc', $baseDir);