@@ -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 |
@@ -16,9 +16,9 @@ |
||
16 | 16 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
17 | 17 | } |
18 | 18 | |
19 | - /** |
|
20 | - * The composer autoloader |
|
21 | - */ |
|
19 | + /** |
|
20 | + * The composer autoloader |
|
21 | + */ |
|
22 | 22 | require_once $autoload; |
23 | 23 | |
24 | 24 | // the folder in which the localization .ini files are stored |
@@ -12,7 +12,7 @@ |
||
12 | 12 | $autoload = realpath($root.'/../vendor/autoload.php'); |
13 | 13 | |
14 | 14 | // we need the autoloader to be present |
15 | - if(!file_exists($autoload)) { |
|
15 | + if (!file_exists($autoload)) { |
|
16 | 16 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
17 | 17 | } |
18 | 18 |
@@ -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 |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | |
53 | 53 | const NAMESPACE_CONTENT = '__content'; |
54 | 54 | |
55 | - /** |
|
56 | - * Collection of all locales by namespace (application, content, custom...). |
|
57 | - * |
|
58 | - * @var array |
|
59 | - * @see Localization::addLocale() |
|
60 | - */ |
|
55 | + /** |
|
56 | + * Collection of all locales by namespace (application, content, custom...). |
|
57 | + * |
|
58 | + * @var array |
|
59 | + * @see Localization::addLocale() |
|
60 | + */ |
|
61 | 61 | protected static $locales = array(); |
62 | 62 | |
63 | 63 | /** |
@@ -66,44 +66,44 @@ discard block |
||
66 | 66 | */ |
67 | 67 | private static $initDone = false; |
68 | 68 | |
69 | - /** |
|
70 | - * Path to the file in which the scanner results are stored. |
|
71 | - * @var string |
|
72 | - * @see Localization::configure() |
|
73 | - */ |
|
69 | + /** |
|
70 | + * Path to the file in which the scanner results are stored. |
|
71 | + * @var string |
|
72 | + * @see Localization::configure() |
|
73 | + */ |
|
74 | 74 | protected static $storageFile = ''; |
75 | 75 | |
76 | - /** |
|
77 | - * Path to the folder into which the client libraries are written. |
|
78 | - * @var string |
|
79 | - * @see Localization::setClientLibrariesFolder() |
|
80 | - */ |
|
76 | + /** |
|
77 | + * Path to the folder into which the client libraries are written. |
|
78 | + * @var string |
|
79 | + * @see Localization::setClientLibrariesFolder() |
|
80 | + */ |
|
81 | 81 | protected static $clientFolder = ''; |
82 | 82 | |
83 | - /** |
|
84 | - * If this key changes, client libraries are refreshed. |
|
85 | - * @var string |
|
86 | - * @see Localization::setClientLibrariesCacheKey() |
|
87 | - */ |
|
83 | + /** |
|
84 | + * If this key changes, client libraries are refreshed. |
|
85 | + * @var string |
|
86 | + * @see Localization::setClientLibrariesCacheKey() |
|
87 | + */ |
|
88 | 88 | protected static $clientCacheKey = ''; |
89 | 89 | |
90 | - /** |
|
91 | - * Whether the configuration has been made. |
|
92 | - * @var bool |
|
93 | - * @see Localization::configure() |
|
94 | - */ |
|
90 | + /** |
|
91 | + * Whether the configuration has been made. |
|
92 | + * @var bool |
|
93 | + * @see Localization::configure() |
|
94 | + */ |
|
95 | 95 | protected static $configured = false; |
96 | 96 | |
97 | - /** |
|
98 | - * Stores event listener instances. |
|
99 | - * @var array |
|
100 | - */ |
|
97 | + /** |
|
98 | + * Stores event listener instances. |
|
99 | + * @var array |
|
100 | + */ |
|
101 | 101 | protected static $listeners = array(); |
102 | 102 | |
103 | - /** |
|
104 | - * @var integer |
|
105 | - * @see Localization::addEventListener() |
|
106 | - */ |
|
103 | + /** |
|
104 | + * @var integer |
|
105 | + * @see Localization::addEventListener() |
|
106 | + */ |
|
107 | 107 | protected static $listenersCounter = 0; |
108 | 108 | |
109 | 109 | /** |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | return self::getLocalesByNS(self::NAMESPACE_APPLICATION); |
151 | 151 | } |
152 | 152 | |
153 | - /** |
|
154 | - * Retrieves all locales in the specified namespace. |
|
155 | - * |
|
156 | - * @param string $namespace |
|
157 | - * @return Localization_Locale[] |
|
158 | - */ |
|
153 | + /** |
|
154 | + * Retrieves all locales in the specified namespace. |
|
155 | + * |
|
156 | + * @param string $namespace |
|
157 | + * @return Localization_Locale[] |
|
158 | + */ |
|
159 | 159 | public static function getLocalesByNS(string $namespace) |
160 | 160 | { |
161 | 161 | if(isset(self::$locales[$namespace])) { |
@@ -172,35 +172,35 @@ discard block |
||
172 | 172 | ); |
173 | 173 | } |
174 | 174 | |
175 | - /** |
|
176 | - * Adds an application locale to use in the application. |
|
177 | - * |
|
178 | - * @param string $localeName |
|
179 | - * @return Localization_Locale |
|
180 | - */ |
|
175 | + /** |
|
176 | + * Adds an application locale to use in the application. |
|
177 | + * |
|
178 | + * @param string $localeName |
|
179 | + * @return Localization_Locale |
|
180 | + */ |
|
181 | 181 | public static function addAppLocale(string $localeName) : Localization_Locale |
182 | 182 | { |
183 | 183 | return self::addLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
184 | 184 | } |
185 | 185 | |
186 | - /** |
|
187 | - * Adds a content locale to use for content in the application. |
|
188 | - * |
|
189 | - * @param string $localeName |
|
190 | - * @return Localization_Locale |
|
191 | - */ |
|
186 | + /** |
|
187 | + * Adds a content locale to use for content in the application. |
|
188 | + * |
|
189 | + * @param string $localeName |
|
190 | + * @return Localization_Locale |
|
191 | + */ |
|
192 | 192 | public static function addContentLocale(string $localeName) : Localization_Locale |
193 | 193 | { |
194 | 194 | return self::addLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
195 | 195 | } |
196 | 196 | |
197 | - /** |
|
198 | - * Adds a locale to the specified namespace. |
|
199 | - * |
|
200 | - * @param string $localeName |
|
201 | - * @param string $namespace |
|
202 | - * @return Localization_Locale |
|
203 | - */ |
|
197 | + /** |
|
198 | + * Adds a locale to the specified namespace. |
|
199 | + * |
|
200 | + * @param string $localeName |
|
201 | + * @param string $namespace |
|
202 | + * @return Localization_Locale |
|
203 | + */ |
|
204 | 204 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
205 | 205 | { |
206 | 206 | if(!isset(self::$locales[$namespace])) { |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | return new $className(); |
243 | 243 | } |
244 | 244 | |
245 | - /** |
|
246 | - * Retrieves the currency of the selected app locale. |
|
247 | - * |
|
248 | - * @return Localization_Currency |
|
249 | - */ |
|
245 | + /** |
|
246 | + * Retrieves the currency of the selected app locale. |
|
247 | + * |
|
248 | + * @return Localization_Currency |
|
249 | + */ |
|
250 | 250 | public static function getAppCurrency() : Localization_Currency |
251 | 251 | { |
252 | 252 | return self::getCurrencyNS(self::NAMESPACE_APPLICATION); |
@@ -283,44 +283,44 @@ discard block |
||
283 | 283 | return self::getSelectedLocaleByNS(self::NAMESPACE_APPLICATION); |
284 | 284 | } |
285 | 285 | |
286 | - /** |
|
287 | - * Retrieves the name of the selected application locale. |
|
288 | - * |
|
289 | - * @return string |
|
290 | - */ |
|
286 | + /** |
|
287 | + * Retrieves the name of the selected application locale. |
|
288 | + * |
|
289 | + * @return string |
|
290 | + */ |
|
291 | 291 | public static function getAppLocaleName() : string |
292 | 292 | { |
293 | 293 | return self::getLocaleNameByNS(self::NAMESPACE_APPLICATION); |
294 | 294 | } |
295 | 295 | |
296 | - /** |
|
297 | - * Retrieves the names of the available application locales. |
|
298 | - * @return string[] |
|
299 | - */ |
|
296 | + /** |
|
297 | + * Retrieves the names of the available application locales. |
|
298 | + * @return string[] |
|
299 | + */ |
|
300 | 300 | public static function getAppLocaleNames() : array |
301 | 301 | { |
302 | 302 | return self::getLocaleNamesByNS(self::NAMESPACE_APPLICATION); |
303 | 303 | } |
304 | 304 | |
305 | - /** |
|
306 | - * Retrieves the selected locale name in the specified namespace. |
|
307 | - * |
|
308 | - * @param string $namespace |
|
309 | - * @throws Localization_Exception |
|
310 | - * @return string |
|
311 | - */ |
|
305 | + /** |
|
306 | + * Retrieves the selected locale name in the specified namespace. |
|
307 | + * |
|
308 | + * @param string $namespace |
|
309 | + * @throws Localization_Exception |
|
310 | + * @return string |
|
311 | + */ |
|
312 | 312 | public static function getLocaleNameByNS(string $namespace) : string |
313 | 313 | { |
314 | 314 | return self::getSelectedKeyByNS('name', $namespace); |
315 | 315 | } |
316 | 316 | |
317 | - /** |
|
318 | - * Retrieves the selected locale instance for the specified namespace. |
|
319 | - * |
|
320 | - * @param string $namespace |
|
321 | - * @return Localization_Locale |
|
322 | - * @throws Localization_Exception |
|
323 | - */ |
|
317 | + /** |
|
318 | + * Retrieves the selected locale instance for the specified namespace. |
|
319 | + * |
|
320 | + * @param string $namespace |
|
321 | + * @return Localization_Locale |
|
322 | + * @throws Localization_Exception |
|
323 | + */ |
|
324 | 324 | public static function getSelectedLocaleByNS(string $namespace) : Localization_Locale |
325 | 325 | { |
326 | 326 | return self::getSelectedKeyByNS('locale', $namespace); |
@@ -345,20 +345,20 @@ discard block |
||
345 | 345 | ); |
346 | 346 | } |
347 | 347 | |
348 | - /** |
|
349 | - * Stores the selected locale names by namespace. |
|
350 | - * @var string[] |
|
351 | - */ |
|
348 | + /** |
|
349 | + * Stores the selected locale names by namespace. |
|
350 | + * @var string[] |
|
351 | + */ |
|
352 | 352 | protected static $selected = array(); |
353 | 353 | |
354 | - /** |
|
355 | - * Selects the active locale for the specified namespace. |
|
356 | - * |
|
357 | - * @param string $localeName |
|
358 | - * @param string $namespace |
|
359 | - * @return Localization_Locale |
|
360 | - * @throws Localization_Exception |
|
361 | - */ |
|
354 | + /** |
|
355 | + * Selects the active locale for the specified namespace. |
|
356 | + * |
|
357 | + * @param string $localeName |
|
358 | + * @param string $namespace |
|
359 | + * @return Localization_Locale |
|
360 | + * @throws Localization_Exception |
|
361 | + */ |
|
362 | 362 | public static function selectLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
363 | 363 | { |
364 | 364 | self::requireNamespace($namespace); |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | return $locale; |
395 | 395 | } |
396 | 396 | |
397 | - /** |
|
398 | - * Triggers the specified event, with the provided arguments. |
|
399 | - * |
|
400 | - * @param string $name The event name. |
|
401 | - * @param array $argsList |
|
402 | - * @see Localization_Event |
|
403 | - */ |
|
397 | + /** |
|
398 | + * Triggers the specified event, with the provided arguments. |
|
399 | + * |
|
400 | + * @param string $name The event name. |
|
401 | + * @param array $argsList |
|
402 | + * @see Localization_Event |
|
403 | + */ |
|
404 | 404 | protected static function triggerEvent(string $name, array $argsList) : Localization_Event |
405 | 405 | { |
406 | 406 | $class = '\AppLocalize\Localization_Event_'.$name; |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | return $event; |
422 | 422 | } |
423 | 423 | |
424 | - /** |
|
425 | - * Adds a listener to the specified event name. |
|
426 | - * |
|
427 | - * @param string $eventName |
|
428 | - * @param callable $callback |
|
429 | - * @param array $args Additional arguments to add to the event |
|
430 | - * @return int The listener number. |
|
431 | - */ |
|
424 | + /** |
|
425 | + * Adds a listener to the specified event name. |
|
426 | + * |
|
427 | + * @param string $eventName |
|
428 | + * @param callable $callback |
|
429 | + * @param array $args Additional arguments to add to the event |
|
430 | + * @return int The listener number. |
|
431 | + */ |
|
432 | 432 | public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
433 | 433 | { |
434 | 434 | if(!isset(self::$listeners[$eventName])) { |
@@ -458,43 +458,43 @@ discard block |
||
458 | 458 | return self::$listenersCounter; |
459 | 459 | } |
460 | 460 | |
461 | - /** |
|
462 | - * Adds an event listener for the <code>LocaleChanged</code> event, |
|
463 | - * which is triggered every time a locale is changed in any of the |
|
464 | - * available namespaces. |
|
465 | - * |
|
466 | - * The first parameter of the callback is always the event instance. |
|
467 | - * |
|
468 | - * @param callable $callback The listener function to call. |
|
469 | - * @param array $args Optional indexed array with additional arguments to pass on to the callback function. |
|
470 | - * @return int |
|
471 | - * @see Localization_Event_LocaleChanged |
|
472 | - */ |
|
461 | + /** |
|
462 | + * Adds an event listener for the <code>LocaleChanged</code> event, |
|
463 | + * which is triggered every time a locale is changed in any of the |
|
464 | + * available namespaces. |
|
465 | + * |
|
466 | + * The first parameter of the callback is always the event instance. |
|
467 | + * |
|
468 | + * @param callable $callback The listener function to call. |
|
469 | + * @param array $args Optional indexed array with additional arguments to pass on to the callback function. |
|
470 | + * @return int |
|
471 | + * @see Localization_Event_LocaleChanged |
|
472 | + */ |
|
473 | 473 | public static function onLocaleChanged($callback, array $args=array()) : int |
474 | 474 | { |
475 | 475 | return self::addEventListener('LocaleChanged', $callback, $args); |
476 | 476 | } |
477 | 477 | |
478 | - /** |
|
479 | - * Selects the application locale to use. |
|
480 | - * |
|
481 | - * @param string $localeName |
|
482 | - * @return Localization_Locale |
|
483 | - */ |
|
478 | + /** |
|
479 | + * Selects the application locale to use. |
|
480 | + * |
|
481 | + * @param string $localeName |
|
482 | + * @return Localization_Locale |
|
483 | + */ |
|
484 | 484 | public static function selectAppLocale(string $localeName) : Localization_Locale |
485 | 485 | { |
486 | 486 | return self::selectLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
487 | 487 | } |
488 | 488 | |
489 | - /** |
|
490 | - * Retrieves an application locale by its name. |
|
491 | - * Note that the locale must have been added first. |
|
492 | - * |
|
493 | - * @param string $localeName |
|
494 | - * @throws Localization_Exception |
|
495 | - * @return Localization_Locale |
|
496 | - * @see Localization::appLocaleExists() |
|
497 | - */ |
|
489 | + /** |
|
490 | + * Retrieves an application locale by its name. |
|
491 | + * Note that the locale must have been added first. |
|
492 | + * |
|
493 | + * @param string $localeName |
|
494 | + * @throws Localization_Exception |
|
495 | + * @return Localization_Locale |
|
496 | + * @see Localization::appLocaleExists() |
|
497 | + */ |
|
498 | 498 | public static function getAppLocaleByName(string $localeName) : Localization_Locale |
499 | 499 | { |
500 | 500 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_APPLICATION); |
@@ -528,22 +528,22 @@ discard block |
||
528 | 528 | return self::getLocalesByNS(self::NAMESPACE_CONTENT); |
529 | 529 | } |
530 | 530 | |
531 | - /** |
|
532 | - * Retrieves the names of all content locales that have been added. |
|
533 | - * @return string[] |
|
534 | - */ |
|
531 | + /** |
|
532 | + * Retrieves the names of all content locales that have been added. |
|
533 | + * @return string[] |
|
534 | + */ |
|
535 | 535 | public static function getContentLocaleNames() |
536 | 536 | { |
537 | 537 | return self::getLocaleNamesByNS(self::NAMESPACE_CONTENT); |
538 | 538 | } |
539 | 539 | |
540 | - /** |
|
541 | - * Retrieves all locale names available in the specified namespace. |
|
542 | - * The names are sorted alphabetically. |
|
543 | - * |
|
544 | - * @param string $namespace |
|
545 | - * @return array|array |
|
546 | - */ |
|
540 | + /** |
|
541 | + * Retrieves all locale names available in the specified namespace. |
|
542 | + * The names are sorted alphabetically. |
|
543 | + * |
|
544 | + * @param string $namespace |
|
545 | + * @return array|array |
|
546 | + */ |
|
547 | 547 | public static function getLocaleNamesByNS(string $namespace) |
548 | 548 | { |
549 | 549 | self::requireNamespace($namespace); |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | sort($names); |
554 | 554 | |
555 | 555 | return $names; |
556 | - } |
|
556 | + } |
|
557 | 557 | |
558 | 558 | /** |
559 | 559 | * Checks by the locale name if the specified locale is |
@@ -582,14 +582,14 @@ discard block |
||
582 | 582 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_CONTENT); |
583 | 583 | } |
584 | 584 | |
585 | - /** |
|
586 | - * Retrieves a locale by its name in the specified namespace. |
|
587 | - * |
|
588 | - * @param string $localeName |
|
589 | - * @param string $namespace |
|
590 | - * @throws Localization_Exception |
|
591 | - * @return Localization_Locale |
|
592 | - */ |
|
585 | + /** |
|
586 | + * Retrieves a locale by its name in the specified namespace. |
|
587 | + * |
|
588 | + * @param string $localeName |
|
589 | + * @param string $namespace |
|
590 | + * @throws Localization_Exception |
|
591 | + * @return Localization_Locale |
|
592 | + */ |
|
593 | 593 | public static function getLocaleByNameNS(string $localeName, string $namespace) : Localization_Locale |
594 | 594 | { |
595 | 595 | self::requireNamespace($namespace); |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | return self::selectLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
650 | 650 | } |
651 | 651 | |
652 | - /** |
|
653 | - * Checks whether the localization has been configured entirely. |
|
654 | - * @return bool |
|
655 | - */ |
|
652 | + /** |
|
653 | + * Checks whether the localization has been configured entirely. |
|
654 | + * @return bool |
|
655 | + */ |
|
656 | 656 | public static function isConfigured() : bool |
657 | 657 | { |
658 | 658 | return self::$configured; |
@@ -719,29 +719,29 @@ discard block |
||
719 | 719 | ); |
720 | 720 | } |
721 | 721 | |
722 | - /** |
|
723 | - * Injects a content locales selector element into the specified |
|
724 | - * HTML QuickForm2 container. |
|
725 | - * |
|
726 | - * @param string $elementName |
|
727 | - * @param \HTML_QuickForm2_Container $container |
|
728 | - * @param string $label |
|
729 | - * @return \HTML_QuickForm2_Element_Select |
|
730 | - */ |
|
722 | + /** |
|
723 | + * Injects a content locales selector element into the specified |
|
724 | + * HTML QuickForm2 container. |
|
725 | + * |
|
726 | + * @param string $elementName |
|
727 | + * @param \HTML_QuickForm2_Container $container |
|
728 | + * @param string $label |
|
729 | + * @return \HTML_QuickForm2_Element_Select |
|
730 | + */ |
|
731 | 731 | public static function injectContentLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
732 | 732 | { |
733 | 733 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
734 | 734 | } |
735 | 735 | |
736 | - /** |
|
737 | - * Injects an app locales selector element into the specified |
|
736 | + /** |
|
737 | + * Injects an app locales selector element into the specified |
|
738 | 738 | * HTML QuickForm2 container. |
739 | 739 | * |
740 | - * @param string $elementName |
|
741 | - * @param \HTML_QuickForm2_Container $container |
|
742 | - * @param string|NULL $label |
|
743 | - * @return \HTML_QuickForm2_Element_Select |
|
744 | - */ |
|
740 | + * @param string $elementName |
|
741 | + * @param \HTML_QuickForm2_Container $container |
|
742 | + * @param string|NULL $label |
|
743 | + * @return \HTML_QuickForm2_Element_Select |
|
744 | + */ |
|
745 | 745 | public static function injectAppLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
746 | 746 | { |
747 | 747 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
@@ -776,26 +776,26 @@ discard block |
||
776 | 776 | return $select; |
777 | 777 | } |
778 | 778 | |
779 | - /** |
|
780 | - * @var Localization_Source[] |
|
781 | - */ |
|
779 | + /** |
|
780 | + * @var Localization_Source[] |
|
781 | + */ |
|
782 | 782 | protected static $sources = array(); |
783 | 783 | |
784 | - /** |
|
785 | - * @var string[] |
|
786 | - */ |
|
784 | + /** |
|
785 | + * @var string[] |
|
786 | + */ |
|
787 | 787 | protected static $excludeFolders = array(); |
788 | 788 | |
789 | - /** |
|
790 | - * @var string[] |
|
791 | - */ |
|
789 | + /** |
|
790 | + * @var string[] |
|
791 | + */ |
|
792 | 792 | protected static $excludeFiles = array(); |
793 | 793 | |
794 | - /** |
|
795 | - * Retrieves all currently available sources. |
|
796 | - * |
|
797 | - * @return \AppLocalize\Localization_Source[] |
|
798 | - */ |
|
794 | + /** |
|
795 | + * Retrieves all currently available sources. |
|
796 | + * |
|
797 | + * @return \AppLocalize\Localization_Source[] |
|
798 | + */ |
|
799 | 799 | public static function getSources() |
800 | 800 | { |
801 | 801 | return self::$sources; |
@@ -827,10 +827,10 @@ discard block |
||
827 | 827 | return $source; |
828 | 828 | } |
829 | 829 | |
830 | - /** |
|
831 | - * Retrieves all sources grouped by their group name. |
|
832 | - * @return Localization_Source[] |
|
833 | - */ |
|
830 | + /** |
|
831 | + * Retrieves all sources grouped by their group name. |
|
832 | + * @return Localization_Source[] |
|
833 | + */ |
|
834 | 834 | public static function getSourcesGrouped() |
835 | 835 | { |
836 | 836 | $sources = self::getSources(); |
@@ -851,11 +851,11 @@ discard block |
||
851 | 851 | return $grouped; |
852 | 852 | } |
853 | 853 | |
854 | - /** |
|
855 | - * Checks whether a specific source exists by its ID. |
|
856 | - * @param string $sourceID |
|
857 | - * @return boolean |
|
858 | - */ |
|
854 | + /** |
|
855 | + * Checks whether a specific source exists by its ID. |
|
856 | + * @param string $sourceID |
|
857 | + * @return boolean |
|
858 | + */ |
|
859 | 859 | public static function sourceExists(string $sourceID) : bool |
860 | 860 | { |
861 | 861 | $sources = self::getSources(); |
@@ -868,11 +868,11 @@ discard block |
||
868 | 868 | return false; |
869 | 869 | } |
870 | 870 | |
871 | - /** |
|
872 | - * Checks whether a specific source exists by its alias. |
|
873 | - * @param string $sourceAlias |
|
874 | - * @return boolean |
|
875 | - */ |
|
871 | + /** |
|
872 | + * Checks whether a specific source exists by its alias. |
|
873 | + * @param string $sourceAlias |
|
874 | + * @return boolean |
|
875 | + */ |
|
876 | 876 | public static function sourceAliasExists(string $sourceAlias) : bool |
877 | 877 | { |
878 | 878 | $sources = self::getSources(); |
@@ -885,13 +885,13 @@ discard block |
||
885 | 885 | return false; |
886 | 886 | } |
887 | 887 | |
888 | - /** |
|
889 | - * Retrieves a localization source by its ID. |
|
890 | - * |
|
891 | - * @param string $sourceID |
|
892 | - * @throws Localization_Exception |
|
893 | - * @return Localization_Source |
|
894 | - */ |
|
888 | + /** |
|
889 | + * Retrieves a localization source by its ID. |
|
890 | + * |
|
891 | + * @param string $sourceID |
|
892 | + * @throws Localization_Exception |
|
893 | + * @return Localization_Source |
|
894 | + */ |
|
895 | 895 | public static function getSourceByID(string $sourceID) : Localization_Source |
896 | 896 | { |
897 | 897 | $sources = self::getSources(); |
@@ -937,13 +937,13 @@ discard block |
||
937 | 937 | ); |
938 | 938 | } |
939 | 939 | |
940 | - /** |
|
941 | - * Creates the scanner instance that is used to find |
|
942 | - * all translateable strings in the application. |
|
943 | - * |
|
944 | - * @param string $storageFile Path to the file in which to store string information. |
|
945 | - * @return Localization_Scanner |
|
946 | - */ |
|
940 | + /** |
|
941 | + * Creates the scanner instance that is used to find |
|
942 | + * all translateable strings in the application. |
|
943 | + * |
|
944 | + * @param string $storageFile Path to the file in which to store string information. |
|
945 | + * @return Localization_Scanner |
|
946 | + */ |
|
947 | 947 | public static function createScanner() : Localization_Scanner |
948 | 948 | { |
949 | 949 | self::requireConfiguration(); |
@@ -956,14 +956,14 @@ discard block |
||
956 | 956 | // FIXME: TODO: Add this |
957 | 957 | } |
958 | 958 | |
959 | - /** |
|
960 | - * Configures the localization for the application: |
|
961 | - * sets the location of the required files and folders. |
|
962 | - * Also updated the client library files as needed. |
|
963 | - * |
|
964 | - * @param string $storageFile Where to store the file analysis storage file. |
|
965 | - * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created. |
|
966 | - */ |
|
959 | + /** |
|
960 | + * Configures the localization for the application: |
|
961 | + * sets the location of the required files and folders. |
|
962 | + * Also updated the client library files as needed. |
|
963 | + * |
|
964 | + * @param string $storageFile Where to store the file analysis storage file. |
|
965 | + * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created. |
|
966 | + */ |
|
967 | 967 | public static function configure(string $storageFile, string $clientLibrariesFolder='') |
968 | 968 | { |
969 | 969 | self::$configured = true; |
@@ -979,17 +979,17 @@ discard block |
||
979 | 979 | } |
980 | 980 | } |
981 | 981 | |
982 | - /** |
|
983 | - * Sets a key that is used to verify whether the client |
|
984 | - * libraries have to be refreshed. A common use is to set |
|
985 | - * this to the application's version number to guarantee |
|
986 | - * new texts are automatically used with each release. |
|
987 | - * |
|
988 | - * NOTE: Otherwise files are refreshed only when saving |
|
989 | - * them in the editor UI. |
|
990 | - * |
|
991 | - * @param string $key |
|
992 | - */ |
|
982 | + /** |
|
983 | + * Sets a key that is used to verify whether the client |
|
984 | + * libraries have to be refreshed. A common use is to set |
|
985 | + * this to the application's version number to guarantee |
|
986 | + * new texts are automatically used with each release. |
|
987 | + * |
|
988 | + * NOTE: Otherwise files are refreshed only when saving |
|
989 | + * them in the editor UI. |
|
990 | + * |
|
991 | + * @param string $key |
|
992 | + */ |
|
993 | 993 | public static function setClientLibrariesCacheKey(string $key) |
994 | 994 | { |
995 | 995 | self::$clientCacheKey = $key; |
@@ -1000,48 +1000,48 @@ discard block |
||
1000 | 1000 | return self::$clientCacheKey; |
1001 | 1001 | } |
1002 | 1002 | |
1003 | - /** |
|
1004 | - * Sets the folder where client libraries are to be stored. |
|
1005 | - * @param string $folder |
|
1006 | - */ |
|
1003 | + /** |
|
1004 | + * Sets the folder where client libraries are to be stored. |
|
1005 | + * @param string $folder |
|
1006 | + */ |
|
1007 | 1007 | public static function setClientLibrariesFolder(string $folder) |
1008 | 1008 | { |
1009 | 1009 | self::$clientFolder = $folder; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | - /** |
|
1013 | - * Retrieves the path to the folder in which the client |
|
1014 | - * libraries should be stored. |
|
1015 | - * |
|
1016 | - * NOTE: Can return an empty string, when this is disabled. |
|
1017 | - * |
|
1018 | - * @return string |
|
1019 | - */ |
|
1012 | + /** |
|
1013 | + * Retrieves the path to the folder in which the client |
|
1014 | + * libraries should be stored. |
|
1015 | + * |
|
1016 | + * NOTE: Can return an empty string, when this is disabled. |
|
1017 | + * |
|
1018 | + * @return string |
|
1019 | + */ |
|
1020 | 1020 | public static function getClientLibrariesFolder() : string |
1021 | 1021 | { |
1022 | 1022 | return self::$clientFolder; |
1023 | 1023 | } |
1024 | 1024 | |
1025 | - /** |
|
1026 | - * Writes / updates the client library files on disk, |
|
1027 | - * at the location specified in the {@link Localization::configure()} |
|
1028 | - * method. |
|
1029 | - * |
|
1030 | - * @see Localization_ClientGenerator |
|
1031 | - * @param bool $force Whether to refresh the files, even if they exist. |
|
1032 | - */ |
|
1025 | + /** |
|
1026 | + * Writes / updates the client library files on disk, |
|
1027 | + * at the location specified in the {@link Localization::configure()} |
|
1028 | + * method. |
|
1029 | + * |
|
1030 | + * @see Localization_ClientGenerator |
|
1031 | + * @param bool $force Whether to refresh the files, even if they exist. |
|
1032 | + */ |
|
1033 | 1033 | public static function writeClientFiles(bool $force=false) : void |
1034 | 1034 | { |
1035 | 1035 | self::createGenerator()->writeFiles($force); |
1036 | 1036 | } |
1037 | 1037 | |
1038 | - /** |
|
1039 | - * Creates a new instance of the client generator class |
|
1040 | - * that is used to write the localization files into the |
|
1041 | - * target folder on disk. |
|
1042 | - * |
|
1043 | - * @return Localization_ClientGenerator |
|
1044 | - */ |
|
1038 | + /** |
|
1039 | + * Creates a new instance of the client generator class |
|
1040 | + * that is used to write the localization files into the |
|
1041 | + * target folder on disk. |
|
1042 | + * |
|
1043 | + * @return Localization_ClientGenerator |
|
1044 | + */ |
|
1045 | 1045 | public static function createGenerator() : Localization_ClientGenerator |
1046 | 1046 | { |
1047 | 1047 | return new Localization_ClientGenerator(); |
@@ -1084,13 +1084,13 @@ discard block |
||
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | |
1087 | - /** |
|
1088 | - * Creates the editor instance that can be used to |
|
1089 | - * display the localization UI to edit translateable |
|
1090 | - * strings in the browser. |
|
1091 | - * |
|
1092 | - * @return \AppLocalize\Localization_Editor |
|
1093 | - */ |
|
1087 | + /** |
|
1088 | + * Creates the editor instance that can be used to |
|
1089 | + * display the localization UI to edit translateable |
|
1090 | + * strings in the browser. |
|
1091 | + * |
|
1092 | + * @return \AppLocalize\Localization_Editor |
|
1093 | + */ |
|
1094 | 1094 | public static function createEditor() |
1095 | 1095 | { |
1096 | 1096 | self::requireConfiguration(); |
@@ -1098,10 +1098,10 @@ discard block |
||
1098 | 1098 | return new Localization_Editor(); |
1099 | 1099 | } |
1100 | 1100 | |
1101 | - /** |
|
1102 | - * Retrieves a list of all available source IDs. |
|
1103 | - * @return string[] |
|
1104 | - */ |
|
1101 | + /** |
|
1102 | + * Retrieves a list of all available source IDs. |
|
1103 | + * @return string[] |
|
1104 | + */ |
|
1105 | 1105 | public static function getSourceIDs() |
1106 | 1106 | { |
1107 | 1107 | $ids = array(); |
@@ -1128,9 +1128,9 @@ discard block |
||
1128 | 1128 | return $aliases; |
1129 | 1129 | } |
1130 | 1130 | |
1131 | - /** |
|
1132 | - * Resets all locales to the built-in locale. |
|
1133 | - */ |
|
1131 | + /** |
|
1132 | + * Resets all locales to the built-in locale. |
|
1133 | + */ |
|
1134 | 1134 | public static function reset() |
1135 | 1135 | { |
1136 | 1136 | self::$locales = array(); |
@@ -1162,22 +1162,22 @@ discard block |
||
1162 | 1162 | 'de_CH' |
1163 | 1163 | ); |
1164 | 1164 | |
1165 | - /** |
|
1166 | - * Retrieves a list of all supported locales. |
|
1167 | - * |
|
1168 | - * @return array |
|
1169 | - */ |
|
1165 | + /** |
|
1166 | + * Retrieves a list of all supported locales. |
|
1167 | + * |
|
1168 | + * @return array |
|
1169 | + */ |
|
1170 | 1170 | public static function getSupportedLocaleNames() : array |
1171 | 1171 | { |
1172 | 1172 | return self::$supportedLocales; |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - /** |
|
1176 | - * Checks whether the specified locale is supported. |
|
1177 | - * |
|
1178 | - * @param string $localeName |
|
1179 | - * @return bool |
|
1180 | - */ |
|
1175 | + /** |
|
1176 | + * Checks whether the specified locale is supported. |
|
1177 | + * |
|
1178 | + * @param string $localeName |
|
1179 | + * @return bool |
|
1180 | + */ |
|
1181 | 1181 | public static function isLocaleSupported(string $localeName) : bool |
1182 | 1182 | { |
1183 | 1183 | return in_array($localeName, self::$supportedLocales); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public static function init() |
116 | 116 | { |
117 | - if(self::$initDone) { |
|
117 | + if (self::$initDone) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public static function getLocalesByNS(string $namespace) |
160 | 160 | { |
161 | - if(isset(self::$locales[$namespace])) { |
|
161 | + if (isset(self::$locales[$namespace])) { |
|
162 | 162 | return array_values(self::$locales[$namespace]); |
163 | 163 | } |
164 | 164 | |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
205 | 205 | { |
206 | - if(!isset(self::$locales[$namespace])) { |
|
206 | + if (!isset(self::$locales[$namespace])) { |
|
207 | 207 | self::$locales[$namespace] = array(); |
208 | 208 | } |
209 | 209 | |
210 | - if(!isset(self::$locales[$namespace][$localeName])) |
|
210 | + if (!isset(self::$locales[$namespace][$localeName])) |
|
211 | 211 | { |
212 | 212 | self::$locales[$namespace][$localeName] = self::createLocale($localeName); |
213 | 213 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public static function createCountry(string $id) |
240 | 240 | { |
241 | - $className = '\AppLocalize\Localization_Country_' . strtoupper($id); |
|
241 | + $className = '\AppLocalize\Localization_Country_'.strtoupper($id); |
|
242 | 242 | return new $className(); |
243 | 243 | } |
244 | 244 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | { |
331 | 331 | self::requireNamespace($namespace); |
332 | 332 | |
333 | - if(isset(self::$selected[$namespace])) { |
|
333 | + if (isset(self::$selected[$namespace])) { |
|
334 | 334 | return self::$selected[$namespace][$key]; |
335 | 335 | } |
336 | 336 | |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | $locale = self::addLocaleByNS($localeName, $namespace); |
367 | 367 | $previous = null; |
368 | 368 | |
369 | - if(isset(self::$selected[$namespace])) |
|
369 | + if (isset(self::$selected[$namespace])) |
|
370 | 370 | { |
371 | - if(self::$selected[$namespace]['name'] === $localeName) { |
|
371 | + if (self::$selected[$namespace]['name'] === $localeName) { |
|
372 | 372 | return $locale; |
373 | 373 | } |
374 | 374 | |
@@ -406,11 +406,11 @@ discard block |
||
406 | 406 | $class = '\AppLocalize\Localization_Event_'.$name; |
407 | 407 | $event = new $class($argsList); |
408 | 408 | |
409 | - if(!isset(self::$listeners[$name])) { |
|
409 | + if (!isset(self::$listeners[$name])) { |
|
410 | 410 | return $event; |
411 | 411 | } |
412 | 412 | |
413 | - foreach(self::$listeners[$name] as $listener) |
|
413 | + foreach (self::$listeners[$name] as $listener) |
|
414 | 414 | { |
415 | 415 | $callArgs = $listener['args']; |
416 | 416 | array_unshift($callArgs, $event); |
@@ -429,15 +429,15 @@ discard block |
||
429 | 429 | * @param array $args Additional arguments to add to the event |
430 | 430 | * @return int The listener number. |
431 | 431 | */ |
432 | - public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
|
432 | + public static function addEventListener(string $eventName, $callback, array $args = array()) : int |
|
433 | 433 | { |
434 | - if(!isset(self::$listeners[$eventName])) { |
|
434 | + if (!isset(self::$listeners[$eventName])) { |
|
435 | 435 | self::$listeners[$eventName] = array(); |
436 | 436 | } |
437 | 437 | |
438 | 438 | $className = '\AppLocalize\Localization_Event_'.$eventName; |
439 | 439 | |
440 | - if(!class_exists($className)) |
|
440 | + if (!class_exists($className)) |
|
441 | 441 | { |
442 | 442 | throw new Localization_Exception( |
443 | 443 | sprintf('Unknown localization event [%s].', $eventName), |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @return int |
471 | 471 | * @see Localization_Event_LocaleChanged |
472 | 472 | */ |
473 | - public static function onLocaleChanged($callback, array $args=array()) : int |
|
473 | + public static function onLocaleChanged($callback, array $args = array()) : int |
|
474 | 474 | { |
475 | 475 | return self::addEventListener('LocaleChanged', $callback, $args); |
476 | 476 | } |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | { |
595 | 595 | self::requireNamespace($namespace); |
596 | 596 | |
597 | - if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
597 | + if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
598 | 598 | return self::$locales[$namespace][$localeName]; |
599 | 599 | } |
600 | 600 | |
@@ -663,9 +663,9 @@ discard block |
||
663 | 663 | /** |
664 | 664 | * @return Localization_Translator |
665 | 665 | */ |
666 | - public static function getTranslator(Localization_Locale $locale=null) : Localization_Translator |
|
666 | + public static function getTranslator(Localization_Locale $locale = null) : Localization_Translator |
|
667 | 667 | { |
668 | - if($locale !== null) |
|
668 | + if ($locale !== null) |
|
669 | 669 | { |
670 | 670 | $obj = new Localization_Translator(); |
671 | 671 | $obj->addSources(self::getSources()); |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | return $obj; |
674 | 674 | } |
675 | 675 | |
676 | - if(!isset(self::$translator)) |
|
676 | + if (!isset(self::$translator)) |
|
677 | 677 | { |
678 | 678 | $obj = new Localization_Translator(); |
679 | 679 | $obj->addSources(self::getSources()); |
@@ -698,14 +698,14 @@ discard block |
||
698 | 698 | { |
699 | 699 | self::requireNamespace($namespace); |
700 | 700 | |
701 | - if(isset(self::$locales[$namespace])) { |
|
701 | + if (isset(self::$locales[$namespace])) { |
|
702 | 702 | return count(self::$locales[$namespace]); |
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
706 | 706 | protected static function requireNamespace(string $namespace) |
707 | 707 | { |
708 | - if(isset(self::$locales[$namespace])) { |
|
708 | + if (isset(self::$locales[$namespace])) { |
|
709 | 709 | return; |
710 | 710 | } |
711 | 711 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @param string $label |
729 | 729 | * @return \HTML_QuickForm2_Element_Select |
730 | 730 | */ |
731 | - public static function injectContentLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
731 | + public static function injectContentLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
732 | 732 | { |
733 | 733 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
734 | 734 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | * @param string|NULL $label |
743 | 743 | * @return \HTML_QuickForm2_Element_Select |
744 | 744 | */ |
745 | - public static function injectAppLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
745 | + public static function injectAppLocalesSelector(string $elementName, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
746 | 746 | { |
747 | 747 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
748 | 748 | } |
@@ -757,9 +757,9 @@ discard block |
||
757 | 757 | * @param \HTML_QuickForm2_Container $container |
758 | 758 | * @return \HTML_QuickForm2_Element_Select |
759 | 759 | */ |
760 | - public static function injectLocalesSelectorNS(string $elementName, string $namespace, \HTML_QuickForm2_Container $container, string $label='') : \HTML_QuickForm2_Element_Select |
|
760 | + public static function injectLocalesSelectorNS(string $elementName, string $namespace, \HTML_QuickForm2_Container $container, string $label = '') : \HTML_QuickForm2_Element_Select |
|
761 | 761 | { |
762 | - if(empty($label)) { |
|
762 | + if (empty($label)) { |
|
763 | 763 | $label = t('Language'); |
764 | 764 | } |
765 | 765 | |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | |
770 | 770 | $locales = self::getLocalesByNS($namespace); |
771 | 771 | |
772 | - foreach($locales as $locale) { |
|
772 | + foreach ($locales as $locale) { |
|
773 | 773 | $select->addOption($locale->getLabel(), $locale->getName()); |
774 | 774 | } |
775 | 775 | |
@@ -803,14 +803,14 @@ discard block |
||
803 | 803 | |
804 | 804 | public static function addExcludeFolder(string $folderName) : void |
805 | 805 | { |
806 | - if(!in_array($folderName, self::$excludeFolders)) { |
|
806 | + if (!in_array($folderName, self::$excludeFolders)) { |
|
807 | 807 | self::$excludeFolders[] = $folderName; |
808 | 808 | } |
809 | 809 | } |
810 | 810 | |
811 | 811 | public static function addExcludeFile(string $fileName) : void |
812 | 812 | { |
813 | - if(!in_array($fileName, self::$excludeFiles)) { |
|
813 | + if (!in_array($fileName, self::$excludeFiles)) { |
|
814 | 814 | self::$excludeFiles[] = $fileName; |
815 | 815 | } |
816 | 816 | } |
@@ -837,11 +837,11 @@ discard block |
||
837 | 837 | |
838 | 838 | $grouped = array(); |
839 | 839 | |
840 | - foreach($sources as $source) |
|
840 | + foreach ($sources as $source) |
|
841 | 841 | { |
842 | 842 | $group = $source->getGroup(); |
843 | 843 | |
844 | - if(!isset($grouped[$group])) { |
|
844 | + if (!isset($grouped[$group])) { |
|
845 | 845 | $grouped[$group] = array(); |
846 | 846 | } |
847 | 847 | |
@@ -859,8 +859,8 @@ discard block |
||
859 | 859 | public static function sourceExists(string $sourceID) : bool |
860 | 860 | { |
861 | 861 | $sources = self::getSources(); |
862 | - foreach($sources as $source) { |
|
863 | - if($source->getID() == $sourceID) { |
|
862 | + foreach ($sources as $source) { |
|
863 | + if ($source->getID() == $sourceID) { |
|
864 | 864 | return true; |
865 | 865 | } |
866 | 866 | } |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | public static function sourceAliasExists(string $sourceAlias) : bool |
877 | 877 | { |
878 | 878 | $sources = self::getSources(); |
879 | - foreach($sources as $source) { |
|
880 | - if($source->getAlias() == $sourceAlias) { |
|
879 | + foreach ($sources as $source) { |
|
880 | + if ($source->getAlias() == $sourceAlias) { |
|
881 | 881 | return true; |
882 | 882 | } |
883 | 883 | } |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | public static function getSourceByID(string $sourceID) : Localization_Source |
896 | 896 | { |
897 | 897 | $sources = self::getSources(); |
898 | - foreach($sources as $source) { |
|
899 | - if($source->getID() == $sourceID) { |
|
898 | + foreach ($sources as $source) { |
|
899 | + if ($source->getID() == $sourceID) { |
|
900 | 900 | return $source; |
901 | 901 | } |
902 | 902 | } |
@@ -921,8 +921,8 @@ discard block |
||
921 | 921 | public static function getSourceByAlias(string $sourceAlias) : Localization_Source |
922 | 922 | { |
923 | 923 | $sources = self::getSources(); |
924 | - foreach($sources as $source) { |
|
925 | - if($source->getAlias() == $sourceAlias) { |
|
924 | + foreach ($sources as $source) { |
|
925 | + if ($source->getAlias() == $sourceAlias) { |
|
926 | 926 | return $source; |
927 | 927 | } |
928 | 928 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | * @param string $storageFile Where to store the file analysis storage file. |
965 | 965 | * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created. |
966 | 966 | */ |
967 | - public static function configure(string $storageFile, string $clientLibrariesFolder='') |
|
967 | + public static function configure(string $storageFile, string $clientLibrariesFolder = '') |
|
968 | 968 | { |
969 | 969 | self::$configured = true; |
970 | 970 | |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | |
974 | 974 | // only write the client libraries to disk if the folder |
975 | 975 | // has been specified. |
976 | - if(!empty($clientLibrariesFolder)) |
|
976 | + if (!empty($clientLibrariesFolder)) |
|
977 | 977 | { |
978 | 978 | self::writeClientFiles(); |
979 | 979 | } |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | * @see Localization_ClientGenerator |
1031 | 1031 | * @param bool $force Whether to refresh the files, even if they exist. |
1032 | 1032 | */ |
1033 | - public static function writeClientFiles(bool $force=false) : void |
|
1033 | + public static function writeClientFiles(bool $force = false) : void |
|
1034 | 1034 | { |
1035 | 1035 | self::createGenerator()->writeFiles($force); |
1036 | 1036 | } |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | |
1057 | 1057 | protected static function requireConfiguration() |
1058 | 1058 | { |
1059 | - if(!self::$configured) |
|
1059 | + if (!self::$configured) |
|
1060 | 1060 | { |
1061 | 1061 | throw new Localization_Exception( |
1062 | 1062 | 'The localization configuration is incomplete.', |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | ); |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - if(empty(self::$storageFile)) |
|
1068 | + if (empty(self::$storageFile)) |
|
1069 | 1069 | { |
1070 | 1070 | throw new Localization_Exception( |
1071 | 1071 | 'No localization storage file set', |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | ); |
1075 | 1075 | } |
1076 | 1076 | |
1077 | - if(empty(self::$sources)) |
|
1077 | + if (empty(self::$sources)) |
|
1078 | 1078 | { |
1079 | 1079 | throw new Localization_Exception( |
1080 | 1080 | 'No source folders have been defined.', |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | { |
1107 | 1107 | $ids = array(); |
1108 | 1108 | |
1109 | - foreach(self::$sources as $source) { |
|
1109 | + foreach (self::$sources as $source) { |
|
1110 | 1110 | $ids[] = $source->getID(); |
1111 | 1111 | } |
1112 | 1112 | |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | { |
1122 | 1122 | $aliases = array(); |
1123 | 1123 | |
1124 | - foreach(self::$sources as $source) { |
|
1124 | + foreach (self::$sources as $source) { |
|
1125 | 1125 | $aliases[] = $source->getAlias(); |
1126 | 1126 | } |
1127 | 1127 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | function __construct($i = null) |
45 | 45 | { |
46 | 46 | if (!is_null($i)) { |
47 | - $this->i = (int)$i; |
|
47 | + $this->i = (int) $i; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | if (is_int($i)) { |
86 | 86 | if (!isset($this->names[$i])) { |
87 | - trigger_error("symbol " . var_export($i, 1) . " is unknown in " . get_class($this), E_USER_NOTICE); |
|
87 | + trigger_error("symbol ".var_export($i, 1)." is unknown in ".get_class($this), E_USER_NOTICE); |
|
88 | 88 | |
89 | 89 | return 'UNKNOWN'; |
90 | 90 | } else { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | } else { |
94 | 94 | if (!isset($this->literals[$i])) { |
95 | - trigger_error("literal symbol " . var_export($i, 1) . " is unknown in " . get_class($this), E_USER_NOTICE); |
|
95 | + trigger_error("literal symbol ".var_export($i, 1)." is unknown in ".get_class($this), E_USER_NOTICE); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | function dump() |
113 | 113 | { |
114 | 114 | asort($this->names, SORT_STRING); |
115 | - $t = max(2, strlen((string)$this->i)); |
|
115 | + $t = max(2, strlen((string) $this->i)); |
|
116 | 116 | foreach ($this->names as $i => $n) { |
117 | 117 | $i = str_pad($i, $t, ' ', STR_PAD_LEFT); |
118 | 118 | echo "$i => $n \n"; |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | private $targetLocaleName = null; |
47 | 47 | |
48 | - /** |
|
49 | - * @var Localization_Source[] |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var Localization_Source[] |
|
50 | + */ |
|
51 | 51 | private $sources = array(); |
52 | 52 | |
53 | 53 | public function addSource(Localization_Source $source) |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | ); |
175 | 175 | } |
176 | 176 | |
177 | - /** |
|
178 | - * Retrieves all available strings for the specified locale, |
|
179 | - * as hash => text value pairs. |
|
180 | - * |
|
181 | - * @param Localization_Locale $locale |
|
182 | - * @throws Localization_Exception |
|
183 | - * @return string[] |
|
184 | - */ |
|
177 | + /** |
|
178 | + * Retrieves all available strings for the specified locale, |
|
179 | + * as hash => text value pairs. |
|
180 | + * |
|
181 | + * @param Localization_Locale $locale |
|
182 | + * @throws Localization_Exception |
|
183 | + * @return string[] |
|
184 | + */ |
|
185 | 185 | public function getStrings(Localization_Locale $locale) |
186 | 186 | { |
187 | 187 | $this->load($locale); |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | return !empty($this->strings[$locale->getName()]); |
211 | 211 | } |
212 | 212 | |
213 | - /** |
|
214 | - * @param string $type |
|
215 | - * @param Localization_Scanner_StringHash[] $hashes |
|
216 | - * @param string $file |
|
217 | - * @param Localization_Locale $locale |
|
218 | - * @param boolean $editable |
|
219 | - * @throws Localization_Exception |
|
220 | - */ |
|
213 | + /** |
|
214 | + * @param string $type |
|
215 | + * @param Localization_Scanner_StringHash[] $hashes |
|
216 | + * @param string $file |
|
217 | + * @param Localization_Locale $locale |
|
218 | + * @param boolean $editable |
|
219 | + * @throws Localization_Exception |
|
220 | + */ |
|
221 | 221 | protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable=true) |
222 | 222 | { |
223 | 223 | $sourceID = $source->getID(); |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | - /** |
|
284 | - * Sort the strings to ensure they always appear in the same order: |
|
285 | - * first by text, and same strings by their hashes. This is important |
|
286 | - * for strings that have the same translation to avoid them changing |
|
287 | - * order between sorts. |
|
288 | - * |
|
289 | - * @param array $a |
|
290 | - * @param array $b |
|
291 | - * @return number |
|
292 | - */ |
|
283 | + /** |
|
284 | + * Sort the strings to ensure they always appear in the same order: |
|
285 | + * first by text, and same strings by their hashes. This is important |
|
286 | + * for strings that have the same translation to avoid them changing |
|
287 | + * order between sorts. |
|
288 | + * |
|
289 | + * @param array $a |
|
290 | + * @param array $b |
|
291 | + * @return number |
|
292 | + */ |
|
293 | 293 | public function callback_sortStrings($a, $b) |
294 | 294 | { |
295 | 295 | $result = strnatcasecmp($a['text'], $b['text']); |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | ); |
317 | 317 | } |
318 | 318 | |
319 | - /** |
|
320 | - * Retrieves the full path to the strings storage ini file |
|
321 | - * for the clientside strings. |
|
322 | - * |
|
323 | - * @param Localization_Locale $locale |
|
324 | - * @return string |
|
325 | - */ |
|
319 | + /** |
|
320 | + * Retrieves the full path to the strings storage ini file |
|
321 | + * for the clientside strings. |
|
322 | + * |
|
323 | + * @param Localization_Locale $locale |
|
324 | + * @return string |
|
325 | + */ |
|
326 | 326 | protected function getClientStorageFile(Localization_Locale $locale, Localization_Source $source) |
327 | 327 | { |
328 | 328 | return sprintf( |
@@ -444,12 +444,12 @@ discard block |
||
444 | 444 | return null; |
445 | 445 | } |
446 | 446 | |
447 | - /** |
|
448 | - * Retrieves only the strings that are available clientside. |
|
449 | - * |
|
450 | - * @param Localization_Locale $locale |
|
451 | - * @return array |
|
452 | - */ |
|
447 | + /** |
|
448 | + * Retrieves only the strings that are available clientside. |
|
449 | + * |
|
450 | + * @param Localization_Locale $locale |
|
451 | + * @return array |
|
452 | + */ |
|
453 | 453 | public function getClientStrings(Localization_Locale $locale) |
454 | 454 | { |
455 | 455 | $result = array(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public function addSources($sources) |
59 | 59 | { |
60 | - foreach($sources as $source) { |
|
60 | + foreach ($sources as $source) { |
|
61 | 61 | $this->addSource($source); |
62 | 62 | } |
63 | 63 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $this->strings[$localeName] = array(); |
109 | 109 | } |
110 | 110 | |
111 | - foreach($this->sources as $source) |
|
111 | + foreach ($this->sources as $source) |
|
112 | 112 | { |
113 | 113 | $file = $this->resolveStorageFile($locale, $source); |
114 | 114 | if (!file_exists($file)) { |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | $name = $locale->getName(); |
190 | 190 | |
191 | - if(isset($this->strings[$name])) { |
|
191 | + if (isset($this->strings[$name])) { |
|
192 | 192 | return $this->strings[$name]; |
193 | 193 | } |
194 | 194 | |
@@ -218,25 +218,25 @@ discard block |
||
218 | 218 | * @param boolean $editable |
219 | 219 | * @throws Localization_Exception |
220 | 220 | */ |
221 | - protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable=true) |
|
221 | + protected function renderStringsFile($type, Localization_Source $source, $hashes, $file, Localization_Locale $locale, $editable = true) |
|
222 | 222 | { |
223 | 223 | $sourceID = $source->getID(); |
224 | 224 | |
225 | - $title = strtoupper($type).' TRANSLATION FILE FOR ' . strtoupper($locale->getLabel()); |
|
225 | + $title = strtoupper($type).' TRANSLATION FILE FOR '.strtoupper($locale->getLabel()); |
|
226 | 226 | |
227 | - $content = '; -------------------------------------------------------' . PHP_EOL; |
|
228 | - $content .= '; '. $title . PHP_EOL; |
|
229 | - $content .= '; -------------------------------------------------------' . PHP_EOL; |
|
230 | - $content .= '; ' . PHP_EOL; |
|
227 | + $content = '; -------------------------------------------------------'.PHP_EOL; |
|
228 | + $content .= '; '.$title.PHP_EOL; |
|
229 | + $content .= '; -------------------------------------------------------'.PHP_EOL; |
|
230 | + $content .= '; '.PHP_EOL; |
|
231 | 231 | |
232 | - if($editable) { |
|
233 | - $content .= '; You may edit text directly in this file under the following conditions:' . PHP_EOL; |
|
234 | - $content .= '; ' . PHP_EOL; |
|
235 | - $content .= '; 1) Do not to modify the keys (left hand side of the = sign)' . PHP_EOL; |
|
236 | - $content .= '; 2) Save the file as UTF-8 without BOM' . PHP_EOL; |
|
232 | + if ($editable) { |
|
233 | + $content .= '; You may edit text directly in this file under the following conditions:'.PHP_EOL; |
|
234 | + $content .= '; '.PHP_EOL; |
|
235 | + $content .= '; 1) Do not to modify the keys (left hand side of the = sign)'.PHP_EOL; |
|
236 | + $content .= '; 2) Save the file as UTF-8 without BOM'.PHP_EOL; |
|
237 | 237 | } else { |
238 | - $content .= '; Do NOT edit this file directly! It depends on the main translation file' . PHP_EOL; |
|
239 | - $content .= '; and any changes will be lost. Edit the main file instead.' . PHP_EOL; |
|
238 | + $content .= '; Do NOT edit this file directly! It depends on the main translation file'.PHP_EOL; |
|
239 | + $content .= '; and any changes will be lost. Edit the main file instead.'.PHP_EOL; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | $content .= PHP_EOL; |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | $saveList = array(); |
245 | 245 | foreach ($hashes as $hash) |
246 | 246 | { |
247 | - if(!$hash->hasSourceID($sourceID)) { |
|
247 | + if (!$hash->hasSourceID($sourceID)) { |
|
248 | 248 | continue; |
249 | 249 | } |
250 | 250 | |
251 | 251 | $text = $this->getHashTranslation($hash->getHash(), $locale); |
252 | 252 | |
253 | 253 | // skip any empty strings |
254 | - if($text === null || trim($text) == '') { |
|
254 | + if ($text === null || trim($text) == '') { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | 257 | |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | |
264 | 264 | usort($saveList, array($this, 'callback_sortStrings')); |
265 | 265 | |
266 | - foreach($saveList as $entry) { |
|
267 | - $content .= $entry['hash'] . '= "' . $entry['text'] . '"' . PHP_EOL; |
|
266 | + foreach ($saveList as $entry) { |
|
267 | + $content .= $entry['hash'].'= "'.$entry['text'].'"'.PHP_EOL; |
|
268 | 268 | } |
269 | 269 | |
270 | - if(!file_put_contents($file, $content)) { |
|
270 | + if (!file_put_contents($file, $content)) { |
|
271 | 271 | throw new Localization_Exception( |
272 | 272 | 'Cannot save localization file', |
273 | 273 | sprintf( |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | public function callback_sortStrings($a, $b) |
294 | 294 | { |
295 | 295 | $result = strnatcasecmp($a['text'], $b['text']); |
296 | - if($result==0) { |
|
296 | + if ($result == 0) { |
|
297 | 297 | return strnatcmp($a['hash'], $b['hash']); |
298 | 298 | } |
299 | 299 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | |
369 | 369 | // to avoid re-creating the hash for the same texts over and over, |
370 | 370 | // we keep track of the hashes we created, and re-use them. |
371 | - if(isset($this->reverseStrings[$text])) { |
|
371 | + if (isset($this->reverseStrings[$text])) { |
|
372 | 372 | $hash = $this->reverseStrings[$text]; |
373 | 373 | } else { |
374 | 374 | $hash = md5($text); |
@@ -429,15 +429,15 @@ discard block |
||
429 | 429 | * @param string $hash |
430 | 430 | * @return string|NULL |
431 | 431 | */ |
432 | - public function getHashTranslation($hash, Localization_Locale $locale=null) |
|
432 | + public function getHashTranslation($hash, Localization_Locale $locale = null) |
|
433 | 433 | { |
434 | - if(!$locale) { |
|
434 | + if (!$locale) { |
|
435 | 435 | $locale = $this->targetLocale; |
436 | 436 | } |
437 | 437 | |
438 | 438 | $localeName = $locale->getName(); |
439 | 439 | |
440 | - if(isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
440 | + if (isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
441 | 441 | return $this->strings[$localeName][$hash]; |
442 | 442 | } |
443 | 443 | |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | { |
455 | 455 | $result = array(); |
456 | 456 | |
457 | - foreach($this->sources as $source) |
|
457 | + foreach ($this->sources as $source) |
|
458 | 458 | { |
459 | 459 | $localeFile = self::getClientStorageFile($locale, $source); |
460 | - if(!file_exists($localeFile)) { |
|
460 | + if (!file_exists($localeFile)) { |
|
461 | 461 | continue; |
462 | 462 | } |
463 | 463 |
@@ -10,19 +10,19 @@ discard block |
||
10 | 10 | |
11 | 11 | const STORAGE_FORMAT_VERSION = 1; |
12 | 12 | |
13 | - /** |
|
14 | - * @var Localization_Scanner |
|
15 | - */ |
|
13 | + /** |
|
14 | + * @var Localization_Scanner |
|
15 | + */ |
|
16 | 16 | protected $scanner; |
17 | 17 | |
18 | - /** |
|
19 | - * @var Localization_Scanner_StringHash[] |
|
20 | - */ |
|
18 | + /** |
|
19 | + * @var Localization_Scanner_StringHash[] |
|
20 | + */ |
|
21 | 21 | protected $hashes = array(); |
22 | 22 | |
23 | - /** |
|
24 | - * @var array |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var array |
|
25 | + */ |
|
26 | 26 | protected $warnings = array(); |
27 | 27 | |
28 | 28 | public function __construct(Localization_Scanner $scanner) |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | return $string; |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * Adds a single translateable string. |
|
56 | - * |
|
57 | - * @param Localization_Scanner_StringInfo $string |
|
58 | - * @return Localization_Scanner_StringsCollection |
|
59 | - */ |
|
54 | + /** |
|
55 | + * Adds a single translateable string. |
|
56 | + * |
|
57 | + * @param Localization_Scanner_StringInfo $string |
|
58 | + * @return Localization_Scanner_StringsCollection |
|
59 | + */ |
|
60 | 60 | protected function add(Localization_Scanner_StringInfo $string) |
61 | 61 | { |
62 | 62 | $hash = $string->getHash(); |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | return $this; |
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Retrieves all available translateable strings, |
|
74 | - * grouped by their hash to identify unique strings. |
|
75 | - * |
|
76 | - * @return Localization_Scanner_StringHash[] |
|
77 | - */ |
|
72 | + /** |
|
73 | + * Retrieves all available translateable strings, |
|
74 | + * grouped by their hash to identify unique strings. |
|
75 | + * |
|
76 | + * @return Localization_Scanner_StringHash[] |
|
77 | + */ |
|
78 | 78 | public function getHashes() |
79 | 79 | { |
80 | 80 | return array_values($this->hashes); |
@@ -133,32 +133,32 @@ discard block |
||
133 | 133 | return true; |
134 | 134 | } |
135 | 135 | |
136 | - /** |
|
137 | - * Whether the parser reported warnings during the |
|
138 | - * search for translateable texts. |
|
139 | - * |
|
140 | - * @return bool |
|
141 | - */ |
|
136 | + /** |
|
137 | + * Whether the parser reported warnings during the |
|
138 | + * search for translateable texts. |
|
139 | + * |
|
140 | + * @return bool |
|
141 | + */ |
|
142 | 142 | public function hasWarnings() : bool |
143 | 143 | { |
144 | 144 | return !empty($this->warnings); |
145 | 145 | } |
146 | 146 | |
147 | - /** |
|
148 | - * Retrieves the amount of warnings. |
|
149 | - * @return int |
|
150 | - */ |
|
147 | + /** |
|
148 | + * Retrieves the amount of warnings. |
|
149 | + * @return int |
|
150 | + */ |
|
151 | 151 | public function countWarnings() : int |
152 | 152 | { |
153 | 153 | return count($this->warnings); |
154 | 154 | } |
155 | 155 | |
156 | - /** |
|
157 | - * Retrieves all warning messages that were added |
|
158 | - * during the search for translateable texts, if any. |
|
159 | - * |
|
160 | - * @return Localization_Scanner_StringsCollection_Warning[] |
|
161 | - */ |
|
156 | + /** |
|
157 | + * Retrieves all warning messages that were added |
|
158 | + * during the search for translateable texts, if any. |
|
159 | + * |
|
160 | + * @return Localization_Scanner_StringsCollection_Warning[] |
|
161 | + */ |
|
162 | 162 | public function getWarnings() : array |
163 | 163 | { |
164 | 164 | $result = array(); |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | return $amount; |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Retrieves all string hashed for the specified source. |
|
190 | - * |
|
191 | - * @param string $id |
|
192 | - * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
193 | - */ |
|
188 | + /** |
|
189 | + * Retrieves all string hashed for the specified source. |
|
190 | + * |
|
191 | + * @param string $id |
|
192 | + * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
193 | + */ |
|
194 | 194 | public function getHashesBySourceID(string $id) |
195 | 195 | { |
196 | 196 | $hashes = array(); |
@@ -204,12 +204,12 @@ discard block |
||
204 | 204 | return $hashes; |
205 | 205 | } |
206 | 206 | |
207 | - /** |
|
208 | - * Retrieves all hashes for the specified language ID. |
|
209 | - * |
|
210 | - * @param string $languageID The language ID, e.g. "PHP" |
|
211 | - * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
212 | - */ |
|
207 | + /** |
|
208 | + * Retrieves all hashes for the specified language ID. |
|
209 | + * |
|
210 | + * @param string $languageID The language ID, e.g. "PHP" |
|
211 | + * @return \AppLocalize\Localization_Scanner_StringHash[] |
|
212 | + */ |
|
213 | 213 | public function getHashesByLanguageID(string $languageID) |
214 | 214 | { |
215 | 215 | $hashes = array(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $hash = $string->getHash(); |
63 | 63 | |
64 | - if(!isset($this->hashes[$hash])) { |
|
64 | + if (!isset($this->hashes[$hash])) { |
|
65 | 65 | $this->hashes[$hash] = new Localization_Scanner_StringHash($this, $hash); |
66 | 66 | } |
67 | 67 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | public function getHash($hash) |
89 | 89 | { |
90 | - if(isset($this->hashes[$hash])) { |
|
90 | + if (isset($this->hashes[$hash])) { |
|
91 | 91 | return $this->hashes[$hash]; |
92 | 92 | } |
93 | 93 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'warnings' => array() |
107 | 107 | ); |
108 | 108 | |
109 | - foreach($this->hashes as $hash) |
|
109 | + foreach ($this->hashes as $hash) |
|
110 | 110 | { |
111 | 111 | $data['hashes'] = array_merge($data['hashes'], $hash->toArray()); |
112 | 112 | } |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | |
119 | 119 | public function fromArray($array) : bool |
120 | 120 | { |
121 | - if(!isset($array['formatVersion']) || $array['formatVersion'] != self::STORAGE_FORMAT_VERSION) { |
|
121 | + if (!isset($array['formatVersion']) || $array['formatVersion'] != self::STORAGE_FORMAT_VERSION) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
125 | - foreach($array['hashes'] as $entry) |
|
125 | + foreach ($array['hashes'] as $entry) |
|
126 | 126 | { |
127 | 127 | $string = Localization_Scanner_StringInfo::fromArray($this, $entry); |
128 | 128 | $this->add($string); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | { |
164 | 164 | $result = array(); |
165 | 165 | |
166 | - foreach($this->warnings as $def) { |
|
166 | + foreach ($this->warnings as $def) { |
|
167 | 167 | $result[] = new Localization_Scanner_StringsCollection_Warning($def); |
168 | 168 | } |
169 | 169 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function countFiles() : int |
179 | 179 | { |
180 | 180 | $amount = 0; |
181 | - foreach($this->hashes as $hash) { |
|
181 | + foreach ($this->hashes as $hash) { |
|
182 | 182 | $amount = $amount + $hash->countFiles(); |
183 | 183 | } |
184 | 184 | |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | { |
196 | 196 | $hashes = array(); |
197 | 197 | |
198 | - foreach($this->hashes as $hash) { |
|
199 | - if($hash->hasSourceID($id)) { |
|
198 | + foreach ($this->hashes as $hash) { |
|
199 | + if ($hash->hasSourceID($id)) { |
|
200 | 200 | $hashes[] = $hash; |
201 | 201 | } |
202 | 202 | } |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | { |
215 | 215 | $hashes = array(); |
216 | 216 | |
217 | - foreach($this->hashes as $hash) { |
|
218 | - if($hash->hasLanguageType($languageID)) { |
|
217 | + foreach ($this->hashes as $hash) { |
|
218 | + if ($hash->hasLanguageType($languageID)) { |
|
219 | 219 | $hashes[] = $hash; |
220 | 220 | } |
221 | 221 | } |
@@ -4,9 +4,9 @@ |
||
4 | 4 | |
5 | 5 | class Localization_Scanner_StringInfo |
6 | 6 | { |
7 | - /** |
|
8 | - * @var Localization_Scanner_StringsCollection |
|
9 | - */ |
|
7 | + /** |
|
8 | + * @var Localization_Scanner_StringsCollection |
|
9 | + */ |
|
10 | 10 | protected $collection; |
11 | 11 | |
12 | 12 | protected $properties = array(); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function getProperty($name) |
76 | 76 | { |
77 | - if(isset($this->properties[$name])) { |
|
77 | + if (isset($this->properties[$name])) { |
|
78 | 78 | return $this->properties[$name]; |
79 | 79 | } |
80 | 80 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $array['line'] |
124 | 124 | ); |
125 | 125 | |
126 | - foreach($array['properties'] as $name => $value) { |
|
126 | + foreach ($array['properties'] as $name => $value) { |
|
127 | 127 | $string->setProperty($name, $value); |
128 | 128 | } |
129 | 129 |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class Localization_Scanner_StringHash |
15 | 15 | { |
16 | - /** |
|
17 | - * @var Localization_Scanner_StringsCollection |
|
18 | - */ |
|
16 | + /** |
|
17 | + * @var Localization_Scanner_StringsCollection |
|
18 | + */ |
|
19 | 19 | protected $collection; |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | 24 | protected $hash; |
25 | 25 | |
26 | - /** |
|
27 | - * @var Localization_Scanner_StringInfo[] |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var Localization_Scanner_StringInfo[] |
|
28 | + */ |
|
29 | 29 | protected $strings = array(); |
30 | 30 | |
31 | 31 | protected $sourceIDs = array(); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | return $entries; |
56 | 56 | } |
57 | 57 | |
58 | - /** |
|
59 | - * Retrieves all individual string locations where this text was found. |
|
60 | - * @return Localization_Scanner_StringInfo[] |
|
61 | - */ |
|
58 | + /** |
|
59 | + * Retrieves all individual string locations where this text was found. |
|
60 | + * @return Localization_Scanner_StringInfo[] |
|
61 | + */ |
|
62 | 62 | public function getStrings() |
63 | 63 | { |
64 | 64 | return $this->strings; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | return count($this->strings); |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Retrieves the translated text, if any. |
|
123 | - * @return string|NULL |
|
124 | - */ |
|
121 | + /** |
|
122 | + * Retrieves the translated text, if any. |
|
123 | + * @return string|NULL |
|
124 | + */ |
|
125 | 125 | public function getTranslatedText() : string |
126 | 126 | { |
127 | 127 | $translator = Localization::getTranslator(); |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | return ''; |
135 | 135 | } |
136 | 136 | |
137 | - /** |
|
138 | - * Retrieves a list of all file names, with relative paths. |
|
139 | - * @return string[] |
|
140 | - */ |
|
137 | + /** |
|
138 | + * Retrieves a list of all file names, with relative paths. |
|
139 | + * @return string[] |
|
140 | + */ |
|
141 | 141 | public function getFiles() : array |
142 | 142 | { |
143 | 143 | $files = array(); |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | return $files; |
160 | 160 | } |
161 | 161 | |
162 | - /** |
|
163 | - * Retrieves a list of all file names this string is used in. |
|
164 | - * @return string[] |
|
165 | - */ |
|
162 | + /** |
|
163 | + * Retrieves a list of all file names this string is used in. |
|
164 | + * @return string[] |
|
165 | + */ |
|
166 | 166 | public function getFileNames() : array |
167 | 167 | { |
168 | 168 | $files = $this->getFiles(); |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | return $result; |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Retrieves a text comprised of all strings that are relevant |
|
184 | - * for a full text search, imploded together. Used in the search |
|
185 | - * function to find matching strings. |
|
186 | - * |
|
187 | - * @return string |
|
188 | - */ |
|
182 | + /** |
|
183 | + * Retrieves a text comprised of all strings that are relevant |
|
184 | + * for a full text search, imploded together. Used in the search |
|
185 | + * function to find matching strings. |
|
186 | + * |
|
187 | + * @return string |
|
188 | + */ |
|
189 | 189 | public function getSearchString() : string |
190 | 190 | { |
191 | 191 | $parts = array($this->getTranslatedText(), $this->getText()); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $entries = array(); |
50 | 50 | |
51 | - foreach($this->strings as $string) { |
|
51 | + foreach ($this->strings as $string) { |
|
52 | 52 | $entries[] = $string->toArray(); |
53 | 53 | } |
54 | 54 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | { |
69 | 69 | $amount = 0; |
70 | 70 | |
71 | - foreach($this->strings as $string) { |
|
72 | - if($string->isFile()) { |
|
71 | + foreach ($this->strings as $string) { |
|
72 | + if ($string->isFile()) { |
|
73 | 73 | $amount++; |
74 | 74 | } |
75 | 75 | } |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | |
85 | 85 | public function hasLanguageType(string $type) : bool |
86 | 86 | { |
87 | - foreach($this->strings as $string) { |
|
88 | - if($string->getLanguageType() == $type) { |
|
87 | + foreach ($this->strings as $string) { |
|
88 | + if ($string->getLanguageType() == $type) { |
|
89 | 89 | return true; |
90 | 90 | } |
91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | public function getText() : string |
97 | 97 | { |
98 | - if(isset($this->strings[0])) { |
|
98 | + if (isset($this->strings[0])) { |
|
99 | 99 | return $this->strings[0]->getText(); |
100 | 100 | } |
101 | 101 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $translator = Localization::getTranslator(); |
128 | 128 | $text = $translator->getHashTranslation($this->getHash()); |
129 | 129 | |
130 | - if($text !== null) { |
|
130 | + if ($text !== null) { |
|
131 | 131 | return $text; |
132 | 132 | } |
133 | 133 | |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | { |
143 | 143 | $files = array(); |
144 | 144 | |
145 | - foreach($this->strings as $string) |
|
145 | + foreach ($this->strings as $string) |
|
146 | 146 | { |
147 | - if(!$string->isFile()) { |
|
147 | + if (!$string->isFile()) { |
|
148 | 148 | continue; |
149 | 149 | } |
150 | 150 | |
151 | 151 | $file = $string->getSourceFile(); |
152 | - if(!in_array($file, $files)) { |
|
152 | + if (!in_array($file, $files)) { |
|
153 | 153 | $files[] = $file; |
154 | 154 | } |
155 | 155 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $files = $this->getFiles(); |
169 | 169 | $result = array(); |
170 | 170 | |
171 | - foreach($files as $path) { |
|
171 | + foreach ($files as $path) { |
|
172 | 172 | $result[] = basename($path); |
173 | 173 | } |
174 | 174 |