Passed
Push — master ( 7e3913...f58fec )
by Sebastian
05:25
created
src/Localization/Scanner/StringHash.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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());
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Localization/Parser/Token.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@  discard block
 block discarded – undo
8 8
 
9 9
 abstract class Localization_Parser_Token
10 10
 {
11
-   /**
12
-    * @var array|string
13
-    */
11
+    /**
12
+     * @var array|string
13
+     */
14 14
     protected $definition;
15 15
     
16
-   /**
17
-    * @var Localization_Parser_Token|NULL
18
-    */
16
+    /**
17
+     * @var Localization_Parser_Token|NULL
18
+     */
19 19
     protected $parentToken;
20 20
 
21 21
     /**
@@ -98,6 +98,6 @@  discard block
 block discarded – undo
98 98
             'value' => $this->getValue(),
99 99
             'line' => $this->getLine(),
100 100
             'isEncapsedString' => ConvertHelper::bool2string($this->isEncapsedString())
101
-         );
101
+            );
102 102
     }
103 103
 }
Please login to merge, or discard this patch.
src/Localization/Editor/Template/PageScaffold.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -290,8 +290,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Localization/Source/Scanner.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
src/Localization/Source/Folder.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,24 +23,24 @@
 block discarded – undo
23 23
  */
24 24
 class Localization_Source_Folder extends Localization_Source
25 25
 {
26
-   /**
27
-    * The folder under which all translatable files are kept.
28
-    * @var string
29
-    */
26
+    /**
27
+     * The folder under which all translatable files are kept.
28
+     * @var string
29
+     */
30 30
     protected $sourcesFolder;
31 31
     
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     protected $id;
36 36
 
37
-   /**
38
-    * @param string $alias An alias for this source, to recognize it by.
39
-    * @param string $label The human-readable label, used in the editor.
40
-    * @param string $group A human-readable group label to group several sources by. Used in the editor.
41
-    * @param string $storageFolder The folder in which to store the localization files.
42
-    * @param string $sourcesFolder The folder in which to analyze files to find translatable strings.
43
-    */
37
+    /**
38
+     * @param string $alias An alias for this source, to recognize it by.
39
+     * @param string $label The human-readable label, used in the editor.
40
+     * @param string $group A human-readable group label to group several sources by. Used in the editor.
41
+     * @param string $storageFolder The folder in which to store the localization files.
42
+     * @param string $sourcesFolder The folder in which to analyze files to find translatable strings.
43
+     */
44 44
     public function __construct(string $alias, string $label, string $group, string $storageFolder, string $sourcesFolder)
45 45
     {
46 46
         parent::__construct($alias, $label, $group, $storageFolder);
Please login to merge, or discard this patch.
src/Localization/Source.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,27 +27,27 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
src/Localization/Editor.php 3 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -36,54 +36,54 @@  discard block
 block discarded – undo
36 36
     const ERROR_LOCAL_PATH_NOT_FOUND = 40002;
37 37
     const ERROR_STRING_HASH_WITHOUT_TEXT = 40003;
38 38
 
39
-   /**
40
-    * @var string
41
-    */
39
+    /**
40
+     * @var string
41
+     */
42 42
     protected $installPath;
43 43
     
44
-   /**
45
-    * @var Localization_Source[]
46
-    */
44
+    /**
45
+     * @var Localization_Source[]
46
+     */
47 47
     protected $sources;
48 48
     
49
-   /**
50
-    * @var Request
51
-    */
49
+    /**
50
+     * @var Request
51
+     */
52 52
     protected $request;
53 53
     
54
-   /**
55
-    * @var Localization_Source
56
-    */
54
+    /**
55
+     * @var Localization_Source
56
+     */
57 57
     protected $activeSource;
58 58
     
59
-   /**
60
-    * @var Localization_Scanner
61
-    */
59
+    /**
60
+     * @var Localization_Scanner
61
+     */
62 62
     protected $scanner;
63 63
     
64
-   /**
65
-    * @var Localization_Locale[]
66
-    */
64
+    /**
65
+     * @var Localization_Locale[]
66
+     */
67 67
     protected $appLocales = array();
68 68
     
69
-   /**
70
-    * @var Localization_Locale
71
-    */
69
+    /**
70
+     * @var Localization_Locale
71
+     */
72 72
     protected $activeAppLocale;
73 73
     
74
-   /**
75
-    * @var Localization_Editor_Filters
76
-    */
74
+    /**
75
+     * @var Localization_Editor_Filters
76
+     */
77 77
     protected $filters;
78 78
 
79
-   /**
80
-    * @var array<string,string>
81
-    */
79
+    /**
80
+     * @var array<string,string>
81
+     */
82 82
     protected $requestParams = array();
83 83
     
84
-   /**
85
-    * @var string
86
-    */
84
+    /**
85
+     * @var string
86
+     */
87 87
     protected $varPrefix = 'applocalize_';
88 88
 
89 89
     /**
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
         return $this->request;
125 125
     }
126 126
     
127
-   /**
128
-    * Adds a request parameter that will be persisted in all URLs
129
-    * within the editor. This can be used when integrating the
130
-    * editor in an existing page that needs specific request params.
131
-    * 
132
-    * @param string $name
133
-    * @param string $value
134
-    * @return Localization_Editor
135
-    */
127
+    /**
128
+     * Adds a request parameter that will be persisted in all URLs
129
+     * within the editor. This can be used when integrating the
130
+     * editor in an existing page that needs specific request params.
131
+     * 
132
+     * @param string $name
133
+     * @param string $value
134
+     * @return Localization_Editor
135
+     */
136 136
     public function addRequestParam(string $name, string $value) : Localization_Editor
137 137
     {
138 138
         $this->requestParams[$name] = $value;
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
         );
487 487
     }
488 488
     
489
-   /**
490
-    * Sets the application name shown in the main navigation
491
-    * in the user interface.
492
-    * 
493
-    * @param string $name
494
-    * @return Localization_Editor
495
-    */
489
+    /**
490
+     * Sets the application name shown in the main navigation
491
+     * in the user interface.
492
+     * 
493
+     * @param string $name
494
+     * @return Localization_Editor
495
+     */
496 496
     public function setAppName(string $name) : Localization_Editor
497 497
     {
498 498
         $this->setOption('appname', $name);
@@ -522,15 +522,15 @@  discard block
 block discarded – undo
522 522
         return $this;
523 523
     }
524 524
     
525
-   /**
526
-    * Sets an URL that the translators can use to go back to
527
-    * the main application, for example if it is integrated into
528
-    * an existing application.
529
-    * 
530
-    * @param string $url The URL to use for the link
531
-    * @param string $label Label of the link
532
-    * @return Localization_Editor
533
-    */
525
+    /**
526
+     * Sets an URL that the translators can use to go back to
527
+     * the main application, for example if it is integrated into
528
+     * an existing application.
529
+     * 
530
+     * @param string $url The URL to use for the link
531
+     * @param string $label Label of the link
532
+     * @return Localization_Editor
533
+     */
534 534
     public function setBackURL(string $url, string $label) : Localization_Editor
535 535
     {
536 536
         $this->setOption('back-url', $url);
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     public function __construct()
99 99
     {
100 100
         $path = realpath(__DIR__.'/../');
101
-        if($path === false)
101
+        if ($path === false)
102 102
         {
103 103
             throw new Localization_Exception(
104 104
                 'Local path not found',
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
     
147 147
     protected function initSession() : void
148 148
     {
149
-        if(session_status() != PHP_SESSION_ACTIVE) {
149
+        if (session_status() != PHP_SESSION_ACTIVE) {
150 150
             session_start();
151 151
         }
152 152
         
153
-        if(!isset($_SESSION['localization_messages'])) {
153
+        if (!isset($_SESSION['localization_messages'])) {
154 154
             $_SESSION['localization_messages'] = array();
155 155
         }
156 156
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     {
168 168
         $this->sources = Localization::getSources();
169 169
         
170
-        if(empty($this->sources)) 
170
+        if (empty($this->sources)) 
171 171
         {
172 172
             throw new Localization_Exception(
173 173
                 'Cannot start editor: no sources defined.',
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         }
178 178
         
179 179
         $activeID = $this->request->registerParam($this->getVarName('source'))->setEnum(Localization::getSourceIDs())->get();
180
-        if(empty($activeID)) {
180
+        if (empty($activeID)) {
181 181
             $activeID = $this->getDefaultSourceID();
182 182
         }
183 183
         
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     protected function getDefaultSourceID() : string
188 188
     {
189 189
         $default = $this->getOption('default-source');
190
-        if(!empty($default) && Localization::sourceAliasExists($default)) {
190
+        if (!empty($default) && Localization::sourceAliasExists($default)) {
191 191
             return Localization::getSourceByAlias($default)->getID();
192 192
         }
193 193
         
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
         $names = array();
200 200
         
201 201
         $locales = Localization::getAppLocales();
202
-        foreach($locales as $locale) {
203
-            if(!$locale->isNative()) {
202
+        foreach ($locales as $locale) {
203
+            if (!$locale->isNative()) {
204 204
                 $this->appLocales[] = $locale;
205 205
                 $names[] = $locale->getName();
206 206
             }
207 207
         }
208 208
         
209 209
         // use the default locale if no other is available.
210
-        if(empty($names)) {
210
+        if (empty($names)) {
211 211
             $this->activeAppLocale = Localization::getAppLocale();
212 212
             return;
213 213
         }
214 214
        
215 215
         $activeID = $this->request->registerParam($this->getVarName('locale'))->setEnum($names)->get();
216
-        if(empty($activeID)) {
216
+        if (empty($activeID)) {
217 217
             $activeID = $this->appLocales[0]->getName();
218 218
         }
219 219
         
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
         
255 255
         $this->filters = new Localization_Editor_Filters($this);
256 256
         
257
-        if($this->request->getBool($this->getVarName('scan'))) 
257
+        if ($this->request->getBool($this->getVarName('scan'))) 
258 258
         {
259 259
             $this->executeScan();
260 260
         } 
261
-        else if($this->request->getBool($this->getVarName('save'))) 
261
+        else if ($this->request->getBool($this->getVarName('save'))) 
262 262
         {
263 263
             $this->executeSave();
264 264
         }
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
         
313 313
         $result = array();
314 314
         
315
-        foreach($strings as $string)
315
+        foreach ($strings as $string)
316 316
         {
317
-            if($this->filters->isStringMatch($string)) {
317
+            if ($this->filters->isStringMatch($string)) {
318 318
                 $result[] = $string;
319 319
             }
320 320
         }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
         return $this->activeAppLocale;
352 352
     }
353 353
 
354
-    public function getPaginationURL(int $page, array $params=array()) : string
354
+    public function getPaginationURL(int $page, array $params = array()) : string
355 355
     {
356 356
         $params[$this->getVarName('page')] = $page;
357 357
         
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
         $result = array();
364 364
         preg_match_all('/%[0-9]+d|%s|%[0-9]+\$s/i', $string, $result, PREG_PATTERN_ORDER);
365 365
 
366
-        if(isset($result[0]) && !empty($result[0])) {
366
+        if (isset($result[0]) && !empty($result[0])) {
367 367
             return $result[0];
368 368
         }
369 369
         
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
         echo $this->render();
376 376
     }
377 377
     
378
-    public function getSourceURL(Localization_Source $source, array $params=array()) : string
378
+    public function getSourceURL(Localization_Source $source, array $params = array()) : string
379 379
     {
380 380
         $params[$this->getVarName('source')] = $source->getID();
381 381
         
382 382
         return $this->getURL($params);
383 383
     }
384 384
     
385
-    public function getLocaleURL(Localization_Locale $locale, array $params=array()) : string
385
+    public function getLocaleURL(Localization_Locale $locale, array $params = array()) : string
386 386
     {
387 387
         $params[$this->getVarName('locale')] = $locale->getName();
388 388
         
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
         return $this->getSourceURL($this->activeSource, array($this->getVarName('warnings') => 'yes'));
400 400
     }
401 401
     
402
-    public function getURL(array $params=array()) : string
402
+    public function getURL(array $params = array()) : string
403 403
     {
404 404
         $persist = $this->getRequestParams();
405 405
         
406
-        foreach($persist as $name => $value) {
407
-            if(!isset($params[$name])) {
406
+        foreach ($persist as $name => $value) {
407
+            if (!isset($params[$name])) {
408 408
                 $params[$name] = $value;
409 409
             }
410 410
         }
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
         $translator = Localization::getTranslator($this->activeAppLocale);
442 442
         
443 443
         $strings = $data[$this->getVarName('strings')];
444
-        foreach($strings as $hash => $text) 
444
+        foreach ($strings as $hash => $text) 
445 445
         {
446 446
             $text = trim($text);
447 447
             
448
-            if(empty($text)) {
448
+            if (empty($text)) {
449 449
                 continue;
450 450
             } 
451 451
             
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         $this->redirect($this->getURL());
466 466
     }
467 467
     
468
-    protected function addMessage(string $message, string $type=self::MESSAGE_INFO) : void
468
+    protected function addMessage(string $message, string $type = self::MESSAGE_INFO) : void
469 469
     {
470 470
         $_SESSION['localization_messages'][] = array(
471 471
             'text' => $message,
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
     public function getAppName() : string
503 503
     {
504 504
         $name = $this->getOption('appname');
505
-        if(!empty($name)) {
505
+        if (!empty($name)) {
506 506
             return $name;
507 507
         }
508 508
         
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -257,8 +257,7 @@
 block discarded – undo
257 257
         if($this->request->getBool($this->getVarName('scan'))) 
258 258
         {
259 259
             $this->executeScan();
260
-        } 
261
-        else if($this->request->getBool($this->getVarName('save'))) 
260
+        } else if($this->request->getBool($this->getVarName('save'))) 
262 261
         {
263 262
             $this->executeSave();
264 263
         }
Please login to merge, or discard this patch.