@@ -18,24 +18,24 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | const FILES_CACHE_KEY = 'cachekey'; |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var bool |
|
| 23 | - */ |
|
| 21 | + /** |
|
| 22 | + * @var bool |
|
| 23 | + */ |
|
| 24 | 24 | protected $force = false; |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var Localization_Translator |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var Localization_Translator |
|
| 28 | + */ |
|
| 29 | 29 | protected $translator; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | 34 | protected $targetFolder; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | 39 | protected $cacheKeyFile; |
| 40 | 40 | |
| 41 | 41 | protected $cacheKey = ''; |
@@ -118,14 +118,14 @@ discard block |
||
| 118 | 118 | $this->writeCacheKey(); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Retrieves a list of all localization client |
|
| 123 | - * files that are written to disk. This includes |
|
| 124 | - * the locale files and the libraries required |
|
| 125 | - * to make it work clientside. |
|
| 126 | - * |
|
| 127 | - * @return string[] |
|
| 128 | - */ |
|
| 121 | + /** |
|
| 122 | + * Retrieves a list of all localization client |
|
| 123 | + * files that are written to disk. This includes |
|
| 124 | + * the locale files and the libraries required |
|
| 125 | + * to make it work clientside. |
|
| 126 | + * |
|
| 127 | + * @return string[] |
|
| 128 | + */ |
|
| 129 | 129 | public function getFilesList() : array |
| 130 | 130 | { |
| 131 | 131 | $files = array(); |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | $this->written[self::FILES_LOCALES] = true; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * Generates the cache key file, which is used to determine |
|
| 278 | - * automatically whether the client libraries need to be |
|
| 279 | - * refreshed. |
|
| 280 | - */ |
|
| 276 | + /** |
|
| 277 | + * Generates the cache key file, which is used to determine |
|
| 278 | + * automatically whether the client libraries need to be |
|
| 279 | + * refreshed. |
|
| 280 | + */ |
|
| 281 | 281 | protected function writeCacheKey() |
| 282 | 282 | { |
| 283 | 283 | if(file_exists($this->cacheKeyFile) && !$this->force) { |
@@ -289,18 +289,18 @@ discard block |
||
| 289 | 289 | $this->written[self::FILES_CACHE_KEY] = true; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - /** |
|
| 293 | - * Whether the specified files have been written to |
|
| 294 | - * disk this session. |
|
| 295 | - * |
|
| 296 | - * NOTE: only useful when called after <code>writeFiles</code>. |
|
| 297 | - * |
|
| 298 | - * @param string $filesID |
|
| 299 | - * |
|
| 300 | - * @see Localization_ClientGenerator::FILES_CACHE_KEY |
|
| 301 | - * @see Localization_ClientGenerator::FILES_LOCALES |
|
| 302 | - * @see Localization_ClientGenerator::FILES_LIBRARIES |
|
| 303 | - */ |
|
| 292 | + /** |
|
| 293 | + * Whether the specified files have been written to |
|
| 294 | + * disk this session. |
|
| 295 | + * |
|
| 296 | + * NOTE: only useful when called after <code>writeFiles</code>. |
|
| 297 | + * |
|
| 298 | + * @param string $filesID |
|
| 299 | + * |
|
| 300 | + * @see Localization_ClientGenerator::FILES_CACHE_KEY |
|
| 301 | + * @see Localization_ClientGenerator::FILES_LOCALES |
|
| 302 | + * @see Localization_ClientGenerator::FILES_LIBRARIES |
|
| 303 | + */ |
|
| 304 | 304 | public function areFilesWritten(string $filesID) |
| 305 | 305 | { |
| 306 | 306 | if(isset($this->written[$filesID])) { |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | protected function initCache() |
| 59 | 59 | { |
| 60 | 60 | // ignore it if it does not exist. |
| 61 | - if(!file_exists($this->cacheKeyFile)) { |
|
| 61 | + if (!file_exists($this->cacheKeyFile)) { |
|
| 62 | 62 | return; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $this->cacheKey = file_get_contents($this->cacheKeyFile); |
| 66 | 66 | |
| 67 | - if($this->cacheKey !== false) { |
|
| 67 | + if ($this->cacheKey !== false) { |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -77,22 +77,22 @@ discard block |
||
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function writeFiles(bool $force=false) : void |
|
| 80 | + public function writeFiles(bool $force = false) : void |
|
| 81 | 81 | { |
| 82 | 82 | // reset the write states for all files |
| 83 | 83 | $fileIDs = array_keys($this->written); |
| 84 | - foreach($fileIDs as $fileID) { |
|
| 84 | + foreach ($fileIDs as $fileID) { |
|
| 85 | 85 | $this->written[$fileID] = false; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // no client libraries folder set: ignore. |
| 89 | - if(empty($this->targetFolder)) { |
|
| 89 | + if (empty($this->targetFolder)) { |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | \AppUtils\FileHelper::createFolder($this->targetFolder); |
| 94 | 94 | |
| 95 | - if(!is_writable($this->targetFolder)) |
|
| 95 | + if (!is_writable($this->targetFolder)) |
|
| 96 | 96 | { |
| 97 | 97 | throw new Localization_Exception( |
| 98 | 98 | sprintf( |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if($this->cacheKey !== Localization::getClientLibrariesCacheKey()) { |
|
| 110 | + if ($this->cacheKey !== Localization::getClientLibrariesCacheKey()) { |
|
| 111 | 111 | $force = true; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -130,16 +130,16 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | $files = array(); |
| 132 | 132 | |
| 133 | - foreach($this->libraries as $fileName) |
|
| 133 | + foreach ($this->libraries as $fileName) |
|
| 134 | 134 | { |
| 135 | 135 | $files[] = $this->getLibraryFilePath($fileName); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $locales = Localization::getAppLocales(); |
| 139 | 139 | |
| 140 | - foreach($locales as $locale) |
|
| 140 | + foreach ($locales as $locale) |
|
| 141 | 141 | { |
| 142 | - if($locale->isNative()) { |
|
| 142 | + if ($locale->isNative()) { |
|
| 143 | 143 | continue; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | { |
| 154 | 154 | $locales = Localization::getAppLocales(); |
| 155 | 155 | |
| 156 | - foreach($locales as $locale) |
|
| 156 | + foreach ($locales as $locale) |
|
| 157 | 157 | { |
| 158 | - if($locale->isNative()) { |
|
| 158 | + if ($locale->isNative()) { |
|
| 159 | 159 | continue; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | $sourceFolder = realpath(__DIR__.'/../js'); |
| 174 | 174 | |
| 175 | - if($sourceFolder === false) |
|
| 175 | + if ($sourceFolder === false) |
|
| 176 | 176 | { |
| 177 | 177 | throw new Localization_Exception( |
| 178 | 178 | 'Unexpected folder structure encountered.', |
@@ -184,11 +184,11 @@ discard block |
||
| 184 | 184 | ); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - foreach($this->libraries as $fileName) |
|
| 187 | + foreach ($this->libraries as $fileName) |
|
| 188 | 188 | { |
| 189 | 189 | $targetFile = $this->getLibraryFilePath($fileName); |
| 190 | 190 | |
| 191 | - if(file_exists($targetFile) && !$this->force) { |
|
| 191 | + if (file_exists($targetFile) && !$this->force) { |
|
| 192 | 192 | continue; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -235,16 +235,16 @@ discard block |
||
| 235 | 235 | { |
| 236 | 236 | $path = $this->getLocaleFilePath($locale); |
| 237 | 237 | |
| 238 | - if(file_exists($path) && !$this->force) { |
|
| 238 | + if (file_exists($path) && !$this->force) { |
|
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $strings = $this->translator->getClientStrings($locale); |
| 243 | 243 | |
| 244 | 244 | $tokens = array(); |
| 245 | - foreach($strings as $hash => $text) |
|
| 245 | + foreach ($strings as $hash => $text) |
|
| 246 | 246 | { |
| 247 | - if(empty($text)) { |
|
| 247 | + if (empty($text)) { |
|
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | 250 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | ); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if(empty($tokens)) |
|
| 258 | + if (empty($tokens)) |
|
| 259 | 259 | { |
| 260 | 260 | $content = '/* No strings found. */'; |
| 261 | 261 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | */ |
| 281 | 281 | protected function writeCacheKey() |
| 282 | 282 | { |
| 283 | - if(file_exists($this->cacheKeyFile) && !$this->force) { |
|
| 283 | + if (file_exists($this->cacheKeyFile) && !$this->force) { |
|
| 284 | 284 | return; |
| 285 | 285 | } |
| 286 | 286 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | public function areFilesWritten(string $filesID) |
| 305 | 305 | { |
| 306 | - if(isset($this->written[$filesID])) { |
|
| 306 | + if (isset($this->written[$filesID])) { |
|
| 307 | 307 | return $this->written[$filesID]; |
| 308 | 308 | } |
| 309 | 309 | |
@@ -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. |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | protected $country; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | 39 | protected $countryCode; |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | 44 | protected $languageCode; |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | $this->languageCode = $tokens[0]; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Retrieves the two-letter language code of the locale. |
|
| 74 | - * |
|
| 75 | - * @return string Language code, e.g. "en", "de" |
|
| 76 | - */ |
|
| 72 | + /** |
|
| 73 | + * Retrieves the two-letter language code of the locale. |
|
| 74 | + * |
|
| 75 | + * @return string Language code, e.g. "en", "de" |
|
| 76 | + */ |
|
| 77 | 77 | public function getLanguageCode() : string |
| 78 | 78 | { |
| 79 | 79 | return $this->languageCode; |
@@ -100,25 +100,25 @@ discard block |
||
| 100 | 100 | return $this->localeName; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Retrieves the shortened version of the locale name, |
|
| 105 | - * e.g. "en" or "de". |
|
| 106 | - * |
|
| 107 | - * @return string |
|
| 108 | - * @deprecated |
|
| 109 | - * @see Localization_Locale::getLanguageCode() |
|
| 110 | - */ |
|
| 103 | + /** |
|
| 104 | + * Retrieves the shortened version of the locale name, |
|
| 105 | + * e.g. "en" or "de". |
|
| 106 | + * |
|
| 107 | + * @return string |
|
| 108 | + * @deprecated |
|
| 109 | + * @see Localization_Locale::getLanguageCode() |
|
| 110 | + */ |
|
| 111 | 111 | public function getShortName() : string |
| 112 | 112 | { |
| 113 | 113 | return $this->getLanguageCode(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Retrieves the two-letter country code of |
|
| 118 | - * the locale. |
|
| 119 | - * |
|
| 120 | - * @return string Lowercase code, e.g. "uk" |
|
| 121 | - */ |
|
| 116 | + /** |
|
| 117 | + * Retrieves the two-letter country code of |
|
| 118 | + * the locale. |
|
| 119 | + * |
|
| 120 | + * @return string Lowercase code, e.g. "uk" |
|
| 121 | + */ |
|
| 122 | 122 | public function getCountryCode() : string |
| 123 | 123 | { |
| 124 | 124 | return $this->countryCode; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function __construct(string $localeName) |
| 51 | 51 | { |
| 52 | - if(!self::isLocaleKnown($localeName)) |
|
| 52 | + if (!self::isLocaleKnown($localeName)) |
|
| 53 | 53 | { |
| 54 | 54 | throw new Localization_Exception( |
| 55 | 55 | 'Invalid locale', |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function getLabel() : string |
| 146 | 146 | { |
| 147 | - switch($this->localeName) |
|
| 147 | + switch ($this->localeName) |
|
| 148 | 148 | { |
| 149 | 149 | case 'de_DE': |
| 150 | 150 | return t('German'); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | throw new Localization_Exception( |
| 172 | - 'Label is missing for the locale ' . $this->localeName, |
|
| 172 | + 'Label is missing for the locale '.$this->localeName, |
|
| 173 | 173 | null, |
| 174 | 174 | self::ERROR_LOCALE_LABEL_MISSING |
| 175 | 175 | ); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function getCountry() : Localization_Country |
| 183 | 183 | { |
| 184 | - if(!isset($this->country)) { |
|
| 184 | + if (!isset($this->country)) { |
|
| 185 | 185 | $this->country = Localization::createCountry($this->countryCode); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -17,49 +17,49 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | protected $parser; |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * The function names that are included in the search. |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 20 | + /** |
|
| 21 | + * The function names that are included in the search. |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | 24 | protected $functionNames = array(); |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The tokens definitions. |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 26 | + /** |
|
| 27 | + * The tokens definitions. |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | 30 | protected $tokens = array(); |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The total amount of tokens found in the content. |
|
| 34 | - * @var integer |
|
| 35 | - */ |
|
| 32 | + /** |
|
| 33 | + * The total amount of tokens found in the content. |
|
| 34 | + * @var integer |
|
| 35 | + */ |
|
| 36 | 36 | protected $totalTokens = 0; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * All texts that have been collected. |
|
| 40 | - * @var array |
|
| 41 | - */ |
|
| 38 | + /** |
|
| 39 | + * All texts that have been collected. |
|
| 40 | + * @var array |
|
| 41 | + */ |
|
| 42 | 42 | protected $texts = array(); |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 44 | + /** |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | 47 | protected $content = ''; |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 49 | + /** |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | 52 | protected $id; |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var array |
|
| 56 | - */ |
|
| 54 | + /** |
|
| 55 | + * @var array |
|
| 56 | + */ |
|
| 57 | 57 | protected $warnings = array(); |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * The source file that was parsed (if any) |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 59 | + /** |
|
| 60 | + * The source file that was parsed (if any) |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | 63 | protected $sourceFile = ''; |
| 64 | 64 | |
| 65 | 65 | public function __construct(Localization_Parser $parser) |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | abstract protected function getTokens() : array; |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Retrieves the ID of the language. |
|
| 75 | - * @return string E.g. "PHP", "Javascript" |
|
| 76 | - */ |
|
| 73 | + /** |
|
| 74 | + * Retrieves the ID of the language. |
|
| 75 | + * @return string E.g. "PHP", "Javascript" |
|
| 76 | + */ |
|
| 77 | 77 | public function getID() : string |
| 78 | 78 | { |
| 79 | 79 | if(!isset($this->id)) { |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | return $this->sourceFile; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * Parses the code from a file. |
|
| 98 | - * |
|
| 99 | - * @param string $path |
|
| 100 | - * @throws Localization_Exception |
|
| 101 | - */ |
|
| 96 | + /** |
|
| 97 | + * Parses the code from a file. |
|
| 98 | + * |
|
| 99 | + * @param string $path |
|
| 100 | + * @throws Localization_Exception |
|
| 101 | + */ |
|
| 102 | 102 | public function parseFile(string $path) : void |
| 103 | 103 | { |
| 104 | 104 | if(!file_exists($path)) |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | ); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Parses a source code string. |
|
| 136 | - * @param string $content |
|
| 137 | - */ |
|
| 134 | + /** |
|
| 135 | + * Parses a source code string. |
|
| 136 | + * @param string $content |
|
| 137 | + */ |
|
| 138 | 138 | public function parseString($content) : void |
| 139 | 139 | { |
| 140 | 140 | $this->content = $content; |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Retrieves a list of all the function names that are |
|
| 180 | - * used as translation functions in the language. |
|
| 181 | - * @return array |
|
| 182 | - */ |
|
| 178 | + /** |
|
| 179 | + * Retrieves a list of all the function names that are |
|
| 180 | + * used as translation functions in the language. |
|
| 181 | + * @return array |
|
| 182 | + */ |
|
| 183 | 183 | public function getFunctionNames() : array |
| 184 | 184 | { |
| 185 | 185 | return $this->createToken('dummy')->getFunctionNames(); |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | Localization::log(sprintf('%1$s parser | %2$s', $this->getID(), $message)); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Adds a warning message when a text cannot be parsed correctly for some reason. |
|
| 195 | - * |
|
| 196 | - * @param Localization_Parser_Token $token |
|
| 197 | - * @param string $message |
|
| 198 | - * @return Localization_Parser_Warning |
|
| 199 | - */ |
|
| 193 | + /** |
|
| 194 | + * Adds a warning message when a text cannot be parsed correctly for some reason. |
|
| 195 | + * |
|
| 196 | + * @param Localization_Parser_Token $token |
|
| 197 | + * @param string $message |
|
| 198 | + * @return Localization_Parser_Warning |
|
| 199 | + */ |
|
| 200 | 200 | protected function addWarning(Localization_Parser_Token $token, string $message) : Localization_Parser_Warning |
| 201 | 201 | { |
| 202 | 202 | $warning = new Localization_Parser_Warning($this, $token, $message); |
@@ -206,34 +206,34 @@ discard block |
||
| 206 | 206 | return $warning; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * Whether any warnings were generated during parsing. |
|
| 211 | - * @return bool |
|
| 212 | - */ |
|
| 209 | + /** |
|
| 210 | + * Whether any warnings were generated during parsing. |
|
| 211 | + * @return bool |
|
| 212 | + */ |
|
| 213 | 213 | public function hasWarnings() : bool |
| 214 | 214 | { |
| 215 | 215 | return !empty($this->warnings); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - /** |
|
| 219 | - * Retrieves all warnings that were generated during parsing, |
|
| 220 | - * if any. |
|
| 221 | - * |
|
| 222 | - * @return Localization_Parser_Warning[] |
|
| 223 | - */ |
|
| 218 | + /** |
|
| 219 | + * Retrieves all warnings that were generated during parsing, |
|
| 220 | + * if any. |
|
| 221 | + * |
|
| 222 | + * @return Localization_Parser_Warning[] |
|
| 223 | + */ |
|
| 224 | 224 | public function getWarnings() |
| 225 | 225 | { |
| 226 | 226 | return $this->warnings; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Creates a token instance: this retrieves information on |
|
| 231 | - * the language token being parsed. |
|
| 232 | - * |
|
| 233 | - * @param array|string $definition The token definition. |
|
| 234 | - * @param Localization_Parser_Token $parentToken |
|
| 235 | - * @return Localization_Parser_Token |
|
| 236 | - */ |
|
| 229 | + /** |
|
| 230 | + * Creates a token instance: this retrieves information on |
|
| 231 | + * the language token being parsed. |
|
| 232 | + * |
|
| 233 | + * @param array|string $definition The token definition. |
|
| 234 | + * @param Localization_Parser_Token $parentToken |
|
| 235 | + * @return Localization_Parser_Token |
|
| 236 | + */ |
|
| 237 | 237 | protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token |
| 238 | 238 | { |
| 239 | 239 | $class = '\AppLocalize\Localization_Parser_Token_'.$this->getID(); |
@@ -241,12 +241,12 @@ discard block |
||
| 241 | 241 | return new $class($definition, $parentToken); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - /** |
|
| 245 | - * Parses a translation function token. |
|
| 246 | - * |
|
| 247 | - * @param int $number |
|
| 248 | - * @param Localization_Parser_Token $token |
|
| 249 | - */ |
|
| 244 | + /** |
|
| 245 | + * Parses a translation function token. |
|
| 246 | + * |
|
| 247 | + * @param int $number |
|
| 248 | + * @param Localization_Parser_Token $token |
|
| 249 | + */ |
|
| 250 | 250 | protected function parseToken(int $number, Localization_Parser_Token $token) |
| 251 | 251 | { |
| 252 | 252 | $textParts = array(); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getID() : string |
| 78 | 78 | { |
| 79 | - if(!isset($this->id)) { |
|
| 79 | + if (!isset($this->id)) { |
|
| 80 | 80 | $this->id = str_replace('AppLocalize\Localization_Parser_Language_', '', get_class($this)); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function parseFile(string $path) : void |
| 103 | 103 | { |
| 104 | - if(!file_exists($path)) |
|
| 104 | + if (!file_exists($path)) |
|
| 105 | 105 | { |
| 106 | 106 | throw new Localization_Exception( |
| 107 | 107 | sprintf('Source code file [%s] not found', basename($path)), |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $this->sourceFile = $path; |
| 117 | 117 | $this->content = file_get_contents($path); |
| 118 | 118 | |
| 119 | - if($this->content !== false) { |
|
| 119 | + if ($this->content !== false) { |
|
| 120 | 120 | $this->parse(); |
| 121 | 121 | return; |
| 122 | 122 | } |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | $this->tokens = $this->getTokens(); |
| 151 | 151 | $this->totalTokens = count($this->tokens); |
| 152 | 152 | |
| 153 | - for($i = 0; $i < $this->totalTokens; $i++) |
|
| 153 | + for ($i = 0; $i < $this->totalTokens; $i++) |
|
| 154 | 154 | { |
| 155 | 155 | $token = $this->createToken($this->tokens[$i]); |
| 156 | 156 | |
| 157 | - if($token->isTranslationFunction()) { |
|
| 158 | - $this->parseToken($i+1, $token); |
|
| 157 | + if ($token->isTranslationFunction()) { |
|
| 158 | + $this->parseToken($i + 1, $token); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | return $this->texts; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - protected function addResult($text, $line=null) |
|
| 168 | + protected function addResult($text, $line = null) |
|
| 169 | 169 | { |
| 170 | 170 | $this->log(sprintf('Line [%1$s] | Found string [%2$s]', $line, $text)); |
| 171 | 171 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param Localization_Parser_Token $parentToken |
| 235 | 235 | * @return Localization_Parser_Token |
| 236 | 236 | */ |
| 237 | - protected function createToken($definition, Localization_Parser_Token $parentToken=null) : Localization_Parser_Token |
|
| 237 | + protected function createToken($definition, Localization_Parser_Token $parentToken = null) : Localization_Parser_Token |
|
| 238 | 238 | { |
| 239 | 239 | $class = '\AppLocalize\Localization_Parser_Token_'.$this->getID(); |
| 240 | 240 | |
@@ -253,43 +253,43 @@ discard block |
||
| 253 | 253 | $max = $number + 200; |
| 254 | 254 | $open = false; |
| 255 | 255 | |
| 256 | - for($i = $number; $i < $max; $i++) |
|
| 256 | + for ($i = $number; $i < $max; $i++) |
|
| 257 | 257 | { |
| 258 | - if(!isset($this->tokens[$i])) { |
|
| 258 | + if (!isset($this->tokens[$i])) { |
|
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $subToken = $this->createToken($this->tokens[$i], $token); |
| 263 | 263 | |
| 264 | - if(!$open && $subToken->isOpeningFuncParams()) |
|
| 264 | + if (!$open && $subToken->isOpeningFuncParams()) |
|
| 265 | 265 | { |
| 266 | 266 | $open = true; |
| 267 | 267 | continue; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if($open && $subToken->isClosingFuncParams()) { |
|
| 270 | + if ($open && $subToken->isClosingFuncParams()) { |
|
| 271 | 271 | break; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // additional parameters in the translation function, we don't want to capture these now. |
| 275 | - if($open && $subToken->isArgumentSeparator()) { |
|
| 275 | + if ($open && $subToken->isArgumentSeparator()) { |
|
| 276 | 276 | break; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if($open && $subToken->isEncapsedString()) |
|
| 279 | + if ($open && $subToken->isEncapsedString()) |
|
| 280 | 280 | { |
| 281 | 281 | $textParts[] = $this->trimText($subToken->getValue()); |
| 282 | 282 | continue; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - if($open && $subToken->isVariableOrFunction()) { |
|
| 285 | + if ($open && $subToken->isVariableOrFunction()) { |
|
| 286 | 286 | $textParts = null; |
| 287 | 287 | $this->addWarning($subToken, t('Variables or functions are not supported in translation functions.')); |
| 288 | 288 | break; |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if(empty($textParts)) { |
|
| 292 | + if (empty($textParts)) { |
|
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | protected function debug($text) |
| 302 | 302 | { |
| 303 | - if($this->debug) { |
|
| 303 | + if ($this->debug) { |
|
| 304 | 304 | echo $text; |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -4,14 +4,14 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | abstract class Localization_Parser_Token |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * @var array|string |
|
| 9 | - */ |
|
| 7 | + /** |
|
| 8 | + * @var array|string |
|
| 9 | + */ |
|
| 10 | 10 | protected $definition; |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @var Localization_Parser_Token |
|
| 14 | - */ |
|
| 12 | + /** |
|
| 13 | + * @var Localization_Parser_Token |
|
| 14 | + */ |
|
| 15 | 15 | protected $parentToken; |
| 16 | 16 | |
| 17 | 17 | protected $token; |
@@ -66,6 +66,6 @@ discard block |
||
| 66 | 66 | 'value' => $this->getValue(), |
| 67 | 67 | 'line' => $this->getLine(), |
| 68 | 68 | 'isEncapsedString' => \AppUtils\ConvertHelper::bool2string($this->isEncapsedString()) |
| 69 | - ); |
|
| 69 | + ); |
|
| 70 | 70 | } |
| 71 | 71 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | protected $line = 0; |
| 22 | 22 | |
| 23 | - public function __construct($definition, Localization_Parser_Token $parentToken=null) |
|
| 23 | + public function __construct($definition, Localization_Parser_Token $parentToken = null) |
|
| 24 | 24 | { |
| 25 | 25 | $this->definition = $definition; |
| 26 | 26 | $this->parentToken = $parentToken; |
@@ -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 | } |
@@ -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 = \JTokenizer\JTokenizer::getTokenName($this->definition[0]); |
| 24 | 23 | $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]; |
@@ -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 | } |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | const ERROR_UNSUPPORTED_FILE_EXTENSION = 40602; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var Localization_Scanner |
|
| 32 | - */ |
|
| 30 | + /** |
|
| 31 | + * @var Localization_Scanner |
|
| 32 | + */ |
|
| 33 | 33 | protected $scanner; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var Localization_Scanner_StringsCollection |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var Localization_Scanner_StringsCollection |
|
| 37 | + */ |
|
| 38 | 38 | protected $collection; |
| 39 | 39 | |
| 40 | 40 | protected $languageMappings = array( |
@@ -48,15 +48,15 @@ discard block |
||
| 48 | 48 | $this->collection = $scanner->getCollection(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Parses a source file. Must have a valid supported file extension. |
|
| 53 | - * |
|
| 54 | - * @param string $path |
|
| 55 | - * @return Localization_Parser_Language |
|
| 56 | - * @throws Localization_Exception |
|
| 57 | - * |
|
| 58 | - * @see Localization_Parser::ERROR_UNSUPPORTED_FILE_EXTENSION |
|
| 59 | - */ |
|
| 51 | + /** |
|
| 52 | + * Parses a source file. Must have a valid supported file extension. |
|
| 53 | + * |
|
| 54 | + * @param string $path |
|
| 55 | + * @return Localization_Parser_Language |
|
| 56 | + * @throws Localization_Exception |
|
| 57 | + * |
|
| 58 | + * @see Localization_Parser::ERROR_UNSUPPORTED_FILE_EXTENSION |
|
| 59 | + */ |
|
| 60 | 60 | public function parseFile(string $path) : Localization_Parser_Language |
| 61 | 61 | { |
| 62 | 62 | $this->requireValidFile($path); |
@@ -70,16 +70,16 @@ discard block |
||
| 70 | 70 | return $language; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Parses the string for the specified language. |
|
| 75 | - * |
|
| 76 | - * @param string $languageID |
|
| 77 | - * @param string $code |
|
| 78 | - * @return Localization_Parser_Language |
|
| 79 | - * @throws Localization_Exception |
|
| 80 | - * |
|
| 81 | - * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID |
|
| 82 | - */ |
|
| 73 | + /** |
|
| 74 | + * Parses the string for the specified language. |
|
| 75 | + * |
|
| 76 | + * @param string $languageID |
|
| 77 | + * @param string $code |
|
| 78 | + * @return Localization_Parser_Language |
|
| 79 | + * @throws Localization_Exception |
|
| 80 | + * |
|
| 81 | + * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID |
|
| 82 | + */ |
|
| 83 | 83 | public function parseString(string $languageID, string $code) : Localization_Parser_Language |
| 84 | 84 | { |
| 85 | 85 | $this->requireValidLanguageID($languageID); |
@@ -128,29 +128,29 @@ discard block |
||
| 128 | 128 | ); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Retrieves a list of all language IDs that are supported. |
|
| 133 | - * @return string[] IDs list like "PHP", "Javascript" |
|
| 134 | - */ |
|
| 131 | + /** |
|
| 132 | + * Retrieves a list of all language IDs that are supported. |
|
| 133 | + * @return string[] IDs list like "PHP", "Javascript" |
|
| 134 | + */ |
|
| 135 | 135 | public function getLanguageIDs() : array |
| 136 | 136 | { |
| 137 | 137 | return array_values($this->languageMappings); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * @var Localization_Parser_Language[] |
|
| 142 | - */ |
|
| 140 | + /** |
|
| 141 | + * @var Localization_Parser_Language[] |
|
| 142 | + */ |
|
| 143 | 143 | protected $languageParsers = array(); |
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Creates a parser for the specified language, e.g. "PHP". |
|
| 147 | - * NOTE: Existing parser instances are re-used. |
|
| 148 | - * |
|
| 149 | - * @param string $languageID |
|
| 150 | - * @return Localization_Parser_Language |
|
| 151 | - * |
|
| 152 | - * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID |
|
| 153 | - */ |
|
| 145 | + /** |
|
| 146 | + * Creates a parser for the specified language, e.g. "PHP". |
|
| 147 | + * NOTE: Existing parser instances are re-used. |
|
| 148 | + * |
|
| 149 | + * @param string $languageID |
|
| 150 | + * @return Localization_Parser_Language |
|
| 151 | + * |
|
| 152 | + * @see Localization_Parser::ERROR_INVALID_LANGUAGE_ID |
|
| 153 | + */ |
|
| 154 | 154 | public function createLanguage(string $languageID) |
| 155 | 155 | { |
| 156 | 156 | $this->requireValidLanguageID($languageID); |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | return $this->languageParsers[$languageID]; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Whether the specified file extension is supported. |
|
| 170 | - * |
|
| 171 | - * @param string $ext |
|
| 172 | - * @return bool |
|
| 173 | - */ |
|
| 168 | + /** |
|
| 169 | + * Whether the specified file extension is supported. |
|
| 170 | + * |
|
| 171 | + * @param string $ext |
|
| 172 | + * @return bool |
|
| 173 | + */ |
|
| 174 | 174 | public function isExtensionSupported(string $ext) : bool |
| 175 | 175 | { |
| 176 | 176 | $ext = strtolower($ext); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | $ext = \AppUtils\FileHelper::getExtension($path); |
| 97 | 97 | |
| 98 | - if($this->isExtensionSupported($ext)) { |
|
| 98 | + if ($this->isExtensionSupported($ext)) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | { |
| 114 | 114 | $values = $this->getLanguageIDs(); |
| 115 | 115 | |
| 116 | - if(in_array($languageID, $values)) { |
|
| 116 | + if (in_array($languageID, $values)) { |
|
| 117 | 117 | return; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | $this->requireValidLanguageID($languageID); |
| 157 | 157 | |
| 158 | - if(!isset($this->languageParsers[$languageID])) |
|
| 158 | + if (!isset($this->languageParsers[$languageID])) |
|
| 159 | 159 | { |
| 160 | 160 | $class = '\AppLocalize\Localization_Parser_Language_'.$languageID; |
| 161 | 161 | |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class Localization_Event_LocaleChanged extends Localization_Event |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * The locale that was used before the change, if any. |
|
| 25 | - * @return Localization_Locale|NULL |
|
| 26 | - */ |
|
| 23 | + /** |
|
| 24 | + * The locale that was used before the change, if any. |
|
| 25 | + * @return Localization_Locale|NULL |
|
| 26 | + */ |
|
| 27 | 27 | public function getPrevious() : ?Localization_Locale |
| 28 | 28 | { |
| 29 | 29 | $arg = $this->getArgument(1); |
@@ -34,38 +34,38 @@ discard block |
||
| 34 | 34 | return null; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * The locale that is used now after the change. |
|
| 39 | - * @return Localization_Locale |
|
| 40 | - */ |
|
| 37 | + /** |
|
| 38 | + * The locale that is used now after the change. |
|
| 39 | + * @return Localization_Locale |
|
| 40 | + */ |
|
| 41 | 41 | public function getCurrent() : Localization_Locale |
| 42 | 42 | { |
| 43 | 43 | $arg = $this->getArgument(2); |
| 44 | 44 | return $arg['locale']; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The namespace in which the locale change occurred. |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 47 | + /** |
|
| 48 | + * The namespace in which the locale change occurred. |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | 51 | public function getNamespace() : string |
| 52 | 52 | { |
| 53 | 53 | return $this->getArgument(0); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Whether the change occurred for an application locale. |
|
| 58 | - * @return bool |
|
| 59 | - */ |
|
| 56 | + /** |
|
| 57 | + * Whether the change occurred for an application locale. |
|
| 58 | + * @return bool |
|
| 59 | + */ |
|
| 60 | 60 | public function isAppLocale() : bool |
| 61 | 61 | { |
| 62 | 62 | return $this->getNamespace() === Localization::NAMESPACE_APPLICATION; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Whether the change occurred for a content locale. |
|
| 67 | - * @return bool |
|
| 68 | - */ |
|
| 65 | + /** |
|
| 66 | + * Whether the change occurred for a content locale. |
|
| 67 | + * @return bool |
|
| 68 | + */ |
|
| 69 | 69 | public function isContentLocale() : bool |
| 70 | 70 | { |
| 71 | 71 | return $this->getNamespace() === Localization::NAMESPACE_CONTENT; |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | public function getPrevious() : ?Localization_Locale |
| 28 | 28 | { |
| 29 | 29 | $arg = $this->getArgument(1); |
| 30 | - if(is_array($arg)) { |
|
| 30 | + if (is_array($arg)) { |
|
| 31 | 31 | return $arg['locale']; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | protected function initSession() |
| 109 | 109 | { |
| 110 | - if(session_status() != PHP_SESSION_ACTIVE) { |
|
| 110 | + if (session_status() != PHP_SESSION_ACTIVE) { |
|
| 111 | 111 | session_start(); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if(!isset($_SESSION['localization_messages'])) { |
|
| 114 | + if (!isset($_SESSION['localization_messages'])) { |
|
| 115 | 115 | $_SESSION['localization_messages'] = array(); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | { |
| 126 | 126 | $this->sources = Localization::getSources(); |
| 127 | 127 | |
| 128 | - if(empty($this->sources)) |
|
| 128 | + if (empty($this->sources)) |
|
| 129 | 129 | { |
| 130 | 130 | throw new Localization_Exception( |
| 131 | 131 | 'Cannot start editor: no sources defined.', |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $activeID = $this->request->registerParam($this->getVarName('source'))->setEnum(Localization::getSourceIDs())->get(); |
| 138 | - if(empty($activeID)) { |
|
| 138 | + if (empty($activeID)) { |
|
| 139 | 139 | $activeID = $this->getDefaultSourceID(); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | protected function getDefaultSourceID() |
| 146 | 146 | { |
| 147 | 147 | $default = $this->getOption('default-source'); |
| 148 | - if(!empty($default) && Localization::sourceAliasExists($default)) { |
|
| 148 | + if (!empty($default) && Localization::sourceAliasExists($default)) { |
|
| 149 | 149 | return Localization::getSourceByAlias($default)->getID(); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -157,21 +157,21 @@ discard block |
||
| 157 | 157 | $names = array(); |
| 158 | 158 | |
| 159 | 159 | $locales = Localization::getAppLocales(); |
| 160 | - foreach($locales as $locale) { |
|
| 161 | - if(!$locale->isNative()) { |
|
| 160 | + foreach ($locales as $locale) { |
|
| 161 | + if (!$locale->isNative()) { |
|
| 162 | 162 | $this->appLocales[] = $locale; |
| 163 | 163 | $names[] = $locale->getName(); |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // use the default locale if no other is available. |
| 168 | - if(empty($names)) { |
|
| 168 | + if (empty($names)) { |
|
| 169 | 169 | $this->activeAppLocale = Localization::getAppLocale(); |
| 170 | 170 | return; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $activeID = $this->request->registerParam($this->getVarName('locale'))->setEnum($names)->get(); |
| 174 | - if(empty($activeID)) { |
|
| 174 | + if (empty($activeID)) { |
|
| 175 | 175 | $activeID = $this->appLocales[0]->getName(); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $this->filters = new Localization_Editor_Filters($this); |
| 191 | 191 | |
| 192 | - if($this->request->getBool($this->getVarName('scan'))) |
|
| 192 | + if ($this->request->getBool($this->getVarName('scan'))) |
|
| 193 | 193 | { |
| 194 | 194 | $this->executeScan(); |
| 195 | 195 | } |
| 196 | - else if($this->request->getBool($this->getVarName('save'))) |
|
| 196 | + else if ($this->request->getBool($this->getVarName('save'))) |
|
| 197 | 197 | { |
| 198 | 198 | $this->executeSave(); |
| 199 | 199 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | <div class="collapse navbar-collapse" id="navbarsExampleDefault"> |
| 233 | 233 | <?php |
| 234 | - if(!empty($this->appLocales)) |
|
| 234 | + if (!empty($this->appLocales)) |
|
| 235 | 235 | { |
| 236 | 236 | ?> |
| 237 | 237 | <ul class="navbar-nav mr-auto"> |
@@ -241,12 +241,12 @@ discard block |
||
| 241 | 241 | </a> |
| 242 | 242 | <div class="dropdown-menu" aria-labelledby="dropdown01"> |
| 243 | 243 | <?php |
| 244 | - foreach($this->sources as $source) |
|
| 244 | + foreach ($this->sources as $source) |
|
| 245 | 245 | { |
| 246 | 246 | ?> |
| 247 | 247 | <a class="dropdown-item" href="<?php echo $this->getSourceURL($source) ?>"> |
| 248 | 248 | <?php |
| 249 | - if($source->getID() === $this->activeSource->getID()) |
|
| 249 | + if ($source->getID() === $this->activeSource->getID()) |
|
| 250 | 250 | { |
| 251 | 251 | ?> |
| 252 | 252 | <b><?php echo $source->getLabel() ?></b> |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | ?> |
| 260 | 260 | <?php |
| 261 | 261 | $untranslated = $source->countUntranslated($this->scanner); |
| 262 | - if($untranslated > 0) { |
|
| 262 | + if ($untranslated > 0) { |
|
| 263 | 263 | ?> |
| 264 | 264 | (<span class="text-danger" title="<?php pt('%1$s texts have not been translated in this text source.', $untranslated) ?>"><?php echo $untranslated ?></span>) |
| 265 | 265 | <?php |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | </a> |
| 278 | 278 | <div class="dropdown-menu" aria-labelledby="dropdown01"> |
| 279 | 279 | <?php |
| 280 | - foreach($this->appLocales as $locale) |
|
| 280 | + foreach ($this->appLocales as $locale) |
|
| 281 | 281 | { |
| 282 | 282 | ?> |
| 283 | 283 | <a class="dropdown-item" href="<?php echo $this->getLocaleURL($locale) ?>"> |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | </a> |
| 296 | 296 | </li> |
| 297 | 297 | <?php |
| 298 | - if($this->scanner->hasWarnings()) { |
|
| 298 | + if ($this->scanner->hasWarnings()) { |
|
| 299 | 299 | ?> |
| 300 | 300 | <li class="nav-item"> |
| 301 | 301 | <a href="<?php echo $this->getWarningsURL() ?>"> |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | ?> |
| 315 | 315 | <?php |
| 316 | 316 | $backURL = $this->getOption('back-url'); |
| 317 | - if(!empty($backURL)) |
|
| 317 | + if (!empty($backURL)) |
|
| 318 | 318 | { |
| 319 | 319 | ?> |
| 320 | 320 | <a href="<?php echo $backURL ?>" class="btn btn-light btn-sm"> |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | <main role="main" class="container"> |
| 330 | 330 | <div> |
| 331 | 331 | <?php |
| 332 | - if(empty($this->appLocales)) |
|
| 332 | + if (empty($this->appLocales)) |
|
| 333 | 333 | { |
| 334 | 334 | ?> |
| 335 | 335 | <div class="alert alert-danger"> |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | </div> |
| 340 | 340 | <?php |
| 341 | 341 | } |
| 342 | - else if($this->request->getBool($this->getVarName('warnings'))) |
|
| 342 | + else if ($this->request->getBool($this->getVarName('warnings'))) |
|
| 343 | 343 | { |
| 344 | 344 | echo $this->renderWarnings(); |
| 345 | 345 | } |
@@ -348,9 +348,9 @@ discard block |
||
| 348 | 348 | ?> |
| 349 | 349 | <h1><?php echo $this->activeSource->getLabel() ?></h1> |
| 350 | 350 | <?php |
| 351 | - if(!empty($_SESSION['localization_messages'])) |
|
| 351 | + if (!empty($_SESSION['localization_messages'])) |
|
| 352 | 352 | { |
| 353 | - foreach($_SESSION['localization_messages'] as $def) |
|
| 353 | + foreach ($_SESSION['localization_messages'] as $def) |
|
| 354 | 354 | { |
| 355 | 355 | ?> |
| 356 | 356 | <div class="alert alert-<?php echo $def['type'] ?>" role="alert"> |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | </p> |
| 380 | 380 | <br> |
| 381 | 381 | <?php |
| 382 | - if(!$this->scanner->isScanAvailable()) |
|
| 382 | + if (!$this->scanner->isScanAvailable()) |
|
| 383 | 383 | { |
| 384 | 384 | ?> |
| 385 | 385 | <div class="alert alert-primary" role="alert"> |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | <?php |
| 427 | 427 | $warnings = $this->scanner->getWarnings(); |
| 428 | 428 | |
| 429 | - foreach($warnings as $warning) |
|
| 429 | + foreach ($warnings as $warning) |
|
| 430 | 430 | { |
| 431 | 431 | ?> |
| 432 | 432 | <dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt> |
@@ -447,9 +447,9 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | $result = array(); |
| 449 | 449 | |
| 450 | - foreach($strings as $string) |
|
| 450 | + foreach ($strings as $string) |
|
| 451 | 451 | { |
| 452 | - if($this->filters->isStringMatch($string)) { |
|
| 452 | + if ($this->filters->isStringMatch($string)) { |
|
| 453 | 453 | $result[] = $string; |
| 454 | 454 | } |
| 455 | 455 | } |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | { |
| 473 | 473 | $strings = $this->getFilteredStrings(); |
| 474 | 474 | |
| 475 | - if(empty($strings)) |
|
| 475 | + if (empty($strings)) |
|
| 476 | 476 | { |
| 477 | 477 | ?> |
| 478 | 478 | <div class="alert alert-info"> |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | <div class="form-hiddens"> |
| 495 | 495 | <?php |
| 496 | 496 | $params = $this->getRequestParams(); |
| 497 | - foreach($params as $name => $value) { |
|
| 497 | + foreach ($params as $name => $value) { |
|
| 498 | 498 | ?> |
| 499 | 499 | <input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>"> |
| 500 | 500 | <?php |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | </thead> |
| 513 | 513 | <tbody> |
| 514 | 514 | <?php |
| 515 | - foreach($keep as $string) |
|
| 515 | + foreach ($keep as $string) |
|
| 516 | 516 | { |
| 517 | 517 | $this->renderListEntry($string); |
| 518 | 518 | } |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | </tbody> |
| 521 | 521 | </table> |
| 522 | 522 | <?php |
| 523 | - if($pager->hasPages()) |
|
| 523 | + if ($pager->hasPages()) |
|
| 524 | 524 | { |
| 525 | 525 | $prevUrl = $this->getPaginationURL($pager->getPreviousPage()); |
| 526 | 526 | $nextUrl = $this->getPaginationURL($pager->getNextPage()); |
@@ -535,12 +535,12 @@ discard block |
||
| 535 | 535 | </li> |
| 536 | 536 | <?php |
| 537 | 537 | $numbers = $pager->getPageNumbers(); |
| 538 | - foreach($numbers as $number) |
|
| 538 | + foreach ($numbers as $number) |
|
| 539 | 539 | { |
| 540 | 540 | $url = $this->getPaginationURL($number); |
| 541 | 541 | |
| 542 | 542 | ?> |
| 543 | - <li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>"> |
|
| 543 | + <li class="page-item <?php if ($pager->isCurrentPage($number)) { echo 'active'; } ?>"> |
|
| 544 | 544 | <a class="page-link" href="<?php echo $url ?>"> |
| 545 | 545 | <?php echo $number ?> |
| 546 | 546 | </a> |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | <?php |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - protected function getPaginationURL(int $page, $params=array()) |
|
| 573 | + protected function getPaginationURL(int $page, $params = array()) |
|
| 574 | 574 | { |
| 575 | 575 | $params[$this->getVarName('page')] = $page; |
| 576 | 576 | |
@@ -582,11 +582,11 @@ discard block |
||
| 582 | 582 | $hash = $string->getHash(); |
| 583 | 583 | |
| 584 | 584 | $previewText = $string->getTranslatedText(); |
| 585 | - if(empty($previewText)) { |
|
| 585 | + if (empty($previewText)) { |
|
| 586 | 586 | $previewText = $string->getText(); |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - $shortText = $this->renderText($previewText, 50); |
|
| 589 | + $shortText = $this->renderText($previewText, 50); |
|
| 590 | 590 | |
| 591 | 591 | $files = $string->getFiles(); |
| 592 | 592 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | <?php |
| 618 | 618 | $totalFiles = count($files); |
| 619 | 619 | |
| 620 | - if($totalFiles == 1) |
|
| 620 | + if ($totalFiles == 1) |
|
| 621 | 621 | { |
| 622 | 622 | pt('Found in a single file:'); |
| 623 | 623 | } |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | <?php |
| 633 | 633 | $locations = $string->getStrings(); |
| 634 | 634 | |
| 635 | - foreach($locations as $location) |
|
| 635 | + foreach ($locations as $location) |
|
| 636 | 636 | { |
| 637 | 637 | $file = $location->getSourceFile(); |
| 638 | 638 | $line = $location->getLine(); |
@@ -641,9 +641,9 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | $ext = \AppUtils\FileHelper::getExtension($file); |
| 643 | 643 | |
| 644 | - if($ext == 'php') { |
|
| 644 | + if ($ext == 'php') { |
|
| 645 | 645 | $icon = 'fab fa-php'; |
| 646 | - } else if($ext == 'js') { |
|
| 646 | + } else if ($ext == 'js') { |
|
| 647 | 647 | $icon = 'fab fa-js-square'; |
| 648 | 648 | } else { |
| 649 | 649 | $icon = 'fas fa-file-code'; |
@@ -666,13 +666,13 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - protected function renderText(string $text, int $cutAt=0) : string |
|
| 669 | + protected function renderText(string $text, int $cutAt = 0) : string |
|
| 670 | 670 | { |
| 671 | - if(empty($text)) { |
|
| 671 | + if (empty($text)) { |
|
| 672 | 672 | return $text; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - if($cutAt > 0) { |
|
| 675 | + if ($cutAt > 0) { |
|
| 676 | 676 | $text = \AppUtils\ConvertHelper::text_cut($text, $cutAt); |
| 677 | 677 | } |
| 678 | 678 | |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | $vars = $this->detectVariables($text); |
| 682 | 682 | |
| 683 | - foreach($vars as $var) { |
|
| 683 | + foreach ($vars as $var) { |
|
| 684 | 684 | $text = str_replace($var, '<span class="placeholder">'.$var.'</span>', $text); |
| 685 | 685 | } |
| 686 | 686 | |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | $result = array(); |
| 693 | 693 | preg_match_all('/%[0-9]+d|%s|%[0-9]+\$s/i', $string, $result, PREG_PATTERN_ORDER); |
| 694 | 694 | |
| 695 | - if(isset($result[0]) && !empty($result[0])) { |
|
| 695 | + if (isset($result[0]) && !empty($result[0])) { |
|
| 696 | 696 | return $result[0]; |
| 697 | 697 | } |
| 698 | 698 | |
@@ -708,10 +708,10 @@ discard block |
||
| 708 | 708 | |
| 709 | 709 | // add a counter of the additional files if the total |
| 710 | 710 | // is higher than the maximum to show |
| 711 | - if($total > $max) |
|
| 711 | + if ($total > $max) |
|
| 712 | 712 | { |
| 713 | 713 | $length = $max; |
| 714 | - if($length > $keepTotal) { |
|
| 714 | + if ($length > $keepTotal) { |
|
| 715 | 715 | $length = $keepTotal; |
| 716 | 716 | } |
| 717 | 717 | |
@@ -739,14 +739,14 @@ discard block |
||
| 739 | 739 | return file_get_contents($this->installPath.'/css/editor.css'); |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - public function getSourceURL(Localization_Source $source, array $params=array()) |
|
| 742 | + public function getSourceURL(Localization_Source $source, array $params = array()) |
|
| 743 | 743 | { |
| 744 | 744 | $params[$this->getVarName('source')] = $source->getID(); |
| 745 | 745 | |
| 746 | 746 | return $this->getURL($params); |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | - public function getLocaleURL(Localization_Locale $locale, array $params=array()) |
|
| 749 | + public function getLocaleURL(Localization_Locale $locale, array $params = array()) |
|
| 750 | 750 | { |
| 751 | 751 | $params[$this->getVarName('locale')] = $locale->getName(); |
| 752 | 752 | |
@@ -763,12 +763,12 @@ discard block |
||
| 763 | 763 | return $this->getSourceURL($this->activeSource, array($this->getVarName('warnings') => 'yes')); |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - public function getURL(array $params=array()) |
|
| 766 | + public function getURL(array $params = array()) |
|
| 767 | 767 | { |
| 768 | 768 | $persist = $this->getRequestParams(); |
| 769 | 769 | |
| 770 | - foreach($persist as $name => $value) { |
|
| 771 | - if(!isset($params[$name])) { |
|
| 770 | + foreach ($persist as $name => $value) { |
|
| 771 | + if (!isset($params[$name])) { |
|
| 772 | 772 | $params[$name] = $value; |
| 773 | 773 | } |
| 774 | 774 | } |
@@ -801,11 +801,11 @@ discard block |
||
| 801 | 801 | $translator = Localization::getTranslator($this->activeAppLocale); |
| 802 | 802 | |
| 803 | 803 | $strings = $data[$this->getVarName('strings')]; |
| 804 | - foreach($strings as $hash => $text) |
|
| 804 | + foreach ($strings as $hash => $text) |
|
| 805 | 805 | { |
| 806 | 806 | $text = trim($text); |
| 807 | 807 | |
| 808 | - if(empty($text)) { |
|
| 808 | + if (empty($text)) { |
|
| 809 | 809 | continue; |
| 810 | 810 | } |
| 811 | 811 | |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | |
| 828 | 828 | protected function renderStatus(Localization_Scanner_StringHash $hash) |
| 829 | 829 | { |
| 830 | - if($hash->isTranslated()) { |
|
| 830 | + if ($hash->isTranslated()) { |
|
| 831 | 831 | return '<i class="fa fa-check text-success"></i>'; |
| 832 | 832 | } |
| 833 | 833 | |
@@ -838,18 +838,18 @@ discard block |
||
| 838 | 838 | { |
| 839 | 839 | $types = array(); |
| 840 | 840 | |
| 841 | - if($hash->hasLanguageType('PHP')) { |
|
| 841 | + if ($hash->hasLanguageType('PHP')) { |
|
| 842 | 842 | $types[] = t('Server'); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if($hash->hasLanguageType('Javascript')) { |
|
| 845 | + if ($hash->hasLanguageType('Javascript')) { |
|
| 846 | 846 | $types[] = t('Client'); |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | return implode(', ', $types); |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | - protected function addMessage($message, $type=self::MESSAGE_INFO) |
|
| 852 | + protected function addMessage($message, $type = self::MESSAGE_INFO) |
|
| 853 | 853 | { |
| 854 | 854 | $_SESSION['localization_messages'][] = array( |
| 855 | 855 | 'text' => $message, |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | public function getAppName() : string |
| 884 | 884 | { |
| 885 | 885 | $name = $this->getOption('appname'); |
| 886 | - if(!empty($name)) { |
|
| 886 | + if (!empty($name)) { |
|
| 887 | 887 | return $name; |
| 888 | 888 | } |
| 889 | 889 | |
@@ -192,8 +192,7 @@ discard block |
||
| 192 | 192 | if($this->request->getBool($this->getVarName('scan'))) |
| 193 | 193 | { |
| 194 | 194 | $this->executeScan(); |
| 195 | - } |
|
| 196 | - else if($this->request->getBool($this->getVarName('save'))) |
|
| 195 | + } else if($this->request->getBool($this->getVarName('save'))) |
|
| 197 | 196 | { |
| 198 | 197 | $this->executeSave(); |
| 199 | 198 | } |
@@ -251,8 +250,7 @@ discard block |
||
| 251 | 250 | ?> |
| 252 | 251 | <b><?php echo $source->getLabel() ?></b> |
| 253 | 252 | <?php |
| 254 | - } |
|
| 255 | - else |
|
| 253 | + } else |
|
| 256 | 254 | { |
| 257 | 255 | echo $source->getLabel(); |
| 258 | 256 | } |
@@ -338,12 +336,10 @@ discard block |
||
| 338 | 336 | <?php pt('No application locales were added to translate to.') ?> |
| 339 | 337 | </div> |
| 340 | 338 | <?php |
| 341 | - } |
|
| 342 | - else if($this->request->getBool($this->getVarName('warnings'))) |
|
| 339 | + } else if($this->request->getBool($this->getVarName('warnings'))) |
|
| 343 | 340 | { |
| 344 | 341 | echo $this->renderWarnings(); |
| 345 | - } |
|
| 346 | - else |
|
| 342 | + } else |
|
| 347 | 343 | { |
| 348 | 344 | ?> |
| 349 | 345 | <h1><?php echo $this->activeSource->getLabel() ?></h1> |
@@ -393,8 +389,7 @@ discard block |
||
| 393 | 389 | </a> |
| 394 | 390 | </p> |
| 395 | 391 | <?php |
| 396 | - } |
|
| 397 | - else |
|
| 392 | + } else |
|
| 398 | 393 | { |
| 399 | 394 | echo $this->filters->renderForm(); |
| 400 | 395 | echo $this->renderList(); |
@@ -620,8 +615,7 @@ discard block |
||
| 620 | 615 | if($totalFiles == 1) |
| 621 | 616 | { |
| 622 | 617 | pt('Found in a single file:'); |
| 623 | - } |
|
| 624 | - else |
|
| 618 | + } else |
|
| 625 | 619 | { |
| 626 | 620 | pt('Found in %1$s files:', $totalFiles); |
| 627 | 621 | } |
@@ -34,54 +34,54 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | const ERROR_NO_SOURCES_AVAILABLE = 40001; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | 40 | protected $installPath; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var Localization_Source[] |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var Localization_Source[] |
|
| 44 | + */ |
|
| 45 | 45 | protected $sources; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var \AppUtils\Request |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var \AppUtils\Request |
|
| 49 | + */ |
|
| 50 | 50 | protected $request; |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var Localization_Source |
|
| 54 | - */ |
|
| 52 | + /** |
|
| 53 | + * @var Localization_Source |
|
| 54 | + */ |
|
| 55 | 55 | protected $activeSource; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var Localization_Scanner |
|
| 59 | - */ |
|
| 57 | + /** |
|
| 58 | + * @var Localization_Scanner |
|
| 59 | + */ |
|
| 60 | 60 | protected $scanner; |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @var Localization_Locale[] |
|
| 64 | - */ |
|
| 62 | + /** |
|
| 63 | + * @var Localization_Locale[] |
|
| 64 | + */ |
|
| 65 | 65 | protected $appLocales = array(); |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @var Localization_Locale |
|
| 69 | - */ |
|
| 67 | + /** |
|
| 68 | + * @var Localization_Locale |
|
| 69 | + */ |
|
| 70 | 70 | protected $activeAppLocale; |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @var Localization_Editor_Filters |
|
| 74 | - */ |
|
| 72 | + /** |
|
| 73 | + * @var Localization_Editor_Filters |
|
| 74 | + */ |
|
| 75 | 75 | protected $filters; |
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @var string[]string |
|
| 79 | - */ |
|
| 77 | + /** |
|
| 78 | + * @var string[]string |
|
| 79 | + */ |
|
| 80 | 80 | protected $requestParams = array(); |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @var string |
|
| 84 | - */ |
|
| 82 | + /** |
|
| 83 | + * @var string |
|
| 84 | + */ |
|
| 85 | 85 | protected $varPrefix = 'applocalize_'; |
| 86 | 86 | |
| 87 | 87 | public function __construct() |
@@ -100,15 +100,15 @@ discard block |
||
| 100 | 100 | return $this->request; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Adds a request parameter that will be persisted in all URLs |
|
| 105 | - * within the editor. This can be used when integrating the |
|
| 106 | - * editor in an existing page that needs specific request params. |
|
| 107 | - * |
|
| 108 | - * @param string $name |
|
| 109 | - * @param string $value |
|
| 110 | - * @return Localization_Editor |
|
| 111 | - */ |
|
| 103 | + /** |
|
| 104 | + * Adds a request parameter that will be persisted in all URLs |
|
| 105 | + * within the editor. This can be used when integrating the |
|
| 106 | + * editor in an existing page that needs specific request params. |
|
| 107 | + * |
|
| 108 | + * @param string $name |
|
| 109 | + * @param string $value |
|
| 110 | + * @return Localization_Editor |
|
| 111 | + */ |
|
| 112 | 112 | public function addRequestParam(string $name, string $value) : Localization_Editor |
| 113 | 113 | { |
| 114 | 114 | $this->requestParams[$name] = $value; |
@@ -263,34 +263,34 @@ discard block |
||
| 263 | 263 | </a> |
| 264 | 264 | <div class="dropdown-menu" aria-labelledby="dropdown01"> |
| 265 | 265 | <?php |
| 266 | - foreach($this->sources as $source) |
|
| 267 | - { |
|
| 268 | - ?> |
|
| 266 | + foreach($this->sources as $source) |
|
| 267 | + { |
|
| 268 | + ?> |
|
| 269 | 269 | <a class="dropdown-item" href="<?php echo $this->getSourceURL($source) ?>"> |
| 270 | 270 | <?php |
| 271 | - if($source->getID() === $this->activeSource->getID()) |
|
| 272 | - { |
|
| 273 | - ?> |
|
| 271 | + if($source->getID() === $this->activeSource->getID()) |
|
| 272 | + { |
|
| 273 | + ?> |
|
| 274 | 274 | <b><?php echo $source->getLabel() ?></b> |
| 275 | 275 | <?php |
| 276 | - } |
|
| 277 | - else |
|
| 278 | - { |
|
| 279 | - echo $source->getLabel(); |
|
| 280 | - } |
|
| 281 | - ?> |
|
| 276 | + } |
|
| 277 | + else |
|
| 278 | + { |
|
| 279 | + echo $source->getLabel(); |
|
| 280 | + } |
|
| 281 | + ?> |
|
| 282 | 282 | <?php |
| 283 | - $untranslated = $source->countUntranslated($this->scanner); |
|
| 284 | - if($untranslated > 0) { |
|
| 285 | - ?> |
|
| 283 | + $untranslated = $source->countUntranslated($this->scanner); |
|
| 284 | + if($untranslated > 0) { |
|
| 285 | + ?> |
|
| 286 | 286 | (<span class="text-danger" title="<?php pt('%1$s texts have not been translated in this text source.', $untranslated) ?>"><?php echo $untranslated ?></span>) |
| 287 | 287 | <?php |
| 288 | - } |
|
| 289 | - ?> |
|
| 288 | + } |
|
| 289 | + ?> |
|
| 290 | 290 | </a> |
| 291 | 291 | <?php |
| 292 | - } |
|
| 293 | - ?> |
|
| 292 | + } |
|
| 293 | + ?> |
|
| 294 | 294 | </div> |
| 295 | 295 | </li> |
| 296 | 296 | <li class="nav-item dropdown"> |
@@ -299,15 +299,15 @@ discard block |
||
| 299 | 299 | </a> |
| 300 | 300 | <div class="dropdown-menu" aria-labelledby="dropdown01"> |
| 301 | 301 | <?php |
| 302 | - foreach($this->appLocales as $locale) |
|
| 303 | - { |
|
| 304 | - ?> |
|
| 302 | + foreach($this->appLocales as $locale) |
|
| 303 | + { |
|
| 304 | + ?> |
|
| 305 | 305 | <a class="dropdown-item" href="<?php echo $this->getLocaleURL($locale) ?>"> |
| 306 | 306 | <?php echo $locale->getLabel() ?> |
| 307 | 307 | </a> |
| 308 | 308 | <?php |
| 309 | - } |
|
| 310 | - ?> |
|
| 309 | + } |
|
| 310 | + ?> |
|
| 311 | 311 | </div> |
| 312 | 312 | </li> |
| 313 | 313 | <li class="nav-item"> |
@@ -317,8 +317,8 @@ discard block |
||
| 317 | 317 | </a> |
| 318 | 318 | </li> |
| 319 | 319 | <?php |
| 320 | - if($this->scanner->hasWarnings()) { |
|
| 321 | - ?> |
|
| 320 | + if($this->scanner->hasWarnings()) { |
|
| 321 | + ?> |
|
| 322 | 322 | <li class="nav-item"> |
| 323 | 323 | <a href="<?php echo $this->getWarningsURL() ?>"> |
| 324 | 324 | <span class="badge badge-warning" title="<?php pts('The last scan for translateable texts reported warnings.'); pts('Click for details.'); ?>" data-toggle="tooltip"> |
@@ -328,8 +328,8 @@ discard block |
||
| 328 | 328 | </a> |
| 329 | 329 | </li> |
| 330 | 330 | <?php |
| 331 | - } |
|
| 332 | - ?> |
|
| 331 | + } |
|
| 332 | + ?> |
|
| 333 | 333 | </ul> |
| 334 | 334 | <?php |
| 335 | 335 | } |
@@ -345,36 +345,36 @@ discard block |
||
| 345 | 345 | </a> |
| 346 | 346 | <?php |
| 347 | 347 | } |
| 348 | - ?> |
|
| 348 | + ?> |
|
| 349 | 349 | </div> |
| 350 | 350 | </nav> |
| 351 | 351 | <main role="main" class="container"> |
| 352 | 352 | <div> |
| 353 | 353 | <?php |
| 354 | - if(empty($this->appLocales)) |
|
| 355 | - { |
|
| 356 | - ?> |
|
| 354 | + if(empty($this->appLocales)) |
|
| 355 | + { |
|
| 356 | + ?> |
|
| 357 | 357 | <div class="alert alert-danger"> |
| 358 | 358 | <i class="fa fa-exclamation-triangle"></i> |
| 359 | 359 | <b><?php pt('Nothing to translate:') ?></b> |
| 360 | 360 | <?php pt('No application locales were added to translate to.') ?> |
| 361 | 361 | </div> |
| 362 | 362 | <?php |
| 363 | - } |
|
| 364 | - else if($this->request->getBool($this->getVarName('warnings'))) |
|
| 365 | - { |
|
| 366 | - echo $this->renderWarnings(); |
|
| 367 | - } |
|
| 368 | - else |
|
| 369 | - { |
|
| 370 | - ?> |
|
| 363 | + } |
|
| 364 | + else if($this->request->getBool($this->getVarName('warnings'))) |
|
| 365 | + { |
|
| 366 | + echo $this->renderWarnings(); |
|
| 367 | + } |
|
| 368 | + else |
|
| 369 | + { |
|
| 370 | + ?> |
|
| 371 | 371 | <h1><?php echo $this->activeSource->getLabel() ?></h1> |
| 372 | 372 | <?php |
| 373 | - if(!empty($_SESSION['localization_messages'])) |
|
| 374 | - { |
|
| 375 | - foreach($_SESSION['localization_messages'] as $def) |
|
| 376 | - { |
|
| 377 | - ?> |
|
| 373 | + if(!empty($_SESSION['localization_messages'])) |
|
| 374 | + { |
|
| 375 | + foreach($_SESSION['localization_messages'] as $def) |
|
| 376 | + { |
|
| 377 | + ?> |
|
| 378 | 378 | <div class="alert alert-<?php echo $def['type'] ?>" role="alert"> |
| 379 | 379 | <?php echo $def['text'] ?> |
| 380 | 380 | <button type="button" class="close" data-dismiss="alert" aria-label="<?php pt('Close') ?>" title="<?php pt('Dismiss this message.') ?>" data-toggle="tooltip"> |
@@ -382,28 +382,28 @@ discard block |
||
| 382 | 382 | </button> |
| 383 | 383 | </div> |
| 384 | 384 | <?php |
| 385 | - } |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - // reset the messages after having displayed them |
|
| 388 | - $_SESSION['localization_messages'] = array(); |
|
| 389 | - } |
|
| 390 | - ?> |
|
| 387 | + // reset the messages after having displayed them |
|
| 388 | + $_SESSION['localization_messages'] = array(); |
|
| 389 | + } |
|
| 390 | + ?> |
|
| 391 | 391 | <p> |
| 392 | 392 | <?php |
| 393 | - pt( |
|
| 394 | - 'You are translating to %1$s', |
|
| 395 | - '<span class="badge badge-info">'. |
|
| 396 | - $this->activeAppLocale->getLabel(). |
|
| 397 | - '</span>' |
|
| 393 | + pt( |
|
| 394 | + 'You are translating to %1$s', |
|
| 395 | + '<span class="badge badge-info">'. |
|
| 396 | + $this->activeAppLocale->getLabel(). |
|
| 397 | + '</span>' |
|
| 398 | 398 | ); |
| 399 | - ?><br> |
|
| 399 | + ?><br> |
|
| 400 | 400 | <?php pt('Found %1$s texts to translate.', $this->activeSource->countUntranslated($this->scanner)) ?> |
| 401 | 401 | </p> |
| 402 | 402 | <br> |
| 403 | 403 | <?php |
| 404 | - if(!$this->scanner->isScanAvailable()) |
|
| 405 | - { |
|
| 406 | - ?> |
|
| 404 | + if(!$this->scanner->isScanAvailable()) |
|
| 405 | + { |
|
| 406 | + ?> |
|
| 407 | 407 | <div class="alert alert-primary" role="alert"> |
| 408 | 408 | <b><?php pt('No texts found:') ?></b> |
| 409 | 409 | <?php pt('The source folders have not been scanned yet.') ?> |
@@ -415,15 +415,15 @@ discard block |
||
| 415 | 415 | </a> |
| 416 | 416 | </p> |
| 417 | 417 | <?php |
| 418 | - } |
|
| 419 | - else |
|
| 420 | - { |
|
| 421 | - echo $this->filters->renderForm(); |
|
| 422 | - echo $this->renderList(); |
|
| 423 | - } |
|
| 418 | + } |
|
| 419 | + else |
|
| 420 | + { |
|
| 421 | + echo $this->filters->renderForm(); |
|
| 422 | + echo $this->renderList(); |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | - } |
|
| 426 | - ?> |
|
| 425 | + } |
|
| 426 | + ?> |
|
| 427 | 427 | </div> |
| 428 | 428 | </main> |
| 429 | 429 | </body> |
@@ -441,22 +441,22 @@ discard block |
||
| 441 | 441 | <h1><?php pt('Warnings') ?></h1> |
| 442 | 442 | <p class="abstract"> |
| 443 | 443 | <?php |
| 444 | - pts('The following shows all texts where the system decided that they cannot be translated.'); |
|
| 445 | - ?> |
|
| 444 | + pts('The following shows all texts where the system decided that they cannot be translated.'); |
|
| 445 | + ?> |
|
| 446 | 446 | </p> |
| 447 | 447 | <dl> |
| 448 | 448 | <?php |
| 449 | - $warnings = $this->scanner->getWarnings(); |
|
| 449 | + $warnings = $this->scanner->getWarnings(); |
|
| 450 | 450 | |
| 451 | - foreach($warnings as $warning) |
|
| 452 | - { |
|
| 453 | - ?> |
|
| 451 | + foreach($warnings as $warning) |
|
| 452 | + { |
|
| 453 | + ?> |
|
| 454 | 454 | <dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt> |
| 455 | 455 | <dd><?php echo $warning->getMessage() ?></dd> |
| 456 | 456 | <?php |
| 457 | - } |
|
| 457 | + } |
|
| 458 | 458 | |
| 459 | - ?> |
|
| 459 | + ?> |
|
| 460 | 460 | </dl> |
| 461 | 461 | <?php |
| 462 | 462 | |
@@ -525,13 +525,13 @@ discard block |
||
| 525 | 525 | <form method="post"> |
| 526 | 526 | <div class="form-hiddens"> |
| 527 | 527 | <?php |
| 528 | - $params = $this->getRequestParams(); |
|
| 529 | - foreach($params as $name => $value) { |
|
| 530 | - ?> |
|
| 528 | + $params = $this->getRequestParams(); |
|
| 529 | + foreach($params as $name => $value) { |
|
| 530 | + ?> |
|
| 531 | 531 | <input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>"> |
| 532 | 532 | <?php |
| 533 | - } |
|
| 534 | - ?> |
|
| 533 | + } |
|
| 534 | + ?> |
|
| 535 | 535 | </div> |
| 536 | 536 | <table class="table table-hover"> |
| 537 | 537 | <thead> |
@@ -544,20 +544,20 @@ discard block |
||
| 544 | 544 | </thead> |
| 545 | 545 | <tbody> |
| 546 | 546 | <?php |
| 547 | - foreach($keep as $string) |
|
| 548 | - { |
|
| 549 | - $this->renderListEntry($string); |
|
| 550 | - } |
|
| 551 | - ?> |
|
| 547 | + foreach($keep as $string) |
|
| 548 | + { |
|
| 549 | + $this->renderListEntry($string); |
|
| 550 | + } |
|
| 551 | + ?> |
|
| 552 | 552 | </tbody> |
| 553 | 553 | </table> |
| 554 | 554 | <?php |
| 555 | - if($pager->hasPages()) |
|
| 556 | - { |
|
| 557 | - $prevUrl = $this->getPaginationURL($pager->getPreviousPage()); |
|
| 558 | - $nextUrl = $this->getPaginationURL($pager->getNextPage()); |
|
| 555 | + if($pager->hasPages()) |
|
| 556 | + { |
|
| 557 | + $prevUrl = $this->getPaginationURL($pager->getPreviousPage()); |
|
| 558 | + $nextUrl = $this->getPaginationURL($pager->getNextPage()); |
|
| 559 | 559 | |
| 560 | - ?> |
|
| 560 | + ?> |
|
| 561 | 561 | <nav aria-label="<?php pt('Navigate available pages of texts.') ?>"> |
| 562 | 562 | <ul class="pagination"> |
| 563 | 563 | <li class="page-item"> |
@@ -566,20 +566,20 @@ discard block |
||
| 566 | 566 | </a> |
| 567 | 567 | </li> |
| 568 | 568 | <?php |
| 569 | - $numbers = $pager->getPageNumbers(); |
|
| 570 | - foreach($numbers as $number) |
|
| 571 | - { |
|
| 572 | - $url = $this->getPaginationURL($number); |
|
| 569 | + $numbers = $pager->getPageNumbers(); |
|
| 570 | + foreach($numbers as $number) |
|
| 571 | + { |
|
| 572 | + $url = $this->getPaginationURL($number); |
|
| 573 | 573 | |
| 574 | - ?> |
|
| 574 | + ?> |
|
| 575 | 575 | <li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>"> |
| 576 | 576 | <a class="page-link" href="<?php echo $url ?>"> |
| 577 | 577 | <?php echo $number ?> |
| 578 | 578 | </a> |
| 579 | 579 | </li> |
| 580 | 580 | <?php |
| 581 | - } |
|
| 582 | - ?> |
|
| 581 | + } |
|
| 582 | + ?> |
|
| 583 | 583 | <li class="page-item"> |
| 584 | 584 | <a class="page-link" href="<?php echo $nextUrl ?>"> |
| 585 | 585 | <i class="fa fa-arrow-right"></i> |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | </ul> |
| 589 | 589 | </nav> |
| 590 | 590 | <?php |
| 591 | - } |
|
| 592 | - ?> |
|
| 591 | + } |
|
| 592 | + ?> |
|
| 593 | 593 | <br> |
| 594 | 594 | <p> |
| 595 | 595 | <button type="submit" name="<?php echo $this->getVarName('save') ?>" value="yes" class="btn btn-primary"> |
@@ -647,48 +647,48 @@ discard block |
||
| 647 | 647 | <div class="files-list"> |
| 648 | 648 | <p> |
| 649 | 649 | <?php |
| 650 | - $totalFiles = count($files); |
|
| 650 | + $totalFiles = count($files); |
|
| 651 | 651 | |
| 652 | - if($totalFiles == 1) |
|
| 653 | - { |
|
| 654 | - pt('Found in a single file:'); |
|
| 655 | - } |
|
| 656 | - else |
|
| 657 | - { |
|
| 658 | - pt('Found in %1$s files:', $totalFiles); |
|
| 659 | - } |
|
| 660 | - ?> |
|
| 652 | + if($totalFiles == 1) |
|
| 653 | + { |
|
| 654 | + pt('Found in a single file:'); |
|
| 655 | + } |
|
| 656 | + else |
|
| 657 | + { |
|
| 658 | + pt('Found in %1$s files:', $totalFiles); |
|
| 659 | + } |
|
| 660 | + ?> |
|
| 661 | 661 | </p> |
| 662 | 662 | <div class="files-scroller"> |
| 663 | 663 | <ul> |
| 664 | 664 | <?php |
| 665 | - $locations = $string->getStrings(); |
|
| 665 | + $locations = $string->getStrings(); |
|
| 666 | 666 | |
| 667 | - foreach($locations as $location) |
|
| 668 | - { |
|
| 669 | - $file = $location->getSourceFile(); |
|
| 670 | - $line = $location->getLine(); |
|
| 667 | + foreach($locations as $location) |
|
| 668 | + { |
|
| 669 | + $file = $location->getSourceFile(); |
|
| 670 | + $line = $location->getLine(); |
|
| 671 | 671 | |
| 672 | - $icon = ''; |
|
| 672 | + $icon = ''; |
|
| 673 | 673 | |
| 674 | - $ext = \AppUtils\FileHelper::getExtension($file); |
|
| 674 | + $ext = \AppUtils\FileHelper::getExtension($file); |
|
| 675 | 675 | |
| 676 | - if($ext == 'php') { |
|
| 677 | - $icon = 'fab fa-php'; |
|
| 678 | - } else if($ext == 'js') { |
|
| 679 | - $icon = 'fab fa-js-square'; |
|
| 680 | - } else { |
|
| 681 | - $icon = 'fas fa-file-code'; |
|
| 682 | - } |
|
| 676 | + if($ext == 'php') { |
|
| 677 | + $icon = 'fab fa-php'; |
|
| 678 | + } else if($ext == 'js') { |
|
| 679 | + $icon = 'fab fa-js-square'; |
|
| 680 | + } else { |
|
| 681 | + $icon = 'fas fa-file-code'; |
|
| 682 | + } |
|
| 683 | 683 | |
| 684 | - ?> |
|
| 684 | + ?> |
|
| 685 | 685 | <li> |
| 686 | 686 | <i class="<?php echo $icon ?>"></i> |
| 687 | 687 | <?php echo $file ?><span class="line-number">:<?php echo $line ?></span> |
| 688 | 688 | </li> |
| 689 | 689 | <?php |
| 690 | - } |
|
| 691 | - ?> |
|
| 690 | + } |
|
| 691 | + ?> |
|
| 692 | 692 | </ul> |
| 693 | 693 | </div> |
| 694 | 694 | </div> |
@@ -899,13 +899,13 @@ discard block |
||
| 899 | 899 | ); |
| 900 | 900 | } |
| 901 | 901 | |
| 902 | - /** |
|
| 903 | - * Sets the application name shown in the main navigation |
|
| 904 | - * in the user interface. |
|
| 905 | - * |
|
| 906 | - * @param string $name |
|
| 907 | - * @return Localization_Editor |
|
| 908 | - */ |
|
| 902 | + /** |
|
| 903 | + * Sets the application name shown in the main navigation |
|
| 904 | + * in the user interface. |
|
| 905 | + * |
|
| 906 | + * @param string $name |
|
| 907 | + * @return Localization_Editor |
|
| 908 | + */ |
|
| 909 | 909 | public function setAppName(string $name) : Localization_Editor |
| 910 | 910 | { |
| 911 | 911 | $this->setOption('appname', $name); |
@@ -922,27 +922,27 @@ discard block |
||
| 922 | 922 | return t('Localization editor'); |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | - /** |
|
| 926 | - * Selects the default source to use if none has been |
|
| 927 | - * explicitly selected. |
|
| 928 | - * |
|
| 929 | - * @param string $sourceID |
|
| 930 | - */ |
|
| 925 | + /** |
|
| 926 | + * Selects the default source to use if none has been |
|
| 927 | + * explicitly selected. |
|
| 928 | + * |
|
| 929 | + * @param string $sourceID |
|
| 930 | + */ |
|
| 931 | 931 | public function selectDefaultSource(string $sourceID) : Localization_Editor |
| 932 | 932 | { |
| 933 | 933 | $this->setOption('default-source', $sourceID); |
| 934 | 934 | return $this; |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | - /** |
|
| 938 | - * Sets an URL that the translators can use to go back to |
|
| 939 | - * the main application, for example if it is integrated into |
|
| 940 | - * an existing application. |
|
| 941 | - * |
|
| 942 | - * @param string $url The URL to use for the link |
|
| 943 | - * @param string $label Label of the link |
|
| 944 | - * @return Localization_Editor |
|
| 945 | - */ |
|
| 937 | + /** |
|
| 938 | + * Sets an URL that the translators can use to go back to |
|
| 939 | + * the main application, for example if it is integrated into |
|
| 940 | + * an existing application. |
|
| 941 | + * |
|
| 942 | + * @param string $url The URL to use for the link |
|
| 943 | + * @param string $label Label of the link |
|
| 944 | + * @return Localization_Editor |
|
| 945 | + */ |
|
| 946 | 946 | public function setBackURL(string $url, string $label) : Localization_Editor |
| 947 | 947 | { |
| 948 | 948 | $this->setOption('back-url', $url); |