Passed
Branchfeature/useWidgetsNamespaces_c... (264d4b)
by Robin
04:22
created
programs/Ctrl/AppController.php 2 patches
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 use function Cofy\Utilities\User\bab_isUserAdministrator;
56 56
 use function Cofy\Utilities\User\bab_isUserLogged;
57 57
 
58
-require_once dirname(__FILE__) . '/../functions.php';
58
+require_once dirname(__FILE__).'/../functions.php';
59 59
 
60 60
 /**
61 61
  * @method self proxy()
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     public function addReloadSelector($reloadSelector, $withSSE = false, $for = null)
90 90
     {
91 91
         $this->reloadSelectors[$reloadSelector] = $reloadSelector;
92
-        if($withSSE){
92
+        if ($withSSE) {
93 93
             $sseRecordSet = $this->getSSERecordSet();
94 94
             $sseRecordSet->newReloadSelector($reloadSelector, $for);
95 95
         }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     
107 107
     public function getSSERecordSet()
108 108
     {
109
-        if(isset($this->SSERecordSet)){
109
+        if (isset($this->SSERecordSet)) {
110 110
             return $this->SSERecordSet;
111 111
         }
112 112
         
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     public function __call($name, $arguments = array())
152 152
     {
153 153
         $component = $this->App()->getComponentByName($name);
154
-        if($component){
154
+        if ($component) {
155 155
             return call_user_func_array(array(
156 156
                 $component,
157 157
                 'controller'
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     public function isAjaxRequest()
196 196
     {
197
-        if(! isset($this->isAjaxRequest)){
197
+        if (!isset($this->isAjaxRequest)) {
198 198
             $this->isAjaxRequest = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
199 199
         }
200 200
         return $this->isAjaxRequest;
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
      */
207 207
     public function requireCredential($message = null)
208 208
     {
209
-        if($this->isAjaxRequest()){
209
+        if ($this->isAjaxRequest()) {
210 210
             $authType = 'Basic';
211 211
         }
212
-        else{
212
+        else {
213 213
             $authType = '';
214 214
         }
215 215
         
216
-        if(! isset($message)){
216
+        if (!isset($message)) {
217 217
             $message = $this->App()->translate('You must be logged in to access this page.');
218 218
         }
219 219
         
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
         list ($prefix) = explode('_', __CLASS__);
238 238
         $functionalityName = ucwords($prefix);
239 239
         /** @var FuncApp */
240
-        $App = BabFunctionality::get('App/' . $functionalityName);
240
+        $App = BabFunctionality::get('App/'.$functionalityName);
241 241
         
242
-        if(!$App){
243
-            throw new AppException('Faild to autodetect functionality App/' . $functionalityName . ', the getInstance method is deprecated, use $App->ControllerProxy() instead');
242
+        if (!$App) {
243
+            throw new AppException('Faild to autodetect functionality App/'.$functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead');
244 244
         }
245 245
         
246 246
         $controller = $App->ControllerProxy($classname, $proxy);
@@ -258,47 +258,47 @@  discard block
 block discarded – undo
258 258
     static function getProxyInstance(BabFunctionality $App = null, $classname)
259 259
     {
260 260
         $class = new \ReflectionClass($classname);
261
-        $proxyClassname = $class->getShortName() . self::PROXY_CLASS_SUFFIX;
261
+        $proxyClassname = $class->getShortName().self::PROXY_CLASS_SUFFIX;
262 262
         $finalProxyClassname = $class->getNamespaceName()."\\".$proxyClassname;
263
-        if(! class_exists($finalProxyClassname)){
263
+        if (!class_exists($finalProxyClassname)) {
264 264
             $classStr = "";
265
-            if($class->getNamespaceName() != ""){
265
+            if ($class->getNamespaceName() != "") {
266 266
                 $classStr .= " namespace ".$class->getNamespaceName()."; ";
267 267
             }
268
-            $classStr .= 'class ' . $proxyClassname . ' extends ' . $class->getShortName() . ' {' . "\n";
268
+            $classStr .= 'class '.$proxyClassname.' extends '.$class->getShortName().' {'."\n";
269 269
             $methods = $class->getMethods();
270 270
             
271 271
             $classStr .= '	public function __construct($App) {
272 272
                 $this->setApp($App);
273 273
             }' . "\n";
274 274
             
275
-            foreach ($methods as $method){
276
-                if($method->name === '__construct' || ! $method->isPublic() || $method->isStatic() || $method->isFinal() || $method->name === 'setApp' || $method->name === 'App' || $method->name === 'setCrm' || $method->name === 'Crm'){
275
+            foreach ($methods as $method) {
276
+                if ($method->name === '__construct' || !$method->isPublic() || $method->isStatic() || $method->isFinal() || $method->name === 'setApp' || $method->name === 'App' || $method->name === 'setCrm' || $method->name === 'Crm') {
277 277
                     continue;
278 278
                 }
279 279
                 
280
-                $classStr .= '	public function ' . $method->name . '(';
280
+                $classStr .= '	public function '.$method->name.'(';
281 281
                 $parameters = $method->getParameters();
282 282
                 $parametersStr = array();
283
-                foreach ($parameters as $parameter){
283
+                foreach ($parameters as $parameter) {
284 284
                     $reference = "";
285
-                    if($parameter->isPassedByReference()){
285
+                    if ($parameter->isPassedByReference()) {
286 286
                         $reference = "&"; 
287 287
                     }
288
-                    if($parameter->isDefaultValueAvailable()){
289
-                        $parametersStr[] = $reference. '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true);
288
+                    if ($parameter->isDefaultValueAvailable()) {
289
+                        $parametersStr[] = $reference.'$'.$parameter->name.' = '.var_export($parameter->getDefaultValue(), true);
290 290
                     }
291
-                    else{
292
-                        $parametersStr[] = $reference. '$' . $parameter->name;
291
+                    else {
292
+                        $parametersStr[] = $reference.'$'.$parameter->name;
293 293
                     }
294 294
                 }
295 295
                 $classStr .= implode(', ', $parametersStr);
296
-                $classStr .= ') {' . "\n";
297
-                $classStr .= '		$args = func_get_args();' . "\n";
298
-                $classStr .= '		return $this->getMethodAction(__FUNCTION__, $args);' . "\n";
299
-                $classStr .= '	}' . "\n";
296
+                $classStr .= ') {'."\n";
297
+                $classStr .= '		$args = func_get_args();'."\n";
298
+                $classStr .= '		return $this->getMethodAction(__FUNCTION__, $args);'."\n";
299
+                $classStr .= '	}'."\n";
300 300
             }
301
-            $classStr .= '}' . "\n";
301
+            $classStr .= '}'."\n";
302 302
             // We define the proxy class
303 303
             eval($classStr);
304 304
         }
@@ -336,14 +336,14 @@  discard block
 block discarded – undo
336 336
     protected function getObjectName($classname)
337 337
     {
338 338
         list ($objectname) = explode('Controller', $classname);
339
-        if($this->App()->getComponentByName($objectname)){
339
+        if ($this->App()->getComponentByName($objectname)) {
340 340
             return strtolower($objectname);
341 341
         }
342 342
         $field = explode('Ctrl', $classname);
343
-        if(count($field) == 1){
344
-            $objectname= $field[0];
345
-        }else{
346
-            $objectname= $field[1];
343
+        if (count($field) == 1) {
344
+            $objectname = $field[0];
345
+        } else {
346
+            $objectname = $field[1];
347 347
         }
348 348
         return strtolower($objectname);
349 349
     }
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
         
364 364
         $reflector = new \ReflectionClass(get_class($this));
365 365
         $parent = $reflector->getParentClass();
366
-        if($parent){
366
+        if ($parent) {
367 367
             $parentMethod = $parent->getMethod('__construct');
368 368
             $docComment = $parentMethod->getDocComment();
369
-            if(strpos($docComment, '@isComponentController') !== false){
369
+            if (strpos($docComment, '@isComponentController') !== false) {
370 370
                 $fullClassName = $parent->getName();
371 371
             }
372 372
         }
373 373
         
374 374
         $rc = new \ReflectionClass($fullClassName);
375 375
         
376
-        if(! $rc->hasMethod($methodName)){
377
-            throw new BabInvalidActionException($fullClassName . '::' . $methodName);
376
+        if (!$rc->hasMethod($methodName)) {
377
+            throw new BabInvalidActionException($fullClassName.'::'.$methodName);
378 378
         }
379 379
         $method = new \ReflectionMethod($fullClassName, $methodName);
380 380
         
@@ -383,32 +383,32 @@  discard block
 block discarded – undo
383 383
         $parameters = $method->getParameters();
384 384
         $actionParams = array();
385 385
         $argNumber = 0;
386
-        foreach ($parameters as $parameter){
386
+        foreach ($parameters as $parameter) {
387 387
             $parameterName = $parameter->getName();
388
-            if(isset($args[$argNumber])){
388
+            if (isset($args[$argNumber])) {
389 389
                 $actionParams[$parameterName] = $args[$argNumber];
390 390
             }
391
-            elseif($parameter->isDefaultValueAvailable()){
391
+            elseif ($parameter->isDefaultValueAvailable()) {
392 392
                 $actionParams[$parameterName] = $parameter->getDefaultValue();
393 393
             }
394
-            else{
394
+            else {
395 395
                 $actionParams[$parameterName] = null;
396 396
             }
397
-            $argNumber ++;
397
+            $argNumber++;
398 398
         }
399 399
         
400 400
         $action = new WidgetAction();
401 401
         
402
-        $action->setMethod($this->getControllerTg(), $objectName . '.' . $methodName, $actionParams);
402
+        $action->setMethod($this->getControllerTg(), $objectName.'.'.$methodName, $actionParams);
403 403
         
404 404
         $docComment = $method->getDocComment();
405
-        if(strpos($docComment, '@ajax') !== false){
405
+        if (strpos($docComment, '@ajax') !== false) {
406 406
             $action->setAjax(true);
407 407
         }
408
-        if(strpos($docComment, '@requireSaveMethod') !== false && method_exists($action, 'setRequireSaveMethod')){
408
+        if (strpos($docComment, '@requireSaveMethod') !== false && method_exists($action, 'setRequireSaveMethod')) {
409 409
             $action->setRequireSaveMethod(true);
410 410
         }
411
-        if(strpos($docComment, '@requireDeleteMethod') !== false && method_exists($action, 'setRequireDeleteMethod')){
411
+        if (strpos($docComment, '@requireDeleteMethod') !== false && method_exists($action, 'setRequireDeleteMethod')) {
412 412
             $action->setRequireDeleteMethod(true);
413 413
         }
414 414
         
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
         
438 438
         $action->setParameters($actionParams);
439 439
         
440
-        list (, , $file) = explode('/', $App->controllerTg);
440
+        list (,, $file) = explode('/', $App->controllerTg);
441 441
         
442
-        $action->setParameter('addon', $App->getAddonName() . '.' . $file);
442
+        $action->setParameter('addon', $App->getAddonName().'.'.$file);
443 443
         $action->setParameter('idx', $idx);
444 444
         
445 445
         return $action;
@@ -457,44 +457,44 @@  discard block
 block discarded – undo
457 457
         
458 458
         $method = $action->getMethod();
459 459
         
460
-        if(! isset($method) || '' === $method){
460
+        if (!isset($method) || '' === $method) {
461 461
             return false;
462 462
         }
463 463
         
464 464
         list ($objectName,) = explode('.', $method);
465 465
         
466
-        if(! method_exists($this, $objectName)){
466
+        if (!method_exists($this, $objectName)) {
467 467
             /* @var $component AppComponent */
468 468
             $component = $this->app->getComponentByName($objectName);
469
-            if($component){
469
+            if ($component) {
470 470
                 $this->app->setCurrentComponent($component);
471 471
                 $objectController = $component->controller(false);
472 472
             }
473
-            else{
473
+            else {
474 474
                 header('HTTP/1.0 400 Bad Request');
475 475
                 throw new AppUnknownActionException($action);
476 476
             }
477 477
         }
478 478
         
479
-        if(! isset($component)){
479
+        if (!isset($component)) {
480 480
             $objectController = $this->{$objectName}(false);
481
-            if(! ($objectController instanceof AppController)){
481
+            if (!($objectController instanceof AppController)) {
482 482
                 return false;
483 483
             }
484 484
         }
485 485
         
486
-        try{
486
+        try {
487 487
             $returnedValue = $objectController->execAction($action);
488 488
         }
489
-        catch (AppAccessException $e){
489
+        catch (AppAccessException $e) {
490 490
             
491
-            if(! bab_isUserLogged() && $e->requireCredential){
491
+            if (!bab_isUserLogged() && $e->requireCredential) {
492 492
                 bab_requireCredential($e->getMessage());
493 493
             }
494
-            else{
495
-                if($this->isAjaxRequest()){
494
+            else {
495
+                if ($this->isAjaxRequest()) {
496 496
                     
497
-                    header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403);
497
+                    header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403);
498 498
                     
499 499
                     die(bab_json_encode(array(
500 500
                         'exception' => 'app_AccessException',
@@ -505,10 +505,10 @@  discard block
 block discarded – undo
505 505
                 $this->accessPage($e);
506 506
             }
507 507
         }
508
-        catch (AppSaveException $e){
508
+        catch (AppSaveException $e) {
509 509
             
510
-            if($this->isAjaxRequest()){
511
-                header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403);
510
+            if ($this->isAjaxRequest()) {
511
+                header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403);
512 512
                 header('Cache-Control: no-cache, must-revalidate');
513 513
                 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
514 514
                 header('Content-type: application/json');
@@ -520,32 +520,32 @@  discard block
 block discarded – undo
520 520
                 )));
521 521
             }
522 522
         }
523
-        catch (AppDeletedRecordException $e){
523
+        catch (AppDeletedRecordException $e) {
524 524
             $this->deletedItemPage($action, $e);
525 525
         }
526
-        catch (AppNotFoundException $e){
526
+        catch (AppNotFoundException $e) {
527 527
             $this->notFoundPage($action, $e);
528 528
         }
529
-        catch (ORMException $e){
529
+        catch (ORMException $e) {
530 530
             $this->errorPage($e);
531 531
         }
532
-        catch (\Exception $e){
532
+        catch (\Exception $e) {
533 533
             $this->unexpectedErrorPage($e);
534 534
         }
535 535
         
536 536
         $W = bab_Widgets();
537 537
         
538
-        if($returnedValue instanceof WidgetDisplayableInterface){
538
+        if ($returnedValue instanceof WidgetDisplayableInterface) {
539 539
             
540
-            if($returnedValue instanceof WidgetBabPage && ! $this->isAjaxRequest()){
540
+            if ($returnedValue instanceof WidgetBabPage && !$this->isAjaxRequest()) {
541 541
                 
542 542
                 // If the action returned a page, we display it.
543 543
                 $returnedValue->displayHtml();
544 544
             }
545
-            else{
545
+            else {
546 546
                 
547 547
                 $htmlCanvas = $W->HtmlCanvas();
548
-                if(self::$acceptJson){
548
+                if (self::$acceptJson) {
549 549
                     $itemId = $returnedValue->getId();
550 550
                     $returnArray = array(
551 551
                         $itemId => $returnedValue->display($htmlCanvas)
@@ -555,18 +555,18 @@  discard block
 block discarded – undo
555 555
                     header('Content-type: application/json');
556 556
                     die(bab_json_encode($returnArray));
557 557
                 }
558
-                else{
558
+                else {
559 559
                     header('Cache-Control: no-cache, must-revalidate');
560 560
                     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
561 561
                     header('Content-type: text/html');
562
-                    if($returnedValue instanceof WidgetPage && method_exists($returnedValue, 'getPageTitle')){
562
+                    if ($returnedValue instanceof WidgetPage && method_exists($returnedValue, 'getPageTitle')) {
563 563
                         $pageTitle = $returnedValue->getPageTitle();
564 564
                         
565
-                        if(method_exists($htmlCanvas, 'sendPageTitle')){
565
+                        if (method_exists($htmlCanvas, 'sendPageTitle')) {
566 566
                             $htmlCanvas->sendPageTitle($pageTitle);
567 567
                         }
568
-                        else{
569
-                            header('X-Cto-PageTitle: ' . $pageTitle);
568
+                        else {
569
+                            header('X-Cto-PageTitle: '.$pageTitle);
570 570
                         }
571 571
                     }
572 572
                     $html = $returnedValue->display($htmlCanvas);
@@ -574,15 +574,15 @@  discard block
 block discarded – undo
574 574
                 }
575 575
             }
576 576
         }
577
-        elseif(is_array($returnedValue)){
577
+        elseif (is_array($returnedValue)) {
578 578
             
579 579
             $htmlCanvas = $W->HtmlCanvas();
580 580
             $returnedArray = array();
581
-            foreach ($returnedValue as $key => &$item){
582
-                if($item instanceof WidgetDisplayableInterface){
581
+            foreach ($returnedValue as $key => &$item) {
582
+                if ($item instanceof WidgetDisplayableInterface) {
583 583
                     $returnedArray[$item->getId()] = $item->display($htmlCanvas);
584 584
                 }
585
-                else{
585
+                else {
586 586
                     $returnedArray[$key] = $item;
587 587
                 }
588 588
             }
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
             header('Content-type: application/json');
592 592
             die(bab_convertStringFromDatabase(bab_json_encode($returnedArray), BabCharset::UTF_8));
593 593
         }
594
-        elseif(true === $returnedValue || is_string($returnedValue)){
594
+        elseif (true === $returnedValue || is_string($returnedValue)) {
595 595
             
596
-            if($this->isAjaxRequest()){
596
+            if ($this->isAjaxRequest()) {
597 597
                 $body = bab_getBody();
598 598
                 $json = array();
599 599
                 $json['messages'] = array();
@@ -601,24 +601,24 @@  discard block
 block discarded – undo
601 601
                 unset($body->messages['toasts']);
602 602
                 $messages = $body->messages;
603 603
                 $errors = $body->errors;
604
-                foreach ($messages as $message){
604
+                foreach ($messages as $message) {
605 605
                     $json['messages'][] = array(
606 606
                         'level' => 'info',
607 607
                         'content' => $message,
608 608
                         'time' => 4000
609 609
                     );
610 610
                 }
611
-                foreach ($errors as $message){
611
+                foreach ($errors as $message) {
612 612
                     $json['messages'][] = array(
613 613
                         'level' => 'danger',
614 614
                         'content' => $message
615 615
                     );
616 616
                 }
617 617
                 $json['toasts'] = $toasts;
618
-                if($objectController->getReloadSelectors()){
618
+                if ($objectController->getReloadSelectors()) {
619 619
                     $json['reloadSelector'] = implode(',', $objectController->getReloadSelectors());
620 620
                 }
621
-                if($objectController->keepDialogOpened){
621
+                if ($objectController->keepDialogOpened) {
622 622
                     $json['keepDialogOpened'] = true;
623 623
                 }
624 624
                 echo bab_json_encode($json);
@@ -631,8 +631,8 @@  discard block
 block discarded – undo
631 631
     
632 632
     protected function deletedItemPage(WidgetAction $action, AppDeletedRecordException $e)
633 633
     {
634
-        if($this->isAjaxRequest()){
635
-            header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403);
634
+        if ($this->isAjaxRequest()) {
635
+            header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403);
636 636
             header('Cache-Control: no-cache, must-revalidate');
637 637
             header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
638 638
             header('Content-type: application/json');
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
                 'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8')
645 645
             )));
646 646
         }
647
-        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404);
647
+        header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
648 648
         
649 649
         $App = app_App();
650 650
         $W = bab_Widgets();
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
             ->setAlignItems(WidgetFlexLayout::FLEX_ALIGN_ITEMS_CENTER));
667 667
         $section->addItems($W->Title($App->translate('Error'), 1), $W->Title(sprintf($App->translate('This %s has been deleted'), $e->getObjectTitle())));
668 668
         
669
-        if($e instanceof AppDeletedRecordException){
669
+        if ($e instanceof AppDeletedRecordException) {
670 670
             $section->addItems($e->getDeletedBy(), $e->getDeletedOn());
671 671
         }
672 672
         
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
     
676 676
     protected function notFoundPage(WidgetAction $action, AppNotFoundException $e)
677 677
     {
678
-        if($this->isAjaxRequest()){
679
-            $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle() . ' (' . $e->getId() . ')');
678
+        if ($this->isAjaxRequest()) {
679
+            $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle().' ('.$e->getId().')');
680 680
             $json = array(
681 681
                 'messages' => array(
682 682
                     array(
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
             echo bab_json_encode($json);
689 689
             die();
690 690
         }
691
-        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404);
691
+        header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
692 692
         header('Cache-Control: no-cache, must-revalidate');
693 693
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
694 694
         
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
     
718 718
     protected function unexpectedErrorPage(\Exception $e)
719 719
     {
720
-        if($this->isAjaxRequest()){
721
-            $message = sprintf(app_translate('An unexpected error occured') . ':' . '%s', $e->getMessage());
720
+        if ($this->isAjaxRequest()) {
721
+            $message = sprintf(app_translate('An unexpected error occured').':'.'%s', $e->getMessage());
722 722
             $json = array(
723 723
                 'messages' => array(
724 724
                     array(
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
             echo bab_json_encode($json);
731 731
             die();
732 732
         }
733
-        header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500);
733
+        header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500);
734 734
         header('Cache-Control: no-cache, must-revalidate');
735 735
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
736 736
         
@@ -754,25 +754,25 @@  discard block
 block discarded – undo
754 754
             ->addClass('widget-50pc alert alert-danger')
755 755
             ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL));
756 756
         
757
-        $logCode = '#' . hrtime(true);
757
+        $logCode = '#'.hrtime(true);
758 758
         $message = addcslashes($e->getMessage(), "\000..\037\177..\377\\");
759 759
         $trace = addcslashes($e->getTraceAsString(), "\000..\037\177..\377\\");
760 760
         
761
-        error_log(sprintf('Error %s : %s', $logCode, $message) . PHP_EOL . $trace);
761
+        error_log(sprintf('Error %s : %s', $logCode, $message).PHP_EOL.$trace);
762 762
         
763 763
         $section->addItems($W->Title($App->translate('Error'), 1), $W->Title($App->translate('An unexpected error occured')), $W->Label(sprintf($App->translate('It has been logged with the following error code : %s'), $logCode)));
764 764
         
765
-        if(bab_isUserAdministrator()){
765
+        if (bab_isUserAdministrator()) {
766 766
             $contentBox->addItem($W->Section('Stack trace', $stackTraceBox = $W->FlexItems($W->Label($message)
767 767
                 ->addClass('widget-description'))
768 768
                 ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL))
769 769
                 ->setFoldable(true, true));
770 770
             $traces = explode("\n", $e->getTraceAsString());
771
-            foreach ($traces as $trace){
771
+            foreach ($traces as $trace) {
772 772
                 $stackTraceBox->addItem($W->Label($trace));
773 773
             }
774 774
         }
775
-        else{
775
+        else {
776 776
             $section->addItem($W->Label($App->translate('Please contact the administrator')));
777 777
         }
778 778
         
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
     
782 782
     protected function errorPage(\Exception $e)
783 783
     {
784
-        if($this->isAjaxRequest()){
785
-            $message = sprintf(app_translate('An unexpected error occured') . ':' . '%s', $e->getMessage());
784
+        if ($this->isAjaxRequest()) {
785
+            $message = sprintf(app_translate('An unexpected error occured').':'.'%s', $e->getMessage());
786 786
             $json = array(
787 787
                 'messages' => array(
788 788
                     array(
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
             echo bab_json_encode($json);
795 795
             die();
796 796
         }
797
-        header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500);
797
+        header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500);
798 798
         header('Cache-Control: no-cache, must-revalidate');
799 799
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
800 800
         
@@ -818,25 +818,25 @@  discard block
 block discarded – undo
818 818
             ->addClass('widget-50pc alert alert-danger')
819 819
             ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL));
820 820
         
821
-        $logCode = '#' . hrtime(true);
821
+        $logCode = '#'.hrtime(true);
822 822
         $message = addcslashes($e->getMessage(), "\000..\037\177..\377\\");
823 823
         $trace = addcslashes($e->getTraceAsString(), "\000..\037\177..\377\\");
824 824
         
825
-        error_log(sprintf('Error %s : %s', $logCode, $message) . PHP_EOL . $trace);
825
+        error_log(sprintf('Error %s : %s', $logCode, $message).PHP_EOL.$trace);
826 826
         
827 827
         $section->addItems($W->Title($App->translate('Error'), 1), $W->Title($App->translate('An unexpected error occured')), $W->Label(sprintf($App->translate('It has been logged with the following error code : %s'), $logCode)));
828 828
         
829
-        if(bab_isUserAdministrator()){
829
+        if (bab_isUserAdministrator()) {
830 830
             $contentBox->addItem($W->Section('Stack trace', $stackTraceBox = $W->FlexItems($W->Label($message)
831 831
                 ->addClass('widget-description'))
832 832
                 ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL))
833 833
                 ->setFoldable(true, true));
834 834
             $traces = explode("\n", $e->getTraceAsString());
835
-            foreach ($traces as $trace){
835
+            foreach ($traces as $trace) {
836 836
                 $stackTraceBox->addItem($W->Label($trace));
837 837
             }
838 838
         }
839
-        else{
839
+        else {
840 840
             $section->addItem($W->Label($App->translate('Please contact the administrator')));
841 841
         }
842 842
         
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
     
846 846
     protected function accessPage(\Exception $e)
847 847
     {
848
-        if($this->isAjaxRequest()){
848
+        if ($this->isAjaxRequest()) {
849 849
             $message = $e->getMessage();
850 850
             $json = array(
851 851
                 'messages' => array(
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
             echo bab_json_encode($json);
859 859
             die();
860 860
         }
861
-        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403);
861
+        header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403);
862 862
         header('Cache-Control: no-cache, must-revalidate');
863 863
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
864 864
         
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
      */
896 896
     public function requireSaveMethod()
897 897
     {
898
-        if('GET' === $_SERVER['REQUEST_METHOD']){
898
+        if ('GET' === $_SERVER['REQUEST_METHOD']) {
899 899
             throw new AppException('Method not allowed');
900 900
         }
901 901
         
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
      */
911 911
     public function requireDeleteMethod()
912 912
     {
913
-        if('GET' === $_SERVER['REQUEST_METHOD']){
913
+        if ('GET' === $_SERVER['REQUEST_METHOD']) {
914 914
             throw new AppException('Method not allowed');
915 915
         }
916 916
         
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
             'position' => $position
943 943
         );
944 944
         $babBody = bab_getBody();
945
-        if(! isset($babBody->messages['toasts'])){
945
+        if (!isset($babBody->messages['toasts'])) {
946 946
             $babBody->messages['toasts'] = array();
947 947
         }
948 948
         $babBody->messages['toasts'][] = $toast;
Please login to merge, or discard this patch.
Braces   +21 added lines, -41 removed lines patch added patch discarded remove patch
@@ -208,8 +208,7 @@  discard block
 block discarded – undo
208 208
     {
209 209
         if($this->isAjaxRequest()){
210 210
             $authType = 'Basic';
211
-        }
212
-        else{
211
+        } else{
213 212
             $authType = '';
214 213
         }
215 214
         
@@ -287,8 +286,7 @@  discard block
 block discarded – undo
287 286
                     }
288 287
                     if($parameter->isDefaultValueAvailable()){
289 288
                         $parametersStr[] = $reference. '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true);
290
-                    }
291
-                    else{
289
+                    } else{
292 290
                         $parametersStr[] = $reference. '$' . $parameter->name;
293 291
                     }
294 292
                 }
@@ -342,7 +340,7 @@  discard block
 block discarded – undo
342 340
         $field = explode('Ctrl', $classname);
343 341
         if(count($field) == 1){
344 342
             $objectname= $field[0];
345
-        }else{
343
+        } else{
346 344
             $objectname= $field[1];
347 345
         }
348 346
         return strtolower($objectname);
@@ -387,11 +385,9 @@  discard block
 block discarded – undo
387 385
             $parameterName = $parameter->getName();
388 386
             if(isset($args[$argNumber])){
389 387
                 $actionParams[$parameterName] = $args[$argNumber];
390
-            }
391
-            elseif($parameter->isDefaultValueAvailable()){
388
+            } elseif($parameter->isDefaultValueAvailable()){
392 389
                 $actionParams[$parameterName] = $parameter->getDefaultValue();
393
-            }
394
-            else{
390
+            } else{
395 391
                 $actionParams[$parameterName] = null;
396 392
             }
397 393
             $argNumber ++;
@@ -469,8 +465,7 @@  discard block
 block discarded – undo
469 465
             if($component){
470 466
                 $this->app->setCurrentComponent($component);
471 467
                 $objectController = $component->controller(false);
472
-            }
473
-            else{
468
+            } else{
474 469
                 header('HTTP/1.0 400 Bad Request');
475 470
                 throw new AppUnknownActionException($action);
476 471
             }
@@ -485,13 +480,11 @@  discard block
 block discarded – undo
485 480
         
486 481
         try{
487 482
             $returnedValue = $objectController->execAction($action);
488
-        }
489
-        catch (AppAccessException $e){
483
+        } catch (AppAccessException $e){
490 484
             
491 485
             if(! bab_isUserLogged() && $e->requireCredential){
492 486
                 bab_requireCredential($e->getMessage());
493
-            }
494
-            else{
487
+            } else{
495 488
                 if($this->isAjaxRequest()){
496 489
                     
497 490
                     header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403);
@@ -504,8 +497,7 @@  discard block
 block discarded – undo
504 497
                 }
505 498
                 $this->accessPage($e);
506 499
             }
507
-        }
508
-        catch (AppSaveException $e){
500
+        } catch (AppSaveException $e){
509 501
             
510 502
             if($this->isAjaxRequest()){
511 503
                 header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403);
@@ -519,17 +511,13 @@  discard block
 block discarded – undo
519 511
                     'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8')
520 512
                 )));
521 513
             }
522
-        }
523
-        catch (AppDeletedRecordException $e){
514
+        } catch (AppDeletedRecordException $e){
524 515
             $this->deletedItemPage($action, $e);
525
-        }
526
-        catch (AppNotFoundException $e){
516
+        } catch (AppNotFoundException $e){
527 517
             $this->notFoundPage($action, $e);
528
-        }
529
-        catch (ORMException $e){
518
+        } catch (ORMException $e){
530 519
             $this->errorPage($e);
531
-        }
532
-        catch (\Exception $e){
520
+        } catch (\Exception $e){
533 521
             $this->unexpectedErrorPage($e);
534 522
         }
535 523
         
@@ -541,8 +529,7 @@  discard block
 block discarded – undo
541 529
                 
542 530
                 // If the action returned a page, we display it.
543 531
                 $returnedValue->displayHtml();
544
-            }
545
-            else{
532
+            } else{
546 533
                 
547 534
                 $htmlCanvas = $W->HtmlCanvas();
548 535
                 if(self::$acceptJson){
@@ -554,8 +541,7 @@  discard block
 block discarded – undo
554 541
                     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
555 542
                     header('Content-type: application/json');
556 543
                     die(bab_json_encode($returnArray));
557
-                }
558
-                else{
544
+                } else{
559 545
                     header('Cache-Control: no-cache, must-revalidate');
560 546
                     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
561 547
                     header('Content-type: text/html');
@@ -564,8 +550,7 @@  discard block
 block discarded – undo
564 550
                         
565 551
                         if(method_exists($htmlCanvas, 'sendPageTitle')){
566 552
                             $htmlCanvas->sendPageTitle($pageTitle);
567
-                        }
568
-                        else{
553
+                        } else{
569 554
                             header('X-Cto-PageTitle: ' . $pageTitle);
570 555
                         }
571 556
                     }
@@ -573,16 +558,14 @@  discard block
 block discarded – undo
573 558
                     die($html);
574 559
                 }
575 560
             }
576
-        }
577
-        elseif(is_array($returnedValue)){
561
+        } elseif(is_array($returnedValue)){
578 562
             
579 563
             $htmlCanvas = $W->HtmlCanvas();
580 564
             $returnedArray = array();
581 565
             foreach ($returnedValue as $key => &$item){
582 566
                 if($item instanceof WidgetDisplayableInterface){
583 567
                     $returnedArray[$item->getId()] = $item->display($htmlCanvas);
584
-                }
585
-                else{
568
+                } else{
586 569
                     $returnedArray[$key] = $item;
587 570
                 }
588 571
             }
@@ -590,8 +573,7 @@  discard block
 block discarded – undo
590 573
             header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
591 574
             header('Content-type: application/json');
592 575
             die(bab_convertStringFromDatabase(bab_json_encode($returnedArray), BabCharset::UTF_8));
593
-        }
594
-        elseif(true === $returnedValue || is_string($returnedValue)){
576
+        } elseif(true === $returnedValue || is_string($returnedValue)){
595 577
             
596 578
             if($this->isAjaxRequest()){
597 579
                 $body = bab_getBody();
@@ -771,8 +753,7 @@  discard block
 block discarded – undo
771 753
             foreach ($traces as $trace){
772 754
                 $stackTraceBox->addItem($W->Label($trace));
773 755
             }
774
-        }
775
-        else{
756
+        } else{
776 757
             $section->addItem($W->Label($App->translate('Please contact the administrator')));
777 758
         }
778 759
         
@@ -835,8 +816,7 @@  discard block
 block discarded – undo
835 816
             foreach ($traces as $trace){
836 817
                 $stackTraceBox->addItem($W->Label($trace));
837 818
             }
838
-        }
839
-        else{
819
+        } else{
840 820
             $section->addItem($W->Label($App->translate('Please contact the administrator')));
841 821
         }
842 822
         
Please login to merge, or discard this patch.
programs/Ctrl/AppCtrlCustomSection.php 2 patches
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         $customSection = $customSectionSet->request($customSectionSet->id->is($section));
69 69
         
70 70
         $object = $customSection->container->object;
71
-        if(strpos($object, $App->classPrefix) !== false){
71
+        if (strpos($object, $App->classPrefix) !== false) {
72 72
             list (, $object) = explode($App->classPrefix, $object);
73 73
         }
74 74
         $objectCtrl = $App->Controller()->$object(false);
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
             ->_AND_($customSectionSet->object->is($customSection->object)));
78 78
         
79 79
         $allViewFieldNames = array();
80
-        foreach ($allViewSections as $viewSection){
80
+        foreach ($allViewSections as $viewSection) {
81 81
             $fields = $viewSection->getFields();
82
-            foreach ($fields as $field){
83
-                $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id;
84
-                if(isset($field["fields"])){
85
-                    foreach ($field['fields'] as $subField){
86
-                        $allViewFieldNames[$subField['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id;
82
+            foreach ($fields as $field) {
83
+                $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id;
84
+                if (isset($field["fields"])) {
85
+                    foreach ($field['fields'] as $subField) {
86
+                        $allViewFieldNames[$subField['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id;
87 87
                     }
88 88
                 }
89 89
             }
90 90
         }
91 91
         
92 92
         $box = $W->VBoxItems();
93
-        if(isset($itemId)){
93
+        if (isset($itemId)) {
94 94
             $box->setId($itemId);
95 95
         }
96 96
         
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         
106 106
         BabSort::asort($availableFields, 'description', BabSort::CASE_INSENSITIVE);
107 107
         
108
-        foreach ($availableFields as $field){
108
+        foreach ($availableFields as $field) {
109 109
             $fieldName = $field['name'];
110 110
             $fieldDescription = $field['description'];
111 111
             
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         
161 161
         $field = $customSection->getField($fieldName);
162 162
         
163
-        if(! isset($field)){
163
+        if (!isset($field)) {
164 164
             return null;
165 165
         }
166 166
         
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
         
178 178
         $field = $availableFields[$fieldName];
179 179
         $fieldDescription = $field['description'];
180
-        if(substr($fieldName, 0, 1) !== '_'){
180
+        if (substr($fieldName, 0, 1) !== '_') {
181 181
             $fieldDescription = $App->translate($fieldDescription);
182 182
         }
183 183
         
184
-        if(empty($field)){
184
+        if (empty($field)) {
185 185
             // continue;
186 186
         }
187 187
         
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
         
252 252
         $groupField = $customSection->getField($fieldGroupName);
253 253
         
254
-        if(! isset($groupField)){
254
+        if (!isset($groupField)) {
255 255
             return null;
256 256
         }
257 257
         
258 258
         $field = $groupField['fields'][$fieldName];
259
-        if(! isset($field)){
259
+        if (!isset($field)) {
260 260
             return null;
261 261
         }
262 262
         
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
         
273 273
         $field = $availableFields[$fieldName];
274 274
         $fieldDescription = $field['description'];
275
-        if(substr($fieldName, 0, 1) !== '_'){
275
+        if (substr($fieldName, 0, 1) !== '_') {
276 276
             $fieldDescription = $App->translate($fieldDescription);
277 277
         }
278 278
         
279
-        if(empty($field)){
279
+        if (empty($field)) {
280 280
             // continue;
281 281
         }
282 282
         
@@ -359,12 +359,12 @@  discard block
 block discarded – undo
359 359
         
360 360
         $customSection = $customSectionSet->request($customSectionSet->id->is($section));
361 361
         $fields = $customSection->getFields();
362
-        if(! isset($fields[$fieldGroupName])){
362
+        if (!isset($fields[$fieldGroupName])) {
363 363
             throw new AppException($App->translate('This fields group does not seem to exist'));
364 364
         }
365 365
         
366 366
         $object = $customSection->container->object;
367
-        if(strpos($object, $App->classPrefix) !== false){
367
+        if (strpos($object, $App->classPrefix) !== false) {
368 368
             list (, $object) = explode($App->classPrefix, $object);
369 369
         }
370 370
         
@@ -374,20 +374,20 @@  discard block
 block discarded – undo
374 374
             ->_AND_($customSectionSet->object->is($customSection->object)));
375 375
         
376 376
         $allViewFieldNames = array();
377
-        foreach ($allViewSections as $viewSection){
377
+        foreach ($allViewSections as $viewSection) {
378 378
             $fields = $viewSection->getFields();
379
-            foreach ($fields as $field){
380
-                $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id;
381
-                if(isset($field["fields"])){
382
-                    foreach ($field['fields'] as $subField){
383
-                        $allViewFieldNames[$subField['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id;
379
+            foreach ($fields as $field) {
380
+                $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id;
381
+                if (isset($field["fields"])) {
382
+                    foreach ($field['fields'] as $subField) {
383
+                        $allViewFieldNames[$subField['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id;
384 384
                     }
385 385
                 }
386 386
             }
387 387
         }
388 388
         
389 389
         $box = $W->VBoxItems();
390
-        if(isset($itemId)){
390
+        if (isset($itemId)) {
391 391
             $box->setId($itemId);
392 392
         }
393 393
         
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
         
405 405
         BabSort::asort($availableFields, 'description', BabSort::CASE_INSENSITIVE);
406 406
         
407
-        foreach ($availableFields as $field){
407
+        foreach ($availableFields as $field) {
408 408
             $fieldName = $field['name'];
409 409
             $fieldDescription = $field['description'];
410 410
             
@@ -516,10 +516,10 @@  discard block
 block discarded – undo
516 516
         $container = $customContainerSet->request($customContainerSet->id->is($container));
517 517
         
518 518
         $customSectionSet = $App->CustomSectionSet();
519
-        if(isset($id)){
519
+        if (isset($id)) {
520 520
             $record = $customSectionSet->request($id);
521 521
         }
522
-        else{
522
+        else {
523 523
             $record = $customSectionSet->newRecord();
524 524
             $record->container = $container->id;
525 525
         }
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         
532 532
         $editor = new AppEditor($App);
533 533
         $editor->setHiddenValue('tg', $App->controllerTg);
534
-        if($record->id){
534
+        if ($record->id) {
535 535
             $editor->setHiddenValue('data[id]', $record->id);
536 536
         }
537 537
         $editor->setName('data');
@@ -547,16 +547,16 @@  discard block
 block discarded – undo
547 547
         
548 548
         $options = array();
549 549
         $rank = 1;
550
-        foreach ($containers as $container){
550
+        foreach ($containers as $container) {
551 551
             $options[$container->id] = sprintf('%d (%s)', $rank, $container->name);
552
-            $rank ++;
552
+            $rank++;
553 553
         }
554 554
         
555 555
         $containerSections = $customSectionSet->select($customSectionSet->container->is($container->id))
556 556
             ->orderDesc($customSectionSet->rank);
557 557
         
558 558
         $nbSections = 0;
559
-        foreach ($containerSections as $containerSection){
559
+        foreach ($containerSections as $containerSection) {
560 560
             $nbSections = $containerSection->rank + 1;
561 561
             break;
562 562
         }
@@ -640,10 +640,10 @@  discard block
 block discarded – undo
640 640
         $record = $recordSet->request($id);
641 641
         
642 642
         $object = $record->object;
643
-        if(empty($object)){
643
+        if (empty($object)) {
644 644
             $object = $record->container()->object;
645 645
         }
646
-        if(strpos($object, $App->classPrefix) !== false){
646
+        if (strpos($object, $App->classPrefix) !== false) {
647 647
             $object = str_replace($App->classPrefix, '', $object);
648 648
         }
649 649
         $object .= 'Set';
@@ -658,25 +658,25 @@  discard block
 block discarded – undo
658 658
         $manySets = $objectRecordSet->getHasManyRelations();
659 659
         $oneSets = $objectRecordSet->getHasOneRelations();
660 660
         
661
-        if(! empty($record->visibilityCriteria)){
661
+        if (!empty($record->visibilityCriteria)) {
662 662
             $arrCriteria = json_decode($record->visibilityCriteria, true);
663 663
             
664 664
             $data = array();
665
-            foreach ($arrCriteria as $fieldName => $operation){
665
+            foreach ($arrCriteria as $fieldName => $operation) {
666 666
                 $data['field'] = $fieldName;
667
-                foreach ($operation as $condition => $value){
667
+                foreach ($operation as $condition => $value) {
668 668
                     $data['condition']['default'] = $condition;
669 669
                     $data['condition']['bool'] = $condition;
670
-                    if(is_array($value)){
671
-                        foreach ($value as $key => $subValue){
672
-                            foreach ($manySets as $manyFieldName => $manyRelation){
673
-                                if($key . 'Set' == $manyRelation->getForeignSetClassName()){
674
-                                    foreach ($subValue as $subFieldName => $subConditions){
675
-                                        if($subFieldName === '_foreignField'){
670
+                    if (is_array($value)) {
671
+                        foreach ($value as $key => $subValue) {
672
+                            foreach ($manySets as $manyFieldName => $manyRelation) {
673
+                                if ($key.'Set' == $manyRelation->getForeignSetClassName()) {
674
+                                    foreach ($subValue as $subFieldName => $subConditions) {
675
+                                        if ($subFieldName === '_foreignField') {
676 676
                                             continue;
677 677
                                         }
678 678
                                         $data['field'] = "{$manyFieldName}/{$subFieldName}";
679
-                                        foreach ($subConditions as $subCondition => $subConditionValue){
679
+                                        foreach ($subConditions as $subCondition => $subConditionValue) {
680 680
                                             $data['condition']['default'] = $subCondition;
681 681
                                             $data['condition']['bool'] = $subCondition;
682 682
                                             $value = $subConditionValue;
@@ -685,14 +685,14 @@  discard block
 block discarded – undo
685 685
                                     break;
686 686
                                 }
687 687
                             }
688
-                            foreach ($oneSets as $oneFieldName => $oneRelation){
689
-                                if($key . 'Set' == $oneRelation->getForeignSetClassName()){
690
-                                    foreach ($subValue as $subFieldName => $subConditions){
691
-                                        if($subFieldName === '_foreignField'){
688
+                            foreach ($oneSets as $oneFieldName => $oneRelation) {
689
+                                if ($key.'Set' == $oneRelation->getForeignSetClassName()) {
690
+                                    foreach ($subValue as $subFieldName => $subConditions) {
691
+                                        if ($subFieldName === '_foreignField') {
692 692
                                             continue;
693 693
                                         }
694 694
                                         $data['field'] = "{$oneFieldName}/{$subFieldName}";
695
-                                        foreach ($subConditions as $subCondition => $subConditionValue){
695
+                                        foreach ($subConditions as $subCondition => $subConditionValue) {
696 696
                                             $data['condition']['default'] = $subCondition;
697 697
                                             $data['condition']['bool'] = $subCondition;
698 698
                                             $value = $subConditionValue;
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
      */
728 728
     public function save($data = null)
729 729
     {
730
-        if(! isset($data['id']) && isset($data['container']) && $data['container'] != 0 && ! isset($data['rank'])){
730
+        if (!isset($data['id']) && isset($data['container']) && $data['container'] != 0 && !isset($data['rank'])) {
731 731
             $set = $this->getRecordSet();
732 732
             $data['rank'] = $set->select($set->container->is($data['container']))
733 733
                 ->count();
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
         return true;
740 740
     }
741 741
     
742
-    protected function postSave(ORMRecord &$record, $data)
742
+    protected function postSave(ORMRecord & $record, $data)
743 743
     {
744 744
         parent::postSave($record, $data);
745 745
         $set = $record->getParentSet();
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
             $set->rank->greaterThanOrEqual($record->rank)
761 761
         )));
762 762
         
763
-        $position ++;
764
-        foreach ($afterSections as $afterSection){
763
+        $position++;
764
+        foreach ($afterSections as $afterSection) {
765 765
             $afterSection->rank = $position;
766 766
             $afterSection->save();
767
-            $position ++;
767
+            $position++;
768 768
         }
769 769
     }
770 770
     
@@ -792,10 +792,10 @@  discard block
 block discarded – undo
792 792
         $record = $recordSet->request($data['id']);
793 793
         
794 794
         $object = $record->object;
795
-        if(empty($object)){
795
+        if (empty($object)) {
796 796
             $object = $record->container()->object;
797 797
         }
798
-        if(strpos($object, $App->classPrefix) !== false){
798
+        if (strpos($object, $App->classPrefix) !== false) {
799 799
             $object = str_replace($App->classPrefix, '', $object);
800 800
         }
801 801
         $object .= 'Set';
@@ -805,14 +805,14 @@  discard block
 block discarded – undo
805 805
         $field = $data['field'];
806 806
         $condition = $data['condition'];
807 807
         
808
-        if(strpos($field, '/') !== false){
808
+        if (strpos($field, '/') !== false) {
809 809
             // The selected field is a hasMany or a hasOne relation
810 810
             list ($selectedRelation, $selectedField) = explode('/', $field);
811 811
             $classPrefix = $App->classPrefix;
812 812
             
813 813
             $manyRelations = $objectRecordSet->getHasManyRelations();
814
-            foreach ($manyRelations as $manyRelation){
815
-                if($selectedRelation != $manyRelation->getOwnerSetFieldName()){
814
+            foreach ($manyRelations as $manyRelation) {
815
+                if ($selectedRelation != $manyRelation->getOwnerSetFieldName()) {
816 816
                     continue;
817 817
                 }
818 818
                 $foreignSetName = str_replace($classPrefix, '', $manyRelation->getForeignSetClassName());
@@ -820,13 +820,13 @@  discard block
 block discarded – undo
820 820
                 
821 821
                 $visibilityCriteria = '';
822 822
                 
823
-                if($foreignSet){
823
+                if ($foreignSet) {
824 824
                     $selectedManyField = $foreignSet->$selectedField;
825 825
                     
826
-                    if($selectedManyField instanceof ORMBoolInterface){
826
+                    if ($selectedManyField instanceof ORMBoolInterface) {
827 827
                         $condition = $condition['bool'];
828 828
                     }
829
-                    else{
829
+                    else {
830 830
                         $condition = $condition['default'];
831 831
                     }
832 832
                     
@@ -838,9 +838,9 @@  discard block
 block discarded – undo
838 838
             }
839 839
             
840 840
             $oneRelations = $objectRecordSet->getHasOneRelations();
841
-            foreach ($oneRelations as $oneRelation){
841
+            foreach ($oneRelations as $oneRelation) {
842 842
                 /* @var $oneRelation ORMOneRelation*/
843
-                if($selectedRelation != $oneRelation->getOwnerSetFieldName()){
843
+                if ($selectedRelation != $oneRelation->getOwnerSetFieldName()) {
844 844
                     continue;
845 845
                 }
846 846
                 $foreignSetClassName = $oneRelation->getForeignSetClassName();
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
                 
850 850
                 $visibilityCriteria = '';
851 851
                 
852
-                if($foreignSet){
852
+                if ($foreignSet) {
853 853
                     $selectedOneField = $foreignSet->$selectedField;
854 854
                     
855
-                    if($selectedOneField instanceof ORMBoolInterface){
855
+                    if ($selectedOneField instanceof ORMBoolInterface) {
856 856
                         $condition = $condition['bool'];
857 857
                     }
858
-                    else{
858
+                    else {
859 859
                         $condition = $condition['default'];
860 860
                     }
861 861
                     
@@ -865,20 +865,20 @@  discard block
 block discarded – undo
865 865
                 break;
866 866
             }
867 867
         }
868
-        else{
868
+        else {
869 869
             
870 870
             $field = $objectRecordSet->$field;
871 871
             
872
-            if($field instanceof ORMBoolInterface){
872
+            if ($field instanceof ORMBoolInterface) {
873 873
                 $condition = $condition['bool'];
874 874
             }
875
-            else{
875
+            else {
876 876
                 $condition = $condition['default'];
877 877
             }
878 878
             
879 879
             $visibilityCriteria = '';
880 880
             
881
-            if(! empty($condition)){
881
+            if (!empty($condition)) {
882 882
                 $criteria = $field->{$condition}($data['value']);
883 883
                 $visibilityCriteria = $criteria->toJson();
884 884
             }
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
         $customContainer = $customContainerSet->request($container);
908 908
         
909 909
         $object = $customContainer->object;
910
-        if(strpos($object, $App->classPrefix) !== false){
910
+        if (strpos($object, $App->classPrefix) !== false) {
911 911
             list (, $object) = explode($App->classPrefix, $object);
912 912
         }
913 913
         
@@ -934,17 +934,17 @@  discard block
 block discarded – undo
934 934
         
935 935
         $nbCol = 0;
936 936
         
937
-        foreach ($customSections as $customSection){
937
+        foreach ($customSections as $customSection) {
938 938
             
939
-            list (, , $nbCol) = explode('-', $customSection->sizePolicy);
939
+            list (,, $nbCol) = explode('-', $customSection->sizePolicy);
940 940
             
941 941
             $currentColumn += $nbCol;
942 942
             
943
-            $sectionSection = $W->Section($customSection->name . ' (' . $customSection->rank . ')', $sectionBox = $W->VBoxItems($W->Hidden()
944
-                ->setName('#' . $customSection->id)));
943
+            $sectionSection = $W->Section($customSection->name.' ('.$customSection->rank.')', $sectionBox = $W->VBoxItems($W->Hidden()
944
+                ->setName('#'.$customSection->id)));
945 945
             $sectionSection->addClass('app-custom-section');
946 946
             $sectionSection->addClass($customSection->classname);
947
-            $sectionSection->setSizePolicy($customSection->sizePolicy . ' widget-sameheight');
947
+            $sectionSection->setSizePolicy($customSection->sizePolicy.' widget-sameheight');
948 948
             
949 949
             $row->addItem($sectionSection);
950 950
             
@@ -962,45 +962,45 @@  discard block
 block discarded – undo
962 962
                 ->addClass('icon', FuncIcons::ACTIONS_EDIT_DELETE)
963 963
                 ->setOpenMode(WidgetLink::OPEN_DIALOG)
964 964
                 ->setDialogClass('box red')));
965
-            if(! empty($customSection->visibilityCriteria)){
965
+            if (!empty($customSection->visibilityCriteria)) {
966 966
                 $sectionBox->addItem($W->HBoxItems($W->Label($App->translate('This section has a visibility condition')))
967 967
                     ->setSizePolicy('alert alert-warning widget-100pc'));
968 968
             }
969 969
             $fields = $customSection->getFields();
970
-            if(count($fields) == 0){
970
+            if (count($fields) == 0) {
971 971
                 $sectionBox->addItem($W->HBoxItems($W->Label($App->translate('This section does not contain any field')))
972 972
                     ->setSizePolicy('alert alert-warning'));
973 973
             }
974
-            foreach ($fields as $fieldId => $field){
975
-                if(empty($field)){
974
+            foreach ($fields as $fieldId => $field) {
975
+                if (empty($field)) {
976 976
                     continue;
977 977
                 }
978 978
                 
979 979
                 $fieldName = $field['fieldname'];
980 980
                 
981 981
                 $isFieldsGroup = false;
982
-                if(strpos($fieldName, '_fieldsGroup') !== false){
982
+                if (strpos($fieldName, '_fieldsGroup') !== false) {
983 983
                     $fieldName = '_fieldsGroup';
984 984
                     $isFieldsGroup = true;
985 985
                 }
986 986
                 
987
-                if(!isset($availableFields[$fieldName])){
987
+                if (!isset($availableFields[$fieldName])) {
988 988
                     $field = array();
989 989
                     $fieldDescription = "";
990
-                }else{
990
+                } else {
991 991
                     $field = $availableFields[$fieldName];
992 992
                     $fieldDescription = $field['description'];
993 993
                 }
994
-                if(substr($fieldName, 0, 1) !== '_'){
994
+                if (substr($fieldName, 0, 1) !== '_') {
995 995
                     $fieldDescription = $App->translate($fieldDescription);
996 996
                 }
997 997
                 
998
-                if(empty($field)){
998
+                if (empty($field)) {
999 999
                     continue;
1000 1000
                 }
1001 1001
                 
1002 1002
                 $fieldName = $field['name'];
1003
-                if($isFieldsGroup){
1003
+                if ($isFieldsGroup) {
1004 1004
                     $fieldName = $fieldId;
1005 1005
                 }
1006 1006
                 
@@ -1011,21 +1011,21 @@  discard block
 block discarded – undo
1011 1011
                     ->setGrowable(true)
1012 1012
                     ->setWrap(WidgetFlexLayout::FLEX_WRAP_WRAP))
1013 1013
                     ->setSizePolicy('maximum'), $btnBox = $W->HBoxItems($W->Hidden()
1014
-                    ->setName($customSection->id . '.' . $fieldId)
1014
+                    ->setName($customSection->id.'.'.$fieldId)
1015 1015
                     ->setValue($fieldName))
1016 1016
                     ->addClass('widget-actions'))
1017 1017
                     ->setSizePolicy('widget-list-element widget-actions-target')
1018 1018
                     ->addClass(FuncIcons::ICON_LEFT_16);
1019
-                if(strpos($field['name'], '_fieldsGroup') !== false){
1019
+                if (strpos($field['name'], '_fieldsGroup') !== false) {
1020 1020
                     $btnBox->addItem($W->Link('', $customSectionCtrl->addDisplayFieldToGroup($customSection->id, $fieldName))
1021 1021
                         ->addClass('icon', FuncIcons::ACTIONS_LIST_ADD)
1022 1022
                         ->setOpenMode(WidgetLink::OPEN_DIALOG));
1023
-                        if(isset($fields[$fieldName]["fields"])){
1023
+                        if (isset($fields[$fieldName]["fields"])) {
1024 1024
                             $groupedFields = $fields[$fieldName]['fields'];
1025
-                            foreach ($groupedFields as $groupedField){
1025
+                            foreach ($groupedFields as $groupedField) {
1026 1026
                                 $groupedFieldDetails = $availableFields[$groupedField['fieldname']];
1027 1027
                                 $fieldGroupBox->addItem($flexField = $W->FlowItems($W->Hidden(null, array(
1028
-                                    $customSection->id . '.fieldsGroups',
1028
+                                    $customSection->id.'.fieldsGroups',
1029 1029
                                     $fieldName,
1030 1030
                                     $groupedField['fieldname']
1031 1031
                                 ), $groupedField['fieldname']), $W->Label($groupedFieldDetails['description']), $W->FlowItems($W->Link('', $customSectionCtrl->editGroupFieldDisplayField($customSection->id, $fieldName, $groupedField['fieldname']))
@@ -1054,23 +1054,23 @@  discard block
 block discarded – undo
1054 1054
             $sectionsBoxes[] = $sectionBox;
1055 1055
         }
1056 1056
         
1057
-        if($currentColumn + $nbCol > 0){
1057
+        if ($currentColumn + $nbCol > 0) {
1058 1058
             $sectionsSection->addItem($row);
1059 1059
         }
1060 1060
         
1061
-        foreach ($sectionsBoxes as $sectionsBox){
1061
+        foreach ($sectionsBoxes as $sectionsBox) {
1062 1062
             $sectionsBox->sortable(true, $sectionsBoxes);
1063 1063
             $sectionsBox->setMetadata('samePlaceholderSize', true);
1064 1064
         }
1065 1065
         
1066
-        foreach ($rows as $row){
1066
+        foreach ($rows as $row) {
1067 1067
             $row->sortable(true, $rows);
1068 1068
             $row->setMetadata('samePlaceholderSize', true);
1069 1069
         }
1070 1070
         
1071 1071
         $form = $W->Form();
1072 1072
         
1073
-        if(isset($itemId)){
1073
+        if (isset($itemId)) {
1074 1074
             $form->setId($itemId);
1075 1075
         }
1076 1076
         $form->setHiddenValue('tg', $App->controllerTg);
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
         $customSections = $customSectionSet->select($customSectionSet->container->is($container));
1098 1098
         
1099 1099
         $sectionsValues = array();
1100
-        foreach ($customSections as $customSection){
1100
+        foreach ($customSections as $customSection) {
1101 1101
             $values = $customSection->getValues();
1102 1102
             unset($values['id']);
1103 1103
             unset($values['createdBy']);
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
         }
1112 1112
         
1113 1113
         header('Content-type: application/json');
1114
-        header('Content-Disposition: attachment; filename="' . $container->object . '.' . ($container->view === '' ? 'default' : $container->view) . '.' . $container->name . '.json"' . "\n");
1114
+        header('Content-Disposition: attachment; filename="'.$container->object.'.'.($container->view === '' ? 'default' : $container->view).'.'.$container->name.'.json"'."\n");
1115 1115
         
1116 1116
         $json = bab_json_encode($sectionsValues);
1117 1117
         $json = bab_convertStringFromDatabase($json, BabCharset::UTF_8);
@@ -1163,12 +1163,12 @@  discard block
 block discarded – undo
1163 1163
         $files->push($sectionsfile['uid']);
1164 1164
         
1165 1165
         $data = null;
1166
-        foreach ($files as $f){
1166
+        foreach ($files as $f) {
1167 1167
             $data = file_get_contents($f->toString());
1168 1168
             break;
1169 1169
         }
1170 1170
         
1171
-        if(! isset($data)){
1171
+        if (!isset($data)) {
1172 1172
             $this->addError($App->translate('Unable to get file content'));
1173 1173
             return true;
1174 1174
         }
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
         
1181 1181
         $customSectionSet->delete($customSectionSet->container->is($container));
1182 1182
         
1183
-        foreach ($sectionsValues as $sectionValues){
1183
+        foreach ($sectionsValues as $sectionValues) {
1184 1184
             $customSection = $customSectionSet->newRecord();
1185 1185
             $customSection->setValues($sectionValues);
1186 1186
             $customSection->container = $container;
@@ -1258,59 +1258,59 @@  discard block
 block discarded – undo
1258 1258
         $ranks = array();
1259 1259
         $rank = 0;
1260 1260
         
1261
-        foreach ($sections as $key => $value){
1261
+        foreach ($sections as $key => $value) {
1262 1262
             // Sections ids start with #, while section fields start with their original section id
1263
-            if(substr($key, 0, 1) === '#'){
1263
+            if (substr($key, 0, 1) === '#') {
1264 1264
                 $currentSectionId = substr($key, 1);
1265 1265
                 $rawSectionData[$currentSectionId] = array();
1266
-                if(! isset($oldSectionId)){
1266
+                if (!isset($oldSectionId)) {
1267 1267
                     $oldSectionId = $currentSectionId;
1268 1268
                 }
1269
-                if(isset($currentSection) && $oldSectionId != $currentSectionId){
1269
+                if (isset($currentSection) && $oldSectionId != $currentSectionId) {
1270 1270
                     $oldSectionId = $currentSectionId;
1271 1271
                 }
1272 1272
                 $ranks[$currentSectionId] = $rank;
1273
-                $rank ++;
1273
+                $rank++;
1274 1274
                 $currentSection = $customSectionSet->get($customSectionSet->id->is($currentSectionId));
1275 1275
                 continue;
1276 1276
             }
1277
-            if(! isset($currentSection)){
1277
+            if (!isset($currentSection)) {
1278 1278
                 continue;
1279 1279
             }
1280 1280
             list ($fieldSectionId, $fieldName) = explode('.', $key);
1281
-            if($fieldSectionId == $currentSectionId){
1281
+            if ($fieldSectionId == $currentSectionId) {
1282 1282
                 $field = $currentSection->getField($fieldName);
1283
-                if(strpos($fieldName, '_fieldsGroup') !== false && isset($rawSectionData[$currentSectionId][$fieldName])){
1283
+                if (strpos($fieldName, '_fieldsGroup') !== false && isset($rawSectionData[$currentSectionId][$fieldName])) {
1284 1284
                     $rawSectionData[$currentSectionId][$fieldName]['block'] = $field['block'];
1285 1285
                     $rawSectionData[$currentSectionId][$fieldName]['fieldname'] = '_fieldsGroup';
1286 1286
                     $rawSectionData[$currentSectionId][$fieldName]['parameters'] = $field['parameters'];
1287
-                    foreach ($sections[$currentSection->id . '.fieldsGroups'][$fieldName] as $subKey => $subValue){
1287
+                    foreach ($sections[$currentSection->id.'.fieldsGroups'][$fieldName] as $subKey => $subValue) {
1288 1288
                         $rawSectionData[$currentSectionId][$fieldName]['fields'][$subKey] = $field['fields'][$subKey];
1289 1289
                     }
1290 1290
                 }
1291
-                elseif($fieldName != 'fieldsGroups'){
1291
+                elseif ($fieldName != 'fieldsGroups') {
1292 1292
                     $rawSectionData[$currentSectionId][$fieldName] = $field;
1293 1293
                 }
1294 1294
             }
1295
-            else{
1295
+            else {
1296 1296
                 $field = null;
1297 1297
                 $tmpSection = $customSectionSet->get($customSectionSet->id->is($fieldSectionId));
1298
-                if($tmpSection){
1298
+                if ($tmpSection) {
1299 1299
                     $field = $tmpSection->getField($fieldName);
1300 1300
                 }
1301
-                if(isset($field)){
1301
+                if (isset($field)) {
1302 1302
                     $rawSectionData[$currentSectionId][$fieldName] = $field;
1303 1303
                 }
1304 1304
             }
1305 1305
         }
1306 1306
         
1307
-        foreach ($rawSectionData as $sectionId => $fields){
1307
+        foreach ($rawSectionData as $sectionId => $fields) {
1308 1308
             $section = $customSectionSet->get($customSectionSet->id->is($sectionId));
1309
-            if($section){
1309
+            if ($section) {
1310 1310
                 $section->fields = json_encode($fields);
1311 1311
                 $section->rank = isset($ranks[$sectionId]) ? $ranks[$sectionId] : 0;
1312 1312
                 $section->save();
1313
-                $rank ++;
1313
+                $rank++;
1314 1314
             }
1315 1315
         }
1316 1316
         
Please login to merge, or discard this patch.
Braces   +8 added lines, -15 removed lines patch added patch discarded remove patch
@@ -518,8 +518,7 @@  discard block
 block discarded – undo
518 518
         $customSectionSet = $App->CustomSectionSet();
519 519
         if(isset($id)){
520 520
             $record = $customSectionSet->request($id);
521
-        }
522
-        else{
521
+        } else{
523 522
             $record = $customSectionSet->newRecord();
524 523
             $record->container = $container->id;
525 524
         }
@@ -825,8 +824,7 @@  discard block
 block discarded – undo
825 824
                     
826 825
                     if($selectedManyField instanceof ORMBoolInterface){
827 826
                         $condition = $condition['bool'];
828
-                    }
829
-                    else{
827
+                    } else{
830 828
                         $condition = $condition['default'];
831 829
                     }
832 830
                     
@@ -854,8 +852,7 @@  discard block
 block discarded – undo
854 852
                     
855 853
                     if($selectedOneField instanceof ORMBoolInterface){
856 854
                         $condition = $condition['bool'];
857
-                    }
858
-                    else{
855
+                    } else{
859 856
                         $condition = $condition['default'];
860 857
                     }
861 858
                     
@@ -864,15 +861,13 @@  discard block
 block discarded – undo
864 861
                 }
865 862
                 break;
866 863
             }
867
-        }
868
-        else{
864
+        } else{
869 865
             
870 866
             $field = $objectRecordSet->$field;
871 867
             
872 868
             if($field instanceof ORMBoolInterface){
873 869
                 $condition = $condition['bool'];
874
-            }
875
-            else{
870
+            } else{
876 871
                 $condition = $condition['default'];
877 872
             }
878 873
             
@@ -987,7 +982,7 @@  discard block
 block discarded – undo
987 982
                 if(!isset($availableFields[$fieldName])){
988 983
                     $field = array();
989 984
                     $fieldDescription = "";
990
-                }else{
985
+                } else{
991 986
                     $field = $availableFields[$fieldName];
992 987
                     $fieldDescription = $field['description'];
993 988
                 }
@@ -1287,12 +1282,10 @@  discard block
 block discarded – undo
1287 1282
                     foreach ($sections[$currentSection->id . '.fieldsGroups'][$fieldName] as $subKey => $subValue){
1288 1283
                         $rawSectionData[$currentSectionId][$fieldName]['fields'][$subKey] = $field['fields'][$subKey];
1289 1284
                     }
1290
-                }
1291
-                elseif($fieldName != 'fieldsGroups'){
1285
+                } elseif($fieldName != 'fieldsGroups'){
1292 1286
                     $rawSectionData[$currentSectionId][$fieldName] = $field;
1293 1287
                 }
1294
-            }
1295
-            else{
1288
+            } else{
1296 1289
                 $field = null;
1297 1290
                 $tmpSection = $customSectionSet->get($customSectionSet->id->is($fieldSectionId));
1298 1291
                 if($tmpSection){
Please login to merge, or discard this patch.
programs/init.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 use function Cofy\Utilities\bab_GetDatabaseInstance;
36 36
 use function Cofy\Utilities\User\bab_isUserLogged;
37 37
 
38
-require_once dirname(__FILE__). '/functions.php';
38
+require_once dirname(__FILE__).'/functions.php';
39 39
 
40 40
 
41 41
 function LibApp_upgrade($sVersionBase, $sVersionIni)
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     
45 45
     $addon->unregisterFunctionality('App');
46 46
     $functionnalities = new BabFunctionalities();
47
-    $functionnalities->registerNamespace('App',"Capwelton\LibApp\FuncApp",$addon->getPhpPath().'FuncApp.php');
47
+    $functionnalities->registerNamespace('App', "Capwelton\LibApp\FuncApp", $addon->getPhpPath().'FuncApp.php');
48 48
 
49 49
     $addon->registerFunctionality('App', 'FuncApp.php');
50 50
     $addon->addEventListener('BabEventBeforePageCreated', 'libapp_onBeforePageCreated', 'init.php', -10);
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
     
93 93
     $babBody = bab_getBody();
94 94
     $addon = bab_getAddonInfosInstance('libapp');
95
-    $babBody->addStyleSheet($addon->getStylePath() . '/styles.css');
96
-    $babBody->addJavascriptFile($addon->getTemplatePath() . 'libapp.js');
95
+    $babBody->addStyleSheet($addon->getStylePath().'/styles.css');
96
+    $babBody->addJavascriptFile($addon->getTemplatePath().'libapp.js');
97 97
     $App = app_App();
98
-    if($App && $App->isSSEEnabled()){
99
-        $babBody->addJavascriptFile($addon->getTemplatePath() . 'notification.js');
100
-        if(bab_isUserLogged()){
98
+    if ($App && $App->isSSEEnabled()) {
99
+        $babBody->addJavascriptFile($addon->getTemplatePath().'notification.js');
100
+        if (bab_isUserLogged()) {
101 101
             $babBody->babecho('<script>window.libapp={"sseServerUrl": "'.$App->Controller()->SSE()->server()->url().'"}</script>');
102 102
             $babBody->addJavascriptFile($addon->getTemplatePath().'sse.js');
103 103
         }
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
     if (class_exists('FuncPortletBackend')) {
122 122
         $addon = bab_getAddonInfosInstance('libapp');
123 123
         $addonPhpPath = $addon->getPhpPath();
124
-        require_once dirname(__FILE__) . '/portletbackend.class.php';
124
+        require_once dirname(__FILE__).'/portletbackend.class.php';
125 125
         $functionalities = new BabFunctionalities();
126
-        $functionalities->registerClass('FuncPortletBackendApp', $addonPhpPath . 'portletbackend.class.php');
126
+        $functionalities->registerClass('FuncPortletBackendApp', $addonPhpPath.'portletbackend.class.php');
127 127
     }
128 128
 }
129 129
\ No newline at end of file
Please login to merge, or discard this patch.