@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | |
47 | 47 | $refreshFrequency = $this->getRefreshFrequency(); |
48 | 48 | |
49 | - while (1){ |
|
49 | + while (1) { |
|
50 | 50 | $data = $this->getSSEData(); |
51 | - if($data != '{}'){ |
|
51 | + if ($data != '{}') { |
|
52 | 52 | echo "event: ping\n"; |
53 | 53 | echo "\n\n"; |
54 | - echo 'data: ' . $this->getSSEData() . "\n\n"; |
|
54 | + echo 'data: '.$this->getSSEData()."\n\n"; |
|
55 | 55 | } |
56 | 56 | ob_end_flush(); |
57 | 57 | flush(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | private function getRefreshFrequency() |
63 | 63 | { |
64 | - if(! isset($this->refreshFrequency)){ |
|
64 | + if (!isset($this->refreshFrequency)) { |
|
65 | 65 | $registry = app_getRegistry(); |
66 | 66 | $registry->changeDirectory('configuration'); |
67 | 67 | $registry->changeDirectory('SSE'); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | private function getCurrentUser() |
82 | 82 | { |
83 | - if(isset($this->currentUser)){ |
|
83 | + if (isset($this->currentUser)) { |
|
84 | 84 | return $this->currentUser; |
85 | 85 | } |
86 | 86 |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | ->_AND_($customSectionSet->object->is($customSection->object))); |
60 | 60 | |
61 | 61 | $allViewFieldNames = array(); |
62 | - foreach ($allViewSections as $viewSection){ |
|
62 | + foreach ($allViewSections as $viewSection) { |
|
63 | 63 | $fields = $viewSection->getFields(); |
64 | - foreach ($fields as $field){ |
|
65 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
64 | + foreach ($fields as $field) { |
|
65 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | 69 | $box = $W->VBoxItems(); |
70 | - if(isset($itemId)){ |
|
70 | + if (isset($itemId)) { |
|
71 | 71 | $box->setId($itemId); |
72 | 72 | } |
73 | 73 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | \bab_Sort::asort($availableFields, 'description', \bab_Sort::CASE_INSENSITIVE); |
84 | 84 | |
85 | - foreach ($availableFields as $field){ |
|
85 | + foreach ($availableFields as $field) { |
|
86 | 86 | $fieldName = $field['name']; |
87 | 87 | $fieldDescription = $field['description']; |
88 | 88 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | $field = $customSection->getField($fieldName); |
138 | 138 | |
139 | - if(! isset($field)){ |
|
139 | + if (!isset($field)) { |
|
140 | 140 | return null; |
141 | 141 | } |
142 | 142 | |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | |
153 | 153 | $field = $availableFields[$fieldName]; |
154 | 154 | $fieldDescription = $field['description']; |
155 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
155 | + if (substr($fieldName, 0, 1) !== '_') { |
|
156 | 156 | $fieldDescription = $App->translate($fieldDescription); |
157 | 157 | } |
158 | 158 | |
159 | - if(empty($field)){ |
|
159 | + if (empty($field)) { |
|
160 | 160 | // continue; |
161 | 161 | } |
162 | 162 | |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | $W = bab_Widgets(); |
258 | 258 | |
259 | 259 | $customSectionSet = $App->CustomContainerSet(); |
260 | - if(isset($id)){ |
|
260 | + if (isset($id)) { |
|
261 | 261 | $record = $customSectionSet->request($id); |
262 | 262 | } |
263 | - else{ |
|
263 | + else { |
|
264 | 264 | $record = $customSectionSet->newRecord(); |
265 | 265 | $record->object = $object; |
266 | 266 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $editor = new AppEditor($App); |
274 | 274 | $editor->setHiddenValue('tg', $App->controllerTg); |
275 | 275 | $editor->setHiddenValue('data[view]', $view); |
276 | - if($record->id){ |
|
276 | + if ($record->id) { |
|
277 | 277 | $editor->setHiddenValue('data[id]', $record->id); |
278 | 278 | } |
279 | 279 | $editor->setName('data'); |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | $record = $recordSet->request($id); |
352 | 352 | |
353 | 353 | $object = $record->object; |
354 | - if(empty($object)){ |
|
354 | + if (empty($object)) { |
|
355 | 355 | $object = $record->container()->object; |
356 | 356 | } |
357 | - if(strpos($object, $App->classPrefix) !== false){ |
|
357 | + if (strpos($object, $App->classPrefix) !== false) { |
|
358 | 358 | $object = str_replace($App->classPrefix, '', $object); |
359 | 359 | } |
360 | 360 | $object .= 'Set'; |
@@ -369,25 +369,25 @@ discard block |
||
369 | 369 | $manySets = $objectRecordSet->getHasManyRelations(); |
370 | 370 | $oneSets = $objectRecordSet->getHasOneRelations(); |
371 | 371 | |
372 | - if(! empty($record->visibilityCriteria)){ |
|
372 | + if (!empty($record->visibilityCriteria)) { |
|
373 | 373 | $arrCriteria = json_decode($record->visibilityCriteria, true); |
374 | 374 | |
375 | 375 | $data = array(); |
376 | - foreach ($arrCriteria as $fieldName => $operation){ |
|
376 | + foreach ($arrCriteria as $fieldName => $operation) { |
|
377 | 377 | $data['field'] = $fieldName; |
378 | - foreach ($operation as $condition => $value){ |
|
378 | + foreach ($operation as $condition => $value) { |
|
379 | 379 | $data['condition']['default'] = $condition; |
380 | 380 | $data['condition']['bool'] = $condition; |
381 | - if(is_array($value)){ |
|
382 | - foreach ($value as $key => $subValue){ |
|
383 | - foreach ($manySets as $manyFieldName => $manyRelation){ |
|
384 | - if($key . 'Set' == $manyRelation->getForeignSetClassName()){ |
|
385 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
386 | - if($subFieldName === '_foreignField'){ |
|
381 | + if (is_array($value)) { |
|
382 | + foreach ($value as $key => $subValue) { |
|
383 | + foreach ($manySets as $manyFieldName => $manyRelation) { |
|
384 | + if ($key.'Set' == $manyRelation->getForeignSetClassName()) { |
|
385 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
386 | + if ($subFieldName === '_foreignField') { |
|
387 | 387 | continue; |
388 | 388 | } |
389 | 389 | $data['field'] = "{$manyFieldName}/{$subFieldName}"; |
390 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
390 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
391 | 391 | $data['condition']['default'] = $subCondition; |
392 | 392 | $data['condition']['bool'] = $subCondition; |
393 | 393 | $value = $subConditionValue; |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | break; |
397 | 397 | } |
398 | 398 | } |
399 | - foreach ($oneSets as $oneFieldName => $oneRelation){ |
|
400 | - if($key . 'Set' == $oneRelation->getForeignSetClassName()){ |
|
401 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
402 | - if($subFieldName === '_foreignField'){ |
|
399 | + foreach ($oneSets as $oneFieldName => $oneRelation) { |
|
400 | + if ($key.'Set' == $oneRelation->getForeignSetClassName()) { |
|
401 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
402 | + if ($subFieldName === '_foreignField') { |
|
403 | 403 | continue; |
404 | 404 | } |
405 | 405 | $data['field'] = "{$oneFieldName}/{$subFieldName}"; |
406 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
406 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
407 | 407 | $data['condition']['default'] = $subCondition; |
408 | 408 | $data['condition']['bool'] = $subCondition; |
409 | 409 | $value = $subConditionValue; |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | protected function preSave(\ORM_Record $record, $data) |
449 | 449 | { |
450 | 450 | parent::preSave($record, $data); |
451 | - if(! isset($record->id) || empty($record->id)){ |
|
451 | + if (!isset($record->id) || empty($record->id)) { |
|
452 | 452 | $set = $record->getParentSet(); |
453 | 453 | $nbContainers = $set->select($set->all(array( |
454 | 454 | $set->object->is($record->object), |
@@ -483,10 +483,10 @@ discard block |
||
483 | 483 | $record = $recordSet->request($data['id']); |
484 | 484 | |
485 | 485 | $object = $record->object; |
486 | - if(empty($object)){ |
|
486 | + if (empty($object)) { |
|
487 | 487 | $object = $record->container()->object; |
488 | 488 | } |
489 | - if(strpos($object, $App->classPrefix) !== false){ |
|
489 | + if (strpos($object, $App->classPrefix) !== false) { |
|
490 | 490 | $object = str_replace($App->classPrefix, '', $object); |
491 | 491 | } |
492 | 492 | $object .= 'Set'; |
@@ -497,14 +497,14 @@ discard block |
||
497 | 497 | $field = $data['field']; |
498 | 498 | $condition = $data['condition']; |
499 | 499 | |
500 | - if(strpos($field, '/') !== false){ |
|
500 | + if (strpos($field, '/') !== false) { |
|
501 | 501 | // The selected field is a hasMany or a hasOne relation |
502 | 502 | list ($selectedRelation, $selectedField) = explode('/', $field); |
503 | 503 | $classPrefix = $App->classPrefix; |
504 | 504 | |
505 | 505 | $manyRelations = $objectRecordSet->getHasManyRelations(); |
506 | - foreach ($manyRelations as $manyRelation){ |
|
507 | - if($selectedRelation != $manyRelation->getOwnerSetFieldName()){ |
|
506 | + foreach ($manyRelations as $manyRelation) { |
|
507 | + if ($selectedRelation != $manyRelation->getOwnerSetFieldName()) { |
|
508 | 508 | continue; |
509 | 509 | } |
510 | 510 | $foreignSetName = str_replace($classPrefix, '', $manyRelation->getForeignSetClassName()); |
@@ -512,13 +512,13 @@ discard block |
||
512 | 512 | |
513 | 513 | $visibilityCriteria = ''; |
514 | 514 | |
515 | - if($foreignSet){ |
|
515 | + if ($foreignSet) { |
|
516 | 516 | $selectedManyField = $foreignSet->$selectedField; |
517 | 517 | |
518 | - if($selectedManyField instanceof \ORM_BoolInterface){ |
|
518 | + if ($selectedManyField instanceof \ORM_BoolInterface) { |
|
519 | 519 | $condition = $condition['bool']; |
520 | 520 | } |
521 | - else{ |
|
521 | + else { |
|
522 | 522 | $condition = $condition['default']; |
523 | 523 | } |
524 | 524 | |
@@ -530,9 +530,9 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | $oneRelations = $objectRecordSet->getHasOneRelations(); |
533 | - foreach ($oneRelations as $oneRelation){ |
|
533 | + foreach ($oneRelations as $oneRelation) { |
|
534 | 534 | /* @var $oneRelation \ORM_OneRelation*/ |
535 | - if($selectedRelation != $oneRelation->getOwnerSetFieldName()){ |
|
535 | + if ($selectedRelation != $oneRelation->getOwnerSetFieldName()) { |
|
536 | 536 | continue; |
537 | 537 | } |
538 | 538 | $foreignSetClassName = $oneRelation->getForeignSetClassName(); |
@@ -541,13 +541,13 @@ discard block |
||
541 | 541 | |
542 | 542 | $visibilityCriteria = ''; |
543 | 543 | |
544 | - if($foreignSet){ |
|
544 | + if ($foreignSet) { |
|
545 | 545 | $selectedOneField = $foreignSet->$selectedField; |
546 | 546 | |
547 | - if($selectedOneField instanceof \ORM_BoolInterface){ |
|
547 | + if ($selectedOneField instanceof \ORM_BoolInterface) { |
|
548 | 548 | $condition = $condition['bool']; |
549 | 549 | } |
550 | - else{ |
|
550 | + else { |
|
551 | 551 | $condition = $condition['default']; |
552 | 552 | } |
553 | 553 | |
@@ -557,20 +557,20 @@ discard block |
||
557 | 557 | break; |
558 | 558 | } |
559 | 559 | } |
560 | - else{ |
|
560 | + else { |
|
561 | 561 | |
562 | 562 | $field = $objectRecordSet->$field; |
563 | 563 | |
564 | - if($field instanceof \ORM_BoolInterface){ |
|
564 | + if ($field instanceof \ORM_BoolInterface) { |
|
565 | 565 | $condition = $condition['bool']; |
566 | 566 | } |
567 | - else{ |
|
567 | + else { |
|
568 | 568 | $condition = $condition['default']; |
569 | 569 | } |
570 | 570 | |
571 | 571 | $visibilityCriteria = ''; |
572 | 572 | |
573 | - if(! empty($condition)){ |
|
573 | + if (!empty($condition)) { |
|
574 | 574 | $criteria = $field->{$condition}($data['value']); |
575 | 575 | $visibilityCriteria = $criteria->toJson(); |
576 | 576 | } |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | |
606 | 606 | $containerBoxes = $W->Items(); |
607 | 607 | |
608 | - foreach ($customContainers as $customContainer){ |
|
608 | + foreach ($customContainers as $customContainer) { |
|
609 | 609 | |
610 | 610 | $menu = $W->HBoxItems($W->Link('', $customSectionCtrl->edit($customContainer->id)) |
611 | 611 | ->addClass('icon', \Func_Icons::ACTIONS_LIST_ADD) |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | $menu->setSizePolicy(\Func_Icons::ICON_LEFT_16); |
621 | 621 | |
622 | 622 | $hasVisibilityBox = $W->FlowItems()->addClass('widget-100'); |
623 | - if(! empty($customContainer->visibilityCriteria)){ |
|
623 | + if (!empty($customContainer->visibilityCriteria)) { |
|
624 | 624 | $hasVisibilityBox->addItem($W->HBoxItems($W->Label($App->translate('This container has a visibility condition'))) |
625 | 625 | ->setSizePolicy('alert alert-warning widget-100pc')); |
626 | 626 | } |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | ->addClass($customContainer->classname)); |
632 | 632 | } |
633 | 633 | |
634 | - if(isset($itemId)){ |
|
634 | + if (isset($itemId)) { |
|
635 | 635 | $containerBoxes->setId($itemId); |
636 | 636 | } |
637 | 637 | |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | $customSectionSet = $App->CustomSectionSet(); |
658 | 658 | |
659 | 659 | $containersValues = array(); |
660 | - foreach ($customContainers as $customContainer){ |
|
660 | + foreach ($customContainers as $customContainer) { |
|
661 | 661 | $values = $customContainer->getValues(); |
662 | 662 | unset($values['id']); |
663 | 663 | unset($values['uuid']); |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | unset($values['deleted']); |
671 | 671 | $values['customSections'] = array(); |
672 | 672 | $customSections = $customSectionSet->select($customSectionSet->container->is($customContainer->id)); |
673 | - foreach ($customSections as $customSection){ |
|
673 | + foreach ($customSections as $customSection) { |
|
674 | 674 | $customSectionValues = $customSection->getValues(); |
675 | 675 | unset($customSectionValues['id']); |
676 | 676 | unset($customSectionValues['uuid']); |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | } |
690 | 690 | |
691 | 691 | header('Content-type: application/json'); |
692 | - header('Content-Disposition: attachment; filename="' . $object . '.' . ($view === '' ? 'default' : $view) . '.json"' . "\n"); |
|
692 | + header('Content-Disposition: attachment; filename="'.$object.'.'.($view === '' ? 'default' : $view).'.json"'."\n"); |
|
693 | 693 | |
694 | 694 | $json = bab_json_encode($containersValues); |
695 | 695 | $json = bab_convertStringFromDatabase($json, \bab_charset::UTF_8); |
@@ -747,12 +747,12 @@ discard block |
||
747 | 747 | $files->push($containersfile['uid']); |
748 | 748 | |
749 | 749 | $data = null; |
750 | - foreach ($files as $f){ |
|
750 | + foreach ($files as $f) { |
|
751 | 751 | $data = file_get_contents($f->toString()); |
752 | 752 | break; |
753 | 753 | } |
754 | 754 | |
755 | - if(! isset($data)){ |
|
755 | + if (!isset($data)) { |
|
756 | 756 | $this->addError($App->translate('Unable to get file content')); |
757 | 757 | return true; |
758 | 758 | } |
@@ -768,13 +768,13 @@ discard block |
||
768 | 768 | $customContainerSet->delete($customContainerSet->view->is($view) |
769 | 769 | ->_AND_($customContainerSet->object->is($object))); |
770 | 770 | |
771 | - foreach ($containersValues as $containerValues){ |
|
771 | + foreach ($containersValues as $containerValues) { |
|
772 | 772 | $customContainer = $customContainerSet->newRecord(); |
773 | 773 | $customContainer->setValues($containerValues); |
774 | 774 | $customContainer->object = $object; |
775 | 775 | $customContainer->view = $view; |
776 | 776 | $customContainer->save(); |
777 | - foreach ($containerValues['customSections'] as $sectionValues){ |
|
777 | + foreach ($containerValues['customSections'] as $sectionValues) { |
|
778 | 778 | $customSection = $customSectionSet->newRecord(); |
779 | 779 | $sectionValues['fields'] = json_encode($sectionValues['fields']); |
780 | 780 | $customSection->setValues($sectionValues); |
@@ -907,9 +907,9 @@ discard block |
||
907 | 907 | $containersRawFields = array(); |
908 | 908 | |
909 | 909 | $rank = 0; |
910 | - foreach (array_keys($containers) as $containerFieldId){ |
|
910 | + foreach (array_keys($containers) as $containerFieldId) { |
|
911 | 911 | |
912 | - if(substr($containerFieldId, 0, 1) === '#'){ |
|
912 | + if (substr($containerFieldId, 0, 1) === '#') { |
|
913 | 913 | $currentContainerId = substr($containerFieldId, 1); |
914 | 914 | |
915 | 915 | $customContainer = $customContainerSet->request($customContainerSet->id->is($currentContainerId)); |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | $containersRawFields[$currentContainerId] = $customContainer->getRawFields(); |
919 | 919 | |
920 | 920 | $customContainer->rank = $rank; |
921 | - $rank ++; |
|
921 | + $rank++; |
|
922 | 922 | $customContainer->save(); |
923 | 923 | continue; |
924 | 924 | } |
@@ -926,18 +926,18 @@ discard block |
||
926 | 926 | $containersFields[$currentContainerId][] = $containerFieldId; |
927 | 927 | } |
928 | 928 | |
929 | - foreach ($containersFields as $containerId => $containerFieldIds){ |
|
930 | - foreach ($containerFieldIds as $containerFieldId){ |
|
929 | + foreach ($containersFields as $containerId => $containerFieldIds) { |
|
930 | + foreach ($containerFieldIds as $containerFieldId) { |
|
931 | 931 | list ($srcContainerId, $srcfieldId) = explode('.', $containerFieldId); |
932 | - if(! isset($containersRawFields[$srcContainerId][$srcfieldId])){ |
|
932 | + if (!isset($containersRawFields[$srcContainerId][$srcfieldId])) { |
|
933 | 933 | return true; |
934 | 934 | } |
935 | 935 | } |
936 | 936 | } |
937 | 937 | |
938 | - foreach ($containersFields as $containerId => $containerFieldIds){ |
|
938 | + foreach ($containersFields as $containerId => $containerFieldIds) { |
|
939 | 939 | $newRawFields = array(); |
940 | - foreach ($containerFieldIds as $containerFieldId){ |
|
940 | + foreach ($containerFieldIds as $containerFieldId) { |
|
941 | 941 | list ($srcContainerId, $srcfieldId) = explode('.', $containerFieldId); |
942 | 942 | $newRawFields[] = $containersRawFields[$srcContainerId][$srcfieldId]; |
943 | 943 | } |
@@ -259,8 +259,7 @@ discard block |
||
259 | 259 | $customSectionSet = $App->CustomContainerSet(); |
260 | 260 | if(isset($id)){ |
261 | 261 | $record = $customSectionSet->request($id); |
262 | - } |
|
263 | - else{ |
|
262 | + } else{ |
|
264 | 263 | $record = $customSectionSet->newRecord(); |
265 | 264 | $record->object = $object; |
266 | 265 | } |
@@ -517,8 +516,7 @@ discard block |
||
517 | 516 | |
518 | 517 | if($selectedManyField instanceof \ORM_BoolInterface){ |
519 | 518 | $condition = $condition['bool']; |
520 | - } |
|
521 | - else{ |
|
519 | + } else{ |
|
522 | 520 | $condition = $condition['default']; |
523 | 521 | } |
524 | 522 | |
@@ -546,8 +544,7 @@ discard block |
||
546 | 544 | |
547 | 545 | if($selectedOneField instanceof \ORM_BoolInterface){ |
548 | 546 | $condition = $condition['bool']; |
549 | - } |
|
550 | - else{ |
|
547 | + } else{ |
|
551 | 548 | $condition = $condition['default']; |
552 | 549 | } |
553 | 550 | |
@@ -556,15 +553,13 @@ discard block |
||
556 | 553 | } |
557 | 554 | break; |
558 | 555 | } |
559 | - } |
|
560 | - else{ |
|
556 | + } else{ |
|
561 | 557 | |
562 | 558 | $field = $objectRecordSet->$field; |
563 | 559 | |
564 | 560 | if($field instanceof \ORM_BoolInterface){ |
565 | 561 | $condition = $condition['bool']; |
566 | - } |
|
567 | - else{ |
|
562 | + } else{ |
|
568 | 563 | $condition = $condition['default']; |
569 | 564 | } |
570 | 565 |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | public function __construct(Func_App $app = null) |
40 | 40 | { |
41 | 41 | parent::__construct($app); |
42 | - if(! bab_isUserAdministrator()){ |
|
42 | + if (!bab_isUserAdministrator()) { |
|
43 | 43 | $action = WidgetAction::fromRequest(); |
44 | 44 | list (, $method) = explode('.', $action->getMethod()); |
45 | - if($method !== 'denied'){ |
|
45 | + if ($method !== 'denied') { |
|
46 | 46 | $this->redirect($this->proxy() |
47 | 47 | ->denied()); |
48 | 48 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $box->addClass('reload-configuration-page'); |
110 | 110 | $box->addClass('widget-100pc'); |
111 | 111 | |
112 | - if(! isset($itemId)){ |
|
112 | + if (!isset($itemId)) { |
|
113 | 113 | $this->resetCurrentTab(); |
114 | 114 | } |
115 | 115 | |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | $navBoxHtml = '<ul class="nav nav-tabs">'; |
120 | 120 | $htmlCanvas = $W->HtmlCanvas(); |
121 | 121 | |
122 | - foreach ($configurationItems as $tabId => $tab){ |
|
122 | + foreach ($configurationItems as $tabId => $tab) { |
|
123 | 123 | $tabLink = $W->Link($tab['tabTitle'], $this->proxy() |
124 | 124 | ->setDisplayTab($tabId)) |
125 | 125 | ->setOpenMode(WidgetLink::OPEN_DIALOG); |
126 | 126 | $tabLinkHtml = '<li role="configuration"'; |
127 | - if($tabId == $currentTab){ |
|
127 | + if ($tabId == $currentTab) { |
|
128 | 128 | $tabLinkHtml .= ' class="active"'; |
129 | 129 | } |
130 | 130 | $tabLinkHtml .= '>'; |
131 | - $tabLinkHtml .= $tabLink->display($htmlCanvas) . '</li>'; |
|
131 | + $tabLinkHtml .= $tabLink->display($htmlCanvas).'</li>'; |
|
132 | 132 | $navBoxHtml .= $tabLinkHtml; |
133 | 133 | } |
134 | 134 | |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | ->addClass('icon-left icon-48x48 icon-left-48'); |
158 | 158 | $box->addItem($configBox); |
159 | 159 | |
160 | - if(! isset($configurationItems[$currentTab])){ |
|
160 | + if (!isset($configurationItems[$currentTab])) { |
|
161 | 161 | return $box; |
162 | 162 | } |
163 | 163 | |
164 | 164 | $tab = $configurationItems[$currentTab]; |
165 | 165 | |
166 | - foreach ($tab['tabContent'] as $tabSection){ |
|
167 | - if(! isset($tabSection['sectionContent']) || empty($tabSection['sectionContent'])){ |
|
166 | + foreach ($tab['tabContent'] as $tabSection) { |
|
167 | + if (!isset($tabSection['sectionContent']) || empty($tabSection['sectionContent'])) { |
|
168 | 168 | continue; |
169 | 169 | } |
170 | 170 | $configBox->addItem($W->Section($tabSection['sectionName'], $sectionContentBox = $W->HBoxItems()) |
171 | 171 | ->setFoldable(true)); |
172 | - foreach ($tabSection['sectionContent'] as $tabSection){ |
|
172 | + foreach ($tabSection['sectionContent'] as $tabSection) { |
|
173 | 173 | $sectionContentBox->addItem($tabSection); |
174 | 174 | } |
175 | 175 | } |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | ); |
195 | 195 | |
196 | 196 | $definitions = $App->getComponentDefinitions(); |
197 | - foreach ($definitions as $packageName => $definition){ |
|
197 | + foreach ($definitions as $packageName => $definition) { |
|
198 | 198 | /* @var $definition AppComponentDefinition */ |
199 | - if(! method_exists($definition, 'getConfiguration')){ |
|
199 | + if (!method_exists($definition, 'getConfiguration')) { |
|
200 | 200 | continue; |
201 | 201 | } |
202 | 202 | $configurationItems[$packageName] = array( |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $customSection = $customSectionSet->request($customSectionSet->id->is($section)); |
58 | 58 | |
59 | 59 | $object = $customSection->container->object; |
60 | - if(strpos($object, $App->classPrefix) !== false){ |
|
60 | + if (strpos($object, $App->classPrefix) !== false) { |
|
61 | 61 | list (, $object) = explode($App->classPrefix, $object); |
62 | 62 | } |
63 | 63 | $objectCtrl = $App->Controller()->$object(false); |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | ->_AND_($customSectionSet->object->is($customSection->object))); |
67 | 67 | |
68 | 68 | $allViewFieldNames = array(); |
69 | - foreach ($allViewSections as $viewSection){ |
|
69 | + foreach ($allViewSections as $viewSection) { |
|
70 | 70 | $fields = $viewSection->getFields(); |
71 | - foreach ($fields as $field){ |
|
72 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
73 | - foreach ($field['fields'] as $subField){ |
|
74 | - $allViewFieldNames[$subField['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
71 | + foreach ($fields as $field) { |
|
72 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
73 | + foreach ($field['fields'] as $subField) { |
|
74 | + $allViewFieldNames[$subField['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | 79 | $box = $W->VBoxItems(); |
80 | - if(isset($itemId)){ |
|
80 | + if (isset($itemId)) { |
|
81 | 81 | $box->setId($itemId); |
82 | 82 | } |
83 | 83 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | \bab_Sort::asort($availableFields, 'description', \bab_Sort::CASE_INSENSITIVE); |
94 | 94 | |
95 | - foreach ($availableFields as $field){ |
|
95 | + foreach ($availableFields as $field) { |
|
96 | 96 | $fieldName = $field['name']; |
97 | 97 | $fieldDescription = $field['description']; |
98 | 98 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | $field = $customSection->getField($fieldName); |
149 | 149 | |
150 | - if(! isset($field)){ |
|
150 | + if (!isset($field)) { |
|
151 | 151 | return null; |
152 | 152 | } |
153 | 153 | |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | |
165 | 165 | $field = $availableFields[$fieldName]; |
166 | 166 | $fieldDescription = $field['description']; |
167 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
167 | + if (substr($fieldName, 0, 1) !== '_') { |
|
168 | 168 | $fieldDescription = $App->translate($fieldDescription); |
169 | 169 | } |
170 | 170 | |
171 | - if(empty($field)){ |
|
171 | + if (empty($field)) { |
|
172 | 172 | // continue; |
173 | 173 | } |
174 | 174 | |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | |
239 | 239 | $groupField = $customSection->getField($fieldGroupName); |
240 | 240 | |
241 | - if(! isset($groupField)){ |
|
241 | + if (!isset($groupField)) { |
|
242 | 242 | return null; |
243 | 243 | } |
244 | 244 | |
245 | 245 | $field = $groupField['fields'][$fieldName]; |
246 | - if(! isset($field)){ |
|
246 | + if (!isset($field)) { |
|
247 | 247 | return null; |
248 | 248 | } |
249 | 249 | |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | |
260 | 260 | $field = $availableFields[$fieldName]; |
261 | 261 | $fieldDescription = $field['description']; |
262 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
262 | + if (substr($fieldName, 0, 1) !== '_') { |
|
263 | 263 | $fieldDescription = $App->translate($fieldDescription); |
264 | 264 | } |
265 | 265 | |
266 | - if(empty($field)){ |
|
266 | + if (empty($field)) { |
|
267 | 267 | // continue; |
268 | 268 | } |
269 | 269 | |
@@ -346,12 +346,12 @@ discard block |
||
346 | 346 | |
347 | 347 | $customSection = $customSectionSet->request($customSectionSet->id->is($section)); |
348 | 348 | $fields = $customSection->getFields(); |
349 | - if(! isset($fields[$fieldGroupName])){ |
|
349 | + if (!isset($fields[$fieldGroupName])) { |
|
350 | 350 | throw new AppException($App->translate('This fields group does not seem to exist')); |
351 | 351 | } |
352 | 352 | |
353 | 353 | $object = $customSection->container->object; |
354 | - if(strpos($object, $App->classPrefix) !== false){ |
|
354 | + if (strpos($object, $App->classPrefix) !== false) { |
|
355 | 355 | list (, $object) = explode($App->classPrefix, $object); |
356 | 356 | } |
357 | 357 | |
@@ -361,18 +361,18 @@ discard block |
||
361 | 361 | ->_AND_($customSectionSet->object->is($customSection->object))); |
362 | 362 | |
363 | 363 | $allViewFieldNames = array(); |
364 | - foreach ($allViewSections as $viewSection){ |
|
364 | + foreach ($allViewSections as $viewSection) { |
|
365 | 365 | $fields = $viewSection->getFields(); |
366 | - foreach ($fields as $field){ |
|
367 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
368 | - foreach ($field['fields'] as $subField){ |
|
369 | - $allViewFieldNames[$subField['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
366 | + foreach ($fields as $field) { |
|
367 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
368 | + foreach ($field['fields'] as $subField) { |
|
369 | + $allViewFieldNames[$subField['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
374 | 374 | $box = $W->VBoxItems(); |
375 | - if(isset($itemId)){ |
|
375 | + if (isset($itemId)) { |
|
376 | 376 | $box->setId($itemId); |
377 | 377 | } |
378 | 378 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | \bab_Sort::asort($availableFields, 'description', \bab_Sort::CASE_INSENSITIVE); |
391 | 391 | |
392 | - foreach ($availableFields as $field){ |
|
392 | + foreach ($availableFields as $field) { |
|
393 | 393 | $fieldName = $field['name']; |
394 | 394 | $fieldDescription = $field['description']; |
395 | 395 | |
@@ -501,10 +501,10 @@ discard block |
||
501 | 501 | $container = $customContainerSet->request($customContainerSet->id->is($container)); |
502 | 502 | |
503 | 503 | $customSectionSet = $App->CustomSectionSet(); |
504 | - if(isset($id)){ |
|
504 | + if (isset($id)) { |
|
505 | 505 | $record = $customSectionSet->request($id); |
506 | 506 | } |
507 | - else{ |
|
507 | + else { |
|
508 | 508 | $record = $customSectionSet->newRecord(); |
509 | 509 | $record->container = $container->id; |
510 | 510 | } |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | |
517 | 517 | $editor = new AppEditor($App); |
518 | 518 | $editor->setHiddenValue('tg', $App->controllerTg); |
519 | - if($record->id){ |
|
519 | + if ($record->id) { |
|
520 | 520 | $editor->setHiddenValue('data[id]', $record->id); |
521 | 521 | } |
522 | 522 | $editor->setName('data'); |
@@ -532,16 +532,16 @@ discard block |
||
532 | 532 | |
533 | 533 | $options = array(); |
534 | 534 | $rank = 1; |
535 | - foreach ($containers as $container){ |
|
535 | + foreach ($containers as $container) { |
|
536 | 536 | $options[$container->id] = sprintf('%d (%s)', $rank, $container->name); |
537 | - $rank ++; |
|
537 | + $rank++; |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | $containerSections = $customSectionSet->select($customSectionSet->container->is($container->id)) |
541 | 541 | ->orderDesc($customSectionSet->rank); |
542 | 542 | |
543 | 543 | $nbSections = 0; |
544 | - foreach ($containerSections as $containerSection){ |
|
544 | + foreach ($containerSections as $containerSection) { |
|
545 | 545 | $nbSections = $containerSection->rank + 1; |
546 | 546 | break; |
547 | 547 | } |
@@ -625,10 +625,10 @@ discard block |
||
625 | 625 | $record = $recordSet->request($id); |
626 | 626 | |
627 | 627 | $object = $record->object; |
628 | - if(empty($object)){ |
|
628 | + if (empty($object)) { |
|
629 | 629 | $object = $record->container()->object; |
630 | 630 | } |
631 | - if(strpos($object, $App->classPrefix) !== false){ |
|
631 | + if (strpos($object, $App->classPrefix) !== false) { |
|
632 | 632 | $object = str_replace($App->classPrefix, '', $object); |
633 | 633 | } |
634 | 634 | $object .= 'Set'; |
@@ -643,25 +643,25 @@ discard block |
||
643 | 643 | $manySets = $objectRecordSet->getHasManyRelations(); |
644 | 644 | $oneSets = $objectRecordSet->getHasOneRelations(); |
645 | 645 | |
646 | - if(! empty($record->visibilityCriteria)){ |
|
646 | + if (!empty($record->visibilityCriteria)) { |
|
647 | 647 | $arrCriteria = json_decode($record->visibilityCriteria, true); |
648 | 648 | |
649 | 649 | $data = array(); |
650 | - foreach ($arrCriteria as $fieldName => $operation){ |
|
650 | + foreach ($arrCriteria as $fieldName => $operation) { |
|
651 | 651 | $data['field'] = $fieldName; |
652 | - foreach ($operation as $condition => $value){ |
|
652 | + foreach ($operation as $condition => $value) { |
|
653 | 653 | $data['condition']['default'] = $condition; |
654 | 654 | $data['condition']['bool'] = $condition; |
655 | - if(is_array($value)){ |
|
656 | - foreach ($value as $key => $subValue){ |
|
657 | - foreach ($manySets as $manyFieldName => $manyRelation){ |
|
658 | - if($key . 'Set' == $manyRelation->getForeignSetClassName()){ |
|
659 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
660 | - if($subFieldName === '_foreignField'){ |
|
655 | + if (is_array($value)) { |
|
656 | + foreach ($value as $key => $subValue) { |
|
657 | + foreach ($manySets as $manyFieldName => $manyRelation) { |
|
658 | + if ($key.'Set' == $manyRelation->getForeignSetClassName()) { |
|
659 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
660 | + if ($subFieldName === '_foreignField') { |
|
661 | 661 | continue; |
662 | 662 | } |
663 | 663 | $data['field'] = "{$manyFieldName}/{$subFieldName}"; |
664 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
664 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
665 | 665 | $data['condition']['default'] = $subCondition; |
666 | 666 | $data['condition']['bool'] = $subCondition; |
667 | 667 | $value = $subConditionValue; |
@@ -670,14 +670,14 @@ discard block |
||
670 | 670 | break; |
671 | 671 | } |
672 | 672 | } |
673 | - foreach ($oneSets as $oneFieldName => $oneRelation){ |
|
674 | - if($key . 'Set' == $oneRelation->getForeignSetClassName()){ |
|
675 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
676 | - if($subFieldName === '_foreignField'){ |
|
673 | + foreach ($oneSets as $oneFieldName => $oneRelation) { |
|
674 | + if ($key.'Set' == $oneRelation->getForeignSetClassName()) { |
|
675 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
676 | + if ($subFieldName === '_foreignField') { |
|
677 | 677 | continue; |
678 | 678 | } |
679 | 679 | $data['field'] = "{$oneFieldName}/{$subFieldName}"; |
680 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
680 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
681 | 681 | $data['condition']['default'] = $subCondition; |
682 | 682 | $data['condition']['bool'] = $subCondition; |
683 | 683 | $value = $subConditionValue; |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | */ |
713 | 713 | public function save($data = null) |
714 | 714 | { |
715 | - if(! isset($data['id']) && isset($data['container']) && $data['container'] != 0 && ! isset($data['rank'])){ |
|
715 | + if (!isset($data['id']) && isset($data['container']) && $data['container'] != 0 && !isset($data['rank'])) { |
|
716 | 716 | $set = $this->getRecordSet(); |
717 | 717 | $data['rank'] = $set->select($set->container->is($data['container'])) |
718 | 718 | ->count(); |
@@ -745,11 +745,11 @@ discard block |
||
745 | 745 | $set->rank->greaterThanOrEqual($record->rank) |
746 | 746 | ))); |
747 | 747 | |
748 | - $position ++; |
|
749 | - foreach ($afterSections as $afterSection){ |
|
748 | + $position++; |
|
749 | + foreach ($afterSections as $afterSection) { |
|
750 | 750 | $afterSection->rank = $position; |
751 | 751 | $afterSection->save(); |
752 | - $position ++; |
|
752 | + $position++; |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | |
@@ -777,10 +777,10 @@ discard block |
||
777 | 777 | $record = $recordSet->request($data['id']); |
778 | 778 | |
779 | 779 | $object = $record->object; |
780 | - if(empty($object)){ |
|
780 | + if (empty($object)) { |
|
781 | 781 | $object = $record->container()->object; |
782 | 782 | } |
783 | - if(strpos($object, $App->classPrefix) !== false){ |
|
783 | + if (strpos($object, $App->classPrefix) !== false) { |
|
784 | 784 | $object = str_replace($App->classPrefix, '', $object); |
785 | 785 | } |
786 | 786 | $object .= 'Set'; |
@@ -790,14 +790,14 @@ discard block |
||
790 | 790 | $field = $data['field']; |
791 | 791 | $condition = $data['condition']; |
792 | 792 | |
793 | - if(strpos($field, '/') !== false){ |
|
793 | + if (strpos($field, '/') !== false) { |
|
794 | 794 | // The selected field is a hasMany or a hasOne relation |
795 | 795 | list ($selectedRelation, $selectedField) = explode('/', $field); |
796 | 796 | $classPrefix = $App->classPrefix; |
797 | 797 | |
798 | 798 | $manyRelations = $objectRecordSet->getHasManyRelations(); |
799 | - foreach ($manyRelations as $manyRelation){ |
|
800 | - if($selectedRelation != $manyRelation->getOwnerSetFieldName()){ |
|
799 | + foreach ($manyRelations as $manyRelation) { |
|
800 | + if ($selectedRelation != $manyRelation->getOwnerSetFieldName()) { |
|
801 | 801 | continue; |
802 | 802 | } |
803 | 803 | $foreignSetName = str_replace($classPrefix, '', $manyRelation->getForeignSetClassName()); |
@@ -805,13 +805,13 @@ discard block |
||
805 | 805 | |
806 | 806 | $visibilityCriteria = ''; |
807 | 807 | |
808 | - if($foreignSet){ |
|
808 | + if ($foreignSet) { |
|
809 | 809 | $selectedManyField = $foreignSet->$selectedField; |
810 | 810 | |
811 | - if($selectedManyField instanceof \ORM_BoolInterface){ |
|
811 | + if ($selectedManyField instanceof \ORM_BoolInterface) { |
|
812 | 812 | $condition = $condition['bool']; |
813 | 813 | } |
814 | - else{ |
|
814 | + else { |
|
815 | 815 | $condition = $condition['default']; |
816 | 816 | } |
817 | 817 | |
@@ -823,9 +823,9 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | $oneRelations = $objectRecordSet->getHasOneRelations(); |
826 | - foreach ($oneRelations as $oneRelation){ |
|
826 | + foreach ($oneRelations as $oneRelation) { |
|
827 | 827 | /* @var $oneRelation \ORM_OneRelation*/ |
828 | - if($selectedRelation != $oneRelation->getOwnerSetFieldName()){ |
|
828 | + if ($selectedRelation != $oneRelation->getOwnerSetFieldName()) { |
|
829 | 829 | continue; |
830 | 830 | } |
831 | 831 | $foreignSetClassName = $oneRelation->getForeignSetClassName(); |
@@ -834,13 +834,13 @@ discard block |
||
834 | 834 | |
835 | 835 | $visibilityCriteria = ''; |
836 | 836 | |
837 | - if($foreignSet){ |
|
837 | + if ($foreignSet) { |
|
838 | 838 | $selectedOneField = $foreignSet->$selectedField; |
839 | 839 | |
840 | - if($selectedOneField instanceof \ORM_BoolInterface){ |
|
840 | + if ($selectedOneField instanceof \ORM_BoolInterface) { |
|
841 | 841 | $condition = $condition['bool']; |
842 | 842 | } |
843 | - else{ |
|
843 | + else { |
|
844 | 844 | $condition = $condition['default']; |
845 | 845 | } |
846 | 846 | |
@@ -850,20 +850,20 @@ discard block |
||
850 | 850 | break; |
851 | 851 | } |
852 | 852 | } |
853 | - else{ |
|
853 | + else { |
|
854 | 854 | |
855 | 855 | $field = $objectRecordSet->$field; |
856 | 856 | |
857 | - if($field instanceof \ORM_BoolInterface){ |
|
857 | + if ($field instanceof \ORM_BoolInterface) { |
|
858 | 858 | $condition = $condition['bool']; |
859 | 859 | } |
860 | - else{ |
|
860 | + else { |
|
861 | 861 | $condition = $condition['default']; |
862 | 862 | } |
863 | 863 | |
864 | 864 | $visibilityCriteria = ''; |
865 | 865 | |
866 | - if(! empty($condition)){ |
|
866 | + if (!empty($condition)) { |
|
867 | 867 | $criteria = $field->{$condition}($data['value']); |
868 | 868 | $visibilityCriteria = $criteria->toJson(); |
869 | 869 | } |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | $customContainer = $customContainerSet->request($container); |
893 | 893 | |
894 | 894 | $object = $customContainer->object; |
895 | - if(strpos($object, $App->classPrefix) !== false){ |
|
895 | + if (strpos($object, $App->classPrefix) !== false) { |
|
896 | 896 | list (, $object) = explode($App->classPrefix, $object); |
897 | 897 | } |
898 | 898 | |
@@ -919,17 +919,17 @@ discard block |
||
919 | 919 | |
920 | 920 | $nbCol = 0; |
921 | 921 | |
922 | - foreach ($customSections as $customSection){ |
|
922 | + foreach ($customSections as $customSection) { |
|
923 | 923 | |
924 | - list (, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
924 | + list (,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
925 | 925 | |
926 | 926 | $currentColumn += $nbCol; |
927 | 927 | |
928 | - $sectionSection = $W->Section($customSection->name . ' (' . $customSection->rank . ')', $sectionBox = $W->VBoxItems($W->Hidden() |
|
929 | - ->setName('#' . $customSection->id))); |
|
928 | + $sectionSection = $W->Section($customSection->name.' ('.$customSection->rank.')', $sectionBox = $W->VBoxItems($W->Hidden() |
|
929 | + ->setName('#'.$customSection->id))); |
|
930 | 930 | $sectionSection->addClass('app-custom-section'); |
931 | 931 | $sectionSection->addClass($customSection->classname); |
932 | - $sectionSection->setSizePolicy($customSection->sizePolicy . ' widget-sameheight'); |
|
932 | + $sectionSection->setSizePolicy($customSection->sizePolicy.' widget-sameheight'); |
|
933 | 933 | |
934 | 934 | $row->addItem($sectionSection); |
935 | 935 | |
@@ -947,40 +947,40 @@ discard block |
||
947 | 947 | ->addClass('icon', \Func_Icons::ACTIONS_EDIT_DELETE) |
948 | 948 | ->setOpenMode(WidgetLink::OPEN_DIALOG) |
949 | 949 | ->setDialogClass('box red'))); |
950 | - if(! empty($customSection->visibilityCriteria)){ |
|
950 | + if (!empty($customSection->visibilityCriteria)) { |
|
951 | 951 | $sectionBox->addItem($W->HBoxItems($W->Label($App->translate('This section has a visibility condition'))) |
952 | 952 | ->setSizePolicy('alert alert-warning widget-100pc')); |
953 | 953 | } |
954 | 954 | $fields = $customSection->getFields(); |
955 | - if(count($fields) == 0){ |
|
955 | + if (count($fields) == 0) { |
|
956 | 956 | $sectionBox->addItem($W->HBoxItems($W->Label($App->translate('This section does not contain any field'))) |
957 | 957 | ->setSizePolicy('alert alert-warning')); |
958 | 958 | } |
959 | - foreach ($fields as $fieldId => $field){ |
|
960 | - if(empty($field)){ |
|
959 | + foreach ($fields as $fieldId => $field) { |
|
960 | + if (empty($field)) { |
|
961 | 961 | continue; |
962 | 962 | } |
963 | 963 | |
964 | 964 | $fieldName = $field['fieldname']; |
965 | 965 | |
966 | 966 | $isFieldsGroup = false; |
967 | - if(strpos($fieldName, '_fieldsGroup') !== false){ |
|
967 | + if (strpos($fieldName, '_fieldsGroup') !== false) { |
|
968 | 968 | $fieldName = '_fieldsGroup'; |
969 | 969 | $isFieldsGroup = true; |
970 | 970 | } |
971 | 971 | |
972 | 972 | $field = $availableFields[$fieldName]; |
973 | 973 | $fieldDescription = $field['description']; |
974 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
974 | + if (substr($fieldName, 0, 1) !== '_') { |
|
975 | 975 | $fieldDescription = $App->translate($fieldDescription); |
976 | 976 | } |
977 | 977 | |
978 | - if(empty($field)){ |
|
978 | + if (empty($field)) { |
|
979 | 979 | continue; |
980 | 980 | } |
981 | 981 | |
982 | 982 | $fieldName = $field['name']; |
983 | - if($isFieldsGroup){ |
|
983 | + if ($isFieldsGroup) { |
|
984 | 984 | $fieldName = $fieldId; |
985 | 985 | } |
986 | 986 | |
@@ -991,20 +991,20 @@ discard block |
||
991 | 991 | ->setGrowable(true) |
992 | 992 | ->setWrap(WidgetFlexLayout::FLEX_WRAP_WRAP)) |
993 | 993 | ->setSizePolicy('maximum'), $btnBox = $W->HBoxItems($W->Hidden() |
994 | - ->setName($customSection->id . '.' . $fieldId) |
|
994 | + ->setName($customSection->id.'.'.$fieldId) |
|
995 | 995 | ->setValue($fieldName)) |
996 | 996 | ->addClass('widget-actions')) |
997 | 997 | ->setSizePolicy('widget-list-element widget-actions-target') |
998 | 998 | ->addClass(\Func_Icons::ICON_LEFT_16); |
999 | - if(strpos($field['name'], '_fieldsGroup') !== false){ |
|
999 | + if (strpos($field['name'], '_fieldsGroup') !== false) { |
|
1000 | 1000 | $btnBox->addItem($W->Link('', $customSectionCtrl->addDisplayFieldToGroup($customSection->id, $fieldName)) |
1001 | 1001 | ->addClass('icon', \Func_Icons::ACTIONS_LIST_ADD) |
1002 | 1002 | ->setOpenMode(WidgetLink::OPEN_DIALOG)); |
1003 | 1003 | $groupedFields = $fields[$fieldName]['fields']; |
1004 | - foreach ($groupedFields as $groupedField){ |
|
1004 | + foreach ($groupedFields as $groupedField) { |
|
1005 | 1005 | $groupedFieldDetails = $availableFields[$groupedField['fieldname']]; |
1006 | 1006 | $fieldGroupBox->addItem($flexField = $W->FlowItems($W->Hidden(null, array( |
1007 | - $customSection->id . '.fieldsGroups', |
|
1007 | + $customSection->id.'.fieldsGroups', |
|
1008 | 1008 | $fieldName, |
1009 | 1009 | $groupedField['fieldname'] |
1010 | 1010 | ), $groupedField['fieldname']), $W->Label($groupedFieldDetails['description']), $W->FlowItems($W->Link('', $customSectionCtrl->editGroupFieldDisplayField($customSection->id, $fieldName, $groupedField['fieldname'])) |
@@ -1032,23 +1032,23 @@ discard block |
||
1032 | 1032 | $sectionsBoxes[] = $sectionBox; |
1033 | 1033 | } |
1034 | 1034 | |
1035 | - if($currentColumn + $nbCol > 0){ |
|
1035 | + if ($currentColumn + $nbCol > 0) { |
|
1036 | 1036 | $sectionsSection->addItem($row); |
1037 | 1037 | } |
1038 | 1038 | |
1039 | - foreach ($sectionsBoxes as $sectionsBox){ |
|
1039 | + foreach ($sectionsBoxes as $sectionsBox) { |
|
1040 | 1040 | $sectionsBox->sortable(true, $sectionsBoxes); |
1041 | 1041 | $sectionsBox->setMetadata('samePlaceholderSize', true); |
1042 | 1042 | } |
1043 | 1043 | |
1044 | - foreach ($rows as $row){ |
|
1044 | + foreach ($rows as $row) { |
|
1045 | 1045 | $row->sortable(true, $rows); |
1046 | 1046 | $row->setMetadata('samePlaceholderSize', true); |
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | $form = $W->Form(); |
1050 | 1050 | |
1051 | - if(isset($itemId)){ |
|
1051 | + if (isset($itemId)) { |
|
1052 | 1052 | $form->setId($itemId); |
1053 | 1053 | } |
1054 | 1054 | $form->setHiddenValue('tg', $App->controllerTg); |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | $customSections = $customSectionSet->select($customSectionSet->container->is($container)); |
1076 | 1076 | |
1077 | 1077 | $sectionsValues = array(); |
1078 | - foreach ($customSections as $customSection){ |
|
1078 | + foreach ($customSections as $customSection) { |
|
1079 | 1079 | $values = $customSection->getValues(); |
1080 | 1080 | unset($values['id']); |
1081 | 1081 | unset($values['createdBy']); |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | header('Content-type: application/json'); |
1092 | - header('Content-Disposition: attachment; filename="' . $container->object . '.' . ($container->view === '' ? 'default' : $container->view) . '.' . $container->name . '.json"' . "\n"); |
|
1092 | + header('Content-Disposition: attachment; filename="'.$container->object.'.'.($container->view === '' ? 'default' : $container->view).'.'.$container->name.'.json"'."\n"); |
|
1093 | 1093 | |
1094 | 1094 | $json = bab_json_encode($sectionsValues); |
1095 | 1095 | $json = bab_convertStringFromDatabase($json, \bab_charset::UTF_8); |
@@ -1141,12 +1141,12 @@ discard block |
||
1141 | 1141 | $files->push($sectionsfile['uid']); |
1142 | 1142 | |
1143 | 1143 | $data = null; |
1144 | - foreach ($files as $f){ |
|
1144 | + foreach ($files as $f) { |
|
1145 | 1145 | $data = file_get_contents($f->toString()); |
1146 | 1146 | break; |
1147 | 1147 | } |
1148 | 1148 | |
1149 | - if(! isset($data)){ |
|
1149 | + if (!isset($data)) { |
|
1150 | 1150 | $this->addError($App->translate('Unable to get file content')); |
1151 | 1151 | return true; |
1152 | 1152 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | |
1159 | 1159 | $customSectionSet->delete($customSectionSet->container->is($container)); |
1160 | 1160 | |
1161 | - foreach ($sectionsValues as $sectionValues){ |
|
1161 | + foreach ($sectionsValues as $sectionValues) { |
|
1162 | 1162 | $customSection = $customSectionSet->newRecord(); |
1163 | 1163 | $customSection->setValues($sectionValues); |
1164 | 1164 | $customSection->container = $container; |
@@ -1236,59 +1236,59 @@ discard block |
||
1236 | 1236 | $ranks = array(); |
1237 | 1237 | $rank = 0; |
1238 | 1238 | |
1239 | - foreach ($sections as $key => $value){ |
|
1239 | + foreach ($sections as $key => $value) { |
|
1240 | 1240 | // Sections ids start with #, while section fields start with their original section id |
1241 | - if(substr($key, 0, 1) === '#'){ |
|
1241 | + if (substr($key, 0, 1) === '#') { |
|
1242 | 1242 | $currentSectionId = substr($key, 1); |
1243 | 1243 | $rawSectionData[$currentSectionId] = array(); |
1244 | - if(! isset($oldSectionId)){ |
|
1244 | + if (!isset($oldSectionId)) { |
|
1245 | 1245 | $oldSectionId = $currentSectionId; |
1246 | 1246 | } |
1247 | - if(isset($currentSection) && $oldSectionId != $currentSectionId){ |
|
1247 | + if (isset($currentSection) && $oldSectionId != $currentSectionId) { |
|
1248 | 1248 | $oldSectionId = $currentSectionId; |
1249 | 1249 | } |
1250 | 1250 | $ranks[$currentSectionId] = $rank; |
1251 | - $rank ++; |
|
1251 | + $rank++; |
|
1252 | 1252 | $currentSection = $customSectionSet->get($customSectionSet->id->is($currentSectionId)); |
1253 | 1253 | continue; |
1254 | 1254 | } |
1255 | - if(! isset($currentSection)){ |
|
1255 | + if (!isset($currentSection)) { |
|
1256 | 1256 | continue; |
1257 | 1257 | } |
1258 | 1258 | list ($fieldSectionId, $fieldName) = explode('.', $key); |
1259 | - if($fieldSectionId == $currentSectionId){ |
|
1259 | + if ($fieldSectionId == $currentSectionId) { |
|
1260 | 1260 | $field = $currentSection->getField($fieldName); |
1261 | - if(strpos($fieldName, '_fieldsGroup') !== false){ |
|
1261 | + if (strpos($fieldName, '_fieldsGroup') !== false) { |
|
1262 | 1262 | $rawSectionData[$currentSectionId][$fieldName]['block'] = $field['block']; |
1263 | 1263 | $rawSectionData[$currentSectionId][$fieldName]['fieldname'] = '_fieldsGroup'; |
1264 | 1264 | $rawSectionData[$currentSectionId][$fieldName]['parameters'] = $field['parameters']; |
1265 | - foreach ($sections[$currentSection->id . '.fieldsGroups'][$fieldName] as $subKey => $subValue){ |
|
1265 | + foreach ($sections[$currentSection->id.'.fieldsGroups'][$fieldName] as $subKey => $subValue) { |
|
1266 | 1266 | $rawSectionData[$currentSectionId][$fieldName]['fields'][$subKey] = $field['fields'][$subKey]; |
1267 | 1267 | } |
1268 | 1268 | } |
1269 | - elseif($fieldName != 'fieldsGroups'){ |
|
1269 | + elseif ($fieldName != 'fieldsGroups') { |
|
1270 | 1270 | $rawSectionData[$currentSectionId][$fieldName] = $field; |
1271 | 1271 | } |
1272 | 1272 | } |
1273 | - else{ |
|
1273 | + else { |
|
1274 | 1274 | $field = null; |
1275 | 1275 | $tmpSection = $customSectionSet->get($customSectionSet->id->is($fieldSectionId)); |
1276 | - if($tmpSection){ |
|
1276 | + if ($tmpSection) { |
|
1277 | 1277 | $field = $tmpSection->getField($fieldName); |
1278 | 1278 | } |
1279 | - if(isset($field)){ |
|
1279 | + if (isset($field)) { |
|
1280 | 1280 | $rawSectionData[$currentSectionId][$fieldName] = $field; |
1281 | 1281 | } |
1282 | 1282 | } |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - foreach ($rawSectionData as $sectionId => $fields){ |
|
1285 | + foreach ($rawSectionData as $sectionId => $fields) { |
|
1286 | 1286 | $section = $customSectionSet->get($customSectionSet->id->is($sectionId)); |
1287 | - if($section){ |
|
1287 | + if ($section) { |
|
1288 | 1288 | $section->fields = json_encode($fields); |
1289 | 1289 | $section->rank = isset($ranks[$sectionId]) ? $ranks[$sectionId] : 0; |
1290 | 1290 | $section->save(); |
1291 | - $rank ++; |
|
1291 | + $rank++; |
|
1292 | 1292 | } |
1293 | 1293 | } |
1294 | 1294 |
@@ -503,8 +503,7 @@ discard block |
||
503 | 503 | $customSectionSet = $App->CustomSectionSet(); |
504 | 504 | if(isset($id)){ |
505 | 505 | $record = $customSectionSet->request($id); |
506 | - } |
|
507 | - else{ |
|
506 | + } else{ |
|
508 | 507 | $record = $customSectionSet->newRecord(); |
509 | 508 | $record->container = $container->id; |
510 | 509 | } |
@@ -810,8 +809,7 @@ discard block |
||
810 | 809 | |
811 | 810 | if($selectedManyField instanceof \ORM_BoolInterface){ |
812 | 811 | $condition = $condition['bool']; |
813 | - } |
|
814 | - else{ |
|
812 | + } else{ |
|
815 | 813 | $condition = $condition['default']; |
816 | 814 | } |
817 | 815 | |
@@ -839,8 +837,7 @@ discard block |
||
839 | 837 | |
840 | 838 | if($selectedOneField instanceof \ORM_BoolInterface){ |
841 | 839 | $condition = $condition['bool']; |
842 | - } |
|
843 | - else{ |
|
840 | + } else{ |
|
844 | 841 | $condition = $condition['default']; |
845 | 842 | } |
846 | 843 | |
@@ -849,15 +846,13 @@ discard block |
||
849 | 846 | } |
850 | 847 | break; |
851 | 848 | } |
852 | - } |
|
853 | - else{ |
|
849 | + } else{ |
|
854 | 850 | |
855 | 851 | $field = $objectRecordSet->$field; |
856 | 852 | |
857 | 853 | if($field instanceof \ORM_BoolInterface){ |
858 | 854 | $condition = $condition['bool']; |
859 | - } |
|
860 | - else{ |
|
855 | + } else{ |
|
861 | 856 | $condition = $condition['default']; |
862 | 857 | } |
863 | 858 | |
@@ -1265,12 +1260,10 @@ discard block |
||
1265 | 1260 | foreach ($sections[$currentSection->id . '.fieldsGroups'][$fieldName] as $subKey => $subValue){ |
1266 | 1261 | $rawSectionData[$currentSectionId][$fieldName]['fields'][$subKey] = $field['fields'][$subKey]; |
1267 | 1262 | } |
1268 | - } |
|
1269 | - elseif($fieldName != 'fieldsGroups'){ |
|
1263 | + } elseif($fieldName != 'fieldsGroups'){ |
|
1270 | 1264 | $rawSectionData[$currentSectionId][$fieldName] = $field; |
1271 | 1265 | } |
1272 | - } |
|
1273 | - else{ |
|
1266 | + } else{ |
|
1274 | 1267 | $field = null; |
1275 | 1268 | $tmpSection = $customSectionSet->get($customSectionSet->id->is($fieldSectionId)); |
1276 | 1269 | if($tmpSection){ |
@@ -183,8 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | if($this->isAjaxRequest()){ |
185 | 185 | $authType = 'Basic'; |
186 | - } |
|
187 | - else{ |
|
186 | + } else{ |
|
188 | 187 | $authType = ''; |
189 | 188 | } |
190 | 189 | |
@@ -253,8 +252,7 @@ discard block |
||
253 | 252 | |
254 | 253 | if($parameter->isDefaultValueAvailable()){ |
255 | 254 | $parametersStr[] = '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true); |
256 | - } |
|
257 | - else{ |
|
255 | + } else{ |
|
258 | 256 | $parametersStr[] = '$' . $parameter->name; |
259 | 257 | } |
260 | 258 | } |
@@ -349,11 +347,9 @@ discard block |
||
349 | 347 | $parameterName = $parameter->getName(); |
350 | 348 | if(isset($args[$argNumber])){ |
351 | 349 | $actionParams[$parameterName] = $args[$argNumber]; |
352 | - } |
|
353 | - elseif($parameter->isDefaultValueAvailable()){ |
|
350 | + } elseif($parameter->isDefaultValueAvailable()){ |
|
354 | 351 | $actionParams[$parameterName] = $parameter->getDefaultValue(); |
355 | - } |
|
356 | - else{ |
|
352 | + } else{ |
|
357 | 353 | $actionParams[$parameterName] = null; |
358 | 354 | } |
359 | 355 | $argNumber ++; |
@@ -431,8 +427,7 @@ discard block |
||
431 | 427 | if($component){ |
432 | 428 | $this->app->setCurrentComponent($component); |
433 | 429 | $objectController = $component->controller(false); |
434 | - } |
|
435 | - else{ |
|
430 | + } else{ |
|
436 | 431 | header('HTTP/1.0 400 Bad Request'); |
437 | 432 | throw new AppUnknownActionException($action); |
438 | 433 | } |
@@ -447,13 +442,11 @@ discard block |
||
447 | 442 | |
448 | 443 | try{ |
449 | 444 | $returnedValue = $objectController->execAction($action); |
450 | - } |
|
451 | - catch (AppAccessException $e){ |
|
445 | + } catch (AppAccessException $e){ |
|
452 | 446 | |
453 | 447 | if(! bab_isUserLogged() && $e->requireCredential){ |
454 | 448 | bab_requireCredential($e->getMessage()); |
455 | - } |
|
456 | - else{ |
|
449 | + } else{ |
|
457 | 450 | if($this->isAjaxRequest()){ |
458 | 451 | |
459 | 452 | header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
@@ -466,8 +459,7 @@ discard block |
||
466 | 459 | } |
467 | 460 | $this->accessPage($e); |
468 | 461 | } |
469 | - } |
|
470 | - catch (AppSaveException $e){ |
|
462 | + } catch (AppSaveException $e){ |
|
471 | 463 | |
472 | 464 | if($this->isAjaxRequest()){ |
473 | 465 | header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
@@ -481,17 +473,13 @@ discard block |
||
481 | 473 | 'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8') |
482 | 474 | ))); |
483 | 475 | } |
484 | - } |
|
485 | - catch (AppDeletedRecordException $e){ |
|
476 | + } catch (AppDeletedRecordException $e){ |
|
486 | 477 | $this->deletedItemPage($action, $e); |
487 | - } |
|
488 | - catch (AppNotFoundException $e){ |
|
478 | + } catch (AppNotFoundException $e){ |
|
489 | 479 | $this->notFoundPage($action, $e); |
490 | - } |
|
491 | - catch (\ORM_Exception $e){ |
|
480 | + } catch (\ORM_Exception $e){ |
|
492 | 481 | $this->errorPage($e); |
493 | - } |
|
494 | - catch (\Exception $e){ |
|
482 | + } catch (\Exception $e){ |
|
495 | 483 | $this->unexpectedErrorPage($e); |
496 | 484 | } |
497 | 485 | |
@@ -503,8 +491,7 @@ discard block |
||
503 | 491 | |
504 | 492 | // If the action returned a page, we display it. |
505 | 493 | $returnedValue->displayHtml(); |
506 | - } |
|
507 | - else{ |
|
494 | + } else{ |
|
508 | 495 | |
509 | 496 | $htmlCanvas = $W->HtmlCanvas(); |
510 | 497 | if(self::$acceptJson){ |
@@ -516,8 +503,7 @@ discard block |
||
516 | 503 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
517 | 504 | header('Content-type: application/json'); |
518 | 505 | die(bab_json_encode($returnArray)); |
519 | - } |
|
520 | - else{ |
|
506 | + } else{ |
|
521 | 507 | header('Cache-Control: no-cache, must-revalidate'); |
522 | 508 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
523 | 509 | header('Content-type: text/html'); |
@@ -526,8 +512,7 @@ discard block |
||
526 | 512 | |
527 | 513 | if(method_exists($htmlCanvas, 'sendPageTitle')){ |
528 | 514 | $htmlCanvas->sendPageTitle($pageTitle); |
529 | - } |
|
530 | - else{ |
|
515 | + } else{ |
|
531 | 516 | header('X-Cto-PageTitle: ' . $pageTitle); |
532 | 517 | } |
533 | 518 | } |
@@ -535,16 +520,14 @@ discard block |
||
535 | 520 | die($html); |
536 | 521 | } |
537 | 522 | } |
538 | - } |
|
539 | - elseif(is_array($returnedValue)){ |
|
523 | + } elseif(is_array($returnedValue)){ |
|
540 | 524 | |
541 | 525 | $htmlCanvas = $W->HtmlCanvas(); |
542 | 526 | $returnedArray = array(); |
543 | 527 | foreach ($returnedValue as $key => &$item){ |
544 | 528 | if($item instanceof WidgetDisplayableInterface){ |
545 | 529 | $returnedArray[$item->getId()] = $item->display($htmlCanvas); |
546 | - } |
|
547 | - else{ |
|
530 | + } else{ |
|
548 | 531 | $returnedArray[$key] = $item; |
549 | 532 | } |
550 | 533 | } |
@@ -552,8 +535,7 @@ discard block |
||
552 | 535 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
553 | 536 | header('Content-type: application/json'); |
554 | 537 | die(bab_convertStringFromDatabase(bab_json_encode($returnedArray), \bab_charset::UTF_8)); |
555 | - } |
|
556 | - elseif(true === $returnedValue || is_string($returnedValue)){ |
|
538 | + } elseif(true === $returnedValue || is_string($returnedValue)){ |
|
557 | 539 | |
558 | 540 | if($this->isAjaxRequest()){ |
559 | 541 | $body = bab_getBody(); |
@@ -730,8 +712,7 @@ discard block |
||
730 | 712 | foreach ($traces as $trace){ |
731 | 713 | $stackTraceBox->addItem($W->Label($trace)); |
732 | 714 | } |
733 | - } |
|
734 | - else{ |
|
715 | + } else{ |
|
735 | 716 | $section->addItem($W->Label($App->translate('Please contact the administrator'))); |
736 | 717 | } |
737 | 718 | |
@@ -794,8 +775,7 @@ discard block |
||
794 | 775 | foreach ($traces as $trace){ |
795 | 776 | $stackTraceBox->addItem($W->Label($trace)); |
796 | 777 | } |
797 | - } |
|
798 | - else{ |
|
778 | + } else{ |
|
799 | 779 | $section->addItem($W->Label($App->translate('Please contact the administrator'))); |
800 | 780 | } |
801 | 781 |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | use Capwelton\LibApp\Exceptions\AppNotFoundException; |
39 | 39 | use Capwelton\LibApp\Func_App; |
40 | 40 | use Capwelton\LibApp\AppComponent; |
41 | -require_once $GLOBALS['babInstallPath'] . 'utilit/controller.class.php'; |
|
42 | -require_once $GLOBALS['babInstallPath'] . 'utilit/json.php'; |
|
41 | +require_once $GLOBALS['babInstallPath'].'utilit/controller.class.php'; |
|
42 | +require_once $GLOBALS['babInstallPath'].'utilit/json.php'; |
|
43 | 43 | |
44 | -require_once dirname(__FILE__) . '/functions.php'; |
|
44 | +require_once dirname(__FILE__).'/functions.php'; |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @method self proxy() |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function addReloadSelector($reloadSelector, $withSSE = false, $for = null) |
74 | 74 | { |
75 | 75 | $this->reloadSelectors[$reloadSelector] = $reloadSelector; |
76 | - if($withSSE){ |
|
76 | + if ($withSSE) { |
|
77 | 77 | $sseRecordSet = $this->getSSERecordSet(); |
78 | 78 | $sseRecordSet->newReloadSelector($reloadSelector, $for); |
79 | 79 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | public function getSSERecordSet() |
92 | 92 | { |
93 | - if(isset($this->SSERecordSet)){ |
|
93 | + if (isset($this->SSERecordSet)) { |
|
94 | 94 | return $this->SSERecordSet; |
95 | 95 | } |
96 | 96 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function __call($name, $arguments = array()) |
130 | 130 | { |
131 | 131 | $component = $this->App()->getComponentByName($name); |
132 | - if($component){ |
|
132 | + if ($component) { |
|
133 | 133 | return call_user_func_array(array( |
134 | 134 | $component, |
135 | 135 | 'controller' |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function isAjaxRequest() |
174 | 174 | { |
175 | - if(! isset($this->isAjaxRequest)){ |
|
175 | + if (!isset($this->isAjaxRequest)) { |
|
176 | 176 | $this->isAjaxRequest = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); |
177 | 177 | } |
178 | 178 | return $this->isAjaxRequest; |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function requireCredential($message = null) |
186 | 186 | { |
187 | - if($this->isAjaxRequest()){ |
|
187 | + if ($this->isAjaxRequest()) { |
|
188 | 188 | $authType = 'Basic'; |
189 | 189 | } |
190 | - else{ |
|
190 | + else { |
|
191 | 191 | $authType = ''; |
192 | 192 | } |
193 | 193 | |
194 | - if(! isset($message)){ |
|
194 | + if (!isset($message)) { |
|
195 | 195 | $message = $this->App()->translate('You must be logged in to access this page.'); |
196 | 196 | } |
197 | 197 | |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | // we try to select one according to the classname prefix. |
215 | 215 | list ($prefix) = explode('_', __CLASS__); |
216 | 216 | $functionalityName = ucwords($prefix); |
217 | - $App = @\bab_functionality::get('App/' . $functionalityName); |
|
217 | + $App = @\bab_functionality::get('App/'.$functionalityName); |
|
218 | 218 | |
219 | - if(! $App){ |
|
220 | - throw new AppException('Faild to autodetect functionality App/' . $functionalityName . ', the getInstance method is deprecated, use $App->ControllerProxy() instead'); |
|
219 | + if (!$App) { |
|
220 | + throw new AppException('Faild to autodetect functionality App/'.$functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | $controller = $App->ControllerProxy($classname, $proxy); |
@@ -235,39 +235,39 @@ discard block |
||
235 | 235 | static function getProxyInstance(Func_App $App, $classname) |
236 | 236 | { |
237 | 237 | $class = new \ReflectionClass($classname); |
238 | - $proxyClassname = $class->getShortName() . self::PROXY_CLASS_SUFFIX; |
|
239 | - if(! class_exists($proxyClassname)){ |
|
240 | - $classStr = 'class ' . $proxyClassname . ' extends ' . $class->name . ' {' . "\n"; |
|
238 | + $proxyClassname = $class->getShortName().self::PROXY_CLASS_SUFFIX; |
|
239 | + if (!class_exists($proxyClassname)) { |
|
240 | + $classStr = 'class '.$proxyClassname.' extends '.$class->name.' {'."\n"; |
|
241 | 241 | $methods = $class->getMethods(); |
242 | 242 | |
243 | 243 | $classStr .= ' public function __construct(Func_App $App) { |
244 | 244 | $this->setApp($App); |
245 | 245 | }' . "\n"; |
246 | 246 | |
247 | - foreach ($methods as $method){ |
|
248 | - if($method->name === '__construct' || ! $method->isPublic() || $method->isStatic() || $method->isFinal() || $method->name === 'setApp' || $method->name === 'App' || $method->name === 'setCrm' || $method->name === 'Crm'){ |
|
247 | + foreach ($methods as $method) { |
|
248 | + if ($method->name === '__construct' || !$method->isPublic() || $method->isStatic() || $method->isFinal() || $method->name === 'setApp' || $method->name === 'App' || $method->name === 'setCrm' || $method->name === 'Crm') { |
|
249 | 249 | continue; |
250 | 250 | } |
251 | 251 | |
252 | - $classStr .= ' public function ' . $method->name . '('; |
|
252 | + $classStr .= ' public function '.$method->name.'('; |
|
253 | 253 | $parameters = $method->getParameters(); |
254 | 254 | $parametersStr = array(); |
255 | - foreach ($parameters as $parameter){ |
|
255 | + foreach ($parameters as $parameter) { |
|
256 | 256 | |
257 | - if($parameter->isDefaultValueAvailable()){ |
|
258 | - $parametersStr[] = '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true); |
|
257 | + if ($parameter->isDefaultValueAvailable()) { |
|
258 | + $parametersStr[] = '$'.$parameter->name.' = '.var_export($parameter->getDefaultValue(), true); |
|
259 | 259 | } |
260 | - else{ |
|
261 | - $parametersStr[] = '$' . $parameter->name; |
|
260 | + else { |
|
261 | + $parametersStr[] = '$'.$parameter->name; |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | $classStr .= implode(', ', $parametersStr); |
265 | - $classStr .= ') {' . "\n"; |
|
266 | - $classStr .= ' $args = func_get_args();' . "\n"; |
|
267 | - $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);' . "\n"; |
|
268 | - $classStr .= ' }' . "\n"; |
|
265 | + $classStr .= ') {'."\n"; |
|
266 | + $classStr .= ' $args = func_get_args();'."\n"; |
|
267 | + $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);'."\n"; |
|
268 | + $classStr .= ' }'."\n"; |
|
269 | 269 | } |
270 | - $classStr .= '}' . "\n"; |
|
270 | + $classStr .= '}'."\n"; |
|
271 | 271 | |
272 | 272 | // We define the proxy class |
273 | 273 | eval($classStr); |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | protected function getObjectName($classname) |
307 | 307 | { |
308 | 308 | list ($objectname) = explode('Controller', $classname); |
309 | - if($this->App()->getComponentByName($objectname)){ |
|
309 | + if ($this->App()->getComponentByName($objectname)) { |
|
310 | 310 | return strtolower($objectname); |
311 | 311 | } |
312 | 312 | list (, $objectname) = explode('_Ctrl', $classname); |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | |
329 | 329 | $reflector = new \ReflectionClass(get_class($this)); |
330 | 330 | $parent = $reflector->getParentClass(); |
331 | - if($parent){ |
|
331 | + if ($parent) { |
|
332 | 332 | $parentMethod = $parent->getMethod('__construct'); |
333 | 333 | $docComment = $parentMethod->getDocComment(); |
334 | - if(strpos($docComment, '@isComponentController') !== false){ |
|
334 | + if (strpos($docComment, '@isComponentController') !== false) { |
|
335 | 335 | $fullClassName = $parent->getName(); |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | 339 | $rc = new \ReflectionClass($fullClassName); |
340 | 340 | |
341 | - if(! $rc->hasMethod($methodName)){ |
|
342 | - throw new \bab_InvalidActionException($fullClassName . '::' . $methodName); |
|
341 | + if (!$rc->hasMethod($methodName)) { |
|
342 | + throw new \bab_InvalidActionException($fullClassName.'::'.$methodName); |
|
343 | 343 | } |
344 | 344 | $method = new \ReflectionMethod($fullClassName, $methodName); |
345 | 345 | |
@@ -348,32 +348,32 @@ discard block |
||
348 | 348 | $parameters = $method->getParameters(); |
349 | 349 | $actionParams = array(); |
350 | 350 | $argNumber = 0; |
351 | - foreach ($parameters as $parameter){ |
|
351 | + foreach ($parameters as $parameter) { |
|
352 | 352 | $parameterName = $parameter->getName(); |
353 | - if(isset($args[$argNumber])){ |
|
353 | + if (isset($args[$argNumber])) { |
|
354 | 354 | $actionParams[$parameterName] = $args[$argNumber]; |
355 | 355 | } |
356 | - elseif($parameter->isDefaultValueAvailable()){ |
|
356 | + elseif ($parameter->isDefaultValueAvailable()) { |
|
357 | 357 | $actionParams[$parameterName] = $parameter->getDefaultValue(); |
358 | 358 | } |
359 | - else{ |
|
359 | + else { |
|
360 | 360 | $actionParams[$parameterName] = null; |
361 | 361 | } |
362 | - $argNumber ++; |
|
362 | + $argNumber++; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | $action = new WidgetAction(); |
366 | 366 | |
367 | - $action->setMethod($this->getControllerTg(), $objectName . '.' . $methodName, $actionParams); |
|
367 | + $action->setMethod($this->getControllerTg(), $objectName.'.'.$methodName, $actionParams); |
|
368 | 368 | |
369 | 369 | $docComment = $method->getDocComment(); |
370 | - if(strpos($docComment, '@ajax') !== false){ |
|
370 | + if (strpos($docComment, '@ajax') !== false) { |
|
371 | 371 | $action->setAjax(true); |
372 | 372 | } |
373 | - if(strpos($docComment, '@requireSaveMethod') !== false && method_exists($action, 'setRequireSaveMethod')){ |
|
373 | + if (strpos($docComment, '@requireSaveMethod') !== false && method_exists($action, 'setRequireSaveMethod')) { |
|
374 | 374 | $action->setRequireSaveMethod(true); |
375 | 375 | } |
376 | - if(strpos($docComment, '@requireDeleteMethod') !== false && method_exists($action, 'setRequireDeleteMethod')){ |
|
376 | + if (strpos($docComment, '@requireDeleteMethod') !== false && method_exists($action, 'setRequireDeleteMethod')) { |
|
377 | 377 | $action->setRequireDeleteMethod(true); |
378 | 378 | } |
379 | 379 | |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | |
403 | 403 | $action->setParameters($actionParams); |
404 | 404 | |
405 | - list (, , $file) = explode('/', $App->controllerTg); |
|
405 | + list (,, $file) = explode('/', $App->controllerTg); |
|
406 | 406 | |
407 | - $action->setParameter('addon', $App->getAddonName() . '.' . $file); |
|
407 | + $action->setParameter('addon', $App->getAddonName().'.'.$file); |
|
408 | 408 | $action->setParameter('idx', $idx); |
409 | 409 | |
410 | 410 | return $action; |
@@ -422,44 +422,44 @@ discard block |
||
422 | 422 | |
423 | 423 | $method = $action->getMethod(); |
424 | 424 | |
425 | - if(! isset($method) || '' === $method){ |
|
425 | + if (!isset($method) || '' === $method) { |
|
426 | 426 | return false; |
427 | 427 | } |
428 | 428 | |
429 | 429 | list ($objectName,) = explode('.', $method); |
430 | 430 | |
431 | - if(! method_exists($this, $objectName)){ |
|
431 | + if (!method_exists($this, $objectName)) { |
|
432 | 432 | /* @var $component AppComponent */ |
433 | 433 | $component = $this->app->getComponentByName($objectName); |
434 | - if($component){ |
|
434 | + if ($component) { |
|
435 | 435 | $this->app->setCurrentComponent($component); |
436 | 436 | $objectController = $component->controller(false); |
437 | 437 | } |
438 | - else{ |
|
438 | + else { |
|
439 | 439 | header('HTTP/1.0 400 Bad Request'); |
440 | 440 | throw new AppUnknownActionException($action); |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | - if(! isset($component)){ |
|
444 | + if (!isset($component)) { |
|
445 | 445 | $objectController = $this->{$objectName}(false); |
446 | - if(! ($objectController instanceof AppController)){ |
|
446 | + if (!($objectController instanceof AppController)) { |
|
447 | 447 | return false; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - try{ |
|
451 | + try { |
|
452 | 452 | $returnedValue = $objectController->execAction($action); |
453 | 453 | } |
454 | - catch (AppAccessException $e){ |
|
454 | + catch (AppAccessException $e) { |
|
455 | 455 | |
456 | - if(! bab_isUserLogged() && $e->requireCredential){ |
|
456 | + if (!bab_isUserLogged() && $e->requireCredential) { |
|
457 | 457 | bab_requireCredential($e->getMessage()); |
458 | 458 | } |
459 | - else{ |
|
460 | - if($this->isAjaxRequest()){ |
|
459 | + else { |
|
460 | + if ($this->isAjaxRequest()) { |
|
461 | 461 | |
462 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
462 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
463 | 463 | |
464 | 464 | die(bab_json_encode(array( |
465 | 465 | 'exception' => 'app_AccessException', |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | $this->accessPage($e); |
471 | 471 | } |
472 | 472 | } |
473 | - catch (AppSaveException $e){ |
|
473 | + catch (AppSaveException $e) { |
|
474 | 474 | |
475 | - if($this->isAjaxRequest()){ |
|
476 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
475 | + if ($this->isAjaxRequest()) { |
|
476 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
477 | 477 | header('Cache-Control: no-cache, must-revalidate'); |
478 | 478 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
479 | 479 | header('Content-type: application/json'); |
@@ -485,32 +485,32 @@ discard block |
||
485 | 485 | ))); |
486 | 486 | } |
487 | 487 | } |
488 | - catch (AppDeletedRecordException $e){ |
|
488 | + catch (AppDeletedRecordException $e) { |
|
489 | 489 | $this->deletedItemPage($action, $e); |
490 | 490 | } |
491 | - catch (AppNotFoundException $e){ |
|
491 | + catch (AppNotFoundException $e) { |
|
492 | 492 | $this->notFoundPage($action, $e); |
493 | 493 | } |
494 | - catch (\ORM_Exception $e){ |
|
494 | + catch (\ORM_Exception $e) { |
|
495 | 495 | $this->errorPage($e); |
496 | 496 | } |
497 | - catch (\Exception $e){ |
|
497 | + catch (\Exception $e) { |
|
498 | 498 | $this->unexpectedErrorPage($e); |
499 | 499 | } |
500 | 500 | |
501 | 501 | $W = bab_Widgets(); |
502 | 502 | |
503 | - if($returnedValue instanceof WidgetDisplayableInterface){ |
|
503 | + if ($returnedValue instanceof WidgetDisplayableInterface) { |
|
504 | 504 | |
505 | - if($returnedValue instanceof WidgetBabPage && ! $this->isAjaxRequest()){ |
|
505 | + if ($returnedValue instanceof WidgetBabPage && !$this->isAjaxRequest()) { |
|
506 | 506 | |
507 | 507 | // If the action returned a page, we display it. |
508 | 508 | $returnedValue->displayHtml(); |
509 | 509 | } |
510 | - else{ |
|
510 | + else { |
|
511 | 511 | |
512 | 512 | $htmlCanvas = $W->HtmlCanvas(); |
513 | - if(self::$acceptJson){ |
|
513 | + if (self::$acceptJson) { |
|
514 | 514 | $itemId = $returnedValue->getId(); |
515 | 515 | $returnArray = array( |
516 | 516 | $itemId => $returnedValue->display($htmlCanvas) |
@@ -520,18 +520,18 @@ discard block |
||
520 | 520 | header('Content-type: application/json'); |
521 | 521 | die(bab_json_encode($returnArray)); |
522 | 522 | } |
523 | - else{ |
|
523 | + else { |
|
524 | 524 | header('Cache-Control: no-cache, must-revalidate'); |
525 | 525 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
526 | 526 | header('Content-type: text/html'); |
527 | - if($returnedValue instanceof WidgetPage && method_exists($returnedValue, 'getPageTitle')){ |
|
527 | + if ($returnedValue instanceof WidgetPage && method_exists($returnedValue, 'getPageTitle')) { |
|
528 | 528 | $pageTitle = $returnedValue->getPageTitle(); |
529 | 529 | |
530 | - if(method_exists($htmlCanvas, 'sendPageTitle')){ |
|
530 | + if (method_exists($htmlCanvas, 'sendPageTitle')) { |
|
531 | 531 | $htmlCanvas->sendPageTitle($pageTitle); |
532 | 532 | } |
533 | - else{ |
|
534 | - header('X-Cto-PageTitle: ' . $pageTitle); |
|
533 | + else { |
|
534 | + header('X-Cto-PageTitle: '.$pageTitle); |
|
535 | 535 | } |
536 | 536 | } |
537 | 537 | $html = $returnedValue->display($htmlCanvas); |
@@ -539,15 +539,15 @@ discard block |
||
539 | 539 | } |
540 | 540 | } |
541 | 541 | } |
542 | - elseif(is_array($returnedValue)){ |
|
542 | + elseif (is_array($returnedValue)) { |
|
543 | 543 | |
544 | 544 | $htmlCanvas = $W->HtmlCanvas(); |
545 | 545 | $returnedArray = array(); |
546 | - foreach ($returnedValue as $key => &$item){ |
|
547 | - if($item instanceof WidgetDisplayableInterface){ |
|
546 | + foreach ($returnedValue as $key => &$item) { |
|
547 | + if ($item instanceof WidgetDisplayableInterface) { |
|
548 | 548 | $returnedArray[$item->getId()] = $item->display($htmlCanvas); |
549 | 549 | } |
550 | - else{ |
|
550 | + else { |
|
551 | 551 | $returnedArray[$key] = $item; |
552 | 552 | } |
553 | 553 | } |
@@ -556,9 +556,9 @@ discard block |
||
556 | 556 | header('Content-type: application/json'); |
557 | 557 | die(bab_convertStringFromDatabase(bab_json_encode($returnedArray), \bab_charset::UTF_8)); |
558 | 558 | } |
559 | - elseif(true === $returnedValue || is_string($returnedValue)){ |
|
559 | + elseif (true === $returnedValue || is_string($returnedValue)) { |
|
560 | 560 | |
561 | - if($this->isAjaxRequest()){ |
|
561 | + if ($this->isAjaxRequest()) { |
|
562 | 562 | $body = bab_getBody(); |
563 | 563 | $json = array(); |
564 | 564 | $json['messages'] = array(); |
@@ -566,21 +566,21 @@ discard block |
||
566 | 566 | unset($body->messages['toasts']); |
567 | 567 | $messages = $body->messages; |
568 | 568 | $errors = $body->errors; |
569 | - foreach ($messages as $message){ |
|
569 | + foreach ($messages as $message) { |
|
570 | 570 | $json['messages'][] = array( |
571 | 571 | 'level' => 'info', |
572 | 572 | 'content' => $message, |
573 | 573 | 'time' => 4000 |
574 | 574 | ); |
575 | 575 | } |
576 | - foreach ($errors as $message){ |
|
576 | + foreach ($errors as $message) { |
|
577 | 577 | $json['messages'][] = array( |
578 | 578 | 'level' => 'danger', |
579 | 579 | 'content' => $message |
580 | 580 | ); |
581 | 581 | } |
582 | 582 | $json['toasts'] = $toasts; |
583 | - if($objectController->getReloadSelectors()){ |
|
583 | + if ($objectController->getReloadSelectors()) { |
|
584 | 584 | $json['reloadSelector'] = implode(',', $objectController->getReloadSelectors()); |
585 | 585 | } |
586 | 586 | echo bab_json_encode($json); |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | |
594 | 594 | private function deletedItemPage(WidgetAction $action, AppDeletedRecordException $e) |
595 | 595 | { |
596 | - if($this->isAjaxRequest()){ |
|
597 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
596 | + if ($this->isAjaxRequest()) { |
|
597 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
598 | 598 | header('Cache-Control: no-cache, must-revalidate'); |
599 | 599 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
600 | 600 | header('Content-type: application/json'); |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | 'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8') |
607 | 607 | ))); |
608 | 608 | } |
609 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); |
|
609 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); |
|
610 | 610 | |
611 | 611 | $App = app_App(); |
612 | 612 | $W = bab_Widgets(); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | ->setAlignItems(WidgetFlexLayout::FLEX_ALIGN_ITEMS_CENTER)); |
629 | 629 | $section->addItems($W->Title($App->translate('Error'), 1), $W->Title(sprintf($App->translate('This %s has been deleted'), $e->getObjectTitle()))); |
630 | 630 | |
631 | - if($e instanceof AppDeletedRecordException){ |
|
631 | + if ($e instanceof AppDeletedRecordException) { |
|
632 | 632 | $section->addItems($e->getDeletedBy(), $e->getDeletedOn()); |
633 | 633 | } |
634 | 634 | |
@@ -637,8 +637,8 @@ discard block |
||
637 | 637 | |
638 | 638 | private function notFoundPage(WidgetAction $action, AppNotFoundException $e) |
639 | 639 | { |
640 | - if($this->isAjaxRequest()){ |
|
641 | - $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle() . ' (' . $e->getId() . ')'); |
|
640 | + if ($this->isAjaxRequest()) { |
|
641 | + $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle().' ('.$e->getId().')'); |
|
642 | 642 | $json = array( |
643 | 643 | 'messages' => array( |
644 | 644 | array( |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | echo bab_json_encode($json); |
651 | 651 | die(); |
652 | 652 | } |
653 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); |
|
653 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); |
|
654 | 654 | header('Cache-Control: no-cache, must-revalidate'); |
655 | 655 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
656 | 656 | |
@@ -679,8 +679,8 @@ discard block |
||
679 | 679 | |
680 | 680 | private function unexpectedErrorPage(\Exception $e) |
681 | 681 | { |
682 | - if($this->isAjaxRequest()){ |
|
683 | - $message = sprintf(app_translate('An unexpected error occured') . ':' . '%s', $e->getMessage()); |
|
682 | + if ($this->isAjaxRequest()) { |
|
683 | + $message = sprintf(app_translate('An unexpected error occured').':'.'%s', $e->getMessage()); |
|
684 | 684 | $json = array( |
685 | 685 | 'messages' => array( |
686 | 686 | array( |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | echo bab_json_encode($json); |
693 | 693 | die(); |
694 | 694 | } |
695 | - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500); |
|
695 | + header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500); |
|
696 | 696 | header('Cache-Control: no-cache, must-revalidate'); |
697 | 697 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
698 | 698 | |
@@ -716,25 +716,25 @@ discard block |
||
716 | 716 | ->addClass('widget-50pc alert alert-danger') |
717 | 717 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)); |
718 | 718 | |
719 | - $logCode = '#' . hrtime(true); |
|
719 | + $logCode = '#'.hrtime(true); |
|
720 | 720 | $message = addcslashes($e->getMessage(), "\000..\037\177..\377\\"); |
721 | 721 | $trace = addcslashes($e->getTraceAsString(), "\000..\037\177..\377\\"); |
722 | 722 | |
723 | - error_log(sprintf('Error %s : %s', $logCode, $message) . PHP_EOL . $trace); |
|
723 | + error_log(sprintf('Error %s : %s', $logCode, $message).PHP_EOL.$trace); |
|
724 | 724 | |
725 | 725 | $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))); |
726 | 726 | |
727 | - if(bab_isUserAdministrator()){ |
|
727 | + if (bab_isUserAdministrator()) { |
|
728 | 728 | $contentBox->addItem($W->Section('Stack trace', $stackTraceBox = $W->FlexItems($W->Label($message) |
729 | 729 | ->addClass('widget-description')) |
730 | 730 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)) |
731 | 731 | ->setFoldable(true, true)); |
732 | 732 | $traces = explode("\n", $e->getTraceAsString()); |
733 | - foreach ($traces as $trace){ |
|
733 | + foreach ($traces as $trace) { |
|
734 | 734 | $stackTraceBox->addItem($W->Label($trace)); |
735 | 735 | } |
736 | 736 | } |
737 | - else{ |
|
737 | + else { |
|
738 | 738 | $section->addItem($W->Label($App->translate('Please contact the administrator'))); |
739 | 739 | } |
740 | 740 | |
@@ -743,8 +743,8 @@ discard block |
||
743 | 743 | |
744 | 744 | private function errorPage(\Exception $e) |
745 | 745 | { |
746 | - if($this->isAjaxRequest()){ |
|
747 | - $message = sprintf(app_translate('An unexpected error occured') . ':' . '%s', $e->getMessage()); |
|
746 | + if ($this->isAjaxRequest()) { |
|
747 | + $message = sprintf(app_translate('An unexpected error occured').':'.'%s', $e->getMessage()); |
|
748 | 748 | $json = array( |
749 | 749 | 'messages' => array( |
750 | 750 | array( |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | echo bab_json_encode($json); |
757 | 757 | die(); |
758 | 758 | } |
759 | - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500); |
|
759 | + header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500); |
|
760 | 760 | header('Cache-Control: no-cache, must-revalidate'); |
761 | 761 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
762 | 762 | |
@@ -780,25 +780,25 @@ discard block |
||
780 | 780 | ->addClass('widget-50pc alert alert-danger') |
781 | 781 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)); |
782 | 782 | |
783 | - $logCode = '#' . hrtime(true); |
|
783 | + $logCode = '#'.hrtime(true); |
|
784 | 784 | $message = addcslashes($e->getMessage(), "\000..\037\177..\377\\"); |
785 | 785 | $trace = addcslashes($e->getTraceAsString(), "\000..\037\177..\377\\"); |
786 | 786 | |
787 | - error_log(sprintf('Error %s : %s', $logCode, $message) . PHP_EOL . $trace); |
|
787 | + error_log(sprintf('Error %s : %s', $logCode, $message).PHP_EOL.$trace); |
|
788 | 788 | |
789 | 789 | $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))); |
790 | 790 | |
791 | - if(bab_isUserAdministrator()){ |
|
791 | + if (bab_isUserAdministrator()) { |
|
792 | 792 | $contentBox->addItem($W->Section('Stack trace', $stackTraceBox = $W->FlexItems($W->Label($message) |
793 | 793 | ->addClass('widget-description')) |
794 | 794 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)) |
795 | 795 | ->setFoldable(true, true)); |
796 | 796 | $traces = explode("\n", $e->getTraceAsString()); |
797 | - foreach ($traces as $trace){ |
|
797 | + foreach ($traces as $trace) { |
|
798 | 798 | $stackTraceBox->addItem($W->Label($trace)); |
799 | 799 | } |
800 | 800 | } |
801 | - else{ |
|
801 | + else { |
|
802 | 802 | $section->addItem($W->Label($App->translate('Please contact the administrator'))); |
803 | 803 | } |
804 | 804 | |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | |
808 | 808 | private function accessPage(\Exception $e) |
809 | 809 | { |
810 | - if($this->isAjaxRequest()){ |
|
810 | + if ($this->isAjaxRequest()) { |
|
811 | 811 | $message = $e->getMessage(); |
812 | 812 | $json = array( |
813 | 813 | 'messages' => array( |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | echo bab_json_encode($json); |
821 | 821 | die(); |
822 | 822 | } |
823 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
823 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
824 | 824 | header('Cache-Control: no-cache, must-revalidate'); |
825 | 825 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
826 | 826 | |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | */ |
858 | 858 | public function requireSaveMethod() |
859 | 859 | { |
860 | - if('GET' === $_SERVER['REQUEST_METHOD']){ |
|
860 | + if ('GET' === $_SERVER['REQUEST_METHOD']) { |
|
861 | 861 | throw new AppException('Method not allowed'); |
862 | 862 | } |
863 | 863 | |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | */ |
873 | 873 | public function requireDeleteMethod() |
874 | 874 | { |
875 | - if('GET' === $_SERVER['REQUEST_METHOD']){ |
|
875 | + if ('GET' === $_SERVER['REQUEST_METHOD']) { |
|
876 | 876 | throw new AppException('Method not allowed'); |
877 | 877 | } |
878 | 878 | |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | 'position' => $position |
905 | 905 | ); |
906 | 906 | $babBody = bab_getBody(); |
907 | - if(! isset($babBody->messages['toasts'])){ |
|
907 | + if (!isset($babBody->messages['toasts'])) { |
|
908 | 908 | $babBody->messages['toasts'] = array(); |
909 | 909 | } |
910 | 910 | $babBody->messages['toasts'][] = $toast; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | { |
28 | 28 | public function __construct($action, $code = 0) |
29 | 29 | { |
30 | - $message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; |
|
30 | + $message = 'Unknown method "'.$action->getController().'::'.$action->getMethod().'"'; |
|
31 | 31 | parent::__construct($message, $code); |
32 | 32 | } |
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -72,7 +72,7 @@ |
||
72 | 72 | public function getObjectTitle() |
73 | 73 | { |
74 | 74 | $element = app_translate('object'); |
75 | - if($description = $this->getRecordSet()->getDescription()){ |
|
75 | + if ($description = $this->getRecordSet()->getDescription()) { |
|
76 | 76 | $element = mb_strtolower(app_translate($description)); |
77 | 77 | } |
78 | 78 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getDeletedBy() |
55 | 55 | { |
56 | - if(! $this->record->deletedBy){ |
|
56 | + if (!$this->record->deletedBy) { |
|
57 | 57 | return null; |
58 | 58 | } |
59 | 59 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function getDeletedOn() |
69 | 69 | { |
70 | 70 | $set = $this->getRecordSet(); |
71 | - if(! $set->deletedOn->isValueSet($this->record->deletedOn)){ |
|
71 | + if (!$set->deletedOn->isValueSet($this->record->deletedOn)) { |
|
72 | 72 | return null; |
73 | 73 | } |
74 | 74 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $portlet_path = explode('_', get_class($this)); |
81 | 81 | |
82 | - return implode('/', $app_path) . '/' . $portlet_path[count($portlet_path) - 1]; |
|
82 | + return implode('/', $app_path).'/'.$portlet_path[count($portlet_path) - 1]; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $classname = get_class($this); |
91 | 91 | $suffix = mb_substr($classname, mb_strlen('App_PortletDefinition_')); |
92 | - $classname = 'App_PortletUi_' . $suffix; |
|
92 | + $classname = 'App_PortletUi_'.$suffix; |
|
93 | 93 | |
94 | 94 | return new $classname($this->App()); |
95 | 95 | } |