@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $autoload = realpath($root.'/../vendor/autoload.php'); |
| 14 | 14 | |
| 15 | 15 | // we need the autoloader to be present |
| 16 | - if(!file_exists($autoload)) { |
|
| 16 | + if (!file_exists($autoload)) { |
|
| 17 | 17 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | $text = t('This text is in the global scope.'); |
| 4 | 4 | |
| 5 | 5 | $text2 = t( |
| 6 | - 'It is possible to write long texts ' . |
|
| 7 | - 'using text concatenation in the source ' . |
|
| 6 | + 'It is possible to write long texts '. |
|
| 7 | + 'using text concatenation in the source '. |
|
| 8 | 8 | 'code to keep it readable.' |
| 9 | 9 | ); |
| 10 | 10 | \ No newline at end of file |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | public function excludeFolder(string $folder) : Localization_Source_Folder |
| 51 | 51 | { |
| 52 | - if(!in_array($folder, $this->excludes['folders'])) { |
|
| 52 | + if (!in_array($folder, $this->excludes['folders'])) { |
|
| 53 | 53 | $this->excludes['folders'][] = $folder; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function excludeFolders(array $folders) : Localization_Source_Folder |
| 60 | 60 | { |
| 61 | - foreach($folders as $folder) { |
|
| 61 | + foreach ($folders as $folder) { |
|
| 62 | 62 | $this->excludeFolder($folder); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | public function getArgument(int $index) |
| 41 | 41 | { |
| 42 | - if(isset($this->args[$index])) { |
|
| 42 | + if (isset($this->args[$index])) { |
|
| 43 | 43 | return $this->args[$index]; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -258,8 +258,7 @@ |
||
| 258 | 258 | if(empty($tokens)) |
| 259 | 259 | { |
| 260 | 260 | $content = '/* No strings found. */'; |
| 261 | - } |
|
| 262 | - else |
|
| 261 | + } else |
|
| 263 | 262 | { |
| 264 | 263 | $content = |
| 265 | 264 | '/**'.PHP_EOL. |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $this->translator = Localization::getTranslator(); |
| 26 | 26 | |
| 27 | - Localization::onLocaleChanged(function () { |
|
| 27 | + Localization::onLocaleChanged(function() { |
|
| 28 | 28 | $this->handleLocaleChanged(); |
| 29 | 29 | }); |
| 30 | 30 | |
| 31 | - Localization::onCacheKeyChanged(function () { |
|
| 31 | + Localization::onCacheKeyChanged(function() { |
|
| 32 | 32 | $this->handleCacheKeyChanged(); |
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | - Localization::onClientFolderChanged(function () { |
|
| 35 | + Localization::onClientFolderChanged(function() { |
|
| 36 | 36 | $this->handleFolderChanged(); |
| 37 | 37 | }); |
| 38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $folder = Localization::getClientFolder(); |
| 43 | 43 | |
| 44 | - if(!empty($folder)) { |
|
| 44 | + if (!empty($folder)) { |
|
| 45 | 45 | return FolderInfo::factory($folder); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $folder = $this->getTargetFolder(); |
| 54 | 54 | |
| 55 | - if($folder !== null) { |
|
| 55 | + if ($folder !== null) { |
|
| 56 | 56 | return FileInfo::factory($folder.'/cachekey.txt'); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | private static function log(string $message, ...$args) : void |
| 93 | 93 | { |
| 94 | - if(self::$logging === false) { |
|
| 94 | + if (self::$logging === false) { |
|
| 95 | 95 | return; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -100,13 +100,13 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | public function getCacheKey() : ?string |
| 102 | 102 | { |
| 103 | - if(isset($this->cacheKey)) { |
|
| 103 | + if (isset($this->cacheKey)) { |
|
| 104 | 104 | return $this->cacheKey; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $file = $this->getCacheKeyFile(); |
| 108 | 108 | |
| 109 | - if($file !== null && $file->exists()) { |
|
| 109 | + if ($file !== null && $file->exists()) { |
|
| 110 | 110 | $this->cacheKey = $file->getContents(); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | self::log('Write Files'); |
| 123 | 123 | |
| 124 | - if($this->getCacheKey() === self::getSystemKey()) { |
|
| 124 | + if ($this->getCacheKey() === self::getSystemKey()) { |
|
| 125 | 125 | self::log('Write Files | SKIP | Still up to date.'); |
| 126 | 126 | return; |
| 127 | 127 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $targetFolder = $this->getTargetFolder(); |
| 130 | 130 | |
| 131 | 131 | // no client libraries folder set: ignore. |
| 132 | - if($targetFolder === null) { |
|
| 132 | + if ($targetFolder === null) { |
|
| 133 | 133 | self::log('Write Files | SKIP | No folder set.'); |
| 134 | 134 | return; |
| 135 | 135 | } |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | $files = array(); |
| 157 | 157 | |
| 158 | - foreach($this->libraries as $fileName) |
|
| 158 | + foreach ($this->libraries as $fileName) |
|
| 159 | 159 | { |
| 160 | 160 | $files[] = $this->getLibraryFilePath($fileName); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - foreach($this->getTargetLocales() as $locale) |
|
| 163 | + foreach ($this->getTargetLocales() as $locale) |
|
| 164 | 164 | { |
| 165 | 165 | $files[] = $this->getLocaleFilePath($locale); |
| 166 | 166 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | self::log('Write Files | Writing locales.'); |
| 174 | 174 | |
| 175 | - foreach(self::getTargetLocales() as $locale) |
|
| 175 | + foreach (self::getTargetLocales() as $locale) |
|
| 176 | 176 | { |
| 177 | 177 | $this->writeLocaleFile($locale); |
| 178 | 178 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | $sourceFolder = FolderInfo::factory(__DIR__.'/../js'); |
| 196 | 196 | |
| 197 | - if(!$sourceFolder->exists()) |
|
| 197 | + if (!$sourceFolder->exists()) |
|
| 198 | 198 | { |
| 199 | 199 | throw new Localization_Exception( |
| 200 | 200 | 'Unexpected folder structure encountered.', |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | ); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - foreach($this->libraries as $fileName) |
|
| 209 | + foreach ($this->libraries as $fileName) |
|
| 210 | 210 | { |
| 211 | 211 | $targetFile = $this->getLibraryFilePath($fileName); |
| 212 | 212 | $sourceFile = $sourceFolder.'/'.$fileName; |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $result = array(); |
| 224 | 224 | |
| 225 | - foreach(Localization::getAppLocales() as $locale) { |
|
| 226 | - if($locale->isNative()) { |
|
| 225 | + foreach (Localization::getAppLocales() as $locale) { |
|
| 226 | + if ($locale->isNative()) { |
|
| 227 | 227 | continue; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | { |
| 238 | 238 | $result = array(); |
| 239 | 239 | |
| 240 | - foreach(self::getTargetLocales() as $locale) { |
|
| 240 | + foreach (self::getTargetLocales() as $locale) { |
|
| 241 | 241 | $result[] = $locale->getName(); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -281,9 +281,9 @@ discard block |
||
| 281 | 281 | $strings = $this->translator->getClientStrings($locale); |
| 282 | 282 | |
| 283 | 283 | $tokens = array(); |
| 284 | - foreach($strings as $hash => $text) |
|
| 284 | + foreach ($strings as $hash => $text) |
|
| 285 | 285 | { |
| 286 | - if(empty($text)) { |
|
| 286 | + if (empty($text)) { |
|
| 287 | 287 | continue; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | ); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if(empty($tokens)) |
|
| 297 | + if (empty($tokens)) |
|
| 298 | 298 | { |
| 299 | 299 | $content = '/* No strings found. */'; |
| 300 | 300 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | public static function getSystemKey() : string |
| 316 | 316 | { |
| 317 | - if(!isset(self::$systemKey)) { |
|
| 317 | + if (!isset(self::$systemKey)) { |
|
| 318 | 318 | self::$systemKey = sprintf( |
| 319 | 319 | 'Lib:%s|System:%s|Locales:%s', |
| 320 | 320 | Localization::getClientLibrariesCacheKey(), |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | $file = $this->getCacheKeyFile(); |
| 341 | 341 | |
| 342 | - if($file !== null) { |
|
| 342 | + if ($file !== null) { |
|
| 343 | 343 | $file->putContents($this->cacheKey); |
| 344 | 344 | } |
| 345 | 345 | |
@@ -9,12 +9,12 @@ |
||
| 9 | 9 | protected function parseDefinition() : void |
| 10 | 10 | { |
| 11 | 11 | // some entries are strings, like parenthesises, semicolons and the like. |
| 12 | - if(is_string($this->definition)) |
|
| 12 | + if (is_string($this->definition)) |
|
| 13 | 13 | { |
| 14 | 14 | $this->token = $this->definition; |
| 15 | 15 | $this->value = null; |
| 16 | 16 | |
| 17 | - if(isset($this->parentToken)) { |
|
| 17 | + if (isset($this->parentToken)) { |
|
| 18 | 18 | $this->line = $this->parentToken->getLine(); |
| 19 | 19 | } |
| 20 | 20 | } |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | if(isset($this->parentToken)) { |
| 20 | 20 | $this->line = $this->parentToken->getLine(); |
| 21 | 21 | } |
| 22 | - } |
|
| 23 | - else |
|
| 22 | + } else |
|
| 24 | 23 | { |
| 25 | 24 | $this->token = JTokenizer::getTokenName($this->definition[0]); |
| 26 | 25 | $this->value = $this->definition[1]; |
@@ -17,8 +17,7 @@ |
||
| 17 | 17 | if(isset($this->parentToken)) { |
| 18 | 18 | $this->line = $this->parentToken->getLine(); |
| 19 | 19 | } |
| 20 | - } |
|
| 21 | - else |
|
| 20 | + } else |
|
| 22 | 21 | { |
| 23 | 22 | $this->token = token_name($this->definition[0]); |
| 24 | 23 | $this->value = $this->definition[1]; |
@@ -15,12 +15,12 @@ |
||
| 15 | 15 | protected function parseDefinition() : void |
| 16 | 16 | { |
| 17 | 17 | // some entries are strings, like parentheses, semicolons and the like. |
| 18 | - if(is_string($this->definition)) |
|
| 18 | + if (is_string($this->definition)) |
|
| 19 | 19 | { |
| 20 | 20 | $this->token = $this->definition; |
| 21 | 21 | $this->value = null; |
| 22 | 22 | |
| 23 | - if(isset($this->parentToken)) { |
|
| 23 | + if (isset($this->parentToken)) { |
|
| 24 | 24 | $this->line = $this->parentToken->getLine(); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -50,8 +50,7 @@ discard block |
||
| 50 | 50 | foreach($defaults as $name => $val) { |
| 51 | 51 | $this->setValue($name, $val); |
| 52 | 52 | } |
| 53 | - } |
|
| 54 | - else if($this->request->getBool($this->vars['filter'])) |
|
| 53 | + } else if($this->request->getBool($this->vars['filter'])) |
|
| 55 | 54 | { |
| 56 | 55 | $this->parseSearchTerms($this->request->getParam($this->vars['search'])); |
| 57 | 56 | |
@@ -72,8 +71,7 @@ discard block |
||
| 72 | 71 | ->setEnum('', 'client', 'server') |
| 73 | 72 | ->get('') |
| 74 | 73 | ); |
| 75 | - } |
|
| 76 | - else |
|
| 74 | + } else |
|
| 77 | 75 | { |
| 78 | 76 | $this->parseSearchTerms($this->getValue($this->vars['search'])); |
| 79 | 77 | } |
@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | $this->editor = $editor; |
| 56 | 56 | $this->request = $editor->getRequest(); |
| 57 | 57 | |
| 58 | - foreach($this->vars as $var => $name) { |
|
| 58 | + foreach ($this->vars as $var => $name) { |
|
| 59 | 59 | $this->vars[$var] = $this->editor->getVarName($var); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if(!isset($_SESSION[$this->sessionName])) { |
|
| 62 | + if (!isset($_SESSION[$this->sessionName])) { |
|
| 63 | 63 | $_SESSION[$this->sessionName] = array(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if($this->request->getBool($this->vars['resetfilter'])) |
|
| 66 | + if ($this->request->getBool($this->vars['resetfilter'])) |
|
| 67 | 67 | { |
| 68 | 68 | $defaults = $this->getDefaultValues(); |
| 69 | 69 | |
| 70 | - foreach($defaults as $name => $val) { |
|
| 70 | + foreach ($defaults as $name => $val) { |
|
| 71 | 71 | $this->setValue($name, $val); |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - else if($this->request->getBool($this->vars['filter'])) |
|
| 74 | + else if ($this->request->getBool($this->vars['filter'])) |
|
| 75 | 75 | { |
| 76 | 76 | $this->parseSearchTerms($this->request->getParam($this->vars['search'])); |
| 77 | 77 | |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | protected function getValue(string $filterName) : string |
| 108 | 108 | { |
| 109 | - if(isset($_SESSION[$this->sessionName][$filterName])) { |
|
| 109 | + if (isset($_SESSION[$this->sessionName][$filterName])) { |
|
| 110 | 110 | return $_SESSION[$this->sessionName][$filterName]; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $defaults = $this->getDefaultValues(); |
| 114 | - if(isset($defaults[$filterName])) { |
|
| 114 | + if (isset($defaults[$filterName])) { |
|
| 115 | 115 | return $defaults[$filterName]; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | protected function parseSearchTerms(string $searchString) : void |
| 132 | 132 | { |
| 133 | - if(empty($searchString)) |
|
| 133 | + if (empty($searchString)) |
|
| 134 | 134 | { |
| 135 | 135 | $this->searchTerms = array(); |
| 136 | 136 | $this->searchString = ''; |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | $terms = array_map('trim', $terms); |
| 145 | 145 | |
| 146 | 146 | $keep = array(); |
| 147 | - foreach($terms as $term) { |
|
| 148 | - if(!empty($term)) { |
|
| 147 | + foreach ($terms as $term) { |
|
| 148 | + if (!empty($term)) { |
|
| 149 | 149 | $keep[] = $term; |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -156,28 +156,28 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | public function isStringMatch(Localization_Scanner_StringHash $string) : bool |
| 158 | 158 | { |
| 159 | - if(!empty($this->searchTerms)) |
|
| 159 | + if (!empty($this->searchTerms)) |
|
| 160 | 160 | { |
| 161 | 161 | $haystack = $string->getSearchString(); |
| 162 | 162 | |
| 163 | - foreach($this->searchTerms as $term) { |
|
| 164 | - if(!mb_stristr($haystack, $term)) { |
|
| 163 | + foreach ($this->searchTerms as $term) { |
|
| 164 | + if (!mb_stristr($haystack, $term)) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $status = $this->getValue($this->vars['status']); |
| 171 | - if($status === 'untranslated' && $string->isTranslated()) { |
|
| 171 | + if ($status === 'untranslated' && $string->isTranslated()) { |
|
| 172 | 172 | return false; |
| 173 | - } else if($status === 'translated' && !$string->isTranslated()) { |
|
| 173 | + } else if ($status === 'translated' && !$string->isTranslated()) { |
|
| 174 | 174 | return false; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $location = $this->getValue($this->vars['location']); |
| 178 | - if($location === 'client' && !$string->hasLanguageType('Javascript')) { |
|
| 178 | + if ($location === 'client' && !$string->hasLanguageType('Javascript')) { |
|
| 179 | 179 | return false; |
| 180 | - } else if($location === 'server' && !$string->hasLanguageType('PHP')) { |
|
| 180 | + } else if ($location === 'server' && !$string->hasLanguageType('PHP')) { |
|
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | <div class="form-hiddens"> |
| 206 | 206 | <?php |
| 207 | 207 | $params = $this->editor->getRequestParams(); |
| 208 | - foreach($params as $name => $value) { |
|
| 208 | + foreach ($params as $name => $value) { |
|
| 209 | 209 | ?> |
| 210 | 210 | <input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>"> |
| 211 | 211 | <?php |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | ?> |
| 294 | 294 | <select class="form-control" name="<?php echo $filterName ?>"> |
| 295 | 295 | <?php |
| 296 | - foreach($entries as $entry) |
|
| 296 | + foreach ($entries as $entry) |
|
| 297 | 297 | { |
| 298 | 298 | $selected = ''; |
| 299 | - if($entry['value'] === $value) { |
|
| 299 | + if ($entry['value'] === $value) { |
|
| 300 | 300 | $selected = ' selected'; |
| 301 | 301 | } |
| 302 | 302 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function addHashes(array $hashes) : Localization_Writer |
| 70 | 70 | { |
| 71 | - foreach($hashes as $hash => $text) |
|
| 71 | + foreach ($hashes as $hash => $text) |
|
| 72 | 72 | { |
| 73 | 73 | $this->addHash($hash, $text); |
| 74 | 74 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $hashes = $this->compileHashes(); |
| 91 | 91 | $lines = array(); |
| 92 | 92 | |
| 93 | - foreach($hashes as $entry) |
|
| 93 | + foreach ($hashes as $entry) |
|
| 94 | 94 | { |
| 95 | 95 | $lines[] = sprintf( |
| 96 | 96 | '%s= "%s"', |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | private function renderHead() : string |
| 108 | 108 | { |
| 109 | - $title = strtoupper($this->fileType).' TRANSLATION FILE FOR ' . strtoupper($this->locale->getLabel()); |
|
| 109 | + $title = strtoupper($this->fileType).' TRANSLATION FILE FOR '.strtoupper($this->locale->getLabel()); |
|
| 110 | 110 | |
| 111 | 111 | $lines = array(); |
| 112 | 112 | |
| 113 | 113 | $lines[] = '; -------------------------------------------------------'; |
| 114 | - $lines[] = '; '. $title; |
|
| 114 | + $lines[] = '; '.$title; |
|
| 115 | 115 | $lines[] = '; -------------------------------------------------------'; |
| 116 | 116 | $lines[] = '; '; |
| 117 | 117 | |
| 118 | - if($this->editable) |
|
| 118 | + if ($this->editable) |
|
| 119 | 119 | { |
| 120 | 120 | $lines[] = '; You may edit text directly in this file under the following conditions:'; |
| 121 | 121 | $lines[] = '; '; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $hashes = array(); |
| 139 | 139 | |
| 140 | - foreach($this->hashes as $hash => $text) |
|
| 140 | + foreach ($this->hashes as $hash => $text) |
|
| 141 | 141 | { |
| 142 | 142 | $hashes[] = array( |
| 143 | 143 | 'hash' => $hash, |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | $result = strnatcasecmp($a['text'], $b['text']); |
| 166 | 166 | |
| 167 | - if($result === 0) |
|
| 167 | + if ($result === 0) |
|
| 168 | 168 | { |
| 169 | 169 | return strnatcmp($a['hash'], $b['hash']); |
| 170 | 170 | } |
@@ -121,8 +121,7 @@ |
||
| 121 | 121 | $lines[] = '; '; |
| 122 | 122 | $lines[] = '; 1) Do not to modify the keys (left hand side of the = sign)'; |
| 123 | 123 | $lines[] = '; 2) Save the file as UTF-8 without BOM'; |
| 124 | - } |
|
| 125 | - else |
|
| 124 | + } else |
|
| 126 | 125 | { |
| 127 | 126 | $lines[] = '; Do NOT edit this file directly! It depends on the main translation file'; |
| 128 | 127 | $lines[] = '; and any changes will be lost. Edit the main file instead.'; |