| @@ -85,7 +85,9 @@ discard block | ||
| 85 | 85 | if(!in_array($from, $this->definedExtension)) | 
| 86 | 86 |          { | 
| 87 | 87 | $usable = ""; | 
| 88 | -            foreach($this->definedExtension as $tip) $usable .= sprintf(' "%s",', $tip); | |
| 88 | +            foreach($this->definedExtension as $tip) {
 | |
| 89 | +            	$usable .= sprintf(' "%s",', $tip);
 | |
| 90 | + } | |
| 89 | 91 | $usable = substr($usable, 0, -1); | 
| 90 | 92 |              exit("MultilangPHP: You can only use the". $usable . ' parameters.'); | 
| 91 | 93 | } | 
| @@ -114,9 +116,13 @@ discard block | ||
| 114 | 116 | */ | 
| 115 | 117 | public function controlFileExtention(string $file, string $extension = null): bool | 
| 116 | 118 |      { | 
| 117 | - if (!$extension) $extension = $this->getFrom(); | |
| 119 | +        if (!$extension) {
 | |
| 120 | + $extension = $this->getFrom(); | |
| 121 | + } | |
| 118 | 122 |          $fKontrol = explode(".", $file); | 
| 119 | - if($fKontrol[count($fKontrol)-1] == $extension) return true; | |
| 123 | +        if($fKontrol[count($fKontrol)-1] == $extension) {
 | |
| 124 | + return true; | |
| 125 | + } | |
| 120 | 126 | return false; | 
| 121 | 127 | } | 
| 122 | 128 | |
| @@ -134,9 +140,15 @@ discard block | ||
| 134 | 140 | $langPHP_html = '<div class="multilang">'; | 
| 135 | 141 | $openDir = opendir($this->getDir()); | 
| 136 | 142 |              while (($file = readdir($openDir)) != FALSE ) { | 
| 137 | - if ($file =='.' || $file == '..' || is_file($file) || !$this->controlFileExtention($file)) continue; | |
| 138 | -                if ($returnType == "array") $langPHP_array[basename($file, sprintf(".%s",$this->getFrom()))] = $file; | |
| 139 | -                if ($returnType == "html") $langPHP_html .= sprintf(' <a href="?lang=%s" title="language %s">%s</a> ', basename($file, sprintf('.%s', $this->getFrom())), basename($file, sprintf('.%s', $this->getFrom())), basename($file, sprintf('.%s', $this->getFrom()))); | |
| 143 | +                if ($file =='.' || $file == '..' || is_file($file) || !$this->controlFileExtention($file)) {
 | |
| 144 | + continue; | |
| 145 | + } | |
| 146 | +                if ($returnType == "array") {
 | |
| 147 | +                	$langPHP_array[basename($file, sprintf(".%s",$this->getFrom()))] = $file;
 | |
| 148 | + } | |
| 149 | +                if ($returnType == "html") {
 | |
| 150 | +                	$langPHP_html .= sprintf(' <a href="?lang=%s" title="language %s">%s</a> ', basename($file, sprintf('.%s', $this->getFrom())), basename($file, sprintf('.%s', $this->getFrom())), basename($file, sprintf('.%s', $this->getFrom())));
 | |
| 151 | + } | |
| 140 | 152 | } | 
| 141 | 153 | $langPHP_html .= '</div>'; | 
| 142 | 154 | closedir($openDir); | 
| @@ -154,7 +166,9 @@ discard block | ||
| 154 | 166 | public function callInPHP(string $called): string | 
| 155 | 167 |      { | 
| 156 | 168 | $call = include($this->getLangFile()); | 
| 157 | -        if (!is_array($call)) exit("MultilangPHP: Some have problem in language file, file is not returning array: ".__METHOD__."()"); | |
| 169 | +        if (!is_array($call)) {
 | |
| 170 | +        	exit("MultilangPHP: Some have problem in language file, file is not returning array: ".__METHOD__."()");
 | |
| 171 | + } | |
| 158 | 172 | return $call[$called]; | 
| 159 | 173 | } | 
| 160 | 174 | |
| @@ -167,9 +181,13 @@ discard block | ||
| 167 | 181 | public function callInJSON(string $called): string | 
| 168 | 182 |      { | 
| 169 | 183 | $call = file_get_contents($this->getLangFile()); | 
| 170 | -        if (!$call) exit("MultilangPHP: JSON file not readable!"); | |
| 184 | +        if (!$call) {
 | |
| 185 | +        	exit("MultilangPHP: JSON file not readable!");
 | |
| 186 | + } | |
| 171 | 187 | $decodeCall = json_decode($call, true); | 
| 172 | - if (is_array($decodeCall) && !$decodeCall[$called]) $decodeCall = $decodeCall[0]; | |
| 188 | +        if (is_array($decodeCall) && !$decodeCall[$called]) {
 | |
| 189 | + $decodeCall = $decodeCall[0]; | |
| 190 | + } | |
| 173 | 191 |          return $decodeCall[$called] ? $decodeCall[$called] : exit(sprintf('multilangPHP: "%s" not found in %s file', $called, $this->getLangFile())); | 
| 174 | 192 | } | 
| 175 | 193 | |
| @@ -181,7 +199,9 @@ discard block | ||
| 181 | 199 | */ | 
| 182 | 200 | public function call(string $value): string | 
| 183 | 201 |      { | 
| 184 | -        if (!$value) exit("MultilangPHP: You have to use with a parameter on ".__METHOD__."()"); | |
| 202 | +        if (!$value) {
 | |
| 203 | +        	exit("MultilangPHP: You have to use with a parameter on ".__METHOD__."()");
 | |
| 204 | + } | |
| 185 | 205 |          return call_user_func(array($this, sprintf('callIn%s', strtoupper($this->getFrom()))), $value); | 
| 186 | 206 | } | 
| 187 | 207 | } | 
| 188 | 208 | \ No newline at end of file |