Passed
Push — master ( fda82f...bdc416 )
by Robin
02:13 queued 12s
created
programs/record.class.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     {
192 192
         $App = $this->App();
193 193
 
194
-        $customFieldSet= $App->CustomFieldSet();
194
+        $customFieldSet = $App->CustomFieldSet();
195 195
         $object = mb_substr(get_class($this), mb_strlen($App->classPrefix), -mb_strlen('Set'));
196 196
 
197 197
         $customFields = $customFieldSet->select($customFieldSet->object->is($object));
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
         $linkSet->hasOne('sourceId', get_class($this));
319 319
 
320
-        $criteria =	$linkSet->targetClass->is(get_class($target))
320
+        $criteria = $linkSet->targetClass->is(get_class($target))
321 321
             ->_AND_($linkSet->targetId->is($target->id))
322 322
             ->_AND_($linkSet->sourceClass->is($this->getRecordClassName()));
323 323
         if (isset($linkType)) {
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
         $linkSet->hasOne('targetId', get_class($this));
349 349
 
350
-        $criteria =	$linkSet->sourceClass->is(get_class($source))
350
+        $criteria = $linkSet->sourceClass->is(get_class($source))
351 351
             ->_AND_($linkSet->sourceId->is($source->id))
352 352
             ->_AND_($linkSet->targetClass->is($this->getRecordClassName()));
353 353
         if (isset($linkType)) {
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
             $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds));
392 392
         }
393 393
 
394
-        $criteria =	$linkSet->all(
394
+        $criteria = $linkSet->all(
395 395
             $linkSet->targetClass->is($this->getRecordClassName()),
396 396
             $linkSet->any($sourcesCriteria)
397 397
         );
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
             $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds));
437 437
         }
438 438
 
439
-        $criteria =	$linkSet->all(
439
+        $criteria = $linkSet->all(
440 440
             $linkSet->sourceClass->is($this->getRecordClassName()),
441 441
             $linkSet->any($targetsCriteria)
442 442
         );
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
         $App = $this->App();
674 674
         $rClass = new ReflectionClass(get_class($this));
675 675
         $component = $App->getComponentByName($rClass->getShortName());
676
-        if(isset($component)){
676
+        if (isset($component)) {
677 677
             return $component->getRecordClassName();
678 678
 //             list(, $classname) = explode('_', $component->getRecordClassName());
679 679
 //             return $classname;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
             throw new app_Exception('Trying to get the reference string of a record without an id.');
695 695
         }
696 696
         $classname = $this->getClassName();
697
-        return $classname . ':' . $this->id;
697
+        return $classname.':'.$this->id;
698 698
     }
699 699
 
700 700
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
     {
935 935
         $linkSet = $this->App()->LinkSet();
936 936
 
937
-        $criteria =	$linkSet->sourceClass->is(get_class($source))
937
+        $criteria = $linkSet->sourceClass->is(get_class($source))
938 938
         ->_AND_($linkSet->sourceId->is($source->id))
939 939
         ->_AND_($linkSet->targetClass->is(get_class($this)))
940 940
         ->_AND_($linkSet->targetId->is($this->id));
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
     {
965 965
         $linkSet = $this->App()->LinkSet();
966 966
 
967
-        $criteria =	$linkSet->all(
967
+        $criteria = $linkSet->all(
968 968
             $linkSet->targetClass->is(get_class($target)),
969 969
             $linkSet->targetId->is($target->id),
970 970
             $linkSet->sourceClass->is(get_class($this)),
@@ -1059,13 +1059,13 @@  discard block
 block discarded – undo
1059 1059
      */
1060 1060
     protected function importDate($name, $value)
1061 1061
     {
1062
-        if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/',$value)) {
1062
+        if (preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) {
1063 1063
             return $this->importProperty($name, $value);
1064 1064
         }
1065 1065
 
1066 1066
         // try in DD/MM/YYYY format
1067 1067
 
1068
-        if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/',$value, $matches)) {
1068
+        if (preg_match('/(?P<day>[0-9]+)\/(?P<month>[0-9]+)\/(?P<year>[0-9]{2,4})/', $value, $matches)) {
1069 1069
 
1070 1070
             $value = sprintf('%04d-%02d-%02d', (int) $matches['year'], (int) $matches['month'], (int) $matches['day']);
1071 1071
 
Please login to merge, or discard this patch.
programs/app.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
  * @copyright Copyright (c) 2018 by CANTICO ({@link http://www.cantico.fr})
22 22
  */
23 23
 
24
-require_once dirname(__FILE__) . '/define.php';
25
-require_once dirname(__FILE__) . '/functions.php';
26
-require_once dirname(__FILE__) . '/component.class.php';
24
+require_once dirname(__FILE__).'/define.php';
25
+require_once dirname(__FILE__).'/functions.php';
26
+require_once dirname(__FILE__).'/component.class.php';
27 27
 
28 28
 
29 29
 
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
         $this->addonName = 'libapp';
60 60
         $this->addonPrefix = 'app';
61 61
 
62
-        $this->classPrefix = $this->addonPrefix . '_';
63
-        $this->controllerTg = 'addon/' . $this->addonName . '/main';
62
+        $this->classPrefix = $this->addonPrefix.'_';
63
+        $this->controllerTg = 'addon/'.$this->addonName.'/main';
64 64
 
65 65
         $addon = bab_getAddonInfosInstance($this->addonName);
66 66
         $this->phpPath = $addon->getPhpPath();
67 67
         $this->recordSetPath = $this->phpPath;
68 68
         $this->ctrlPath = $this->phpPath;
69
-        $this->uiPath = $this->phpPath . 'ui/';
69
+        $this->uiPath = $this->phpPath.'ui/';
70 70
 
71 71
         $babDB = bab_getDB();
72 72
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function getComponentByName($componentName)
94 94
     {
95
-        if(isset($this->components[$componentName])){
95
+        if (isset($this->components[$componentName])) {
96 96
             return $this->components[$componentName];
97 97
         }
98 98
         return null;
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
         
132 132
         $messages = array();
133 133
         
134
-        foreach ($components as $componentName => $component){
134
+        foreach ($components as $componentName => $component) {
135 135
             $dependencies = $component->checkDependencies();
136
-            foreach($dependencies['requiredComponents'] as $requiredComponent){
136
+            foreach ($dependencies['requiredComponents'] as $requiredComponent) {
137 137
                 $messages['requiredComponents'][$componentName][] = $requiredComponent;
138 138
             }
139
-            foreach($dependencies['optionalComponents'] as $optionalComponent){
139
+            foreach ($dependencies['optionalComponents'] as $optionalComponent) {
140 140
                 $messages['optionalComponents'][$componentName][] = $optionalComponent;
141 141
             }
142 142
         }
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
     public function getRecordSetPathname($class)
180 180
     {
181 181
         // $App->MyRecordSet() -> myrecord.class.php
182
-        $file = strtolower(substr($class, strlen($this->classPrefix), -3)) . '.class.php';
183
-        return $this->recordSetPath . $file;
182
+        $file = strtolower(substr($class, strlen($this->classPrefix), -3)).'.class.php';
183
+        return $this->recordSetPath.$file;
184 184
     }
185 185
 
186 186
     /**
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
     public function getRecordPathname($class)
193 193
     {
194 194
         // $App->MyRecord() -> myrecord.class.php
195
-        $file = strtolower(substr($class, strlen($this->classPrefix))) . '.class.php';
196
-        return $this->recordSetPath . $file;
195
+        $file = strtolower(substr($class, strlen($this->classPrefix))).'.class.php';
196
+        return $this->recordSetPath.$file;
197 197
     }
198 198
 
199 199
     /**
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 
295 295
             if (substr($method, 0, 7) === 'include' && substr($method, -3) === 'Set') {
296 296
                 $incl = $method;
297
-                $classNameMethod = substr($method, strlen('include')) . 'ClassName';
297
+                $classNameMethod = substr($method, strlen('include')).'ClassName';
298 298
 
299 299
 
300 300
                 $classname = $this->$classNameMethod();
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
                                 // We need to revert to multilang fields before synchronizing.
317 317
                                 $set->useLang(false);
318 318
                             }
319
-                            $sql .= $mysqlbackend->setToSql($set) . "\n";
319
+                            $sql .= $mysqlbackend->setToSql($set)."\n";
320 320
                         }
321 321
                     }
322 322
                 }
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
         $sql = 'SET FOREIGN_KEY_CHECKS=0;
343 343
             ';
344 344
 
345
-        foreach ($this->components as $component){
345
+        foreach ($this->components as $component) {
346 346
             /* @var $component app_Component */
347
-            try{
347
+            try {
348 348
                 /* @var $set ORM_RecordSet */
349 349
                 $set = $component->recordSet();
350 350
                 if (method_exists($set, 'useLang')) {
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
                     // We need to revert to multilang fields before synchronizing.
353 353
                     $set->useLang(false);
354 354
                 }
355
-                $sql .= $mysqlbackend->setToSql($set) . "\n";
355
+                $sql .= $mysqlbackend->setToSql($set)."\n";
356 356
                 
357 357
                 $component->onUpdate();
358 358
             }
359
-            catch (Exception $e){
359
+            catch (Exception $e) {
360 360
                 
361 361
             }
362 362
         }
@@ -367,18 +367,18 @@  discard block
 block discarded – undo
367 367
         $synchronize->fromSqlString($sql);
368 368
         
369 369
         $dependencies = $this->checkComponentsDependencies();
370
-        foreach ($dependencies['requiredComponents'] as $componentName => $requiredComponents){
371
-            foreach ($requiredComponents as $requiredComponent){
370
+        foreach ($dependencies['requiredComponents'] as $componentName => $requiredComponents) {
371
+            foreach ($requiredComponents as $requiredComponent) {
372 372
                 $hasComponent = $this->getComponentByName($requiredComponent);
373
-                if(!$hasComponent){
373
+                if (!$hasComponent) {
374 374
                     bab_installWindow::message(sprintf($this->translate('The component %s is required for the component %s to work. You will encounter fatal errors'), $requiredComponent, $componentName));
375 375
                 }
376 376
             }
377 377
         }
378
-        foreach ($dependencies['optionalComponents'] as $componentName => $optionalComponents){
379
-            foreach ($optionalComponents as $optionalComponent){
378
+        foreach ($dependencies['optionalComponents'] as $componentName => $optionalComponents) {
379
+            foreach ($optionalComponents as $optionalComponent) {
380 380
                 $hasComponent = $this->getComponentByName($optionalComponent);
381
-                if(!$hasComponent){
381
+                if (!$hasComponent) {
382 382
                     bab_installWindow::message(sprintf($this->translate('The optional component %s has not been added. The component %s may have reduced functionalities'), $optionalComponent, $componentName));
383 383
                 }
384 384
             }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
             if (substr($method, 0, strlen('include')) === 'include' && substr($method, -strlen('Set')) === 'Set') {
405 405
                 $incl = $method;
406
-                $classNameMethod = substr($method, strlen('include')) . 'ClassName';
406
+                $classNameMethod = substr($method, strlen('include')).'ClassName';
407 407
 
408 408
                 $classname = $this->$classNameMethod();
409 409
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 
418 418
                             if (class_exists($classname) && method_exists($this, $call)) {
419 419
                                 $set = $this->$call();
420
-                                $sql .= $mysqlbackend->setToSql($set) . "\n";
420
+                                $sql .= $mysqlbackend->setToSql($set)."\n";
421 421
                             }
422 422
                         }
423 423
                     }
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 
432 432
     public function includeBase()
433 433
     {
434
-        require_once APP_PHP_PATH . 'base.class.php';
434
+        require_once APP_PHP_PATH.'base.class.php';
435 435
     }
436 436
 
437 437
     /**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
      */
440 440
     public function includeRecordSet()
441 441
     {
442
-        require_once APP_SET_PATH . 'record.class.php';
442
+        require_once APP_SET_PATH.'record.class.php';
443 443
     }
444 444
 
445 445
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      */
449 449
     public function includeTraceableRecordSet()
450 450
     {
451
-        require_once APP_SET_PATH . 'traceablerecord.class.php';
451
+        require_once APP_SET_PATH.'traceablerecord.class.php';
452 452
     }
453 453
 
454 454
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
     {
461 461
         static $accessManager = null;
462 462
         if (!isset($accessManager)) {
463
-            require_once APP_SET_PATH . 'accessmanager.class.php';
463
+            require_once APP_SET_PATH.'accessmanager.class.php';
464 464
             $accessManager = new app_AccessManager($this);
465 465
         }
466 466
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      */
479 479
     public function includeLogSet()
480 480
     {
481
-        require_once APP_SET_PATH . 'log.class.php';
481
+        require_once APP_SET_PATH.'log.class.php';
482 482
     }
483 483
 
484 484
     /**
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
      */
495 495
     public function LogSetClassName()
496 496
     {
497
-        return $this->LogClassName() . 'Set';
497
+        return $this->LogClassName().'Set';
498 498
     }
499 499
 
500 500
     /**
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
      */
517 517
     public function includeLinkSet()
518 518
     {
519
-        require_once APP_SET_PATH . 'link.class.php';
519
+        require_once APP_SET_PATH.'link.class.php';
520 520
     }
521 521
 
522 522
     /**
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
      */
533 533
     public function LinkSetClassName()
534 534
     {
535
-        return $this->LinkClassName() . 'Set';
535
+        return $this->LinkClassName().'Set';
536 536
     }
537 537
 
538 538
     /**
@@ -556,10 +556,10 @@  discard block
 block discarded – undo
556 556
     public function getRecordSetByRef($recordClassname)
557 557
     {
558 558
         $component = $this->getComponentByName(str_replace($this->classPrefix, '', $recordClassname));
559
-        if(isset($component)){
559
+        if (isset($component)) {
560 560
             return $component->recordSet();
561 561
         }
562
-        $classSet = $recordClassname . 'Set';
562
+        $classSet = $recordClassname.'Set';
563 563
         $set = $this->$classSet();
564 564
         return $set;
565 565
     }
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
     {
597 597
         $fullClassName = get_class($record);
598 598
         list(, $className) = explode('_', $fullClassName);
599
-        return $className . ':' . $record->id;
599
+        return $className.':'.$record->id;
600 600
     }
601 601
 
602 602
 
@@ -687,16 +687,16 @@  discard block
 block discarded – undo
687 687
      */
688 688
     public function mailTo($addr, $subject = null, $body = null)
689 689
     {
690
-        $mailTo = 'mailto:' . $addr;
690
+        $mailTo = 'mailto:'.$addr;
691 691
         $parameters = array();
692 692
         if (isset($subject)) {
693
-            $parameters[] = 'subject=' . $subject;
693
+            $parameters[] = 'subject='.$subject;
694 694
         }
695 695
         if (isset($body)) {
696
-            $parameters[] = 'body=' . $body;
696
+            $parameters[] = 'body='.$body;
697 697
         }
698 698
         if (!empty($parameters)) {
699
-            $mailTo .= '?' . implode('&', $parameters);
699
+            $mailTo .= '?'.implode('&', $parameters);
700 700
         }
701 701
 
702 702
         return $mailTo;
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
         }
748 748
 
749 749
         $number = number_format($number, $decimals, ',', ' ');
750
-        return str_replace(' ', bab_nbsp(), $number . ' ' . $prefix . $unitSymbol);
750
+        return str_replace(' ', bab_nbsp(), $number.' '.$prefix.$unitSymbol);
751 751
     }
752 752
 
753 753
 
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
         }
768 768
 
769 769
         if (!isset($format)) {
770
-            $format = bab_registry::get('/' . $this->addonName . '/numberFormat', $PhoneNumber->getDefaultFormat());
770
+            $format = bab_registry::get('/'.$this->addonName.'/numberFormat', $PhoneNumber->getDefaultFormat());
771 771
         }
772 772
         $phoneNumberUtil = $PhoneNumber->PhoneNumberUtil();
773 773
 
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
      */
789 789
     public function includeController()
790 790
     {
791
-        require_once APP_PHP_PATH . '/controller.class.php';
791
+        require_once APP_PHP_PATH.'/controller.class.php';
792 792
     }
793 793
 
794 794
 
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
      */
798 798
     public function includeRecordController()
799 799
     {
800
-        require_once APP_CTRL_PATH . '/record.ctrl.php';
800
+        require_once APP_CTRL_PATH.'/record.ctrl.php';
801 801
     }
802 802
 
803 803
 
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
      */
838 838
     public function includeUi()
839 839
     {
840
-        require_once APP_UI_PATH . 'ui.class.php';
840
+        require_once APP_UI_PATH.'ui.class.php';
841 841
     }
842 842
 
843 843
 
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     public function Ui()
850 850
     {
851 851
         $this->includeUi();
852
-        return bab_getInstance($this->classPrefix . 'Ui');//->setApp($this);
852
+        return bab_getInstance($this->classPrefix.'Ui'); //->setApp($this);
853 853
     }
854 854
 
855 855
     /**
@@ -877,34 +877,34 @@  discard block
 block discarded – undo
877 877
 
878 878
             case substr($name, -strlen('SetClassName')) === 'SetClassName':
879 879
                 $className = substr($name, 0, strlen($name) - strlen('SetClassName'));
880
-                if($component = $this->getComponentByName(ucfirst($className))){
880
+                if ($component = $this->getComponentByName(ucfirst($className))) {
881 881
                     return $component->getSetClassName();
882 882
                 }
883 883
                 $setName = $className.'Set';
884
-                return $this->classPrefix . $setName;
884
+                return $this->classPrefix.$setName;
885 885
 
886 886
             case substr($name, -strlen('ClassName')) === 'ClassName':
887 887
                 $recordName = substr($name, 0, strlen($name) - strlen('ClassName'));
888
-                if($component = $this->getComponentByName(ucfirst($recordName))){
888
+                if ($component = $this->getComponentByName(ucfirst($recordName))) {
889 889
                     return $component->getRecordClassName();
890 890
                 }
891
-                return $this->classPrefix . $recordName;
891
+                return $this->classPrefix.$recordName;
892 892
 
893 893
             case substr($name, 0, strlen('include')) === 'include' && substr($name, -strlen('Set')) === 'Set':
894 894
                 $fileNameBase = strtolower(substr(substr($name, 0, strlen($name) - strlen('Set')), strlen('include')));
895
-                if($this->getComponentByName(ucfirst($fileNameBase))){
895
+                if ($this->getComponentByName(ucfirst($fileNameBase))) {
896 896
                     return;
897 897
                 }
898
-                require_once APP_SET_PATH . $fileNameBase . '.class.php';
898
+                require_once APP_SET_PATH.$fileNameBase.'.class.php';
899 899
                 return;
900 900
 
901 901
             case substr($name, -strlen('Set')) === 'Set':
902
-                if($component = $this->getComponentByName(ucfirst(substr($name, 0, strlen($name) -strlen('Set'))))){
902
+                if ($component = $this->getComponentByName(ucfirst(substr($name, 0, strlen($name) - strlen('Set'))))) {
903 903
                     return $component->recordSet();
904 904
                 }
905
-                $includeMethod = 'include' . $name;
905
+                $includeMethod = 'include'.$name;
906 906
                 $this->$includeMethod();
907
-                $setClassNameMethod = $name . 'ClassName';
907
+                $setClassNameMethod = $name.'ClassName';
908 908
                 $className = $this->$setClassNameMethod();
909 909
                 $set = new $className($this);
910 910
                 return $set;
@@ -912,8 +912,8 @@  discard block
 block discarded – undo
912 912
             case ($component = $this->getComponentByName(ucfirst($name))) != false:
913 913
                 return $component;
914 914
             default:
915
-                $setName = $name . 'Set';
916
-                $recordClassNameMethod = $name . 'ClassName';
915
+                $setName = $name.'Set';
916
+                $recordClassNameMethod = $name.'ClassName';
917 917
                 $recordClassName = $this->$recordClassNameMethod();
918 918
                 if (isset($arguments[0])) {
919 919
                     if ($arguments[0] instanceof $recordClassName) {
Please login to merge, or discard this patch.