@@ -246,8 +246,7 @@ |
||
| 246 | 246 | { |
| 247 | 247 | return $locale; |
| 248 | 248 | } |
| 249 | - } |
|
| 250 | - catch (Throwable $e) |
|
| 249 | + } catch (Throwable $e) |
|
| 251 | 250 | { |
| 252 | 251 | |
| 253 | 252 | } |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | public const EVENT_CACHE_KEY_CHANGED = 'CacheKeyChanged'; |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * Collection of all locales by namespace (application, content, custom...). |
|
| 67 | - * |
|
| 68 | - * @var array<string,array<string,Localization_Locale>> |
|
| 69 | - * @see Localization::addLocale() |
|
| 70 | - */ |
|
| 66 | + * Collection of all locales by namespace (application, content, custom...). |
|
| 67 | + * |
|
| 68 | + * @var array<string,array<string,Localization_Locale>> |
|
| 69 | + * @see Localization::addLocale() |
|
| 70 | + */ |
|
| 71 | 71 | protected static $locales = array(); |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -76,57 +76,57 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | private static $initDone = false; |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Path to the file in which the scanner results are stored. |
|
| 81 | - * @var string |
|
| 82 | - * @see Localization::configure() |
|
| 83 | - */ |
|
| 79 | + /** |
|
| 80 | + * Path to the file in which the scanner results are stored. |
|
| 81 | + * @var string |
|
| 82 | + * @see Localization::configure() |
|
| 83 | + */ |
|
| 84 | 84 | protected static $storageFile = ''; |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Path to the folder into which the client libraries are written. |
|
| 88 | - * @var string |
|
| 89 | - * @see Localization::setClientLibrariesFolder() |
|
| 90 | - */ |
|
| 86 | + /** |
|
| 87 | + * Path to the folder into which the client libraries are written. |
|
| 88 | + * @var string |
|
| 89 | + * @see Localization::setClientLibrariesFolder() |
|
| 90 | + */ |
|
| 91 | 91 | protected static $clientFolder = ''; |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * If this key changes, client libraries are refreshed. |
|
| 95 | - * @var string |
|
| 96 | - * @see Localization::setClientLibrariesCacheKey() |
|
| 97 | - */ |
|
| 93 | + /** |
|
| 94 | + * If this key changes, client libraries are refreshed. |
|
| 95 | + * @var string |
|
| 96 | + * @see Localization::setClientLibrariesCacheKey() |
|
| 97 | + */ |
|
| 98 | 98 | protected static $clientCacheKey = ''; |
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Whether the configuration has been made. |
|
| 102 | - * @var bool |
|
| 103 | - * @see Localization::configure() |
|
| 104 | - */ |
|
| 100 | + /** |
|
| 101 | + * Whether the configuration has been made. |
|
| 102 | + * @var bool |
|
| 103 | + * @see Localization::configure() |
|
| 104 | + */ |
|
| 105 | 105 | protected static $configured = false; |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Stores event listener instances. |
|
| 109 | - * @var array |
|
| 110 | - */ |
|
| 107 | + /** |
|
| 108 | + * Stores event listener instances. |
|
| 109 | + * @var array |
|
| 110 | + */ |
|
| 111 | 111 | protected static array $listeners = array(); |
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * @var integer |
|
| 115 | - * @see Localization::addEventListener() |
|
| 116 | - */ |
|
| 113 | + /** |
|
| 114 | + * @var integer |
|
| 115 | + * @see Localization::addEventListener() |
|
| 116 | + */ |
|
| 117 | 117 | protected static $listenersCounter = 0; |
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * @var Localization_Translator|NULL |
|
| 121 | - */ |
|
| 119 | + /** |
|
| 120 | + * @var Localization_Translator|NULL |
|
| 121 | + */ |
|
| 122 | 122 | protected static $translator; |
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Initializes the localization layer. This is done |
|
| 126 | - * automatically, and only once per request. |
|
| 127 | - * |
|
| 128 | - * (Called at the end of this file) |
|
| 129 | - */ |
|
| 124 | + /** |
|
| 125 | + * Initializes the localization layer. This is done |
|
| 126 | + * automatically, and only once per request. |
|
| 127 | + * |
|
| 128 | + * (Called at the end of this file) |
|
| 129 | + */ |
|
| 130 | 130 | public static function init() : void |
| 131 | 131 | { |
| 132 | 132 | if(self::$initDone) { |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | return self::getLocalesByNS(self::NAMESPACE_APPLICATION); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Retrieves all locales in the specified namespace. |
|
| 170 | - * |
|
| 171 | - * @param string $namespace |
|
| 172 | - * @return Localization_Locale[] |
|
| 173 | - */ |
|
| 168 | + /** |
|
| 169 | + * Retrieves all locales in the specified namespace. |
|
| 170 | + * |
|
| 171 | + * @param string $namespace |
|
| 172 | + * @return Localization_Locale[] |
|
| 173 | + */ |
|
| 174 | 174 | public static function getLocalesByNS(string $namespace) |
| 175 | 175 | { |
| 176 | 176 | if(isset(self::$locales[$namespace])) { |
@@ -187,35 +187,35 @@ discard block |
||
| 187 | 187 | ); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * Adds an application locale to use in the application. |
|
| 192 | - * |
|
| 193 | - * @param string $localeName |
|
| 194 | - * @return Localization_Locale |
|
| 195 | - */ |
|
| 190 | + /** |
|
| 191 | + * Adds an application locale to use in the application. |
|
| 192 | + * |
|
| 193 | + * @param string $localeName |
|
| 194 | + * @return Localization_Locale |
|
| 195 | + */ |
|
| 196 | 196 | public static function addAppLocale(string $localeName) : Localization_Locale |
| 197 | 197 | { |
| 198 | 198 | return self::addLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * Adds a content locale to use for content in the application. |
|
| 203 | - * |
|
| 204 | - * @param string $localeName |
|
| 205 | - * @return Localization_Locale |
|
| 206 | - */ |
|
| 201 | + /** |
|
| 202 | + * Adds a content locale to use for content in the application. |
|
| 203 | + * |
|
| 204 | + * @param string $localeName |
|
| 205 | + * @return Localization_Locale |
|
| 206 | + */ |
|
| 207 | 207 | public static function addContentLocale(string $localeName) : Localization_Locale |
| 208 | 208 | { |
| 209 | 209 | return self::addLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * Adds a locale to the specified namespace. |
|
| 214 | - * |
|
| 215 | - * @param string $localeName |
|
| 216 | - * @param string $namespace |
|
| 217 | - * @return Localization_Locale |
|
| 218 | - */ |
|
| 212 | + /** |
|
| 213 | + * Adds a locale to the specified namespace. |
|
| 214 | + * |
|
| 215 | + * @param string $localeName |
|
| 216 | + * @param string $namespace |
|
| 217 | + * @return Localization_Locale |
|
| 218 | + */ |
|
| 219 | 219 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 220 | 220 | { |
| 221 | 221 | if(!isset(self::$locales[$namespace])) { |
@@ -368,45 +368,45 @@ discard block |
||
| 368 | 368 | return self::getSelectedLocaleByNS(self::NAMESPACE_APPLICATION); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - /** |
|
| 372 | - * Retrieves the name of the selected application locale. |
|
| 373 | - * |
|
| 374 | - * @return string |
|
| 375 | - */ |
|
| 371 | + /** |
|
| 372 | + * Retrieves the name of the selected application locale. |
|
| 373 | + * |
|
| 374 | + * @return string |
|
| 375 | + */ |
|
| 376 | 376 | public static function getAppLocaleName() : string |
| 377 | 377 | { |
| 378 | 378 | return self::getLocaleNameByNS(self::NAMESPACE_APPLICATION); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - /** |
|
| 382 | - * Retrieves the names of the available application locales. |
|
| 383 | - * @return string[] |
|
| 384 | - */ |
|
| 381 | + /** |
|
| 382 | + * Retrieves the names of the available application locales. |
|
| 383 | + * @return string[] |
|
| 384 | + */ |
|
| 385 | 385 | public static function getAppLocaleNames() : array |
| 386 | 386 | { |
| 387 | 387 | return self::getLocaleNamesByNS(self::NAMESPACE_APPLICATION); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - /** |
|
| 391 | - * Retrieves the selected locale name in the specified namespace. |
|
| 392 | - * |
|
| 393 | - * @param string $namespace |
|
| 394 | - * @throws Localization_Exception |
|
| 395 | - * @return string |
|
| 396 | - */ |
|
| 390 | + /** |
|
| 391 | + * Retrieves the selected locale name in the specified namespace. |
|
| 392 | + * |
|
| 393 | + * @param string $namespace |
|
| 394 | + * @throws Localization_Exception |
|
| 395 | + * @return string |
|
| 396 | + */ |
|
| 397 | 397 | public static function getLocaleNameByNS(string $namespace) : string |
| 398 | 398 | { |
| 399 | 399 | return self::getSelectedLocaleByNS($namespace)->getName(); |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - /** |
|
| 403 | - * Retrieves the selected locale instance for the specified namespace. |
|
| 404 | - * |
|
| 405 | - * @param string $namespace |
|
| 406 | - * @return Localization_Locale |
|
| 407 | - * @throws Localization_Exception |
|
| 408 | - * @see Localization::ERROR_NO_LOCALE_SELECTED_IN_NS |
|
| 409 | - */ |
|
| 402 | + /** |
|
| 403 | + * Retrieves the selected locale instance for the specified namespace. |
|
| 404 | + * |
|
| 405 | + * @param string $namespace |
|
| 406 | + * @return Localization_Locale |
|
| 407 | + * @throws Localization_Exception |
|
| 408 | + * @see Localization::ERROR_NO_LOCALE_SELECTED_IN_NS |
|
| 409 | + */ |
|
| 410 | 410 | public static function getSelectedLocaleByNS(string $namespace) : Localization_Locale |
| 411 | 411 | { |
| 412 | 412 | self::requireNamespace($namespace); |
@@ -425,24 +425,24 @@ discard block |
||
| 425 | 425 | ); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - /** |
|
| 429 | - * Stores the selected locale names by namespace. |
|
| 430 | - * @var array<string,Localization_Locale> |
|
| 431 | - */ |
|
| 428 | + /** |
|
| 429 | + * Stores the selected locale names by namespace. |
|
| 430 | + * @var array<string,Localization_Locale> |
|
| 431 | + */ |
|
| 432 | 432 | protected static $selected = array(); |
| 433 | 433 | |
| 434 | - /** |
|
| 435 | - * Selects the active locale for the specified namespace. |
|
| 436 | - * |
|
| 437 | - * NOTE: Triggers the "LocaleChanged" event. |
|
| 438 | - * |
|
| 439 | - * @param string $localeName |
|
| 440 | - * @param string $namespace |
|
| 441 | - * @return Localization_Locale |
|
| 442 | - * @throws Localization_Exception |
|
| 443 | - * |
|
| 444 | - * @see LocaleChanged |
|
| 445 | - */ |
|
| 434 | + /** |
|
| 435 | + * Selects the active locale for the specified namespace. |
|
| 436 | + * |
|
| 437 | + * NOTE: Triggers the "LocaleChanged" event. |
|
| 438 | + * |
|
| 439 | + * @param string $localeName |
|
| 440 | + * @param string $namespace |
|
| 441 | + * @return Localization_Locale |
|
| 442 | + * @throws Localization_Exception |
|
| 443 | + * |
|
| 444 | + * @see LocaleChanged |
|
| 445 | + */ |
|
| 446 | 446 | public static function selectLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 447 | 447 | { |
| 448 | 448 | self::requireNamespace($namespace); |
@@ -594,15 +594,15 @@ discard block |
||
| 594 | 594 | return self::selectLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - /** |
|
| 598 | - * Retrieves an application locale by its name. |
|
| 599 | - * Note that the locale must have been added first. |
|
| 600 | - * |
|
| 601 | - * @param string $localeName |
|
| 602 | - * @throws Localization_Exception |
|
| 603 | - * @return Localization_Locale |
|
| 604 | - * @see Localization::appLocaleExists() |
|
| 605 | - */ |
|
| 597 | + /** |
|
| 598 | + * Retrieves an application locale by its name. |
|
| 599 | + * Note that the locale must have been added first. |
|
| 600 | + * |
|
| 601 | + * @param string $localeName |
|
| 602 | + * @throws Localization_Exception |
|
| 603 | + * @return Localization_Locale |
|
| 604 | + * @see Localization::appLocaleExists() |
|
| 605 | + */ |
|
| 606 | 606 | public static function getAppLocaleByName(string $localeName) : Localization_Locale |
| 607 | 607 | { |
| 608 | 608 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_APPLICATION); |
@@ -637,10 +637,10 @@ discard block |
||
| 637 | 637 | return self::getLocalesByNS(self::NAMESPACE_CONTENT); |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - /** |
|
| 641 | - * Retrieves the names of all content locales that have been added. |
|
| 642 | - * @return string[] |
|
| 643 | - */ |
|
| 640 | + /** |
|
| 641 | + * Retrieves the names of all content locales that have been added. |
|
| 642 | + * @return string[] |
|
| 643 | + */ |
|
| 644 | 644 | public static function getContentLocaleNames() |
| 645 | 645 | { |
| 646 | 646 | return self::getLocaleNamesByNS(self::NAMESPACE_CONTENT); |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | sort($names); |
| 664 | 664 | |
| 665 | 665 | return $names; |
| 666 | - } |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | 668 | /** |
| 669 | 669 | * Checks by the locale name if the specified locale is |
@@ -692,14 +692,14 @@ discard block |
||
| 692 | 692 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_CONTENT); |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - /** |
|
| 696 | - * Retrieves a locale by its name in the specified namespace. |
|
| 697 | - * |
|
| 698 | - * @param string $localeName |
|
| 699 | - * @param string $namespace |
|
| 700 | - * @throws Localization_Exception |
|
| 701 | - * @return Localization_Locale |
|
| 702 | - */ |
|
| 695 | + /** |
|
| 696 | + * Retrieves a locale by its name in the specified namespace. |
|
| 697 | + * |
|
| 698 | + * @param string $localeName |
|
| 699 | + * @param string $namespace |
|
| 700 | + * @throws Localization_Exception |
|
| 701 | + * @return Localization_Locale |
|
| 702 | + */ |
|
| 703 | 703 | public static function getLocaleByNameNS(string $localeName, string $namespace) : Localization_Locale |
| 704 | 704 | { |
| 705 | 705 | self::requireNamespace($namespace); |
@@ -770,10 +770,10 @@ discard block |
||
| 770 | 770 | return self::selectLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | - /** |
|
| 774 | - * Checks whether the localization has been configured entirely. |
|
| 775 | - * @return bool |
|
| 776 | - */ |
|
| 773 | + /** |
|
| 774 | + * Checks whether the localization has been configured entirely. |
|
| 775 | + * @return bool |
|
| 776 | + */ |
|
| 777 | 777 | public static function isConfigured() : bool |
| 778 | 778 | { |
| 779 | 779 | return self::$configured; |
@@ -845,29 +845,29 @@ discard block |
||
| 845 | 845 | ); |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | - /** |
|
| 849 | - * Injects a content locales selector element into the specified |
|
| 850 | - * HTML QuickForm2 container. |
|
| 851 | - * |
|
| 852 | - * @param string $elementName |
|
| 853 | - * @param HTML_QuickForm2_Container $container |
|
| 854 | - * @param string $label |
|
| 855 | - * @return HTML_QuickForm2_Element_Select |
|
| 856 | - */ |
|
| 848 | + /** |
|
| 849 | + * Injects a content locales selector element into the specified |
|
| 850 | + * HTML QuickForm2 container. |
|
| 851 | + * |
|
| 852 | + * @param string $elementName |
|
| 853 | + * @param HTML_QuickForm2_Container $container |
|
| 854 | + * @param string $label |
|
| 855 | + * @return HTML_QuickForm2_Element_Select |
|
| 856 | + */ |
|
| 857 | 857 | public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
| 858 | 858 | { |
| 859 | 859 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | - /** |
|
| 863 | - * Injects an app locales selector element into the specified |
|
| 862 | + /** |
|
| 863 | + * Injects an app locales selector element into the specified |
|
| 864 | 864 | * HTML QuickForm2 container. |
| 865 | 865 | * |
| 866 | - * @param string $elementName |
|
| 867 | - * @param HTML_QuickForm2_Container $container |
|
| 868 | - * @param string $label |
|
| 869 | - * @return HTML_QuickForm2_Element_Select |
|
| 870 | - */ |
|
| 866 | + * @param string $elementName |
|
| 867 | + * @param HTML_QuickForm2_Container $container |
|
| 868 | + * @param string $label |
|
| 869 | + * @return HTML_QuickForm2_Element_Select |
|
| 870 | + */ |
|
| 871 | 871 | public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
| 872 | 872 | { |
| 873 | 873 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
@@ -903,26 +903,26 @@ discard block |
||
| 903 | 903 | return $select; |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | - /** |
|
| 907 | - * @var Localization_Source[] |
|
| 908 | - */ |
|
| 906 | + /** |
|
| 907 | + * @var Localization_Source[] |
|
| 908 | + */ |
|
| 909 | 909 | protected static $sources = array(); |
| 910 | 910 | |
| 911 | - /** |
|
| 912 | - * @var string[] |
|
| 913 | - */ |
|
| 911 | + /** |
|
| 912 | + * @var string[] |
|
| 913 | + */ |
|
| 914 | 914 | protected static $excludeFolders = array(); |
| 915 | 915 | |
| 916 | - /** |
|
| 917 | - * @var string[] |
|
| 918 | - */ |
|
| 916 | + /** |
|
| 917 | + * @var string[] |
|
| 918 | + */ |
|
| 919 | 919 | protected static $excludeFiles = array(); |
| 920 | 920 | |
| 921 | - /** |
|
| 922 | - * Retrieves all currently available sources. |
|
| 923 | - * |
|
| 924 | - * @return Localization_Source[] |
|
| 925 | - */ |
|
| 921 | + /** |
|
| 922 | + * Retrieves all currently available sources. |
|
| 923 | + * |
|
| 924 | + * @return Localization_Source[] |
|
| 925 | + */ |
|
| 926 | 926 | public static function getSources() : array |
| 927 | 927 | { |
| 928 | 928 | return self::$sources; |
@@ -954,10 +954,10 @@ discard block |
||
| 954 | 954 | return $source; |
| 955 | 955 | } |
| 956 | 956 | |
| 957 | - /** |
|
| 958 | - * Retrieves all sources grouped by their group name. |
|
| 959 | - * @return array |
|
| 960 | - */ |
|
| 957 | + /** |
|
| 958 | + * Retrieves all sources grouped by their group name. |
|
| 959 | + * @return array |
|
| 960 | + */ |
|
| 961 | 961 | public static function getSourcesGrouped() |
| 962 | 962 | { |
| 963 | 963 | $sources = self::getSources(); |
@@ -978,11 +978,11 @@ discard block |
||
| 978 | 978 | return $grouped; |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - /** |
|
| 982 | - * Checks whether a specific source exists by its ID. |
|
| 983 | - * @param string $sourceID |
|
| 984 | - * @return boolean |
|
| 985 | - */ |
|
| 981 | + /** |
|
| 982 | + * Checks whether a specific source exists by its ID. |
|
| 983 | + * @param string $sourceID |
|
| 984 | + * @return boolean |
|
| 985 | + */ |
|
| 986 | 986 | public static function sourceExists(string $sourceID) : bool |
| 987 | 987 | { |
| 988 | 988 | $sources = self::getSources(); |
@@ -995,11 +995,11 @@ discard block |
||
| 995 | 995 | return false; |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | - /** |
|
| 999 | - * Checks whether a specific source exists by its alias. |
|
| 1000 | - * @param string $sourceAlias |
|
| 1001 | - * @return boolean |
|
| 1002 | - */ |
|
| 998 | + /** |
|
| 999 | + * Checks whether a specific source exists by its alias. |
|
| 1000 | + * @param string $sourceAlias |
|
| 1001 | + * @return boolean |
|
| 1002 | + */ |
|
| 1003 | 1003 | public static function sourceAliasExists(string $sourceAlias) : bool |
| 1004 | 1004 | { |
| 1005 | 1005 | $sources = self::getSources(); |
@@ -1012,13 +1012,13 @@ discard block |
||
| 1012 | 1012 | return false; |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | - /** |
|
| 1016 | - * Retrieves a localization source by its ID. |
|
| 1017 | - * |
|
| 1018 | - * @param string $sourceID |
|
| 1019 | - * @throws Localization_Exception |
|
| 1020 | - * @return Localization_Source |
|
| 1021 | - */ |
|
| 1015 | + /** |
|
| 1016 | + * Retrieves a localization source by its ID. |
|
| 1017 | + * |
|
| 1018 | + * @param string $sourceID |
|
| 1019 | + * @throws Localization_Exception |
|
| 1020 | + * @return Localization_Source |
|
| 1021 | + */ |
|
| 1022 | 1022 | public static function getSourceByID(string $sourceID) : Localization_Source |
| 1023 | 1023 | { |
| 1024 | 1024 | $sources = self::getSources(); |
@@ -1108,17 +1108,17 @@ discard block |
||
| 1108 | 1108 | } |
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | - /** |
|
| 1112 | - * Sets a key that is used to verify whether the client |
|
| 1113 | - * libraries have to be refreshed. A common use is to set |
|
| 1114 | - * this to the application's version number to guarantee |
|
| 1115 | - * new texts are automatically used with each release. |
|
| 1116 | - * |
|
| 1117 | - * NOTE: Otherwise files are refreshed only when saving |
|
| 1118 | - * them in the editor UI. |
|
| 1119 | - * |
|
| 1120 | - * @param string $key |
|
| 1121 | - */ |
|
| 1111 | + /** |
|
| 1112 | + * Sets a key that is used to verify whether the client |
|
| 1113 | + * libraries have to be refreshed. A common use is to set |
|
| 1114 | + * this to the application's version number to guarantee |
|
| 1115 | + * new texts are automatically used with each release. |
|
| 1116 | + * |
|
| 1117 | + * NOTE: Otherwise files are refreshed only when saving |
|
| 1118 | + * them in the editor UI. |
|
| 1119 | + * |
|
| 1120 | + * @param string $key |
|
| 1121 | + */ |
|
| 1122 | 1122 | public static function setClientLibrariesCacheKey(string $key) : void |
| 1123 | 1123 | { |
| 1124 | 1124 | if($key !== self::$clientCacheKey) { |
@@ -1132,10 +1132,10 @@ discard block |
||
| 1132 | 1132 | return self::$clientCacheKey; |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | - /** |
|
| 1136 | - * Sets the folder where client libraries are to be stored. |
|
| 1137 | - * @param string $folder |
|
| 1138 | - */ |
|
| 1135 | + /** |
|
| 1136 | + * Sets the folder where client libraries are to be stored. |
|
| 1137 | + * @param string $folder |
|
| 1138 | + */ |
|
| 1139 | 1139 | public static function setClientLibrariesFolder(string $folder) : void |
| 1140 | 1140 | { |
| 1141 | 1141 | if($folder !== self::$clientFolder) { |
@@ -1144,14 +1144,14 @@ discard block |
||
| 1144 | 1144 | } |
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | - /** |
|
| 1148 | - * Retrieves the path to the folder in which the client |
|
| 1149 | - * libraries should be stored. |
|
| 1150 | - * |
|
| 1151 | - * NOTE: Can return an empty string, when this is disabled. |
|
| 1152 | - * |
|
| 1153 | - * @return string |
|
| 1154 | - */ |
|
| 1147 | + /** |
|
| 1148 | + * Retrieves the path to the folder in which the client |
|
| 1149 | + * libraries should be stored. |
|
| 1150 | + * |
|
| 1151 | + * NOTE: Can return an empty string, when this is disabled. |
|
| 1152 | + * |
|
| 1153 | + * @return string |
|
| 1154 | + */ |
|
| 1155 | 1155 | public static function getClientLibrariesFolder() : string |
| 1156 | 1156 | { |
| 1157 | 1157 | return self::$clientFolder; |
@@ -1173,13 +1173,13 @@ discard block |
||
| 1173 | 1173 | |
| 1174 | 1174 | private static ?Localization_ClientGenerator $generator = null; |
| 1175 | 1175 | |
| 1176 | - /** |
|
| 1177 | - * Creates a new instance of the client generator class |
|
| 1178 | - * that is used to write the localization files into the |
|
| 1179 | - * target folder on disk. |
|
| 1180 | - * |
|
| 1181 | - * @return Localization_ClientGenerator |
|
| 1182 | - */ |
|
| 1176 | + /** |
|
| 1177 | + * Creates a new instance of the client generator class |
|
| 1178 | + * that is used to write the localization files into the |
|
| 1179 | + * target folder on disk. |
|
| 1180 | + * |
|
| 1181 | + * @return Localization_ClientGenerator |
|
| 1182 | + */ |
|
| 1183 | 1183 | public static function createGenerator() : Localization_ClientGenerator |
| 1184 | 1184 | { |
| 1185 | 1185 | if(!isset(self::$generator)) { |
@@ -1248,10 +1248,10 @@ discard block |
||
| 1248 | 1248 | return new Localization_Editor(); |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | - /** |
|
| 1252 | - * Retrieves a list of all available source IDs. |
|
| 1253 | - * @return string[] |
|
| 1254 | - */ |
|
| 1251 | + /** |
|
| 1252 | + * Retrieves a list of all available source IDs. |
|
| 1253 | + * @return string[] |
|
| 1254 | + */ |
|
| 1255 | 1255 | public static function getSourceIDs() : array |
| 1256 | 1256 | { |
| 1257 | 1257 | $ids = array(); |
@@ -1278,9 +1278,9 @@ discard block |
||
| 1278 | 1278 | return $aliases; |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | - /** |
|
| 1282 | - * Resets all locales to the built-in locale. |
|
| 1283 | - */ |
|
| 1281 | + /** |
|
| 1282 | + * Resets all locales to the built-in locale. |
|
| 1283 | + */ |
|
| 1284 | 1284 | public static function reset() : void |
| 1285 | 1285 | { |
| 1286 | 1286 | self::$locales = array(); |
@@ -1316,12 +1316,12 @@ discard block |
||
| 1316 | 1316 | return self::$supportedLocales; |
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | - /** |
|
| 1320 | - * Checks whether the specified locale is supported. |
|
| 1321 | - * |
|
| 1322 | - * @param string $localeName |
|
| 1323 | - * @return bool |
|
| 1324 | - */ |
|
| 1319 | + /** |
|
| 1320 | + * Checks whether the specified locale is supported. |
|
| 1321 | + * |
|
| 1322 | + * @param string $localeName |
|
| 1323 | + * @return bool |
|
| 1324 | + */ |
|
| 1325 | 1325 | public static function isLocaleSupported(string $localeName) : bool |
| 1326 | 1326 | { |
| 1327 | 1327 | return file_exists(__DIR__.'/Localization/Locale/'.$localeName.'.php'); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public static function init() : void |
| 131 | 131 | { |
| 132 | - if(self::$initDone) { |
|
| 132 | + if (self::$initDone) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public static function getLocalesByNS(string $namespace) |
| 175 | 175 | { |
| 176 | - if(isset(self::$locales[$namespace])) { |
|
| 176 | + if (isset(self::$locales[$namespace])) { |
|
| 177 | 177 | return array_values(self::$locales[$namespace]); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
| 220 | 220 | { |
| 221 | - if(!isset(self::$locales[$namespace])) { |
|
| 221 | + if (!isset(self::$locales[$namespace])) { |
|
| 222 | 222 | self::$locales[$namespace] = array(); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if(!isset(self::$locales[$namespace][$localeName])) |
|
| 225 | + if (!isset(self::$locales[$namespace][$localeName])) |
|
| 226 | 226 | { |
| 227 | 227 | self::$locales[$namespace][$localeName] = self::createLocale($localeName); |
| 228 | 228 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public static function createCountries() : CountryCollection |
| 283 | 283 | { |
| 284 | - if(!isset(self::$countries)) { |
|
| 284 | + if (!isset(self::$countries)) { |
|
| 285 | 285 | self::$countries = CountryCollection::getInstance(); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | */ |
| 299 | 299 | public static function createCurrencies() : CurrencyCollection |
| 300 | 300 | { |
| 301 | - if(!isset(self::$currencies)) { |
|
| 301 | + if (!isset(self::$currencies)) { |
|
| 302 | 302 | self::$currencies = CurrencyCollection::getInstance(); |
| 303 | 303 | } |
| 304 | 304 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | { |
| 412 | 412 | self::requireNamespace($namespace); |
| 413 | 413 | |
| 414 | - if(isset(self::$selected[$namespace])) { |
|
| 414 | + if (isset(self::$selected[$namespace])) { |
|
| 415 | 415 | return self::$selected[$namespace]; |
| 416 | 416 | } |
| 417 | 417 | |
@@ -450,9 +450,9 @@ discard block |
||
| 450 | 450 | $locale = self::addLocaleByNS($localeName, $namespace); |
| 451 | 451 | $previous = null; |
| 452 | 452 | |
| 453 | - if(isset(self::$selected[$namespace])) |
|
| 453 | + if (isset(self::$selected[$namespace])) |
|
| 454 | 454 | { |
| 455 | - if(self::$selected[$namespace]->getName() === $localeName) { |
|
| 455 | + if (self::$selected[$namespace]->getName() === $localeName) { |
|
| 456 | 456 | return $locale; |
| 457 | 457 | } |
| 458 | 458 | |
@@ -492,11 +492,11 @@ discard block |
||
| 492 | 492 | new $class($argsList) |
| 493 | 493 | ); |
| 494 | 494 | |
| 495 | - if(!isset(self::$listeners[$name])) { |
|
| 495 | + if (!isset(self::$listeners[$name])) { |
|
| 496 | 496 | return $event; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - foreach(self::$listeners[$name] as $listener) |
|
| 499 | + foreach (self::$listeners[$name] as $listener) |
|
| 500 | 500 | { |
| 501 | 501 | $callArgs = $listener['args']; |
| 502 | 502 | array_unshift($callArgs, $event); |
@@ -518,9 +518,9 @@ discard block |
||
| 518 | 518 | * @throws Localization_Exception |
| 519 | 519 | * @see Localization::ERROR_UNKNOWN_EVENT_NAME |
| 520 | 520 | */ |
| 521 | - public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
|
| 521 | + public static function addEventListener(string $eventName, $callback, array $args = array()) : int |
|
| 522 | 522 | { |
| 523 | - if(!isset(self::$listeners[$eventName])) { |
|
| 523 | + if (!isset(self::$listeners[$eventName])) { |
|
| 524 | 524 | self::$listeners[$eventName] = array(); |
| 525 | 525 | } |
| 526 | 526 | |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | 'AppLocalize' |
| 544 | 544 | ); |
| 545 | 545 | |
| 546 | - if(class_exists($className)) { |
|
| 546 | + if (class_exists($className)) { |
|
| 547 | 547 | return $className; |
| 548 | 548 | } |
| 549 | 549 | |
@@ -567,17 +567,17 @@ discard block |
||
| 567 | 567 | * @throws Localization_Exception |
| 568 | 568 | * @see LocaleChanged |
| 569 | 569 | */ |
| 570 | - public static function onLocaleChanged($callback, array $args=array()) : int |
|
| 570 | + public static function onLocaleChanged($callback, array $args = array()) : int |
|
| 571 | 571 | { |
| 572 | 572 | return self::addEventListener(self::EVENT_LOCALE_CHANGED, $callback, $args); |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - public static function onClientFolderChanged(callable $callback, array $args=array()) : int |
|
| 575 | + public static function onClientFolderChanged(callable $callback, array $args = array()) : int |
|
| 576 | 576 | { |
| 577 | 577 | return self::addEventListener(self::EVENT_CLIENT_FOLDER_CHANGED, $callback, $args); |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - public static function onCacheKeyChanged(callable $callback, array $args=array()) : int |
|
| 580 | + public static function onCacheKeyChanged(callable $callback, array $args = array()) : int |
|
| 581 | 581 | { |
| 582 | 582 | return self::addEventListener(self::EVENT_CACHE_KEY_CHANGED, $callback, $args); |
| 583 | 583 | } |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | { |
| 705 | 705 | self::requireNamespace($namespace); |
| 706 | 706 | |
| 707 | - if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
| 707 | + if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
| 708 | 708 | return self::$locales[$namespace][$localeName]; |
| 709 | 709 | } |
| 710 | 710 | |
@@ -783,9 +783,9 @@ discard block |
||
| 783 | 783 | * @param Localization_Locale|null $locale |
| 784 | 784 | * @return Localization_Translator |
| 785 | 785 | */ |
| 786 | - public static function getTranslator(?Localization_Locale $locale=null) : Localization_Translator |
|
| 786 | + public static function getTranslator(?Localization_Locale $locale = null) : Localization_Translator |
|
| 787 | 787 | { |
| 788 | - if($locale !== null) |
|
| 788 | + if ($locale !== null) |
|
| 789 | 789 | { |
| 790 | 790 | $obj = new Localization_Translator(); |
| 791 | 791 | $obj->addSources(self::getSources()); |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | return $obj; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - if(!isset(self::$translator)) |
|
| 796 | + if (!isset(self::$translator)) |
|
| 797 | 797 | { |
| 798 | 798 | $obj = new Localization_Translator(); |
| 799 | 799 | $obj->addSources(self::getSources()); |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | { |
| 819 | 819 | self::requireNamespace($namespace); |
| 820 | 820 | |
| 821 | - if(isset(self::$locales[$namespace])) { |
|
| 821 | + if (isset(self::$locales[$namespace])) { |
|
| 822 | 822 | return count(self::$locales[$namespace]); |
| 823 | 823 | } |
| 824 | 824 | |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | */ |
| 832 | 832 | protected static function requireNamespace(string $namespace) : void |
| 833 | 833 | { |
| 834 | - if(isset(self::$locales[$namespace])) { |
|
| 834 | + if (isset(self::$locales[$namespace])) { |
|
| 835 | 835 | return; |
| 836 | 836 | } |
| 837 | 837 | |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | * @param string $label |
| 855 | 855 | * @return HTML_QuickForm2_Element_Select |
| 856 | 856 | */ |
| 857 | - public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
| 857 | + public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
| 858 | 858 | { |
| 859 | 859 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
| 860 | 860 | } |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | * @param string $label |
| 869 | 869 | * @return HTML_QuickForm2_Element_Select |
| 870 | 870 | */ |
| 871 | - public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
| 871 | + public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
| 872 | 872 | { |
| 873 | 873 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
| 874 | 874 | } |
@@ -885,9 +885,9 @@ discard block |
||
| 885 | 885 | * @return HTML_QuickForm2_Element_Select |
| 886 | 886 | * @throws Localization_Exception |
| 887 | 887 | */ |
| 888 | - public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
| 888 | + public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
| 889 | 889 | { |
| 890 | - if(empty($label)) { |
|
| 890 | + if (empty($label)) { |
|
| 891 | 891 | $label = t('Language'); |
| 892 | 892 | } |
| 893 | 893 | |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | |
| 897 | 897 | $locales = self::getLocalesByNS($namespace); |
| 898 | 898 | |
| 899 | - foreach($locales as $locale) { |
|
| 899 | + foreach ($locales as $locale) { |
|
| 900 | 900 | $select->addOption($locale->getLabel(), $locale->getName()); |
| 901 | 901 | } |
| 902 | 902 | |
@@ -930,14 +930,14 @@ discard block |
||
| 930 | 930 | |
| 931 | 931 | public static function addExcludeFolder(string $folderName) : void |
| 932 | 932 | { |
| 933 | - if(!in_array($folderName, self::$excludeFolders)) { |
|
| 933 | + if (!in_array($folderName, self::$excludeFolders)) { |
|
| 934 | 934 | self::$excludeFolders[] = $folderName; |
| 935 | 935 | } |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | public static function addExcludeFile(string $fileName) : void |
| 939 | 939 | { |
| 940 | - if(!in_array($fileName, self::$excludeFiles)) { |
|
| 940 | + if (!in_array($fileName, self::$excludeFiles)) { |
|
| 941 | 941 | self::$excludeFiles[] = $fileName; |
| 942 | 942 | } |
| 943 | 943 | } |
@@ -964,11 +964,11 @@ discard block |
||
| 964 | 964 | |
| 965 | 965 | $grouped = array(); |
| 966 | 966 | |
| 967 | - foreach($sources as $source) |
|
| 967 | + foreach ($sources as $source) |
|
| 968 | 968 | { |
| 969 | 969 | $group = $source->getGroup(); |
| 970 | 970 | |
| 971 | - if(!isset($grouped[$group])) { |
|
| 971 | + if (!isset($grouped[$group])) { |
|
| 972 | 972 | $grouped[$group] = array(); |
| 973 | 973 | } |
| 974 | 974 | |
@@ -986,8 +986,8 @@ discard block |
||
| 986 | 986 | public static function sourceExists(string $sourceID) : bool |
| 987 | 987 | { |
| 988 | 988 | $sources = self::getSources(); |
| 989 | - foreach($sources as $source) { |
|
| 990 | - if($source->getID() == $sourceID) { |
|
| 989 | + foreach ($sources as $source) { |
|
| 990 | + if ($source->getID() == $sourceID) { |
|
| 991 | 991 | return true; |
| 992 | 992 | } |
| 993 | 993 | } |
@@ -1003,8 +1003,8 @@ discard block |
||
| 1003 | 1003 | public static function sourceAliasExists(string $sourceAlias) : bool |
| 1004 | 1004 | { |
| 1005 | 1005 | $sources = self::getSources(); |
| 1006 | - foreach($sources as $source) { |
|
| 1007 | - if($source->getAlias() == $sourceAlias) { |
|
| 1006 | + foreach ($sources as $source) { |
|
| 1007 | + if ($source->getAlias() == $sourceAlias) { |
|
| 1008 | 1008 | return true; |
| 1009 | 1009 | } |
| 1010 | 1010 | } |
@@ -1022,8 +1022,8 @@ discard block |
||
| 1022 | 1022 | public static function getSourceByID(string $sourceID) : Localization_Source |
| 1023 | 1023 | { |
| 1024 | 1024 | $sources = self::getSources(); |
| 1025 | - foreach($sources as $source) { |
|
| 1026 | - if($source->getID() == $sourceID) { |
|
| 1025 | + foreach ($sources as $source) { |
|
| 1026 | + if ($source->getID() == $sourceID) { |
|
| 1027 | 1027 | return $source; |
| 1028 | 1028 | } |
| 1029 | 1029 | } |
@@ -1048,8 +1048,8 @@ discard block |
||
| 1048 | 1048 | public static function getSourceByAlias(string $sourceAlias) : Localization_Source |
| 1049 | 1049 | { |
| 1050 | 1050 | $sources = self::getSources(); |
| 1051 | - foreach($sources as $source) { |
|
| 1052 | - if($source->getAlias() == $sourceAlias) { |
|
| 1051 | + foreach ($sources as $source) { |
|
| 1052 | + if ($source->getAlias() == $sourceAlias) { |
|
| 1053 | 1053 | return $source; |
| 1054 | 1054 | } |
| 1055 | 1055 | } |
@@ -1093,7 +1093,7 @@ discard block |
||
| 1093 | 1093 | * @throws FileHelper_Exception |
| 1094 | 1094 | * @throws Localization_Exception |
| 1095 | 1095 | */ |
| 1096 | - public static function configure(string $storageFile, string $clientLibrariesFolder='') : void |
|
| 1096 | + public static function configure(string $storageFile, string $clientLibrariesFolder = '') : void |
|
| 1097 | 1097 | { |
| 1098 | 1098 | self::$configured = true; |
| 1099 | 1099 | |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | |
| 1103 | 1103 | // only write the client libraries to disk if the folder |
| 1104 | 1104 | // has been specified. |
| 1105 | - if(!empty($clientLibrariesFolder)) |
|
| 1105 | + if (!empty($clientLibrariesFolder)) |
|
| 1106 | 1106 | { |
| 1107 | 1107 | self::writeClientFiles(); |
| 1108 | 1108 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | */ |
| 1122 | 1122 | public static function setClientLibrariesCacheKey(string $key) : void |
| 1123 | 1123 | { |
| 1124 | - if($key !== self::$clientCacheKey) { |
|
| 1124 | + if ($key !== self::$clientCacheKey) { |
|
| 1125 | 1125 | self::$clientCacheKey = $key; |
| 1126 | 1126 | self::triggerEvent(self::EVENT_CACHE_KEY_CHANGED, array($key)); |
| 1127 | 1127 | } |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | */ |
| 1139 | 1139 | public static function setClientLibrariesFolder(string $folder) : void |
| 1140 | 1140 | { |
| 1141 | - if($folder !== self::$clientFolder) { |
|
| 1141 | + if ($folder !== self::$clientFolder) { |
|
| 1142 | 1142 | self::$clientFolder = $folder; |
| 1143 | 1143 | self::triggerEvent(self::EVENT_CLIENT_FOLDER_CHANGED, array($folder)); |
| 1144 | 1144 | } |
@@ -1166,7 +1166,7 @@ discard block |
||
| 1166 | 1166 | * @throws Localization_Exception|FileHelper_Exception |
| 1167 | 1167 | * @see Localization_ClientGenerator |
| 1168 | 1168 | */ |
| 1169 | - public static function writeClientFiles(bool $force=false) : void |
|
| 1169 | + public static function writeClientFiles(bool $force = false) : void |
|
| 1170 | 1170 | { |
| 1171 | 1171 | self::createGenerator()->writeFiles(); |
| 1172 | 1172 | } |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | */ |
| 1183 | 1183 | public static function createGenerator() : Localization_ClientGenerator |
| 1184 | 1184 | { |
| 1185 | - if(!isset(self::$generator)) { |
|
| 1185 | + if (!isset(self::$generator)) { |
|
| 1186 | 1186 | self::$generator = new Localization_ClientGenerator(); |
| 1187 | 1187 | } |
| 1188 | 1188 | |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | */ |
| 1206 | 1206 | protected static function requireConfiguration() : void |
| 1207 | 1207 | { |
| 1208 | - if(!self::$configured) |
|
| 1208 | + if (!self::$configured) |
|
| 1209 | 1209 | { |
| 1210 | 1210 | throw new Localization_Exception( |
| 1211 | 1211 | 'The localization configuration is incomplete.', |
@@ -1214,7 +1214,7 @@ discard block |
||
| 1214 | 1214 | ); |
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | - if(empty(self::$storageFile)) |
|
| 1217 | + if (empty(self::$storageFile)) |
|
| 1218 | 1218 | { |
| 1219 | 1219 | throw new Localization_Exception( |
| 1220 | 1220 | 'No localization storage file set', |
@@ -1223,7 +1223,7 @@ discard block |
||
| 1223 | 1223 | ); |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | - if(empty(self::$sources)) |
|
| 1226 | + if (empty(self::$sources)) |
|
| 1227 | 1227 | { |
| 1228 | 1228 | throw new Localization_Exception( |
| 1229 | 1229 | 'No source folders have been defined.', |
@@ -1256,7 +1256,7 @@ discard block |
||
| 1256 | 1256 | { |
| 1257 | 1257 | $ids = array(); |
| 1258 | 1258 | |
| 1259 | - foreach(self::$sources as $source) { |
|
| 1259 | + foreach (self::$sources as $source) { |
|
| 1260 | 1260 | $ids[] = $source->getID(); |
| 1261 | 1261 | } |
| 1262 | 1262 | |
@@ -1271,7 +1271,7 @@ discard block |
||
| 1271 | 1271 | { |
| 1272 | 1272 | $aliases = array(); |
| 1273 | 1273 | |
| 1274 | - foreach(self::$sources as $source) { |
|
| 1274 | + foreach (self::$sources as $source) { |
|
| 1275 | 1275 | $aliases[] = $source->getAlias(); |
| 1276 | 1276 | } |
| 1277 | 1277 | |
@@ -1307,7 +1307,7 @@ discard block |
||
| 1307 | 1307 | */ |
| 1308 | 1308 | public static function getSupportedLocaleNames() : array |
| 1309 | 1309 | { |
| 1310 | - if(empty(self::$supportedLocales)) |
|
| 1310 | + if (empty(self::$supportedLocales)) |
|
| 1311 | 1311 | { |
| 1312 | 1312 | self::$supportedLocales = FileHelper::createFileFinder(__DIR__.'/Localization/Locale') |
| 1313 | 1313 | ->getPHPClassNames(); |
@@ -1331,13 +1331,13 @@ discard block |
||
| 1331 | 1331 | |
| 1332 | 1332 | public static function getVersion() : string |
| 1333 | 1333 | { |
| 1334 | - if(isset(self::$version)) { |
|
| 1334 | + if (isset(self::$version)) { |
|
| 1335 | 1335 | return self::$version; |
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | $versionFile = FileInfo::factory(__DIR__.'/../version.txt'); |
| 1339 | 1339 | |
| 1340 | - if($versionFile->exists()) { |
|
| 1340 | + if ($versionFile->exists()) { |
|
| 1341 | 1341 | self::$version = $versionFile->getContents(); |
| 1342 | 1342 | return self::$version; |
| 1343 | 1343 | } |
@@ -15,19 +15,19 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class Localization_Scanner_StringHash |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * @var Localization_Scanner_StringsCollection |
|
| 20 | - */ |
|
| 18 | + /** |
|
| 19 | + * @var Localization_Scanner_StringsCollection |
|
| 20 | + */ |
|
| 21 | 21 | protected $collection; |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | 26 | protected $hash; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var Localization_Scanner_StringInfo[] |
|
| 30 | - */ |
|
| 28 | + /** |
|
| 29 | + * @var Localization_Scanner_StringInfo[] |
|
| 30 | + */ |
|
| 31 | 31 | protected $strings = array(); |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | return $entries; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Retrieves all individual string locations where this text was found. |
|
| 65 | - * @return Localization_Scanner_StringInfo[] |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * Retrieves all individual string locations where this text was found. |
|
| 65 | + * @return Localization_Scanner_StringInfo[] |
|
| 66 | + */ |
|
| 67 | 67 | public function getStrings() : array |
| 68 | 68 | { |
| 69 | 69 | return $this->strings; |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | return count($this->strings); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Retrieves the translated text, if any. |
|
| 128 | - * @return string |
|
| 129 | - */ |
|
| 126 | + /** |
|
| 127 | + * Retrieves the translated text, if any. |
|
| 128 | + * @return string |
|
| 129 | + */ |
|
| 130 | 130 | public function getTranslatedText() : string |
| 131 | 131 | { |
| 132 | 132 | $translator = Localization::getTranslator(); |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | return ''; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Retrieves a list of all file names, with relative paths. |
|
| 144 | - * @return string[] |
|
| 145 | - */ |
|
| 142 | + /** |
|
| 143 | + * Retrieves a list of all file names, with relative paths. |
|
| 144 | + * @return string[] |
|
| 145 | + */ |
|
| 146 | 146 | public function getFiles() : array |
| 147 | 147 | { |
| 148 | 148 | $files = array(); |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | return $files; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Retrieves a list of all file names this string is used in. |
|
| 169 | - * @return string[] |
|
| 170 | - */ |
|
| 167 | + /** |
|
| 168 | + * Retrieves a list of all file names this string is used in. |
|
| 169 | + * @return string[] |
|
| 170 | + */ |
|
| 171 | 171 | public function getFileNames() : array |
| 172 | 172 | { |
| 173 | 173 | $files = $this->getFiles(); |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | return array_unique($result); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Retrieves a text comprised of all strings that are relevant |
|
| 187 | - * for a full text search, imploded together. Used in the search |
|
| 188 | - * function to find matching strings. |
|
| 189 | - * |
|
| 190 | - * @return string |
|
| 191 | - */ |
|
| 185 | + /** |
|
| 186 | + * Retrieves a text comprised of all strings that are relevant |
|
| 187 | + * for a full text search, imploded together. Used in the search |
|
| 188 | + * function to find matching strings. |
|
| 189 | + * |
|
| 190 | + * @return string |
|
| 191 | + */ |
|
| 192 | 192 | public function getSearchString() : string |
| 193 | 193 | { |
| 194 | 194 | $parts = array($this->getTranslatedText(), $this->getTextAsString()); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $entries = array(); |
| 55 | 55 | |
| 56 | - foreach($this->strings as $string) { |
|
| 56 | + foreach ($this->strings as $string) { |
|
| 57 | 57 | $entries[] = $string->toArray(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $amount = 0; |
| 75 | 75 | |
| 76 | - foreach($this->strings as $string) { |
|
| 77 | - if($string->isFile()) { |
|
| 76 | + foreach ($this->strings as $string) { |
|
| 77 | + if ($string->isFile()) { |
|
| 78 | 78 | $amount++; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | public function hasLanguageType(string $type) : bool |
| 91 | 91 | { |
| 92 | - foreach($this->strings as $string) { |
|
| 93 | - if($string->getLanguageType() == $type) { |
|
| 92 | + foreach ($this->strings as $string) { |
|
| 93 | + if ($string->getLanguageType() == $type) { |
|
| 94 | 94 | return true; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | public function getText() : ?Text |
| 102 | 102 | { |
| 103 | - if(isset($this->strings[0])) { |
|
| 103 | + if (isset($this->strings[0])) { |
|
| 104 | 104 | return $this->strings[0]->getText(); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $translator = Localization::getTranslator(); |
| 133 | 133 | $text = $translator->getHashTranslation($this->getHash()); |
| 134 | 134 | |
| 135 | - if($text !== null) { |
|
| 135 | + if ($text !== null) { |
|
| 136 | 136 | return $text; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | $files = array(); |
| 149 | 149 | |
| 150 | - foreach($this->strings as $string) |
|
| 150 | + foreach ($this->strings as $string) |
|
| 151 | 151 | { |
| 152 | - if(!$string->isFile()) { |
|
| 152 | + if (!$string->isFile()) { |
|
| 153 | 153 | continue; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | $file = $string->getSourceFile(); |
| 157 | - if(!in_array($file, $files)) { |
|
| 157 | + if (!in_array($file, $files)) { |
|
| 158 | 158 | $files[] = $file; |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $files = $this->getFiles(); |
| 174 | 174 | $result = array(); |
| 175 | 175 | |
| 176 | - foreach($files as $path) { |
|
| 176 | + foreach ($files as $path) { |
|
| 177 | 177 | $result[] = basename($path); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | $text = $this->getText(); |
| 204 | 204 | |
| 205 | - if($text !== null) |
|
| 205 | + if ($text !== null) |
|
| 206 | 206 | { |
| 207 | 207 | return $text->getText(); |
| 208 | 208 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | <?php $this->renderAppLocales(); ?> |
| 73 | 73 | <?php |
| 74 | 74 | $backURL = $this->editor->getBackURL(); |
| 75 | - if(!empty($backURL)) |
|
| 75 | + if (!empty($backURL)) |
|
| 76 | 76 | { |
| 77 | 77 | ?> |
| 78 | 78 | <a href="<?php echo $backURL ?>" class="btn btn-light btn-sm"> |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | <?php |
| 110 | 110 | $warnings = $this->editor->getScannerWarnings(); |
| 111 | 111 | |
| 112 | - foreach($warnings as $warning) |
|
| 112 | + foreach ($warnings as $warning) |
|
| 113 | 113 | { |
| 114 | 114 | ?> |
| 115 | 115 | <dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt> |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $strings = $this->editor->getFilteredStrings(); |
| 128 | 128 | |
| 129 | - if(empty($strings)) |
|
| 129 | + if (empty($strings)) |
|
| 130 | 130 | { |
| 131 | 131 | ?> |
| 132 | 132 | <div class="alert alert-info"> |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | <div class="form-hiddens"> |
| 149 | 149 | <?php |
| 150 | 150 | $params = $this-> editor->getRequestParams(); |
| 151 | - foreach($params as $name => $value) { |
|
| 151 | + foreach ($params as $name => $value) { |
|
| 152 | 152 | ?> |
| 153 | 153 | <input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>"> |
| 154 | 154 | <?php |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | </thead> |
| 167 | 167 | <tbody> |
| 168 | 168 | <?php |
| 169 | - foreach($keep as $string) |
|
| 169 | + foreach ($keep as $string) |
|
| 170 | 170 | { |
| 171 | 171 | $this->renderTextEditorEntry($string); |
| 172 | 172 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | </tbody> |
| 175 | 175 | </table> |
| 176 | 176 | <?php |
| 177 | - if($pager->hasPages()) |
|
| 177 | + if ($pager->hasPages()) |
|
| 178 | 178 | { |
| 179 | 179 | $prevUrl = $this->editor->getPaginationURL($pager->getPreviousPage()); |
| 180 | 180 | $nextUrl = $this->editor->getPaginationURL($pager->getNextPage()); |
@@ -189,12 +189,12 @@ discard block |
||
| 189 | 189 | </li> |
| 190 | 190 | <?php |
| 191 | 191 | $numbers = $pager->getPageNumbers(); |
| 192 | - foreach($numbers as $number) |
|
| 192 | + foreach ($numbers as $number) |
|
| 193 | 193 | { |
| 194 | 194 | $url = $this->editor->getPaginationURL($number); |
| 195 | 195 | |
| 196 | 196 | ?> |
| 197 | - <li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>"> |
|
| 197 | + <li class="page-item <?php if ($pager->isCurrentPage($number)) { echo 'active'; } ?>"> |
|
| 198 | 198 | <a class="page-link" href="<?php echo $url ?>"> |
| 199 | 199 | <?php echo $number ?> |
| 200 | 200 | </a> |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $hash = $string->getHash(); |
| 230 | 230 | $text = $string->getText(); |
| 231 | 231 | |
| 232 | - if($text===null) |
|
| 232 | + if ($text === null) |
|
| 233 | 233 | { |
| 234 | 234 | throw new EditorException( |
| 235 | 235 | 'String hash has no text', |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | $previewText = $string->getTranslatedText(); |
| 242 | - if(empty($previewText)) { |
|
| 242 | + if (empty($previewText)) { |
|
| 243 | 243 | $previewText = $text->getText(); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $shortText = $this->renderText($previewText, 50); |
|
| 246 | + $shortText = $this->renderText($previewText, 50); |
|
| 247 | 247 | |
| 248 | 248 | $files = $string->getFiles(); |
| 249 | 249 | $labelID = JSHelper::nextElementID(); |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | </p> |
| 265 | 265 | <?php |
| 266 | 266 | $explanation = $text->getExplanation(); |
| 267 | - if(!empty($explanation)) |
|
| 267 | + if (!empty($explanation)) |
|
| 268 | 268 | { |
| 269 | 269 | ?> |
| 270 | 270 | <p> |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | <?php |
| 288 | 288 | $totalFiles = count($files); |
| 289 | 289 | |
| 290 | - if($totalFiles == 1) |
|
| 290 | + if ($totalFiles == 1) |
|
| 291 | 291 | { |
| 292 | 292 | pt('Found in a single file:'); |
| 293 | 293 | } |
@@ -302,16 +302,16 @@ discard block |
||
| 302 | 302 | <?php |
| 303 | 303 | $locations = $string->getStrings(); |
| 304 | 304 | |
| 305 | - foreach($locations as $location) |
|
| 305 | + foreach ($locations as $location) |
|
| 306 | 306 | { |
| 307 | 307 | $file = $location->getSourceFile(); |
| 308 | 308 | $line = $location->getLine(); |
| 309 | 309 | |
| 310 | 310 | $ext = FileHelper::getExtension($file); |
| 311 | 311 | |
| 312 | - if($ext == 'php') { |
|
| 312 | + if ($ext == 'php') { |
|
| 313 | 313 | $icon = 'fab fa-php'; |
| 314 | - } else if($ext == 'js') { |
|
| 314 | + } else if ($ext == 'js') { |
|
| 315 | 315 | $icon = 'fab fa-js-square'; |
| 316 | 316 | } else { |
| 317 | 317 | $icon = 'fas fa-file-code'; |
@@ -333,13 +333,13 @@ discard block |
||
| 333 | 333 | <?php |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - protected function renderText(string $text, int $cutAt=0) : string |
|
| 336 | + protected function renderText(string $text, int $cutAt = 0) : string |
|
| 337 | 337 | { |
| 338 | - if(empty($text)) { |
|
| 338 | + if (empty($text)) { |
|
| 339 | 339 | return ''; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if($cutAt > 0) { |
|
| 342 | + if ($cutAt > 0) { |
|
| 343 | 343 | $text = ConvertHelper::text_cut($text, $cutAt); |
| 344 | 344 | } |
| 345 | 345 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | $vars = $this->editor->detectVariables($text); |
| 349 | 349 | |
| 350 | - foreach($vars as $var) { |
|
| 350 | + foreach ($vars as $var) { |
|
| 351 | 351 | $text = str_replace($var, '<span class="placeholder">'.$var.'</span>', $text); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | <?php |
| 533 | 533 | pt( |
| 534 | 534 | 'You are translating to %1$s', |
| 535 | - '<span class="badge badge-info">' . $activeLocale->getLabel() . '</span>' |
|
| 535 | + '<span class="badge badge-info">'.$activeLocale->getLabel().'</span>' |
|
| 536 | 536 | ); |
| 537 | 537 | ?><br> |
| 538 | 538 | |
@@ -572,10 +572,10 @@ discard block |
||
| 572 | 572 | |
| 573 | 573 | // add a counter of the additional files if the total |
| 574 | 574 | // is higher than the maximum to show |
| 575 | - if($total > $max) |
|
| 575 | + if ($total > $max) |
|
| 576 | 576 | { |
| 577 | 577 | $length = $max; |
| 578 | - if($length > $keepTotal) { |
|
| 578 | + if ($length > $keepTotal) { |
|
| 579 | 579 | $length = $keepTotal; |
| 580 | 580 | } |
| 581 | 581 | |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | protected function renderStatus(Localization_Scanner_StringHash $hash) : string |
| 590 | 590 | { |
| 591 | - if($hash->isTranslated()) { |
|
| 591 | + if ($hash->isTranslated()) { |
|
| 592 | 592 | return '<i class="fa fa-check text-success"></i>'; |
| 593 | 593 | } |
| 594 | 594 | |
@@ -599,11 +599,11 @@ discard block |
||
| 599 | 599 | { |
| 600 | 600 | $types = array(); |
| 601 | 601 | |
| 602 | - if($hash->hasLanguageType('PHP')) { |
|
| 602 | + if ($hash->hasLanguageType('PHP')) { |
|
| 603 | 603 | $types[] = t('Server'); |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - if($hash->hasLanguageType('Javascript')) { |
|
| 606 | + if ($hash->hasLanguageType('Javascript')) { |
|
| 607 | 607 | $types[] = t('Client'); |
| 608 | 608 | } |
| 609 | 609 | |
@@ -290,8 +290,7 @@ discard block |
||
| 290 | 290 | if($totalFiles == 1) |
| 291 | 291 | { |
| 292 | 292 | pt('Found in a single file:'); |
| 293 | - } |
|
| 294 | - else |
|
| 293 | + } else |
|
| 295 | 294 | { |
| 296 | 295 | pt('Found in %1$s files:', $totalFiles); |
| 297 | 296 | } |
@@ -463,8 +462,7 @@ discard block |
||
| 463 | 462 | ?> |
| 464 | 463 | <b><?php echo $source->getLabel() ?></b> |
| 465 | 464 | <?php |
| 466 | - } |
|
| 467 | - else |
|
| 465 | + } else |
|
| 468 | 466 | { |
| 469 | 467 | echo $source->getLabel(); |
| 470 | 468 | } |
@@ -554,8 +552,7 @@ discard block |
||
| 554 | 552 | </a> |
| 555 | 553 | </p> |
| 556 | 554 | <?php |
| 557 | - } |
|
| 558 | - else |
|
| 555 | + } else |
|
| 559 | 556 | { |
| 560 | 557 | echo $this->editor->getFilters()->renderForm(); |
| 561 | 558 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $texts = $language->getTexts(); |
| 61 | 61 | |
| 62 | - foreach($texts as $text) |
|
| 62 | + foreach ($texts as $text) |
|
| 63 | 63 | { |
| 64 | 64 | $this->collection->addFromFile( |
| 65 | 65 | $this->source->getID(), |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $warnings = $language->getWarnings(); |
| 73 | 73 | |
| 74 | - foreach($warnings as $warning) |
|
| 74 | + foreach ($warnings as $warning) |
|
| 75 | 75 | { |
| 76 | 76 | $this->collection->addWarning($warning); |
| 77 | 77 | } |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $hashes = $this->getHashes(); |
| 95 | 95 | |
| 96 | - foreach($hashes as $hash) |
|
| 96 | + foreach ($hashes as $hash) |
|
| 97 | 97 | { |
| 98 | 98 | $text = $translator->getHashTranslation($hash->getHash()); |
| 99 | 99 | |
| 100 | - if(empty($text)) |
|
| 100 | + if (empty($text)) |
|
| 101 | 101 | { |
| 102 | 102 | $amount++; |
| 103 | 103 | } |
@@ -27,27 +27,27 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | abstract class Localization_Source |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * Human-readable label for the source. |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 30 | + /** |
|
| 31 | + * Human-readable label for the source. |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | 34 | protected $label; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Human-readable group name to categorize the source. |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 36 | + /** |
|
| 37 | + * Human-readable group name to categorize the source. |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | 40 | protected $group; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * The folder in which the localization files are stored |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 42 | + /** |
|
| 43 | + * The folder in which the localization files are stored |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | 46 | protected $storageFolder; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var string |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var string |
|
| 50 | + */ |
|
| 51 | 51 | protected $alias; |
| 52 | 52 | |
| 53 | 53 | public function __construct(string $alias, string $label, string $group, string $storageFolder) |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | public function __construct() |
| 103 | 103 | { |
| 104 | 104 | $path = realpath(__DIR__.'/../'); |
| 105 | - if($path === false) |
|
| 105 | + if ($path === false) |
|
| 106 | 106 | { |
| 107 | 107 | throw new Localization_Exception( |
| 108 | 108 | 'Local path not found', |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | protected function initSession() : void |
| 152 | 152 | { |
| 153 | - if(session_status() != PHP_SESSION_ACTIVE) { |
|
| 153 | + if (session_status() != PHP_SESSION_ACTIVE) { |
|
| 154 | 154 | session_start(); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if(!isset($_SESSION['localization_messages'])) { |
|
| 157 | + if (!isset($_SESSION['localization_messages'])) { |
|
| 158 | 158 | $_SESSION['localization_messages'] = array(); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $this->sources = Localization::getSources(); |
| 173 | 173 | |
| 174 | - if(empty($this->sources)) |
|
| 174 | + if (empty($this->sources)) |
|
| 175 | 175 | { |
| 176 | 176 | throw new Localization_Exception( |
| 177 | 177 | 'Cannot start editor: no sources defined.', |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $activeID = $this->request->registerParam($this->getVarName('source'))->setEnum(Localization::getSourceIDs())->get(); |
| 184 | - if(empty($activeID)) { |
|
| 184 | + if (empty($activeID)) { |
|
| 185 | 185 | $activeID = $this->getDefaultSourceID(); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | protected function getDefaultSourceID() : string |
| 192 | 192 | { |
| 193 | 193 | $default = $this->getOption('default-source'); |
| 194 | - if(!empty($default) && Localization::sourceAliasExists($default)) { |
|
| 194 | + if (!empty($default) && Localization::sourceAliasExists($default)) { |
|
| 195 | 195 | return Localization::getSourceByAlias($default)->getID(); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -203,21 +203,21 @@ discard block |
||
| 203 | 203 | $names = array(); |
| 204 | 204 | |
| 205 | 205 | $locales = Localization::getAppLocales(); |
| 206 | - foreach($locales as $locale) { |
|
| 207 | - if(!$locale->isNative()) { |
|
| 206 | + foreach ($locales as $locale) { |
|
| 207 | + if (!$locale->isNative()) { |
|
| 208 | 208 | $this->appLocales[] = $locale; |
| 209 | 209 | $names[] = $locale->getName(); |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // use the default locale if no other is available. |
| 214 | - if(empty($names)) { |
|
| 214 | + if (empty($names)) { |
|
| 215 | 215 | $this->activeAppLocale = Localization::getAppLocale(); |
| 216 | 216 | return; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $activeID = $this->request->registerParam($this->getVarName('locale'))->setEnum($names)->get(); |
| 220 | - if(empty($activeID)) { |
|
| 220 | + if (empty($activeID)) { |
|
| 221 | 221 | $activeID = $this->appLocales[0]->getName(); |
| 222 | 222 | } |
| 223 | 223 | |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | $this->filters = new Localization_Editor_Filters($this); |
| 270 | 270 | |
| 271 | - if($this->request->getBool($this->getVarName(self::VARIABLE_SCAN))) |
|
| 271 | + if ($this->request->getBool($this->getVarName(self::VARIABLE_SCAN))) |
|
| 272 | 272 | { |
| 273 | 273 | $this->executeScan(); |
| 274 | 274 | } |
| 275 | - else if($this->request->getBool($this->getSaveVariableName())) |
|
| 275 | + else if ($this->request->getBool($this->getSaveVariableName())) |
|
| 276 | 276 | { |
| 277 | 277 | $this->executeSave(); |
| 278 | 278 | } |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | $result = array(); |
| 328 | 328 | |
| 329 | - foreach($strings as $string) |
|
| 329 | + foreach ($strings as $string) |
|
| 330 | 330 | { |
| 331 | - if($this->filters->isStringMatch($string)) { |
|
| 331 | + if ($this->filters->isStringMatch($string)) { |
|
| 332 | 332 | $result[] = $string; |
| 333 | 333 | } |
| 334 | 334 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | return $this->activeAppLocale; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - public function getPaginationURL(int $page, array $params=array()) : string |
|
| 368 | + public function getPaginationURL(int $page, array $params = array()) : string |
|
| 369 | 369 | { |
| 370 | 370 | $params[$this->getVarName('page')] = $page; |
| 371 | 371 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | $result = array(); |
| 378 | 378 | preg_match_all('/%[0-9]+d|%s|%[0-9]+\$s/i', $string, $result, PREG_PATTERN_ORDER); |
| 379 | 379 | |
| 380 | - if(isset($result[0]) && !empty($result[0])) { |
|
| 380 | + if (isset($result[0]) && !empty($result[0])) { |
|
| 381 | 381 | return $result[0]; |
| 382 | 382 | } |
| 383 | 383 | |
@@ -389,14 +389,14 @@ discard block |
||
| 389 | 389 | echo $this->render(); |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - public function getSourceURL(Localization_Source $source, array $params=array()) : string |
|
| 392 | + public function getSourceURL(Localization_Source $source, array $params = array()) : string |
|
| 393 | 393 | { |
| 394 | 394 | $params[$this->getVarName('source')] = $source->getID(); |
| 395 | 395 | |
| 396 | 396 | return $this->getURL($params); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - public function getLocaleURL(Localization_Locale $locale, array $params=array()) : string |
|
| 399 | + public function getLocaleURL(Localization_Locale $locale, array $params = array()) : string |
|
| 400 | 400 | { |
| 401 | 401 | $params[$this->getVarName('locale')] = $locale->getName(); |
| 402 | 402 | |
@@ -413,12 +413,12 @@ discard block |
||
| 413 | 413 | return $this->getSourceURL($this->activeSource, array($this->getVarName(self::VARIABLE_WARNINGS) => 'yes')); |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - public function getURL(array $params=array()) : string |
|
| 416 | + public function getURL(array $params = array()) : string |
|
| 417 | 417 | { |
| 418 | 418 | $persist = $this->getRequestParams(); |
| 419 | 419 | |
| 420 | - foreach($persist as $name => $value) { |
|
| 421 | - if(!isset($params[$name])) { |
|
| 420 | + foreach ($persist as $name => $value) { |
|
| 421 | + if (!isset($params[$name])) { |
|
| 422 | 422 | $params[$name] = $value; |
| 423 | 423 | } |
| 424 | 424 | } |
@@ -455,11 +455,11 @@ discard block |
||
| 455 | 455 | $translator = Localization::getTranslator($this->activeAppLocale); |
| 456 | 456 | |
| 457 | 457 | $strings = $data[$this->getVarName(self::VARIABLE_STRINGS)]; |
| 458 | - foreach($strings as $hash => $text) |
|
| 458 | + foreach ($strings as $hash => $text) |
|
| 459 | 459 | { |
| 460 | 460 | $text = trim($text); |
| 461 | 461 | |
| 462 | - if(empty($text)) { |
|
| 462 | + if (empty($text)) { |
|
| 463 | 463 | continue; |
| 464 | 464 | } |
| 465 | 465 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | $this->redirect($this->getURL()); |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - protected function addMessage(string $message, string $type=self::MESSAGE_INFO) : void |
|
| 482 | + protected function addMessage(string $message, string $type = self::MESSAGE_INFO) : void |
|
| 483 | 483 | { |
| 484 | 484 | $_SESSION['localization_messages'][] = array( |
| 485 | 485 | 'text' => $message, |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | public function getAppName() : string |
| 517 | 517 | { |
| 518 | 518 | $name = $this->getOption('appname'); |
| 519 | - if(!empty($name)) { |
|
| 519 | + if (!empty($name)) { |
|
| 520 | 520 | return $name; |
| 521 | 521 | } |
| 522 | 522 | |
@@ -271,8 +271,7 @@ |
||
| 271 | 271 | if($this->request->getBool($this->getVarName(self::VARIABLE_SCAN))) |
| 272 | 272 | { |
| 273 | 273 | $this->executeScan(); |
| 274 | - } |
|
| 275 | - else if($this->request->getBool($this->getSaveVariableName())) |
|
| 274 | + } else if($this->request->getBool($this->getSaveVariableName())) |
|
| 276 | 275 | { |
| 277 | 276 | $this->executeSave(); |
| 278 | 277 | } |
@@ -41,53 +41,53 @@ discard block |
||
| 41 | 41 | const VARIABLE_WARNINGS = 'warnings'; |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * @var string |
|
| 45 | - */ |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | 46 | protected $installPath; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var Localization_Source[] |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var Localization_Source[] |
|
| 50 | + */ |
|
| 51 | 51 | protected $sources; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @var Request |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * @var Request |
|
| 55 | + */ |
|
| 56 | 56 | protected $request; |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @var Localization_Source |
|
| 60 | - */ |
|
| 58 | + /** |
|
| 59 | + * @var Localization_Source |
|
| 60 | + */ |
|
| 61 | 61 | protected $activeSource; |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @var Localization_Scanner |
|
| 65 | - */ |
|
| 63 | + /** |
|
| 64 | + * @var Localization_Scanner |
|
| 65 | + */ |
|
| 66 | 66 | protected $scanner; |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var Localization_Locale[] |
|
| 70 | - */ |
|
| 68 | + /** |
|
| 69 | + * @var Localization_Locale[] |
|
| 70 | + */ |
|
| 71 | 71 | protected array $appLocales = array(); |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @var Localization_Locale |
|
| 75 | - */ |
|
| 73 | + /** |
|
| 74 | + * @var Localization_Locale |
|
| 75 | + */ |
|
| 76 | 76 | protected $activeAppLocale; |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @var Localization_Editor_Filters |
|
| 80 | - */ |
|
| 78 | + /** |
|
| 79 | + * @var Localization_Editor_Filters |
|
| 80 | + */ |
|
| 81 | 81 | protected $filters; |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @var array<string,string> |
|
| 85 | - */ |
|
| 83 | + /** |
|
| 84 | + * @var array<string,string> |
|
| 85 | + */ |
|
| 86 | 86 | protected $requestParams = array(); |
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 88 | + /** |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | 91 | protected $varPrefix = 'applocalize_'; |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -128,15 +128,15 @@ discard block |
||
| 128 | 128 | return $this->request; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Adds a request parameter that will be persisted in all URLs |
|
| 133 | - * within the editor. This can be used when integrating the |
|
| 134 | - * editor in an existing page that needs specific request params. |
|
| 135 | - * |
|
| 136 | - * @param string $name |
|
| 137 | - * @param string $value |
|
| 138 | - * @return Localization_Editor |
|
| 139 | - */ |
|
| 131 | + /** |
|
| 132 | + * Adds a request parameter that will be persisted in all URLs |
|
| 133 | + * within the editor. This can be used when integrating the |
|
| 134 | + * editor in an existing page that needs specific request params. |
|
| 135 | + * |
|
| 136 | + * @param string $name |
|
| 137 | + * @param string $value |
|
| 138 | + * @return Localization_Editor |
|
| 139 | + */ |
|
| 140 | 140 | public function addRequestParam(string $name, string $value) : Localization_Editor |
| 141 | 141 | { |
| 142 | 142 | $this->requestParams[$name] = $value; |
@@ -500,13 +500,13 @@ discard block |
||
| 500 | 500 | ); |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * Sets the application name shown in the main navigation |
|
| 505 | - * in the user interface. |
|
| 506 | - * |
|
| 507 | - * @param string $name |
|
| 508 | - * @return Localization_Editor |
|
| 509 | - */ |
|
| 503 | + /** |
|
| 504 | + * Sets the application name shown in the main navigation |
|
| 505 | + * in the user interface. |
|
| 506 | + * |
|
| 507 | + * @param string $name |
|
| 508 | + * @return Localization_Editor |
|
| 509 | + */ |
|
| 510 | 510 | public function setAppName(string $name) : Localization_Editor |
| 511 | 511 | { |
| 512 | 512 | $this->setOption('appname', $name); |
@@ -536,15 +536,15 @@ discard block |
||
| 536 | 536 | return $this; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - /** |
|
| 540 | - * Sets an URL that the translators can use to go back to |
|
| 541 | - * the main application, for example if it is integrated into |
|
| 542 | - * an existing application. |
|
| 543 | - * |
|
| 544 | - * @param string $url The URL to use for the link |
|
| 545 | - * @param string $label Label of the link |
|
| 546 | - * @return Localization_Editor |
|
| 547 | - */ |
|
| 539 | + /** |
|
| 540 | + * Sets an URL that the translators can use to go back to |
|
| 541 | + * the main application, for example if it is integrated into |
|
| 542 | + * an existing application. |
|
| 543 | + * |
|
| 544 | + * @param string $url The URL to use for the link |
|
| 545 | + * @param string $label Label of the link |
|
| 546 | + * @return Localization_Editor |
|
| 547 | + */ |
|
| 548 | 548 | public function setBackURL(string $url, string $label) : Localization_Editor |
| 549 | 549 | { |
| 550 | 550 | $this->setOption('back-url', $url); |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | return true; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function getStructuralTemplate(?CountryInterface $country=null) : string |
|
| 42 | + public function getStructuralTemplate(?CountryInterface $country = null) : string |
|
| 43 | 43 | { |
| 44 | 44 | return '-{symbol}{amount}'; |
| 45 | 45 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | return t('Swiss Francs'); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function getStructuralTemplate(?CountryInterface $country=null): string |
|
| 44 | + public function getStructuralTemplate(?CountryInterface $country = null): string |
|
| 45 | 45 | { |
| 46 | 46 | return '-{amount} {symbol}'; |
| 47 | 47 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | return false; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function getStructuralTemplate(?CountryInterface $country=null): string |
|
| 44 | + public function getStructuralTemplate(?CountryInterface $country = null): string |
|
| 45 | 45 | { |
| 46 | 46 | return '-{symbol}{amount}'; |
| 47 | 47 | } |