Test Failed
Push — master ( c19a70...4a5f5f )
by Sebastian
05:20
created
src/Localization/Scanner/StringHash.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $entries = array();
52 52
        
53
-        foreach($this->strings as $string) {
53
+        foreach ($this->strings as $string) {
54 54
             $entries[] = $string->toArray();
55 55
         }
56 56
         
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $amount = 0;
72 72
         
73
-        foreach($this->strings as $string) {
74
-            if($string->isFile()) {
73
+        foreach ($this->strings as $string) {
74
+            if ($string->isFile()) {
75 75
                 $amount++;
76 76
             }
77 77
         }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
     
87 87
     public function hasLanguageType(string $type) : bool
88 88
     {
89
-        foreach($this->strings as $string) {
90
-            if($string->getLanguageType() == $type) {
89
+        foreach ($this->strings as $string) {
90
+            if ($string->getLanguageType() == $type) {
91 91
                 return true;
92 92
             }
93 93
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     
98 98
     public function getText() : ?Text
99 99
     {
100
-        if(isset($this->strings[0])) {
100
+        if (isset($this->strings[0])) {
101 101
             return $this->strings[0]->getText();
102 102
         }
103 103
         
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         $translator = Localization::getTranslator();
130 130
         $text = $translator->getHashTranslation($this->getHash());
131 131
         
132
-        if($text !== null) {
132
+        if ($text !== null) {
133 133
             return $text;
134 134
         }
135 135
         
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
     {
145 145
         $files = array();
146 146
         
147
-        foreach($this->strings as $string) 
147
+        foreach ($this->strings as $string) 
148 148
         {
149
-            if(!$string->isFile()) {
149
+            if (!$string->isFile()) {
150 150
                 continue;
151 151
             }
152 152
             
153 153
             $file = $string->getSourceFile();
154
-            if(!in_array($file, $files)) {
154
+            if (!in_array($file, $files)) {
155 155
                 $files[] = $file;
156 156
             }
157 157
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         $files = $this->getFiles();
171 171
         $result = array();
172 172
         
173
-        foreach($files as $path) {
173
+        foreach ($files as $path) {
174 174
             $result[] = basename($path);
175 175
         }
176 176
         
Please login to merge, or discard this patch.
src/Localization/Editor.php 2 patches
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -36,54 +36,54 @@  discard block
 block discarded – undo
36 36
     
37 37
     const ERROR_NO_SOURCES_AVAILABLE = 40001;
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 \AppUtils\Request
51
-    */
49
+    /**
50
+     * @var \AppUtils\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 string[]string
81
-    */
79
+    /**
80
+     * @var 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
     public function __construct()
@@ -102,15 +102,15 @@  discard block
 block discarded – undo
102 102
         return $this->request;
103 103
     }
104 104
     
105
-   /**
106
-    * Adds a request parameter that will be persisted in all URLs
107
-    * within the editor. This can be used when integrating the
108
-    * editor in an existing page that needs specific request params.
109
-    * 
110
-    * @param string $name
111
-    * @param string $value
112
-    * @return Localization_Editor
113
-    */
105
+    /**
106
+     * Adds a request parameter that will be persisted in all URLs
107
+     * within the editor. This can be used when integrating the
108
+     * editor in an existing page that needs specific request params.
109
+     * 
110
+     * @param string $name
111
+     * @param string $value
112
+     * @return Localization_Editor
113
+     */
114 114
     public function addRequestParam(string $name, string $value) : Localization_Editor
115 115
     {
116 116
         $this->requestParams[$name] = $value;
@@ -264,34 +264,34 @@  discard block
 block discarded – undo
264 264
                                 	</a>
265 265
                                     <div class="dropdown-menu" aria-labelledby="dropdown01">
266 266
                                     	<?php 
267
-                                    	    foreach($this->sources as $source)
268
-                                    	    {
269
-                                    	       ?>
267
+                                            foreach($this->sources as $source)
268
+                                            {
269
+                                                ?>
270 270
                                         			<a class="dropdown-item" href="<?php echo $this->getSourceURL($source) ?>">
271 271
                                         				<?php 
272
-                                            				if($source->getID() === $this->activeSource->getID()) 
273
-                                            				{
274
-                                            				    ?>
272
+                                                            if($source->getID() === $this->activeSource->getID()) 
273
+                                                            {
274
+                                                                ?>
275 275
                                             				    	<b><?php echo $source->getLabel() ?></b>
276 276
                                         				    	<?php 
277
-                                            				}
278
-                                            				else
279
-                                            				{
280
-                                            				    echo $source->getLabel();
281
-                                            				}
282
-                                        				?>
277
+                                                            }
278
+                                                            else
279
+                                                            {
280
+                                                                echo $source->getLabel();
281
+                                                            }
282
+                                                        ?>
283 283
                                         				<?php
284
-                                        				    $untranslated = $source->countUntranslated($this->scanner);
285
-                                        				    if($untranslated > 0) {
286
-                                        				        ?>
284
+                                                            $untranslated = $source->countUntranslated($this->scanner);
285
+                                                            if($untranslated > 0) {
286
+                                                                ?>
287 287
                                         				        	(<span class="text-danger" title="<?php ptex('%1$s texts have not been translated in this text source.', 'Amount of texts', $untranslated) ?>"><?php echo $untranslated ?></span>)
288 288
                                 				            	<?php 
289
-                                        				    }
290
-                                    				    ?>
289
+                                                            }
290
+                                                        ?>
291 291
                                     				</a>
292 292
                                     			<?php 
293
-                                    	    }
294
-                                	    ?>
293
+                                            }
294
+                                        ?>
295 295
                                     </div>
296 296
                                 </li>
297 297
                                 <li class="nav-item dropdown">
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
                                 	</a>
301 301
                                     <div class="dropdown-menu" aria-labelledby="dropdown01">
302 302
                                     	<?php 
303
-                                    	    foreach($this->appLocales as $locale)
304
-                                    	    {
305
-                                    	       ?>
303
+                                            foreach($this->appLocales as $locale)
304
+                                            {
305
+                                                ?>
306 306
                                         			<a class="dropdown-item" href="<?php echo $this->getLocaleURL($locale) ?>">
307 307
                                         				<?php echo $locale->getLabel() ?>
308 308
                                     				</a>
309 309
                                     			<?php 
310
-                                    	    }
311
-                                	    ?>
310
+                                            }
311
+                                        ?>
312 312
                                     </div>
313 313
                                 </li>
314 314
                                 <li class="nav-item">
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
                                     </a>
319 319
                     			</li>
320 320
                     			<?php 
321
-                        			if($this->scanner->hasWarnings()) {
322
-                        			    ?>
321
+                                    if($this->scanner->hasWarnings()) {
322
+                                        ?>
323 323
                         			    	<li class="nav-item">
324 324
                         			    		<a href="<?php echo $this->getWarningsURL() ?>">
325 325
                             			    		<span class="badge badge-warning" title="<?php pts('The last scan for translateable texts reported warnings.'); pts('Click for details.'); ?>" data-toggle="tooltip">
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
                         			    		</a>
330 330
                         			    	</li>
331 331
                         			    <?php 
332
-                        			}
333
-                    			?>
332
+                                    }
333
+                                ?>
334 334
                             </ul>
335 335
                         <?php 
336 336
                     }
@@ -346,36 +346,36 @@  discard block
 block discarded – undo
346 346
                         	</a>
347 347
                     	<?php 
348 348
                     }
349
-            	?>
349
+                ?>
350 350
     		</div>
351 351
 		</nav>
352 352
 		<main role="main" class="container">
353 353
 			<div>
354 354
     			<?php 
355
-    			    if(empty($this->appLocales))
356
-    			    {
357
-    			        ?>
355
+                    if(empty($this->appLocales))
356
+                    {
357
+                        ?>
358 358
     			        	<div class="alert alert-danger">
359 359
     			        		<i class="fa fa-exclamation-triangle"></i>
360 360
     			        		<b><?php pt('Nothing to translate:') ?></b>
361 361
     			        		<?php pt('No application locales were added to translate to.') ?>
362 362
     			        	</div>
363 363
     			        <?php 
364
-    			    }
365
-    			    else if($this->request->getBool($this->getVarName('warnings')))
366
-    			    {
367
-    			        echo $this->renderWarnings();
368
-    			    }
369
-    			    else
370
-    			    {
371
-    			        ?>
364
+                    }
365
+                    else if($this->request->getBool($this->getVarName('warnings')))
366
+                    {
367
+                        echo $this->renderWarnings();
368
+                    }
369
+                    else
370
+                    {
371
+                        ?>
372 372
             				<h1><?php echo $this->activeSource->getLabel() ?></h1>
373 373
             				<?php 
374
-                				if(!empty($_SESSION['localization_messages'])) 
375
-                				{
376
-                				    foreach($_SESSION['localization_messages'] as $def)
377
-                				    {
378
-                				        ?>
374
+                                if(!empty($_SESSION['localization_messages'])) 
375
+                                {
376
+                                    foreach($_SESSION['localization_messages'] as $def)
377
+                                    {
378
+                                        ?>
379 379
                 				        	<div class="alert alert-<?php echo $def['type'] ?>" role="alert">
380 380
                                         		<?php echo $def['text'] ?>
381 381
                                         		<button type="button" class="close" data-dismiss="alert" aria-label="<?php pt('Close') ?>" title="<?php pt('Dismiss this message.') ?>" data-toggle="tooltip">
@@ -383,28 +383,28 @@  discard block
 block discarded – undo
383 383
             									</button>
384 384
                                         	</div>
385 385
             				        	<?php 
386
-                				    }
386
+                                    }
387 387
                 				    
388
-                				    // reset the messages after having displayed them
389
-                				    $_SESSION['localization_messages'] = array();
390
-                				}
391
-            				?>
388
+                                    // reset the messages after having displayed them
389
+                                    $_SESSION['localization_messages'] = array();
390
+                                }
391
+                            ?>
392 392
             				<p>
393 393
             					<?php 
394
-            				        pt(
395
-                					    'You are translating to %1$s', 
396
-                					    '<span class="badge badge-info">'.
397
-                					       $this->activeAppLocale->getLabel().
398
-                				        '</span>'
394
+                                    pt(
395
+                                        'You are translating to %1$s', 
396
+                                        '<span class="badge badge-info">'.
397
+                                            $this->activeAppLocale->getLabel().
398
+                                        '</span>'
399 399
                                     );
400
-            				    ?><br>
400
+                                ?><br>
401 401
             					<?php pt('Found %1$s texts to translate.', $this->activeSource->countUntranslated($this->scanner)) ?>
402 402
             				</p>
403 403
             				<br>
404 404
             				<?php
405
-                				if(!$this->scanner->isScanAvailable()) 
406
-                				{
407
-                				    ?>
405
+                                if(!$this->scanner->isScanAvailable()) 
406
+                                {
407
+                                    ?>
408 408
                 				    	<div class="alert alert-primary" role="alert">
409 409
                                         	<b><?php pt('No texts found:') ?></b> 
410 410
                                         	<?php pt('The source folders have not been scanned yet.') ?>
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
                                             </a>
417 417
                                         </p>
418 418
                 				    <?php 
419
-                				}
420
-                				else
421
-                				{
422
-                				    echo $this->filters->renderForm();
423
-                				    echo $this->renderList();
424
-                				}
419
+                                }
420
+                                else
421
+                                {
422
+                                    echo $this->filters->renderForm();
423
+                                    echo $this->renderList();
424
+                                }
425 425
             				
426
-        				}
427
-    				?>
426
+                        }
427
+                    ?>
428 428
 			</div>
429 429
 		</main>
430 430
 	</body>
@@ -442,22 +442,22 @@  discard block
 block discarded – undo
442 442
         	<h1><?php pt('Warnings') ?></h1>
443 443
         	<p class="abstract">
444 444
         		<?php 
445
-        		    pts('The following shows all texts where the system decided that they cannot be translated.');
446
-       		    ?>
445
+                    pts('The following shows all texts where the system decided that they cannot be translated.');
446
+                    ?>
447 447
         	</p>
448 448
         	<dl>
449 449
         		<?php 
450
-        		    $warnings = $this->scanner->getWarnings();
450
+                    $warnings = $this->scanner->getWarnings();
451 451
         		    
452
-        		    foreach($warnings as $warning)
453
-        		    {
454
-        		        ?>
452
+                    foreach($warnings as $warning)
453
+                    {
454
+                        ?>
455 455
         		        	<dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt>
456 456
         		        	<dd><?php echo $warning->getMessage() ?></dd>
457 457
         		        <?php 
458
-        		    }
458
+                    }
459 459
         		        
460
-        		?>
460
+                ?>
461 461
         	</dl>
462 462
     	<?php 
463 463
     	
@@ -526,13 +526,13 @@  discard block
 block discarded – undo
526 526
 			<form method="post">
527 527
 				<div class="form-hiddens">
528 528
 					<?php 
529
-    					$params = $this->getRequestParams();
530
-    					foreach($params as $name => $value) {
531
-    					    ?>
529
+                        $params = $this->getRequestParams();
530
+                        foreach($params as $name => $value) {
531
+                            ?>
532 532
     					    	<input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>">
533 533
     					    <?php 
534
-    					}
535
-					?>
534
+                        }
535
+                    ?>
536 536
 				</div>
537 537
             	<table class="table table-hover">
538 538
     				<thead>
@@ -545,20 +545,20 @@  discard block
 block discarded – undo
545 545
     				</thead>
546 546
     				<tbody>
547 547
     					<?php 
548
-    					    foreach($keep as $string)
549
-    					    {
550
-    					        $this->renderListEntry($string);
551
-    					    }
552
-    					?>
548
+                            foreach($keep as $string)
549
+                            {
550
+                                $this->renderListEntry($string);
551
+                            }
552
+                        ?>
553 553
     				</tbody>
554 554
     			</table>
555 555
     			<?php 
556
-        			if($pager->hasPages()) 
557
-        			{
558
-        			    $prevUrl = $this->getPaginationURL($pager->getPreviousPage());
559
-        			    $nextUrl = $this->getPaginationURL($pager->getNextPage());
556
+                    if($pager->hasPages()) 
557
+                    {
558
+                        $prevUrl = $this->getPaginationURL($pager->getPreviousPage());
559
+                        $nextUrl = $this->getPaginationURL($pager->getNextPage());
560 560
         			    
561
-        			    ?>
561
+                        ?>
562 562
         			    	<nav aria-label="<?php pt('Navigate available pages of texts.') ?>">
563 563
                                 <ul class="pagination">
564 564
                                     <li class="page-item">
@@ -567,20 +567,20 @@  discard block
 block discarded – undo
567 567
                                 		</a>
568 568
                             		</li>
569 569
                             		<?php 
570
-                            		    $numbers = $pager->getPageNumbers();
571
-                            		    foreach($numbers as $number) 
572
-                            		    {
573
-                            		        $url = $this->getPaginationURL($number);
570
+                                        $numbers = $pager->getPageNumbers();
571
+                                        foreach($numbers as $number) 
572
+                                        {
573
+                                            $url = $this->getPaginationURL($number);
574 574
                             		        
575
-                            		        ?>
575
+                                            ?>
576 576
                             		        	<li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>">
577 577
                             		        		<a class="page-link" href="<?php echo $url ?>">
578 578
                             		        			<?php echo $number ?>
579 579
                         		        			</a>
580 580
                         		        		</li>
581 581
                             		        <?php 
582
-                            		    }
583
-                            		?>
582
+                                        }
583
+                                    ?>
584 584
                                     <li class="page-item">
585 585
                                     	<a class="page-link" href="<?php echo $nextUrl ?>">
586 586
                                     		<i class="fa fa-arrow-right"></i>
@@ -589,8 +589,8 @@  discard block
 block discarded – undo
589 589
                                 </ul>
590 590
                             </nav>
591 591
         			    <?php 
592
-        			}
593
-    			?>
592
+                    }
593
+                ?>
594 594
 				<br>
595 595
 				<p>
596 596
 					<button type="submit" name="<?php echo $this->getVarName('save') ?>" value="yes" class="btn btn-primary">
@@ -661,48 +661,48 @@  discard block
 block discarded – undo
661 661
         			<div class="files-list">
662 662
             			<p>
663 663
             				<?php 
664
-            				    $totalFiles = count($files);
664
+                                $totalFiles = count($files);
665 665
             				    
666
-            				    if($totalFiles == 1)
667
-            				    {
668
-            				        pt('Found in a single file:');
669
-            				    }
670
-            				    else
671
-            				    {
672
-            				        pt('Found in %1$s files:', $totalFiles);
673
-            				    }
674
-    				        ?>
666
+                                if($totalFiles == 1)
667
+                                {
668
+                                    pt('Found in a single file:');
669
+                                }
670
+                                else
671
+                                {
672
+                                    pt('Found in %1$s files:', $totalFiles);
673
+                                }
674
+                            ?>
675 675
             			</p>
676 676
         				<div class="files-scroller">
677 677
                 			<ul>
678 678
                 				<?php 
679
-                				    $locations = $string->getStrings();
679
+                                    $locations = $string->getStrings();
680 680
                 				    
681
-                    				foreach($locations as $location) 
682
-                    				{
683
-                    				    $file = $location->getSourceFile();
684
-                    				    $line = $location->getLine();
681
+                                    foreach($locations as $location) 
682
+                                    {
683
+                                        $file = $location->getSourceFile();
684
+                                        $line = $location->getLine();
685 685
                     				    
686
-                    				    $icon = '';
686
+                                        $icon = '';
687 687
                     				    
688
-                    				    $ext = \AppUtils\FileHelper::getExtension($file);
688
+                                        $ext = \AppUtils\FileHelper::getExtension($file);
689 689
                     				    
690
-                    				    if($ext == 'php') {
691
-                    				        $icon = 'fab fa-php';
692
-                    				    } else if($ext == 'js') {
693
-                    				        $icon = 'fab fa-js-square';
694
-                    				    } else {
695
-                    				        $icon = 'fas fa-file-code';
696
-                    				    }
690
+                                        if($ext == 'php') {
691
+                                            $icon = 'fab fa-php';
692
+                                        } else if($ext == 'js') {
693
+                                            $icon = 'fab fa-js-square';
694
+                                        } else {
695
+                                            $icon = 'fas fa-file-code';
696
+                                        }
697 697
                     				    
698
-                    				    ?>
698
+                                        ?>
699 699
                     				    	<li>
700 700
                     				    		<i class="<?php echo $icon ?>"></i>
701 701
                     				    		<?php echo $file ?><span class="line-number">:<?php echo $line ?></span>
702 702
                     				    	</li>
703 703
                     				    <?php 
704
-                    				}
705
-                				?>
704
+                                    }
705
+                                ?>
706 706
                 			</ul>
707 707
             			</div>
708 708
         			</div>
@@ -912,13 +912,13 @@  discard block
 block discarded – undo
912 912
         );
913 913
     }
914 914
     
915
-   /**
916
-    * Sets the application name shown in the main navigation
917
-    * in the user interface.
918
-    * 
919
-    * @param string $name
920
-    * @return Localization_Editor
921
-    */
915
+    /**
916
+     * Sets the application name shown in the main navigation
917
+     * in the user interface.
918
+     * 
919
+     * @param string $name
920
+     * @return Localization_Editor
921
+     */
922 922
     public function setAppName(string $name) : Localization_Editor
923 923
     {
924 924
         $this->setOption('appname', $name);
@@ -935,27 +935,27 @@  discard block
 block discarded – undo
935 935
         return t('Localization editor');
936 936
     }
937 937
 
938
-   /**
939
-    * Selects the default source to use if none has been 
940
-    * explicitly selected.
941
-    * 
942
-    * @param string $sourceID
943
-    */
938
+    /**
939
+     * Selects the default source to use if none has been 
940
+     * explicitly selected.
941
+     * 
942
+     * @param string $sourceID
943
+     */
944 944
     public function selectDefaultSource(string $sourceID) : Localization_Editor
945 945
     {
946 946
         $this->setOption('default-source', $sourceID);
947 947
         return $this;
948 948
     }
949 949
     
950
-   /**
951
-    * Sets an URL that the translators can use to go back to
952
-    * the main application, for example if it is integrated into
953
-    * an existing application.
954
-    * 
955
-    * @param string $url The URL to use for the link
956
-    * @param string $label Label of the link
957
-    * @return Localization_Editor
958
-    */
950
+    /**
951
+     * Sets an URL that the translators can use to go back to
952
+     * the main application, for example if it is integrated into
953
+     * an existing application.
954
+     * 
955
+     * @param string $url The URL to use for the link
956
+     * @param string $label Label of the link
957
+     * @return Localization_Editor
958
+     */
959 959
     public function setBackURL(string $url, string $label) : Localization_Editor
960 960
     {
961 961
         $this->setOption('back-url', $url);
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
     
130 130
     protected function initSession()
131 131
     {
132
-        if(session_status() != PHP_SESSION_ACTIVE) {
132
+        if (session_status() != PHP_SESSION_ACTIVE) {
133 133
             session_start();
134 134
         }
135 135
         
136
-        if(!isset($_SESSION['localization_messages'])) {
136
+        if (!isset($_SESSION['localization_messages'])) {
137 137
             $_SESSION['localization_messages'] = array();
138 138
         }
139 139
     }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     {
148 148
         $this->sources = Localization::getSources();
149 149
         
150
-        if(empty($this->sources)) 
150
+        if (empty($this->sources)) 
151 151
         {
152 152
             throw new Localization_Exception(
153 153
                 'Cannot start editor: no sources defined.',
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         }
158 158
         
159 159
         $activeID = $this->request->registerParam($this->getVarName('source'))->setEnum(Localization::getSourceIDs())->get();
160
-        if(empty($activeID)) {
160
+        if (empty($activeID)) {
161 161
             $activeID = $this->getDefaultSourceID();
162 162
         }
163 163
         
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     protected function getDefaultSourceID()
168 168
     {
169 169
         $default = $this->getOption('default-source');
170
-        if(!empty($default) && Localization::sourceAliasExists($default)) {
170
+        if (!empty($default) && Localization::sourceAliasExists($default)) {
171 171
             return Localization::getSourceByAlias($default)->getID();
172 172
         }
173 173
         
@@ -179,21 +179,21 @@  discard block
 block discarded – undo
179 179
         $names = array();
180 180
         
181 181
         $locales = Localization::getAppLocales();
182
-        foreach($locales as $locale) {
183
-            if(!$locale->isNative()) {
182
+        foreach ($locales as $locale) {
183
+            if (!$locale->isNative()) {
184 184
                 $this->appLocales[] = $locale;
185 185
                 $names[] = $locale->getName();
186 186
             }
187 187
         }
188 188
         
189 189
         // use the default locale if no other is available.
190
-        if(empty($names)) {
190
+        if (empty($names)) {
191 191
             $this->activeAppLocale = Localization::getAppLocale();
192 192
             return;
193 193
         }
194 194
        
195 195
         $activeID = $this->request->registerParam($this->getVarName('locale'))->setEnum($names)->get();
196
-        if(empty($activeID)) {
196
+        if (empty($activeID)) {
197 197
             $activeID = $this->appLocales[0]->getName();
198 198
         }
199 199
         
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
         
209 209
         $this->filters = new Localization_Editor_Filters($this);
210 210
         
211
-        if($this->request->getBool($this->getVarName('scan'))) 
211
+        if ($this->request->getBool($this->getVarName('scan'))) 
212 212
         {
213 213
             $this->executeScan();
214 214
         } 
215
-        else if($this->request->getBool($this->getVarName('save'))) 
215
+        else if ($this->request->getBool($this->getVarName('save'))) 
216 216
         {
217 217
             $this->executeSave();
218 218
         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
             </button>
255 255
             <div class="collapse navbar-collapse" id="navbarsExampleDefault">
256 256
                 <?php 
257
-                    if(!empty($this->appLocales))
257
+                    if (!empty($this->appLocales))
258 258
                     {
259 259
                         ?>
260 260
                             <ul class="navbar-nav mr-auto">
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
                                 	</a>
265 265
                                     <div class="dropdown-menu" aria-labelledby="dropdown01">
266 266
                                     	<?php 
267
-                                    	    foreach($this->sources as $source)
267
+                                    	    foreach ($this->sources as $source)
268 268
                                     	    {
269 269
                                     	       ?>
270 270
                                         			<a class="dropdown-item" href="<?php echo $this->getSourceURL($source) ?>">
271 271
                                         				<?php 
272
-                                            				if($source->getID() === $this->activeSource->getID()) 
272
+                                            				if ($source->getID() === $this->activeSource->getID()) 
273 273
                                             				{
274 274
                                             				    ?>
275 275
                                             				    	<b><?php echo $source->getLabel() ?></b>
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                                         				?>
283 283
                                         				<?php
284 284
                                         				    $untranslated = $source->countUntranslated($this->scanner);
285
-                                        				    if($untranslated > 0) {
285
+                                        				    if ($untranslated > 0) {
286 286
                                         				        ?>
287 287
                                         				        	(<span class="text-danger" title="<?php ptex('%1$s texts have not been translated in this text source.', 'Amount of texts', $untranslated) ?>"><?php echo $untranslated ?></span>)
288 288
                                 				            	<?php 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
                                 	</a>
301 301
                                     <div class="dropdown-menu" aria-labelledby="dropdown01">
302 302
                                     	<?php 
303
-                                    	    foreach($this->appLocales as $locale)
303
+                                    	    foreach ($this->appLocales as $locale)
304 304
                                     	    {
305 305
                                     	       ?>
306 306
                                         			<a class="dropdown-item" href="<?php echo $this->getLocaleURL($locale) ?>">
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
                                     </a>
319 319
                     			</li>
320 320
                     			<?php 
321
-                        			if($this->scanner->hasWarnings()) {
321
+                        			if ($this->scanner->hasWarnings()) {
322 322
                         			    ?>
323 323
                         			    	<li class="nav-item">
324 324
                         			    		<a href="<?php echo $this->getWarningsURL() ?>">
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                 ?>
338 338
                 <?php 
339 339
                     $backURL = $this->getOption('back-url');
340
-                    if(!empty($backURL)) 
340
+                    if (!empty($backURL)) 
341 341
                     {
342 342
                         ?>
343 343
                             <a href="<?php echo $backURL ?>" class="btn btn-light btn-sm">
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 		<main role="main" class="container">
353 353
 			<div>
354 354
     			<?php 
355
-    			    if(empty($this->appLocales))
355
+    			    if (empty($this->appLocales))
356 356
     			    {
357 357
     			        ?>
358 358
     			        	<div class="alert alert-danger">
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     			        	</div>
363 363
     			        <?php 
364 364
     			    }
365
-    			    else if($this->request->getBool($this->getVarName('warnings')))
365
+    			    else if ($this->request->getBool($this->getVarName('warnings')))
366 366
     			    {
367 367
     			        echo $this->renderWarnings();
368 368
     			    }
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
     			        ?>
372 372
             				<h1><?php echo $this->activeSource->getLabel() ?></h1>
373 373
             				<?php 
374
-                				if(!empty($_SESSION['localization_messages'])) 
374
+                				if (!empty($_SESSION['localization_messages'])) 
375 375
                 				{
376
-                				    foreach($_SESSION['localization_messages'] as $def)
376
+                				    foreach ($_SESSION['localization_messages'] as $def)
377 377
                 				    {
378 378
                 				        ?>
379 379
                 				        	<div class="alert alert-<?php echo $def['type'] ?>" role="alert">
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
             				</p>
403 403
             				<br>
404 404
             				<?php
405
-                				if(!$this->scanner->isScanAvailable()) 
405
+                				if (!$this->scanner->isScanAvailable()) 
406 406
                 				{
407 407
                 				    ?>
408 408
                 				    	<div class="alert alert-primary" role="alert">
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
         		<?php 
450 450
         		    $warnings = $this->scanner->getWarnings();
451 451
         		    
452
-        		    foreach($warnings as $warning)
452
+        		    foreach ($warnings as $warning)
453 453
         		    {
454 454
         		        ?>
455 455
         		        	<dt><?php echo FileHelper::relativizePathByDepth($warning->getFile(), 3) ?>:<?php echo $warning->getLine() ?></dt>
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
         
471 471
         $result = array();
472 472
         
473
-        foreach($strings as $string)
473
+        foreach ($strings as $string)
474 474
         {
475
-            if($this->filters->isStringMatch($string)) {
475
+            if ($this->filters->isStringMatch($string)) {
476 476
                 $result[] = $string;
477 477
             }
478 478
         }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
     {
506 506
         $strings = $this->getFilteredStrings();
507 507
         
508
-        if(empty($strings))
508
+        if (empty($strings))
509 509
         {
510 510
             ?>
511 511
             	<div class="alert alert-info">
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 				<div class="form-hiddens">
528 528
 					<?php 
529 529
     					$params = $this->getRequestParams();
530
-    					foreach($params as $name => $value) {
530
+    					foreach ($params as $name => $value) {
531 531
     					    ?>
532 532
     					    	<input type="hidden" name="<?php echo $name ?>" value="<?php echo $value ?>">
533 533
     					    <?php 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
     				</thead>
546 546
     				<tbody>
547 547
     					<?php 
548
-    					    foreach($keep as $string)
548
+    					    foreach ($keep as $string)
549 549
     					    {
550 550
     					        $this->renderListEntry($string);
551 551
     					    }
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
     				</tbody>
554 554
     			</table>
555 555
     			<?php 
556
-        			if($pager->hasPages()) 
556
+        			if ($pager->hasPages()) 
557 557
         			{
558 558
         			    $prevUrl = $this->getPaginationURL($pager->getPreviousPage());
559 559
         			    $nextUrl = $this->getPaginationURL($pager->getNextPage());
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
                             		</li>
569 569
                             		<?php 
570 570
                             		    $numbers = $pager->getPageNumbers();
571
-                            		    foreach($numbers as $number) 
571
+                            		    foreach ($numbers as $number) 
572 572
                             		    {
573 573
                             		        $url = $this->getPaginationURL($number);
574 574
                             		        
575 575
                             		        ?>
576
-                            		        	<li class="page-item <?php if($pager->isCurrentPage($number)) { echo 'active'; } ?>">
576
+                            		        	<li class="page-item <?php if ($pager->isCurrentPage($number)) { echo 'active'; } ?>">
577 577
                             		        		<a class="page-link" href="<?php echo $url ?>">
578 578
                             		        			<?php echo $number ?>
579 579
                         		        			</a>
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
         <?php 
604 604
     }
605 605
     
606
-    protected function getPaginationURL(int $page, $params=array())
606
+    protected function getPaginationURL(int $page, $params = array())
607 607
     {
608 608
         $params[$this->getVarName('page')] = $page;
609 609
         
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
         $text = $string->getText();
617 617
         
618 618
         $previewText = $string->getTranslatedText();
619
-        if(empty($previewText)) {
619
+        if (empty($previewText)) {
620 620
             $previewText = $text->getText();
621 621
         }
622 622
         
623
-        $shortText =  $this->renderText($previewText, 50);
623
+        $shortText = $this->renderText($previewText, 50);
624 624
         
625 625
         $files = $string->getFiles();
626 626
         
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
         			</p>
641 641
                     <?php
642 642
                         $explanation = $text->getExplanation();
643
-                        if(!empty($explanation))
643
+                        if (!empty($explanation))
644 644
                         {
645 645
                             ?>
646 646
                             <p>
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
             				<?php 
664 664
             				    $totalFiles = count($files);
665 665
             				    
666
-            				    if($totalFiles == 1)
666
+            				    if ($totalFiles == 1)
667 667
             				    {
668 668
             				        pt('Found in a single file:');
669 669
             				    }
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
                 				<?php 
679 679
                 				    $locations = $string->getStrings();
680 680
                 				    
681
-                    				foreach($locations as $location) 
681
+                    				foreach ($locations as $location) 
682 682
                     				{
683 683
                     				    $file = $location->getSourceFile();
684 684
                     				    $line = $location->getLine();
@@ -687,9 +687,9 @@  discard block
 block discarded – undo
687 687
                     				    
688 688
                     				    $ext = \AppUtils\FileHelper::getExtension($file);
689 689
                     				    
690
-                    				    if($ext == 'php') {
690
+                    				    if ($ext == 'php') {
691 691
                     				        $icon = 'fab fa-php';
692
-                    				    } else if($ext == 'js') {
692
+                    				    } else if ($ext == 'js') {
693 693
                     				        $icon = 'fab fa-js-square';
694 694
                     				    } else {
695 695
                     				        $icon = 'fas fa-file-code';
@@ -711,13 +711,13 @@  discard block
 block discarded – undo
711 711
         <?php 
712 712
     }
713 713
     
714
-    protected function renderText(string $text, int $cutAt=0) : string
714
+    protected function renderText(string $text, int $cutAt = 0) : string
715 715
     {
716
-        if(empty($text)) {
716
+        if (empty($text)) {
717 717
             return '';
718 718
         }
719 719
 
720
-        if($cutAt > 0) {
720
+        if ($cutAt > 0) {
721 721
             $text = ConvertHelper::text_cut($text, $cutAt);
722 722
         }
723 723
 
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
         
726 726
         $vars = $this->detectVariables($text);
727 727
         
728
-        foreach($vars as $var) {
728
+        foreach ($vars as $var) {
729 729
             $text = str_replace($var, '<span class="placeholder">'.$var.'</span>', $text);
730 730
         }
731 731
         
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
         $result = array();
738 738
         preg_match_all('/%[0-9]+d|%s|%[0-9]+\$s/i', $string, $result, PREG_PATTERN_ORDER);
739 739
 
740
-        if(isset($result[0]) && !empty($result[0])) {
740
+        if (isset($result[0]) && !empty($result[0])) {
741 741
             return $result[0];
742 742
         }
743 743
         
@@ -753,10 +753,10 @@  discard block
 block discarded – undo
753 753
         
754 754
         // add a counter of the additional files if the total
755 755
         // is higher than the maximum to show
756
-        if($total > $max) 
756
+        if ($total > $max) 
757 757
         {
758 758
             $length = $max;
759
-            if($length > $keepTotal) {
759
+            if ($length > $keepTotal) {
760 760
                 $length = $keepTotal; 
761 761
             }
762 762
             
@@ -784,14 +784,14 @@  discard block
 block discarded – undo
784 784
         return file_get_contents($this->installPath.'/css/editor.css');
785 785
     }
786 786
     
787
-    public function getSourceURL(Localization_Source $source, array $params=array())
787
+    public function getSourceURL(Localization_Source $source, array $params = array())
788 788
     {
789 789
         $params[$this->getVarName('source')] = $source->getID();
790 790
         
791 791
         return $this->getURL($params);
792 792
     }
793 793
     
794
-    public function getLocaleURL(Localization_Locale $locale, array $params=array())
794
+    public function getLocaleURL(Localization_Locale $locale, array $params = array())
795 795
     {
796 796
         $params[$this->getVarName('locale')] = $locale->getName();
797 797
         
@@ -808,12 +808,12 @@  discard block
 block discarded – undo
808 808
         return $this->getSourceURL($this->activeSource, array($this->getVarName('warnings') => 'yes'));
809 809
     }
810 810
     
811
-    public function getURL(array $params=array())
811
+    public function getURL(array $params = array())
812 812
     {
813 813
         $persist = $this->getRequestParams();
814 814
         
815
-        foreach($persist as $name => $value) {
816
-            if(!isset($params[$name])) {
815
+        foreach ($persist as $name => $value) {
816
+            if (!isset($params[$name])) {
817 817
                 $params[$name] = $value;
818 818
             }
819 819
         }
@@ -846,11 +846,11 @@  discard block
 block discarded – undo
846 846
         $translator = Localization::getTranslator($this->activeAppLocale);
847 847
         
848 848
         $strings = $data[$this->getVarName('strings')];
849
-        foreach($strings as $hash => $text) 
849
+        foreach ($strings as $hash => $text) 
850 850
         {
851 851
             $text = trim($text);
852 852
             
853
-            if(empty($text)) {
853
+            if (empty($text)) {
854 854
                 continue;
855 855
             } 
856 856
             
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
     
873 873
     protected function renderStatus(Localization_Scanner_StringHash $hash)
874 874
     {
875
-        if($hash->isTranslated()) {
875
+        if ($hash->isTranslated()) {
876 876
             return '<i class="fa fa-check text-success"></i>';
877 877
         }        
878 878
         
@@ -883,18 +883,18 @@  discard block
 block discarded – undo
883 883
     {
884 884
         $types = array();
885 885
         
886
-        if($hash->hasLanguageType('PHP')) {
886
+        if ($hash->hasLanguageType('PHP')) {
887 887
             $types[] = t('Server');
888 888
         }
889 889
         
890
-        if($hash->hasLanguageType('Javascript')) {
890
+        if ($hash->hasLanguageType('Javascript')) {
891 891
             $types[] = t('Client');
892 892
         }
893 893
         
894 894
         return implode(', ', $types);
895 895
     }
896 896
     
897
-    protected function addMessage($message, $type=self::MESSAGE_INFO)
897
+    protected function addMessage($message, $type = self::MESSAGE_INFO)
898 898
     {
899 899
         $_SESSION['localization_messages'][] = array(
900 900
             'text' => $message,
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
     public function getAppName() : string
929 929
     {
930 930
         $name = $this->getOption('appname');
931
-        if(!empty($name)) {
931
+        if (!empty($name)) {
932 932
             return $name;
933 933
         }
934 934
         
Please login to merge, or discard this patch.