@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License |
30 | 30 | */ |
31 | 31 | |
32 | -class multilang{ |
|
33 | - private static $lang ="tr"; // Predefined language |
|
32 | +class multilang { |
|
33 | + private static $lang = "tr"; // Predefined language |
|
34 | 34 | private static $dir = "system/lang/"; // Predefined directory |
35 | 35 | private static $log = array(); // Please don't touch |
36 | 36 | |
37 | - public static function get($req, $return = 0){ |
|
37 | + public static function get($req, $return = 0) { |
|
38 | 38 | global $_SESSION; |
39 | - switch ($req){ |
|
39 | + switch ($req) { |
|
40 | 40 | case 'lang': |
41 | - if($_SESSION['multilang']){ |
|
41 | + if ($_SESSION['multilang']) { |
|
42 | 42 | if ($return) return $_SESSION['multilang']; |
43 | 43 | echo $_SESSION['multilang']; |
44 | 44 | break; |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | echo multilang::$lang; |
48 | 48 | break; |
49 | 49 | case 'dir&lang': |
50 | - if ($return) return multilang::get("dir", 1).multilang::get("lang",1).".php"; |
|
51 | - echo multilang::get("dir",1).multilang::get("lang",1).".php"; |
|
50 | + if ($return) return multilang::get("dir", 1).multilang::get("lang", 1).".php"; |
|
51 | + echo multilang::get("dir", 1).multilang::get("lang", 1).".php"; |
|
52 | 52 | break; |
53 | 53 | case 'dir': |
54 | 54 | if ($return) return multilang::$dir; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - public static function set($type, $set){ |
|
68 | + public static function set($type, $set) { |
|
69 | 69 | global $_SESSION; |
70 | 70 | switch ($type) { |
71 | 71 | case 'lang': |
@@ -83,17 +83,17 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - public static function ctrl($fileLang){ |
|
86 | + public static function ctrl($fileLang) { |
|
87 | 87 | return file_exists(multilang::$dir.$fileLang.".php"); |
88 | 88 | } |
89 | 89 | |
90 | 90 | # Return Type: array, html (div>a*) |
91 | - public static function listlang($returnType = "array"){ |
|
91 | + public static function listlang($returnType = "array") { |
|
92 | 92 | $langPHP_array = array(); |
93 | 93 | $langPHP_html = '<div class="multilang">'; |
94 | 94 | $openDir = opendir(multilang::get("dir", 1)); |
95 | - while (($file = readdir($openDir)) != FALSE ){ |
|
96 | - if ($file =='.' || $file == '..' || is_file($file) || substr($language, -4, 4) == '.php') continue; |
|
95 | + while (($file = readdir($openDir)) != FALSE) { |
|
96 | + if ($file == '.' || $file == '..' || is_file($file) || substr($language, -4, 4) == '.php') continue; |
|
97 | 97 | if ($returnType == "array") $langPHP_array[basename($file, ".php")] = $file; |
98 | 98 | if ($returnType == "html") $langPHP_html .= sprintf(' <a href="?lang=%s" title="language %s">%s</a> ', basename($file, ".php"), $file, $file); |
99 | 99 | } |
@@ -102,29 +102,29 @@ discard block |
||
102 | 102 | return $returnType == "array" ? $langPHP_array : $langPHP_html; |
103 | 103 | } |
104 | 104 | |
105 | - public static function lang($type){ |
|
105 | + public static function lang($type) { |
|
106 | 106 | global $LANG; |
107 | - if(!$LANG[$type]){ |
|
107 | + if (!$LANG[$type]) { |
|
108 | 108 | multilang::set("log", sprintf('NOT FOUND "%s" in %s.php', $type, multilang::get("lang", 1))); |
109 | 109 | return sprintf('<span style="background-color: red; color: white;">NOT FOUND "%s" in %s.php</span>', $type, multilang::get("lang", 1)); |
110 | 110 | } |
111 | 111 | return $LANG[$type]; |
112 | 112 | } |
113 | 113 | |
114 | - public static function setup(){ |
|
114 | + public static function setup() { |
|
115 | 115 | global $_GET, $_SESSION, $LANG; |
116 | - if(session_status() == PHP_SESSION_NONE) session_start(); |
|
117 | - if($_GET && $_GET['lang']){ |
|
118 | - if(multilang::ctrl($_GET['lang'])){ |
|
116 | + if (session_status() == PHP_SESSION_NONE) session_start(); |
|
117 | + if ($_GET && $_GET['lang']) { |
|
118 | + if (multilang::ctrl($_GET['lang'])) { |
|
119 | 119 | multilang::set("lang", $_GET['lang']); |
120 | 120 | require_once(multilang::get("dir&lang", 1)); |
121 | - multilang::set("log", sprintf("Language file loading (%s.php)", multilang::get("dir&lang",1))); |
|
122 | - }else{ |
|
121 | + multilang::set("log", sprintf("Language file loading (%s.php)", multilang::get("dir&lang", 1))); |
|
122 | + }else { |
|
123 | 123 | multilang::set("log", sprintf("Language file not found (%s.php)", multilang::$dir.$_GET['lang'])); |
124 | 124 | } |
125 | - }else{ |
|
125 | + }else { |
|
126 | 126 | require_once(multilang::get("dir&lang", 1)); |
127 | - multilang::set("log", sprintf("Language file loading (%s.php)", multilang::get("dir&lang",1))); |
|
127 | + multilang::set("log", sprintf("Language file loading (%s.php)", multilang::get("dir&lang", 1))); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |