Rev 1016 | Rev 1048 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1016 | Rev 1041 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | private static /*OIDplusLanguagePlugin[]*/ $languagePlugins = array(); |
32 | private static /*OIDplusLanguagePlugin[]*/ $languagePlugins = array(); |
33 | private static /*OIDplusDesignPlugin[]*/ $designPlugins = array(); |
33 | private static /*OIDplusDesignPlugin[]*/ $designPlugins = array(); |
34 | 34 | ||
35 | protected static $html = true; |
35 | protected static $html = true; |
36 | 36 | ||
37 | /*public*/ const DEFAULT_LANGUAGE = 'enus'; // the language of the source code |
- | |
38 | - | ||
39 | /*public*/ const PATH_RELATIVE = 1; // e.g. "../" |
37 | /*public*/ const PATH_RELATIVE = 1; // e.g. "../" |
40 | /*public*/ const PATH_ABSOLUTE = 2; // e.g. "http://www.example.com/oidplus/" |
38 | /*public*/ const PATH_ABSOLUTE = 2; // e.g. "http://www.example.com/oidplus/" |
41 | /*public*/ const PATH_ABSOLUTE_CANONICAL = 3; // e.g. "http://www.example.org/oidplus/" (if baseconfig CANONICAL_SYSTEM_URL is set) |
39 | /*public*/ const PATH_ABSOLUTE_CANONICAL = 3; // e.g. "http://www.example.org/oidplus/" (if baseconfig CANONICAL_SYSTEM_URL is set) |
42 | /*public*/ const PATH_RELATIVE_TO_ROOT = 4; // e.g. "/oidplus/" |
40 | /*public*/ const PATH_RELATIVE_TO_ROOT = 4; // e.g. "/oidplus/" |
43 | /*public*/ const PATH_RELATIVE_TO_ROOT_CANONICAL = 5; // e.g. "/oidplus/" (if baseconfig CANONICAL_SYSTEM_URL is set) |
41 | /*public*/ const PATH_RELATIVE_TO_ROOT_CANONICAL = 5; // e.g. "/oidplus/" (if baseconfig CANONICAL_SYSTEM_URL is set) |
Line 1646... | Line 1644... | ||
1646 | $langs[] = $code; |
1644 | $langs[] = $code; |
1647 | } |
1645 | } |
1648 | return $langs; |
1646 | return $langs; |
1649 | } |
1647 | } |
1650 | 1648 | ||
- | 1649 | public static function getDefaultLang() { |
|
- | 1650 | static $thrownOnce = false; // avoid endless loop inside OIDplusConfigInitializationException |
|
- | 1651 | ||
- | 1652 | $lang = self::$baseConfig->getValue('DEFAULT_LANGUAGE', 'enus'); |
|
- | 1653 | ||
- | 1654 | if (!in_array($lang,self::getAvailableLangs())) { |
|
- | 1655 | if (!$thrownOnce) { |
|
- | 1656 | $thrownOnce = true; |
|
- | 1657 | throw new OIDplusConfigInitializationException(_L('DEFAULT_LANGUAGE points to an invalid language plugin (Consider setting to "enus" = "English USA").')); |
|
- | 1658 | } else { |
|
- | 1659 | return 'enus'; |
|
- | 1660 | } |
|
- | 1661 | } |
|
- | 1662 | ||
- | 1663 | return $lang; |
|
- | 1664 | } |
|
- | 1665 | ||
1651 | public static function getCurrentLang() { |
1666 | public static function getCurrentLang() { |
1652 | if (isset($_GET['lang'])) { |
1667 | if (isset($_GET['lang'])) { |
1653 | $lang = $_GET['lang']; |
1668 | $lang = $_GET['lang']; |
1654 | } else if (isset($_POST['lang'])) { |
1669 | } else if (isset($_POST['lang'])) { |
1655 | $lang = $_POST['lang']; |
1670 | $lang = $_POST['lang']; |
1656 | } else if (isset($_COOKIE['LANGUAGE'])) { |
1671 | } else if (isset($_COOKIE['LANGUAGE'])) { |
1657 | $lang = $_COOKIE['LANGUAGE']; |
1672 | $lang = $_COOKIE['LANGUAGE']; |
1658 | } else { |
1673 | } else { |
1659 | $lang = self::DEFAULT_LANGUAGE; |
1674 | $lang = self::getDefaultLang(); |
1660 | } |
1675 | } |
1661 | $lang = substr(preg_replace('@[^a-z]@ismU', '', $lang),0,4); // sanitize |
1676 | $lang = substr(preg_replace('@[^a-z]@ismU', '', $lang),0,4); // sanitize |
1662 | return $lang; |
1677 | return $lang; |
1663 | } |
1678 | } |
1664 | 1679 |