@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | const EVENT_LOCALE_CHANGED = 'LocaleChanged'; |
54 | 54 | |
55 | 55 | /** |
56 | - * Collection of all locales by namespace (application, content, custom...). |
|
57 | - * |
|
58 | - * @var array<string,array<string,Localization_Locale>> |
|
59 | - * @see Localization::addLocale() |
|
60 | - */ |
|
56 | + * Collection of all locales by namespace (application, content, custom...). |
|
57 | + * |
|
58 | + * @var array<string,array<string,Localization_Locale>> |
|
59 | + * @see Localization::addLocale() |
|
60 | + */ |
|
61 | 61 | protected static $locales = array(); |
62 | 62 | |
63 | 63 | /** |
@@ -66,57 +66,57 @@ 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 | - /** |
|
110 | - * @var Localization_Translator|NULL |
|
111 | - */ |
|
109 | + /** |
|
110 | + * @var Localization_Translator|NULL |
|
111 | + */ |
|
112 | 112 | protected static $translator; |
113 | 113 | |
114 | - /** |
|
115 | - * Initializes the localization layer. This is done |
|
116 | - * automatically, and only once per request. |
|
117 | - * |
|
118 | - * (Called at the end of this file) |
|
119 | - */ |
|
114 | + /** |
|
115 | + * Initializes the localization layer. This is done |
|
116 | + * automatically, and only once per request. |
|
117 | + * |
|
118 | + * (Called at the end of this file) |
|
119 | + */ |
|
120 | 120 | public static function init() : void |
121 | 121 | { |
122 | 122 | if(self::$initDone) { |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | return self::getLocalesByNS(self::NAMESPACE_APPLICATION); |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * Retrieves all locales in the specified namespace. |
|
160 | - * |
|
161 | - * @param string $namespace |
|
162 | - * @return Localization_Locale[] |
|
163 | - */ |
|
158 | + /** |
|
159 | + * Retrieves all locales in the specified namespace. |
|
160 | + * |
|
161 | + * @param string $namespace |
|
162 | + * @return Localization_Locale[] |
|
163 | + */ |
|
164 | 164 | public static function getLocalesByNS(string $namespace) |
165 | 165 | { |
166 | 166 | if(isset(self::$locales[$namespace])) { |
@@ -177,35 +177,35 @@ discard block |
||
177 | 177 | ); |
178 | 178 | } |
179 | 179 | |
180 | - /** |
|
181 | - * Adds an application locale to use in the application. |
|
182 | - * |
|
183 | - * @param string $localeName |
|
184 | - * @return Localization_Locale |
|
185 | - */ |
|
180 | + /** |
|
181 | + * Adds an application locale to use in the application. |
|
182 | + * |
|
183 | + * @param string $localeName |
|
184 | + * @return Localization_Locale |
|
185 | + */ |
|
186 | 186 | public static function addAppLocale(string $localeName) : Localization_Locale |
187 | 187 | { |
188 | 188 | return self::addLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Adds a content locale to use for content in the application. |
|
193 | - * |
|
194 | - * @param string $localeName |
|
195 | - * @return Localization_Locale |
|
196 | - */ |
|
191 | + /** |
|
192 | + * Adds a content locale to use for content in the application. |
|
193 | + * |
|
194 | + * @param string $localeName |
|
195 | + * @return Localization_Locale |
|
196 | + */ |
|
197 | 197 | public static function addContentLocale(string $localeName) : Localization_Locale |
198 | 198 | { |
199 | 199 | return self::addLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
200 | 200 | } |
201 | 201 | |
202 | - /** |
|
203 | - * Adds a locale to the specified namespace. |
|
204 | - * |
|
205 | - * @param string $localeName |
|
206 | - * @param string $namespace |
|
207 | - * @return Localization_Locale |
|
208 | - */ |
|
202 | + /** |
|
203 | + * Adds a locale to the specified namespace. |
|
204 | + * |
|
205 | + * @param string $localeName |
|
206 | + * @param string $namespace |
|
207 | + * @return Localization_Locale |
|
208 | + */ |
|
209 | 209 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
210 | 210 | { |
211 | 211 | if(!isset(self::$locales[$namespace])) { |
@@ -343,45 +343,45 @@ discard block |
||
343 | 343 | return self::getSelectedLocaleByNS(self::NAMESPACE_APPLICATION); |
344 | 344 | } |
345 | 345 | |
346 | - /** |
|
347 | - * Retrieves the name of the selected application locale. |
|
348 | - * |
|
349 | - * @return string |
|
350 | - */ |
|
346 | + /** |
|
347 | + * Retrieves the name of the selected application locale. |
|
348 | + * |
|
349 | + * @return string |
|
350 | + */ |
|
351 | 351 | public static function getAppLocaleName() : string |
352 | 352 | { |
353 | 353 | return self::getLocaleNameByNS(self::NAMESPACE_APPLICATION); |
354 | 354 | } |
355 | 355 | |
356 | - /** |
|
357 | - * Retrieves the names of the available application locales. |
|
358 | - * @return string[] |
|
359 | - */ |
|
356 | + /** |
|
357 | + * Retrieves the names of the available application locales. |
|
358 | + * @return string[] |
|
359 | + */ |
|
360 | 360 | public static function getAppLocaleNames() : array |
361 | 361 | { |
362 | 362 | return self::getLocaleNamesByNS(self::NAMESPACE_APPLICATION); |
363 | 363 | } |
364 | 364 | |
365 | - /** |
|
366 | - * Retrieves the selected locale name in the specified namespace. |
|
367 | - * |
|
368 | - * @param string $namespace |
|
369 | - * @throws Localization_Exception |
|
370 | - * @return string |
|
371 | - */ |
|
365 | + /** |
|
366 | + * Retrieves the selected locale name in the specified namespace. |
|
367 | + * |
|
368 | + * @param string $namespace |
|
369 | + * @throws Localization_Exception |
|
370 | + * @return string |
|
371 | + */ |
|
372 | 372 | public static function getLocaleNameByNS(string $namespace) : string |
373 | 373 | { |
374 | 374 | return self::getSelectedLocaleByNS($namespace)->getName(); |
375 | 375 | } |
376 | 376 | |
377 | - /** |
|
378 | - * Retrieves the selected locale instance for the specified namespace. |
|
379 | - * |
|
380 | - * @param string $namespace |
|
381 | - * @return Localization_Locale |
|
382 | - * @throws Localization_Exception |
|
383 | - * @see Localization::ERROR_NO_LOCALE_SELECTED_IN_NS |
|
384 | - */ |
|
377 | + /** |
|
378 | + * Retrieves the selected locale instance for the specified namespace. |
|
379 | + * |
|
380 | + * @param string $namespace |
|
381 | + * @return Localization_Locale |
|
382 | + * @throws Localization_Exception |
|
383 | + * @see Localization::ERROR_NO_LOCALE_SELECTED_IN_NS |
|
384 | + */ |
|
385 | 385 | public static function getSelectedLocaleByNS(string $namespace) : Localization_Locale |
386 | 386 | { |
387 | 387 | self::requireNamespace($namespace); |
@@ -400,24 +400,24 @@ discard block |
||
400 | 400 | ); |
401 | 401 | } |
402 | 402 | |
403 | - /** |
|
404 | - * Stores the selected locale names by namespace. |
|
405 | - * @var array<string,Localization_Locale> |
|
406 | - */ |
|
403 | + /** |
|
404 | + * Stores the selected locale names by namespace. |
|
405 | + * @var array<string,Localization_Locale> |
|
406 | + */ |
|
407 | 407 | protected static $selected = array(); |
408 | 408 | |
409 | - /** |
|
410 | - * Selects the active locale for the specified namespace. |
|
411 | - * |
|
412 | - * NOTE: Triggers the "LocaleChanged" event. |
|
413 | - * |
|
414 | - * @param string $localeName |
|
415 | - * @param string $namespace |
|
416 | - * @return Localization_Locale |
|
417 | - * @throws Localization_Exception |
|
418 | - * |
|
419 | - * @see Localization_Event_LocaleChanged |
|
420 | - */ |
|
409 | + /** |
|
410 | + * Selects the active locale for the specified namespace. |
|
411 | + * |
|
412 | + * NOTE: Triggers the "LocaleChanged" event. |
|
413 | + * |
|
414 | + * @param string $localeName |
|
415 | + * @param string $namespace |
|
416 | + * @return Localization_Locale |
|
417 | + * @throws Localization_Exception |
|
418 | + * |
|
419 | + * @see Localization_Event_LocaleChanged |
|
420 | + */ |
|
421 | 421 | public static function selectLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
422 | 422 | { |
423 | 423 | self::requireNamespace($namespace); |
@@ -548,15 +548,15 @@ discard block |
||
548 | 548 | return self::selectLocaleByNS($localeName, self::NAMESPACE_APPLICATION); |
549 | 549 | } |
550 | 550 | |
551 | - /** |
|
552 | - * Retrieves an application locale by its name. |
|
553 | - * Note that the locale must have been added first. |
|
554 | - * |
|
555 | - * @param string $localeName |
|
556 | - * @throws Localization_Exception |
|
557 | - * @return Localization_Locale |
|
558 | - * @see Localization::appLocaleExists() |
|
559 | - */ |
|
551 | + /** |
|
552 | + * Retrieves an application locale by its name. |
|
553 | + * Note that the locale must have been added first. |
|
554 | + * |
|
555 | + * @param string $localeName |
|
556 | + * @throws Localization_Exception |
|
557 | + * @return Localization_Locale |
|
558 | + * @see Localization::appLocaleExists() |
|
559 | + */ |
|
560 | 560 | public static function getAppLocaleByName(string $localeName) : Localization_Locale |
561 | 561 | { |
562 | 562 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_APPLICATION); |
@@ -591,10 +591,10 @@ discard block |
||
591 | 591 | return self::getLocalesByNS(self::NAMESPACE_CONTENT); |
592 | 592 | } |
593 | 593 | |
594 | - /** |
|
595 | - * Retrieves the names of all content locales that have been added. |
|
596 | - * @return string[] |
|
597 | - */ |
|
594 | + /** |
|
595 | + * Retrieves the names of all content locales that have been added. |
|
596 | + * @return string[] |
|
597 | + */ |
|
598 | 598 | public static function getContentLocaleNames() |
599 | 599 | { |
600 | 600 | return self::getLocaleNamesByNS(self::NAMESPACE_CONTENT); |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | sort($names); |
618 | 618 | |
619 | 619 | return $names; |
620 | - } |
|
620 | + } |
|
621 | 621 | |
622 | 622 | /** |
623 | 623 | * Checks by the locale name if the specified locale is |
@@ -646,14 +646,14 @@ discard block |
||
646 | 646 | return self::getLocaleByNameNS($localeName, self::NAMESPACE_CONTENT); |
647 | 647 | } |
648 | 648 | |
649 | - /** |
|
650 | - * Retrieves a locale by its name in the specified namespace. |
|
651 | - * |
|
652 | - * @param string $localeName |
|
653 | - * @param string $namespace |
|
654 | - * @throws Localization_Exception |
|
655 | - * @return Localization_Locale |
|
656 | - */ |
|
649 | + /** |
|
650 | + * Retrieves a locale by its name in the specified namespace. |
|
651 | + * |
|
652 | + * @param string $localeName |
|
653 | + * @param string $namespace |
|
654 | + * @throws Localization_Exception |
|
655 | + * @return Localization_Locale |
|
656 | + */ |
|
657 | 657 | public static function getLocaleByNameNS(string $localeName, string $namespace) : Localization_Locale |
658 | 658 | { |
659 | 659 | self::requireNamespace($namespace); |
@@ -724,10 +724,10 @@ discard block |
||
724 | 724 | return self::selectLocaleByNS($localeName, self::NAMESPACE_CONTENT); |
725 | 725 | } |
726 | 726 | |
727 | - /** |
|
728 | - * Checks whether the localization has been configured entirely. |
|
729 | - * @return bool |
|
730 | - */ |
|
727 | + /** |
|
728 | + * Checks whether the localization has been configured entirely. |
|
729 | + * @return bool |
|
730 | + */ |
|
731 | 731 | public static function isConfigured() : bool |
732 | 732 | { |
733 | 733 | return self::$configured; |
@@ -799,29 +799,29 @@ discard block |
||
799 | 799 | ); |
800 | 800 | } |
801 | 801 | |
802 | - /** |
|
803 | - * Injects a content locales selector element into the specified |
|
804 | - * HTML QuickForm2 container. |
|
805 | - * |
|
806 | - * @param string $elementName |
|
807 | - * @param HTML_QuickForm2_Container $container |
|
808 | - * @param string $label |
|
809 | - * @return HTML_QuickForm2_Element_Select |
|
810 | - */ |
|
802 | + /** |
|
803 | + * Injects a content locales selector element into the specified |
|
804 | + * HTML QuickForm2 container. |
|
805 | + * |
|
806 | + * @param string $elementName |
|
807 | + * @param HTML_QuickForm2_Container $container |
|
808 | + * @param string $label |
|
809 | + * @return HTML_QuickForm2_Element_Select |
|
810 | + */ |
|
811 | 811 | public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
812 | 812 | { |
813 | 813 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
814 | 814 | } |
815 | 815 | |
816 | - /** |
|
817 | - * Injects an app locales selector element into the specified |
|
816 | + /** |
|
817 | + * Injects an app locales selector element into the specified |
|
818 | 818 | * HTML QuickForm2 container. |
819 | 819 | * |
820 | - * @param string $elementName |
|
821 | - * @param HTML_QuickForm2_Container $container |
|
822 | - * @param string $label |
|
823 | - * @return HTML_QuickForm2_Element_Select |
|
824 | - */ |
|
820 | + * @param string $elementName |
|
821 | + * @param HTML_QuickForm2_Container $container |
|
822 | + * @param string $label |
|
823 | + * @return HTML_QuickForm2_Element_Select |
|
824 | + */ |
|
825 | 825 | public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
826 | 826 | { |
827 | 827 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
@@ -857,26 +857,26 @@ discard block |
||
857 | 857 | return $select; |
858 | 858 | } |
859 | 859 | |
860 | - /** |
|
861 | - * @var Localization_Source[] |
|
862 | - */ |
|
860 | + /** |
|
861 | + * @var Localization_Source[] |
|
862 | + */ |
|
863 | 863 | protected static $sources = array(); |
864 | 864 | |
865 | - /** |
|
866 | - * @var string[] |
|
867 | - */ |
|
865 | + /** |
|
866 | + * @var string[] |
|
867 | + */ |
|
868 | 868 | protected static $excludeFolders = array(); |
869 | 869 | |
870 | - /** |
|
871 | - * @var string[] |
|
872 | - */ |
|
870 | + /** |
|
871 | + * @var string[] |
|
872 | + */ |
|
873 | 873 | protected static $excludeFiles = array(); |
874 | 874 | |
875 | - /** |
|
876 | - * Retrieves all currently available sources. |
|
877 | - * |
|
878 | - * @return Localization_Source[] |
|
879 | - */ |
|
875 | + /** |
|
876 | + * Retrieves all currently available sources. |
|
877 | + * |
|
878 | + * @return Localization_Source[] |
|
879 | + */ |
|
880 | 880 | public static function getSources() : array |
881 | 881 | { |
882 | 882 | return self::$sources; |
@@ -908,10 +908,10 @@ discard block |
||
908 | 908 | return $source; |
909 | 909 | } |
910 | 910 | |
911 | - /** |
|
912 | - * Retrieves all sources grouped by their group name. |
|
913 | - * @return array |
|
914 | - */ |
|
911 | + /** |
|
912 | + * Retrieves all sources grouped by their group name. |
|
913 | + * @return array |
|
914 | + */ |
|
915 | 915 | public static function getSourcesGrouped() |
916 | 916 | { |
917 | 917 | $sources = self::getSources(); |
@@ -932,11 +932,11 @@ discard block |
||
932 | 932 | return $grouped; |
933 | 933 | } |
934 | 934 | |
935 | - /** |
|
936 | - * Checks whether a specific source exists by its ID. |
|
937 | - * @param string $sourceID |
|
938 | - * @return boolean |
|
939 | - */ |
|
935 | + /** |
|
936 | + * Checks whether a specific source exists by its ID. |
|
937 | + * @param string $sourceID |
|
938 | + * @return boolean |
|
939 | + */ |
|
940 | 940 | public static function sourceExists(string $sourceID) : bool |
941 | 941 | { |
942 | 942 | $sources = self::getSources(); |
@@ -949,11 +949,11 @@ discard block |
||
949 | 949 | return false; |
950 | 950 | } |
951 | 951 | |
952 | - /** |
|
953 | - * Checks whether a specific source exists by its alias. |
|
954 | - * @param string $sourceAlias |
|
955 | - * @return boolean |
|
956 | - */ |
|
952 | + /** |
|
953 | + * Checks whether a specific source exists by its alias. |
|
954 | + * @param string $sourceAlias |
|
955 | + * @return boolean |
|
956 | + */ |
|
957 | 957 | public static function sourceAliasExists(string $sourceAlias) : bool |
958 | 958 | { |
959 | 959 | $sources = self::getSources(); |
@@ -966,13 +966,13 @@ discard block |
||
966 | 966 | return false; |
967 | 967 | } |
968 | 968 | |
969 | - /** |
|
970 | - * Retrieves a localization source by its ID. |
|
971 | - * |
|
972 | - * @param string $sourceID |
|
973 | - * @throws Localization_Exception |
|
974 | - * @return Localization_Source |
|
975 | - */ |
|
969 | + /** |
|
970 | + * Retrieves a localization source by its ID. |
|
971 | + * |
|
972 | + * @param string $sourceID |
|
973 | + * @throws Localization_Exception |
|
974 | + * @return Localization_Source |
|
975 | + */ |
|
976 | 976 | public static function getSourceByID(string $sourceID) : Localization_Source |
977 | 977 | { |
978 | 978 | $sources = self::getSources(); |
@@ -1062,17 +1062,17 @@ discard block |
||
1062 | 1062 | } |
1063 | 1063 | } |
1064 | 1064 | |
1065 | - /** |
|
1066 | - * Sets a key that is used to verify whether the client |
|
1067 | - * libraries have to be refreshed. A common use is to set |
|
1068 | - * this to the application's version number to guarantee |
|
1069 | - * new texts are automatically used with each release. |
|
1070 | - * |
|
1071 | - * NOTE: Otherwise files are refreshed only when saving |
|
1072 | - * them in the editor UI. |
|
1073 | - * |
|
1074 | - * @param string $key |
|
1075 | - */ |
|
1065 | + /** |
|
1066 | + * Sets a key that is used to verify whether the client |
|
1067 | + * libraries have to be refreshed. A common use is to set |
|
1068 | + * this to the application's version number to guarantee |
|
1069 | + * new texts are automatically used with each release. |
|
1070 | + * |
|
1071 | + * NOTE: Otherwise files are refreshed only when saving |
|
1072 | + * them in the editor UI. |
|
1073 | + * |
|
1074 | + * @param string $key |
|
1075 | + */ |
|
1076 | 1076 | public static function setClientLibrariesCacheKey(string $key) : void |
1077 | 1077 | { |
1078 | 1078 | self::$clientCacheKey = $key; |
@@ -1083,23 +1083,23 @@ discard block |
||
1083 | 1083 | return self::$clientCacheKey; |
1084 | 1084 | } |
1085 | 1085 | |
1086 | - /** |
|
1087 | - * Sets the folder where client libraries are to be stored. |
|
1088 | - * @param string $folder |
|
1089 | - */ |
|
1086 | + /** |
|
1087 | + * Sets the folder where client libraries are to be stored. |
|
1088 | + * @param string $folder |
|
1089 | + */ |
|
1090 | 1090 | public static function setClientLibrariesFolder(string $folder) : void |
1091 | 1091 | { |
1092 | 1092 | self::$clientFolder = $folder; |
1093 | 1093 | } |
1094 | 1094 | |
1095 | - /** |
|
1096 | - * Retrieves the path to the folder in which the client |
|
1097 | - * libraries should be stored. |
|
1098 | - * |
|
1099 | - * NOTE: Can return an empty string, when this is disabled. |
|
1100 | - * |
|
1101 | - * @return string |
|
1102 | - */ |
|
1095 | + /** |
|
1096 | + * Retrieves the path to the folder in which the client |
|
1097 | + * libraries should be stored. |
|
1098 | + * |
|
1099 | + * NOTE: Can return an empty string, when this is disabled. |
|
1100 | + * |
|
1101 | + * @return string |
|
1102 | + */ |
|
1103 | 1103 | public static function getClientLibrariesFolder() : string |
1104 | 1104 | { |
1105 | 1105 | return self::$clientFolder; |
@@ -1119,13 +1119,13 @@ discard block |
||
1119 | 1119 | self::createGenerator()->writeFiles($force); |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - /** |
|
1123 | - * Creates a new instance of the client generator class |
|
1124 | - * that is used to write the localization files into the |
|
1125 | - * target folder on disk. |
|
1126 | - * |
|
1127 | - * @return Localization_ClientGenerator |
|
1128 | - */ |
|
1122 | + /** |
|
1123 | + * Creates a new instance of the client generator class |
|
1124 | + * that is used to write the localization files into the |
|
1125 | + * target folder on disk. |
|
1126 | + * |
|
1127 | + * @return Localization_ClientGenerator |
|
1128 | + */ |
|
1129 | 1129 | public static function createGenerator() : Localization_ClientGenerator |
1130 | 1130 | { |
1131 | 1131 | return new Localization_ClientGenerator(); |
@@ -1190,10 +1190,10 @@ discard block |
||
1190 | 1190 | return new Localization_Editor(); |
1191 | 1191 | } |
1192 | 1192 | |
1193 | - /** |
|
1194 | - * Retrieves a list of all available source IDs. |
|
1195 | - * @return string[] |
|
1196 | - */ |
|
1193 | + /** |
|
1194 | + * Retrieves a list of all available source IDs. |
|
1195 | + * @return string[] |
|
1196 | + */ |
|
1197 | 1197 | public static function getSourceIDs() : array |
1198 | 1198 | { |
1199 | 1199 | $ids = array(); |
@@ -1220,9 +1220,9 @@ discard block |
||
1220 | 1220 | return $aliases; |
1221 | 1221 | } |
1222 | 1222 | |
1223 | - /** |
|
1224 | - * Resets all locales to the built-in locale. |
|
1225 | - */ |
|
1223 | + /** |
|
1224 | + * Resets all locales to the built-in locale. |
|
1225 | + */ |
|
1226 | 1226 | public static function reset() : void |
1227 | 1227 | { |
1228 | 1228 | self::$locales = array(); |
@@ -1260,12 +1260,12 @@ discard block |
||
1260 | 1260 | return self::$supportedLocales; |
1261 | 1261 | } |
1262 | 1262 | |
1263 | - /** |
|
1264 | - * Checks whether the specified locale is supported. |
|
1265 | - * |
|
1266 | - * @param string $localeName |
|
1267 | - * @return bool |
|
1268 | - */ |
|
1263 | + /** |
|
1264 | + * Checks whether the specified locale is supported. |
|
1265 | + * |
|
1266 | + * @param string $localeName |
|
1267 | + * @return bool |
|
1268 | + */ |
|
1269 | 1269 | public static function isLocaleSupported(string $localeName) : bool |
1270 | 1270 | { |
1271 | 1271 | return file_exists(__DIR__.'/Localization/Locale/'.$localeName.'.php'); |
@@ -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 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public static function init() : void |
125 | 125 | { |
126 | - if(self::$initDone) { |
|
126 | + if (self::$initDone) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public static function getLocalesByNS(string $namespace) |
169 | 169 | { |
170 | - if(isset(self::$locales[$namespace])) { |
|
170 | + if (isset(self::$locales[$namespace])) { |
|
171 | 171 | return array_values(self::$locales[$namespace]); |
172 | 172 | } |
173 | 173 | |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
214 | 214 | { |
215 | - if(!isset(self::$locales[$namespace])) { |
|
215 | + if (!isset(self::$locales[$namespace])) { |
|
216 | 216 | self::$locales[$namespace] = array(); |
217 | 217 | } |
218 | 218 | |
219 | - if(!isset(self::$locales[$namespace][$localeName])) |
|
219 | + if (!isset(self::$locales[$namespace][$localeName])) |
|
220 | 220 | { |
221 | 221 | self::$locales[$namespace][$localeName] = self::createLocale($localeName); |
222 | 222 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public static function createCountries() : CountryCollection |
277 | 277 | { |
278 | - if(!isset(self::$countries)) { |
|
278 | + if (!isset(self::$countries)) { |
|
279 | 279 | self::$countries = CountryCollection::getInstance(); |
280 | 280 | } |
281 | 281 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public static function createCurrencies() : CurrencyCollection |
294 | 294 | { |
295 | - if(!isset(self::$currencies)) { |
|
295 | + if (!isset(self::$currencies)) { |
|
296 | 296 | self::$currencies = CurrencyCollection::getInstance(); |
297 | 297 | } |
298 | 298 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | { |
406 | 406 | self::requireNamespace($namespace); |
407 | 407 | |
408 | - if(isset(self::$selected[$namespace])) { |
|
408 | + if (isset(self::$selected[$namespace])) { |
|
409 | 409 | return self::$selected[$namespace]; |
410 | 410 | } |
411 | 411 | |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | $locale = self::addLocaleByNS($localeName, $namespace); |
445 | 445 | $previous = null; |
446 | 446 | |
447 | - if(isset(self::$selected[$namespace])) |
|
447 | + if (isset(self::$selected[$namespace])) |
|
448 | 448 | { |
449 | - if(self::$selected[$namespace]->getName() === $localeName) { |
|
449 | + if (self::$selected[$namespace]->getName() === $localeName) { |
|
450 | 450 | return $locale; |
451 | 451 | } |
452 | 452 | |
@@ -482,11 +482,11 @@ discard block |
||
482 | 482 | $class = Localization_Event::class.'_'.$name; |
483 | 483 | $event = new $class($argsList); |
484 | 484 | |
485 | - if(!isset(self::$listeners[$name])) { |
|
485 | + if (!isset(self::$listeners[$name])) { |
|
486 | 486 | return $event; |
487 | 487 | } |
488 | 488 | |
489 | - foreach(self::$listeners[$name] as $listener) |
|
489 | + foreach (self::$listeners[$name] as $listener) |
|
490 | 490 | { |
491 | 491 | $callArgs = $listener['args']; |
492 | 492 | array_unshift($callArgs, $event); |
@@ -508,15 +508,15 @@ discard block |
||
508 | 508 | * @throws Localization_Exception |
509 | 509 | * @see Localization::ERROR_UNKNOWN_EVENT_NAME |
510 | 510 | */ |
511 | - public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
|
511 | + public static function addEventListener(string $eventName, $callback, array $args = array()) : int |
|
512 | 512 | { |
513 | - if(!isset(self::$listeners[$eventName])) { |
|
513 | + if (!isset(self::$listeners[$eventName])) { |
|
514 | 514 | self::$listeners[$eventName] = array(); |
515 | 515 | } |
516 | 516 | |
517 | 517 | $className = Localization_Event::class.'_'.$eventName; |
518 | 518 | |
519 | - if(!class_exists($className)) |
|
519 | + if (!class_exists($className)) |
|
520 | 520 | { |
521 | 521 | throw new Localization_Exception( |
522 | 522 | sprintf('Unknown localization event [%s].', $eventName), |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @throws Localization_Exception |
551 | 551 | * @see Localization_Event_LocaleChanged |
552 | 552 | */ |
553 | - public static function onLocaleChanged($callback, array $args=array()) : int |
|
553 | + public static function onLocaleChanged($callback, array $args = array()) : int |
|
554 | 554 | { |
555 | 555 | return self::addEventListener(self::EVENT_LOCALE_CHANGED, $callback, $args); |
556 | 556 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | { |
678 | 678 | self::requireNamespace($namespace); |
679 | 679 | |
680 | - if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
680 | + if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
681 | 681 | return self::$locales[$namespace][$localeName]; |
682 | 682 | } |
683 | 683 | |
@@ -756,9 +756,9 @@ discard block |
||
756 | 756 | * @param Localization_Locale|null $locale |
757 | 757 | * @return Localization_Translator |
758 | 758 | */ |
759 | - public static function getTranslator(?Localization_Locale $locale=null) : Localization_Translator |
|
759 | + public static function getTranslator(?Localization_Locale $locale = null) : Localization_Translator |
|
760 | 760 | { |
761 | - if($locale !== null) |
|
761 | + if ($locale !== null) |
|
762 | 762 | { |
763 | 763 | $obj = new Localization_Translator(); |
764 | 764 | $obj->addSources(self::getSources()); |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | return $obj; |
767 | 767 | } |
768 | 768 | |
769 | - if(!isset(self::$translator)) |
|
769 | + if (!isset(self::$translator)) |
|
770 | 770 | { |
771 | 771 | $obj = new Localization_Translator(); |
772 | 772 | $obj->addSources(self::getSources()); |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | { |
792 | 792 | self::requireNamespace($namespace); |
793 | 793 | |
794 | - if(isset(self::$locales[$namespace])) { |
|
794 | + if (isset(self::$locales[$namespace])) { |
|
795 | 795 | return count(self::$locales[$namespace]); |
796 | 796 | } |
797 | 797 | |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | */ |
805 | 805 | protected static function requireNamespace(string $namespace) : void |
806 | 806 | { |
807 | - if(isset(self::$locales[$namespace])) { |
|
807 | + if (isset(self::$locales[$namespace])) { |
|
808 | 808 | return; |
809 | 809 | } |
810 | 810 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | * @param string $label |
828 | 828 | * @return HTML_QuickForm2_Element_Select |
829 | 829 | */ |
830 | - public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
830 | + public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
831 | 831 | { |
832 | 832 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
833 | 833 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * @param string $label |
842 | 842 | * @return HTML_QuickForm2_Element_Select |
843 | 843 | */ |
844 | - public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
844 | + public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
845 | 845 | { |
846 | 846 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
847 | 847 | } |
@@ -858,9 +858,9 @@ discard block |
||
858 | 858 | * @return HTML_QuickForm2_Element_Select |
859 | 859 | * @throws Localization_Exception |
860 | 860 | */ |
861 | - public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
861 | + public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
862 | 862 | { |
863 | - if(empty($label)) { |
|
863 | + if (empty($label)) { |
|
864 | 864 | $label = t('Language'); |
865 | 865 | } |
866 | 866 | |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | |
870 | 870 | $locales = self::getLocalesByNS($namespace); |
871 | 871 | |
872 | - foreach($locales as $locale) { |
|
872 | + foreach ($locales as $locale) { |
|
873 | 873 | $select->addOption($locale->getLabel(), $locale->getName()); |
874 | 874 | } |
875 | 875 | |
@@ -903,14 +903,14 @@ discard block |
||
903 | 903 | |
904 | 904 | public static function addExcludeFolder(string $folderName) : void |
905 | 905 | { |
906 | - if(!in_array($folderName, self::$excludeFolders)) { |
|
906 | + if (!in_array($folderName, self::$excludeFolders)) { |
|
907 | 907 | self::$excludeFolders[] = $folderName; |
908 | 908 | } |
909 | 909 | } |
910 | 910 | |
911 | 911 | public static function addExcludeFile(string $fileName) : void |
912 | 912 | { |
913 | - if(!in_array($fileName, self::$excludeFiles)) { |
|
913 | + if (!in_array($fileName, self::$excludeFiles)) { |
|
914 | 914 | self::$excludeFiles[] = $fileName; |
915 | 915 | } |
916 | 916 | } |
@@ -937,11 +937,11 @@ discard block |
||
937 | 937 | |
938 | 938 | $grouped = array(); |
939 | 939 | |
940 | - foreach($sources as $source) |
|
940 | + foreach ($sources as $source) |
|
941 | 941 | { |
942 | 942 | $group = $source->getGroup(); |
943 | 943 | |
944 | - if(!isset($grouped[$group])) { |
|
944 | + if (!isset($grouped[$group])) { |
|
945 | 945 | $grouped[$group] = array(); |
946 | 946 | } |
947 | 947 | |
@@ -959,8 +959,8 @@ discard block |
||
959 | 959 | public static function sourceExists(string $sourceID) : bool |
960 | 960 | { |
961 | 961 | $sources = self::getSources(); |
962 | - foreach($sources as $source) { |
|
963 | - if($source->getID() == $sourceID) { |
|
962 | + foreach ($sources as $source) { |
|
963 | + if ($source->getID() == $sourceID) { |
|
964 | 964 | return true; |
965 | 965 | } |
966 | 966 | } |
@@ -976,8 +976,8 @@ discard block |
||
976 | 976 | public static function sourceAliasExists(string $sourceAlias) : bool |
977 | 977 | { |
978 | 978 | $sources = self::getSources(); |
979 | - foreach($sources as $source) { |
|
980 | - if($source->getAlias() == $sourceAlias) { |
|
979 | + foreach ($sources as $source) { |
|
980 | + if ($source->getAlias() == $sourceAlias) { |
|
981 | 981 | return true; |
982 | 982 | } |
983 | 983 | } |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | public static function getSourceByID(string $sourceID) : Localization_Source |
996 | 996 | { |
997 | 997 | $sources = self::getSources(); |
998 | - foreach($sources as $source) { |
|
999 | - if($source->getID() == $sourceID) { |
|
998 | + foreach ($sources as $source) { |
|
999 | + if ($source->getID() == $sourceID) { |
|
1000 | 1000 | return $source; |
1001 | 1001 | } |
1002 | 1002 | } |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | public static function getSourceByAlias(string $sourceAlias) : Localization_Source |
1022 | 1022 | { |
1023 | 1023 | $sources = self::getSources(); |
1024 | - foreach($sources as $source) { |
|
1025 | - if($source->getAlias() == $sourceAlias) { |
|
1024 | + foreach ($sources as $source) { |
|
1025 | + if ($source->getAlias() == $sourceAlias) { |
|
1026 | 1026 | return $source; |
1027 | 1027 | } |
1028 | 1028 | } |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | * @throws FileHelper_Exception |
1067 | 1067 | * @throws Localization_Exception |
1068 | 1068 | */ |
1069 | - public static function configure(string $storageFile, string $clientLibrariesFolder='') : void |
|
1069 | + public static function configure(string $storageFile, string $clientLibrariesFolder = '') : void |
|
1070 | 1070 | { |
1071 | 1071 | self::$configured = true; |
1072 | 1072 | |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | |
1076 | 1076 | // only write the client libraries to disk if the folder |
1077 | 1077 | // has been specified. |
1078 | - if(!empty($clientLibrariesFolder)) |
|
1078 | + if (!empty($clientLibrariesFolder)) |
|
1079 | 1079 | { |
1080 | 1080 | self::writeClientFiles(); |
1081 | 1081 | } |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | * @throws Localization_Exception|FileHelper_Exception |
1134 | 1134 | * @see Localization_ClientGenerator |
1135 | 1135 | */ |
1136 | - public static function writeClientFiles(bool $force=false) : void |
|
1136 | + public static function writeClientFiles(bool $force = false) : void |
|
1137 | 1137 | { |
1138 | 1138 | self::createGenerator()->writeFiles($force); |
1139 | 1139 | } |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | */ |
1167 | 1167 | protected static function requireConfiguration() : void |
1168 | 1168 | { |
1169 | - if(!self::$configured) |
|
1169 | + if (!self::$configured) |
|
1170 | 1170 | { |
1171 | 1171 | throw new Localization_Exception( |
1172 | 1172 | 'The localization configuration is incomplete.', |
@@ -1175,7 +1175,7 @@ discard block |
||
1175 | 1175 | ); |
1176 | 1176 | } |
1177 | 1177 | |
1178 | - if(empty(self::$storageFile)) |
|
1178 | + if (empty(self::$storageFile)) |
|
1179 | 1179 | { |
1180 | 1180 | throw new Localization_Exception( |
1181 | 1181 | 'No localization storage file set', |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | ); |
1185 | 1185 | } |
1186 | 1186 | |
1187 | - if(empty(self::$sources)) |
|
1187 | + if (empty(self::$sources)) |
|
1188 | 1188 | { |
1189 | 1189 | throw new Localization_Exception( |
1190 | 1190 | 'No source folders have been defined.', |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | { |
1218 | 1218 | $ids = array(); |
1219 | 1219 | |
1220 | - foreach(self::$sources as $source) { |
|
1220 | + foreach (self::$sources as $source) { |
|
1221 | 1221 | $ids[] = $source->getID(); |
1222 | 1222 | } |
1223 | 1223 | |
@@ -1232,7 +1232,7 @@ discard block |
||
1232 | 1232 | { |
1233 | 1233 | $aliases = array(); |
1234 | 1234 | |
1235 | - foreach(self::$sources as $source) { |
|
1235 | + foreach (self::$sources as $source) { |
|
1236 | 1236 | $aliases[] = $source->getAlias(); |
1237 | 1237 | } |
1238 | 1238 | |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | */ |
1271 | 1271 | public static function getSupportedLocaleNames() : array |
1272 | 1272 | { |
1273 | - if(empty(self::$supportedLocales)) |
|
1273 | + if (empty(self::$supportedLocales)) |
|
1274 | 1274 | { |
1275 | 1275 | self::$supportedLocales = FileHelper::createFileFinder(__DIR__.'/Localization/Locale') |
1276 | 1276 | ->getPHPClassNames(); |
@@ -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) |
@@ -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 $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); |
@@ -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 | } |
@@ -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 | } |