@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function initHeaderRow(ORMRecordSet $set) |
87 | 87 | { |
88 | - require_once $GLOBALS['babInstallPath'] . 'utilit/urlincl.php'; |
|
88 | + require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php'; |
|
89 | 89 | |
90 | 90 | \bab_functionality::includefile('Icons'); |
91 | 91 | |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | $sizePolicy = 'widget-actions-target'; |
118 | 118 | |
119 | 119 | if ($this->isMultiSelect() && $columnPath === '_select_') { |
120 | - $this->toggleCheckAllBox = $W->CheckBox(); |
|
120 | + $this->toggleCheckAllBox = $W->CheckBox(); |
|
121 | 121 | $this->toggleCheckAllBox->setName('toggleCheckAllBox'); |
122 | 122 | $this->toggleCheckAllBox->setTitle(widget_translate('Select all on page')); |
123 | 123 | $this->toggleCheckAllBox->setSizePolicy('condensed'); |
124 | 124 | $this->toggleCheckAllBox->setCheckedValue(true); |
125 | - if(isset($_SESSION['toggleCheckAllBox'][$this->getId()]) && !empty($_SESSION['toggleCheckAllBox'][$this->getId()]) && $_SESSION['toggleCheckAllBox'][$this->getId()] == 'on'){ |
|
125 | + if (isset($_SESSION['toggleCheckAllBox'][$this->getId()]) && !empty($_SESSION['toggleCheckAllBox'][$this->getId()]) && $_SESSION['toggleCheckAllBox'][$this->getId()] == 'on') { |
|
126 | 126 | $this->toggleCheckAllBox->setValue(true); |
127 | 127 | } |
128 | 128 | $isSearchable = false; |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | $direction = ':up'; |
140 | 140 | } |
141 | 141 | |
142 | - $url = \bab_url::mod($this->sortBaseUrl, $this->sortParameterName, $columnPath . $direction); |
|
142 | + $url = \bab_url::mod($this->sortBaseUrl, $this->sortParameterName, $columnPath.$direction); |
|
143 | 143 | if ($anchor = $this->getAnchor()) { |
144 | - $url .= '#' . urlencode($anchor); |
|
144 | + $url .= '#'.urlencode($anchor); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | $columnItem = $W->Link( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | )->addClass('widget-table-column-sorting-action'); |
154 | 154 | if ($this->sortAjaxAction) { |
155 | 155 | $columnItem->setAjaxAction( |
156 | - $this->sortAjaxAction->setParameter('sort', $columnPath . $direction), |
|
156 | + $this->sortAjaxAction->setParameter('sort', $columnPath.$direction), |
|
157 | 157 | '' |
158 | 158 | ); |
159 | 159 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | $columnItem->addClass('icon', $columnIcon)->setSizePolicy(\Func_Icons::ICON_LEFT_16); |
175 | 175 | } |
176 | 176 | |
177 | - if($isSortable){ |
|
177 | + if ($isSortable) { |
|
178 | 178 | $sizePolicy .= ' widget-table-column-sortable'; |
179 | 179 | } |
180 | - if($isSearchable){ |
|
180 | + if ($isSearchable) { |
|
181 | 181 | if (!isset($this->filterBaseUrl)) { |
182 | 182 | $this->filterBaseUrl = $this->getRecordControllerProxy()->displayListFilter(); |
183 | 183 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | 0 |
193 | 193 | ); |
194 | 194 | $sizePolicy .= ' widget-table-column-searchable'; |
195 | - if(isset($filterValues[$columnPath]) && !empty($filterValues[$columnPath])){ |
|
195 | + if (isset($filterValues[$columnPath]) && !empty($filterValues[$columnPath])) { |
|
196 | 196 | $sizePolicy .= ' widget-table-column-searched'; |
197 | 197 | } |
198 | 198 | } |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - protected function initRow($record, $row){ |
|
211 | - if($this->highlightRows == null){ |
|
210 | + protected function initRow($record, $row) { |
|
211 | + if ($this->highlightRows == null) { |
|
212 | 212 | $this->highlightRows = $this->getHighlightedRows(); |
213 | 213 | } |
214 | 214 | |
215 | - if(in_array($record->id,$this->highlightRows)){ |
|
215 | + if (in_array($record->id, $this->highlightRows)) { |
|
216 | 216 | $this->addRowClass($row, "app_highlightRow"); |
217 | 217 | } |
218 | 218 | $this->addRowClass($row, "app_highlightAvailable"); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | // we try to select one according to the classname prefix. |
243 | 243 | list($prefix) = explode('_', get_class($this)); |
244 | 244 | $functionalityName = ucwords($prefix); |
245 | - $this->app = @\bab_functionality::get('App/' . $functionalityName); |
|
245 | + $this->app = @\bab_functionality::get('App/'.$functionalityName); |
|
246 | 246 | if (!$this->app) { |
247 | 247 | $this->app = @\bab_functionality::get('App'); |
248 | 248 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $this->setCurrentPage(isset($filter['pageNumber']) ? $filter['pageNumber'] : $pageNumber); |
304 | 304 | |
305 | 305 | if (isset($name)) { |
306 | - $this->sortParameterName = $name . '[filter][sort]'; |
|
306 | + $this->sortParameterName = $name.'[filter][sort]'; |
|
307 | 307 | } else { |
308 | 308 | $this->sortParameterName = 'filter[sort]'; |
309 | 309 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | |
409 | 409 | $values = $set->select(); |
410 | 410 | foreach ($values as $record) { |
411 | - $widget->addOption($record->id, (string)$record->name); |
|
411 | + $widget->addOption($record->id, (string) $record->name); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | return $widget; |
@@ -516,11 +516,11 @@ discard block |
||
516 | 516 | |
517 | 517 | foreach ($columns as $fieldName => $column) { |
518 | 518 | $field = $column->getField(); |
519 | - if (! $column->isSearchable()) { |
|
519 | + if (!$column->isSearchable()) { |
|
520 | 520 | continue; |
521 | 521 | } |
522 | 522 | |
523 | - if (! ($field instanceof ORMField)) { |
|
523 | + if (!($field instanceof ORMField)) { |
|
524 | 524 | $field = null; |
525 | 525 | } |
526 | 526 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | $formItem = $this->handleFilterLabel($label, $input); |
538 | 538 | |
539 | 539 | // $formItem = $W->Section($label->getText(), $input, 7)->setFoldable(true, true); |
540 | - $formItem->addClass('compact', 'field_' . $fieldName); |
|
540 | + $formItem->addClass('compact', 'field_'.$fieldName); |
|
541 | 541 | |
542 | 542 | $mainSearch = (method_exists($column, 'isMainSearch') && $column->isMainSearch()); |
543 | 543 | |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | $W->Link('', $removeColumnsAction) |
562 | 562 | ->setAjaxAction() |
563 | 563 | ->addClass('icon', \Func_Icons::STATUS_DIALOG_ERROR) |
564 | - ->addAttribute('data-removefor', $column->getFieldPath()) |
|
564 | + ->addAttribute('data-removefor', $column->getFieldPath()) |
|
565 | 565 | )->setAlignItems(WidgetFlexLayout::FLEX_ALIGN_ITEMS_FLEX_END) |
566 | 566 | ); |
567 | 567 | } else { |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | } |
573 | 573 | |
574 | 574 | |
575 | - if (! $this->submit) { |
|
575 | + if (!$this->submit) { |
|
576 | 576 | $this->submit = $W->SubmitButton(); |
577 | 577 | $this->submit->setLabel(Widget_translate('Apply filter')); |
578 | 578 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | |
612 | 612 | |
613 | 613 | foreach ($filterNames as $filterName) { |
614 | - $filter = $W->getUserConfiguration($controller->getModelViewDefaultId() . '/filters/' . $filterName, 'widgets', false); |
|
614 | + $filter = $W->getUserConfiguration($controller->getModelViewDefaultId().'/filters/'.$filterName, 'widgets', false); |
|
615 | 615 | |
616 | 616 | // $this->select->addItem( |
617 | 617 | // $W->Link( |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $form->setReadOnly(true); |
666 | 666 | $form->setName('filter'); |
667 | 667 | $form->colon(); |
668 | - $form->checkUnsaved(false,null); |
|
668 | + $form->checkUnsaved(false, null); |
|
669 | 669 | |
670 | 670 | $form->setLayout( |
671 | 671 | $W->FlowItems( |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | // $this->setCurrentPage(isset($filter['pageNumber']) ? $filter['pageNumber'] : $pageNumber); |
728 | 728 | |
729 | 729 | if (isset($name)) { |
730 | - $this->sortParameterName = $name . '[filter][sort]'; |
|
730 | + $this->sortParameterName = $name.'[filter][sort]'; |
|
731 | 731 | } else { |
732 | 732 | $this->sortParameterName = 'filter[sort]'; |
733 | 733 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | /** @var \Func_Icons $I */ |
61 | 61 | $I = \bab_Functionality::get('Icons'); |
62 | - if($I){ |
|
62 | + if ($I) { |
|
63 | 63 | $I->includeCss(); |
64 | 64 | } |
65 | 65 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function addItem(WidgetDisplayableInterface $item = null, $order = null) |
108 | 108 | { |
109 | - if(! isset($this->mainPanel)){ |
|
109 | + if (!isset($this->mainPanel)) { |
|
110 | 110 | $W = bab_widgets(); |
111 | 111 | $this->mainPanel = $W->VBoxLayout(); |
112 | 112 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $W = bab_widgets(); |
129 | 129 | |
130 | - if(null === $this->context){ |
|
130 | + if (null === $this->context) { |
|
131 | 131 | |
132 | 132 | $isAjaxRequest = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); |
133 | 133 | $contextPanelId = $isAjaxRequest ? null : 'app_context_panel'; |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | $this->context = $W->Frame($contextPanelId, $W->VBoxLayout() |
136 | 136 | ->setVerticalSpacing(2, 'em')); |
137 | 137 | } |
138 | - if(isset($title)){ |
|
138 | + if (isset($title)) { |
|
139 | 139 | $this->context->addItem($W->Section($title, $item, 4), $position); |
140 | 140 | } |
141 | - else{ |
|
141 | + else { |
|
142 | 142 | $this->context->addItem($item, $position); |
143 | 143 | } |
144 | 144 | return $this; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | { |
155 | 155 | $W = bab_widgets(); |
156 | 156 | |
157 | - if(null === $this->toolbars){ |
|
157 | + if (null === $this->toolbars) { |
|
158 | 158 | $this->toolbars = $W->Frame(null, $W->VBoxItems()); |
159 | 159 | } |
160 | 160 | $this->toolbars->addItem($item); |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | $W = bab_widgets(); |
168 | 168 | |
169 | 169 | $mainPanel = $W->Frame(null, $this->mainPanel); |
170 | - if(bab_isAjaxRequest()){ |
|
170 | + if (bab_isAjaxRequest()) { |
|
171 | 171 | $mainPanel->addClass('app_main_panel'); |
172 | 172 | } |
173 | - else{ |
|
173 | + else { |
|
174 | 174 | $mainPanel->setId('app_main_panel'); |
175 | 175 | } |
176 | 176 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | $mainPanel = $this->getMainPanel(); |
189 | 189 | |
190 | - if($this->context){ |
|
190 | + if ($this->context) { |
|
191 | 191 | |
192 | 192 | $W = bab_widgets(); |
193 | 193 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | protected function addToolbars(WidgetItem $mainPanel) |
206 | 206 | { |
207 | - if($this->toolbars){ |
|
207 | + if ($this->toolbars) { |
|
208 | 208 | |
209 | 209 | $W = bab_widgets(); |
210 | 210 | |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function addMessageInfo() |
246 | 246 | { |
247 | - if(isset($_SESSION['app_msginfo'])){ |
|
247 | + if (isset($_SESSION['app_msginfo'])) { |
|
248 | 248 | |
249 | 249 | // all widget have static id to not change id of others widgets in page |
250 | 250 | |
251 | 251 | $infoMessages = $_SESSION['app_msginfo']; |
252 | - foreach ($infoMessages as $infoLine){ |
|
252 | + foreach ($infoMessages as $infoLine) { |
|
253 | 253 | $this->App() |
254 | 254 | ->Controller() |
255 | 255 | ->addMessage($infoLine); |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getRecordSet() |
73 | 73 | { |
74 | - if(isset($this->recordSet)){ |
|
74 | + if (isset($this->recordSet)) { |
|
75 | 75 | return $this->recordSet; |
76 | 76 | } |
77 | 77 | |
78 | 78 | $parentField = $this->criteria->getField(); |
79 | 79 | |
80 | - if(! isset($parentField)){ |
|
80 | + if (!isset($parentField)) { |
|
81 | 81 | return null; |
82 | 82 | } |
83 | 83 | |
84 | - do{ |
|
84 | + do { |
|
85 | 85 | $field = $parentField; |
86 | 86 | $parentField = $field->getParentSet(); |
87 | 87 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | |
135 | 135 | $classPrefix = $App->classPrefix; |
136 | 136 | |
137 | - foreach ($recordSetFields as $fieldName => $recordSetField){ |
|
138 | - if($recordSetField instanceof ORMManyRelation){ |
|
137 | + foreach ($recordSetFields as $fieldName => $recordSetField) { |
|
138 | + if ($recordSetField instanceof ORMManyRelation) { |
|
139 | 139 | /* @var $recordSetField ORMManyRelation */ |
140 | 140 | $fieldDescription = $fieldName; |
141 | 141 | $path = $fieldName; |
@@ -144,28 +144,28 @@ discard block |
||
144 | 144 | $foreignRecordSet = $App->$foreignSetName(); |
145 | 145 | $foreignRecordSetFields = $foreignRecordSet->getVisibilityCriteriaFields(); |
146 | 146 | |
147 | - foreach ($foreignRecordSetFields as $foreignFieldName => $foreignRecordSetField){ |
|
147 | + foreach ($foreignRecordSetFields as $foreignFieldName => $foreignRecordSetField) { |
|
148 | 148 | $foreignFieldName = $foreignRecordSetField->getName(); |
149 | 149 | $foreignFieldDescription = $foreignRecordSetField->getDescription(); |
150 | - if(substr($foreignFieldName, 0, 1) !== '_'){ |
|
150 | + if (substr($foreignFieldName, 0, 1) !== '_') { |
|
151 | 151 | $foreignFieldDescription = $App->translate($foreignFieldDescription); |
152 | 152 | } |
153 | - if(empty($foreignFieldDescription)){ |
|
153 | + if (empty($foreignFieldDescription)) { |
|
154 | 154 | $foreignFieldDescription = $foreignFieldName; |
155 | 155 | } |
156 | - $foreignPath = $path . '/' . $foreignRecordSetField->getPath(); |
|
156 | + $foreignPath = $path.'/'.$foreignRecordSetField->getPath(); |
|
157 | 157 | |
158 | 158 | $recordSetFieldSelect->addOption($foreignPath, $foreignFieldDescription, $fieldName); |
159 | 159 | |
160 | - if($foreignRecordSetField instanceof ORMBoolInterface){ |
|
160 | + if ($foreignRecordSetField instanceof ORMBoolInterface) { |
|
161 | 161 | $booleanFieldPathes[] = $foreignPath; |
162 | 162 | } |
163 | - else{ |
|
163 | + else { |
|
164 | 164 | $defaultFieldPathes[] = $foreignPath; |
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
168 | - elseif($recordSetField instanceof ORMFkField){ |
|
168 | + elseif ($recordSetField instanceof ORMFkField) { |
|
169 | 169 | /* @var $recordSetField ORMFkField */ |
170 | 170 | $fieldDescription = $fieldName; |
171 | 171 | $path = $fieldName; |
@@ -174,38 +174,38 @@ discard block |
||
174 | 174 | $foreignRecordSet = $App->$foreignSetName(); |
175 | 175 | $foreignRecordSetFields = $foreignRecordSet->getVisibilityCriteriaFields(); |
176 | 176 | |
177 | - foreach ($foreignRecordSetFields as $foreignFieldName => $foreignRecordSetField){ |
|
177 | + foreach ($foreignRecordSetFields as $foreignFieldName => $foreignRecordSetField) { |
|
178 | 178 | $foreignFieldDescription = $foreignFieldName; |
179 | - $foreignPath = $path . '/' . $foreignFieldName; |
|
179 | + $foreignPath = $path.'/'.$foreignFieldName; |
|
180 | 180 | |
181 | 181 | $recordSetFieldSelect->addOption($foreignPath, $foreignFieldDescription, $fieldName); |
182 | 182 | |
183 | - if($foreignRecordSetField instanceof ORMBoolInterface){ |
|
183 | + if ($foreignRecordSetField instanceof ORMBoolInterface) { |
|
184 | 184 | $booleanFieldPathes[] = $foreignPath; |
185 | 185 | } |
186 | - else{ |
|
186 | + else { |
|
187 | 187 | $defaultFieldPathes[] = $foreignPath; |
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
191 | - else{ |
|
191 | + else { |
|
192 | 192 | /* @var $recordSetField ORMField */ |
193 | 193 | $fieldName = $recordSetField->getName(); |
194 | 194 | $fieldDescription = $recordSetField->getDescription(); |
195 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
195 | + if (substr($fieldName, 0, 1) !== '_') { |
|
196 | 196 | $fieldDescription = $App->translate($fieldDescription); |
197 | 197 | } |
198 | - if(empty($fieldDescription)){ |
|
198 | + if (empty($fieldDescription)) { |
|
199 | 199 | $fieldDescription = $fieldName; |
200 | 200 | } |
201 | 201 | $path = $recordSetField->getPath(); |
202 | 202 | |
203 | 203 | $recordSetFieldSelect->addOption($path, $fieldDescription); |
204 | 204 | |
205 | - if($recordSetField instanceof ORMBoolInterface){ |
|
205 | + if ($recordSetField instanceof ORMBoolInterface) { |
|
206 | 206 | $booleanFieldPathes[] = $path; |
207 | 207 | } |
208 | - else{ |
|
208 | + else { |
|
209 | 209 | $defaultFieldPathes[] = $path; |
210 | 210 | } |
211 | 211 | } |
@@ -159,13 +159,11 @@ discard block |
||
159 | 159 | |
160 | 160 | if($foreignRecordSetField instanceof ORMBoolInterface){ |
161 | 161 | $booleanFieldPathes[] = $foreignPath; |
162 | - } |
|
163 | - else{ |
|
162 | + } else{ |
|
164 | 163 | $defaultFieldPathes[] = $foreignPath; |
165 | 164 | } |
166 | 165 | } |
167 | - } |
|
168 | - elseif($recordSetField instanceof ORMFkField){ |
|
166 | + } elseif($recordSetField instanceof ORMFkField){ |
|
169 | 167 | /* @var $recordSetField ORMFkField */ |
170 | 168 | $fieldDescription = $fieldName; |
171 | 169 | $path = $fieldName; |
@@ -182,13 +180,11 @@ discard block |
||
182 | 180 | |
183 | 181 | if($foreignRecordSetField instanceof ORMBoolInterface){ |
184 | 182 | $booleanFieldPathes[] = $foreignPath; |
185 | - } |
|
186 | - else{ |
|
183 | + } else{ |
|
187 | 184 | $defaultFieldPathes[] = $foreignPath; |
188 | 185 | } |
189 | 186 | } |
190 | - } |
|
191 | - else{ |
|
187 | + } else{ |
|
192 | 188 | /* @var $recordSetField ORMField */ |
193 | 189 | $fieldName = $recordSetField->getName(); |
194 | 190 | $fieldDescription = $recordSetField->getDescription(); |
@@ -204,8 +200,7 @@ discard block |
||
204 | 200 | |
205 | 201 | if($recordSetField instanceof ORMBoolInterface){ |
206 | 202 | $booleanFieldPathes[] = $path; |
207 | - } |
|
208 | - else{ |
|
203 | + } else{ |
|
209 | 204 | $defaultFieldPathes[] = $path; |
210 | 205 | } |
211 | 206 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $page->addClass('app-page-editor'); |
103 | 103 | $page->setTitle($App->translate('Edit custom field')); |
104 | 104 | |
105 | - if(null !== $customfield){ |
|
105 | + if (null !== $customfield) { |
|
106 | 106 | $set = $App->CustomFieldSet(); |
107 | 107 | $customfield = $set->request($customfield); |
108 | 108 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | $page->addItem($form); |
113 | 113 | |
114 | - if($customfield instanceof AppCustomField){ |
|
114 | + if ($customfield instanceof AppCustomField) { |
|
115 | 115 | $actionsFrame = $page->ActionsFrame(); |
116 | 116 | $page->addContextItem($actionsFrame); |
117 | 117 | |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | |
132 | 132 | $set = $App->CustomFieldSet(); |
133 | 133 | |
134 | - if(empty($customfield['id'])){ |
|
134 | + if (empty($customfield['id'])) { |
|
135 | 135 | $record = $set->newRecord(); |
136 | 136 | } |
137 | - else{ |
|
137 | + else { |
|
138 | 138 | $record = $set->get($customfield['id']); |
139 | 139 | } |
140 | 140 | |
141 | - if('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']){ |
|
141 | + if ('Enum' === $customfield['fieldtype'] || 'Set' === $customfield['fieldtype']) { |
|
142 | 142 | $enumvalues = array(); |
143 | - foreach ($customfield['enumvalues'] as $enumkey => $enumvalue){ |
|
143 | + foreach ($customfield['enumvalues'] as $enumkey => $enumvalue) { |
|
144 | 144 | $enumvalues[$enumkey] = $set->enumvalues->input($enumvalue); |
145 | 145 | } |
146 | 146 | $record->enumvalues = serialize($enumvalues); |
147 | 147 | } |
148 | - else{ |
|
148 | + else { |
|
149 | 149 | $record->enumvalues = ''; |
150 | 150 | } |
151 | 151 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | |
157 | 157 | // refresh target table structure |
158 | 158 | |
159 | - $object = $record->object . 'Set'; |
|
159 | + $object = $record->object.'Set'; |
|
160 | 160 | $mysqlbackend = new ORMMySqlBackend($GLOBALS['babDB']); |
161 | 161 | |
162 | 162 | $recordSet = $App->$object(); |
163 | - if(method_exists($recordSet, 'useLang')){ |
|
163 | + if (method_exists($recordSet, 'useLang')) { |
|
164 | 164 | // This is necessary if the recordSet constructor uses a setLang(). |
165 | 165 | // We need to revert to multilang fields before synchronizing. |
166 | 166 | $recordSet->useLang(false); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | $sql = $mysqlbackend->setToSql($recordSet); |
170 | 170 | |
171 | - require_once $GLOBALS['babInstallPath'] . 'utilit/devtools.php'; |
|
171 | + require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
172 | 172 | $synchronize = new \bab_synchronizeSql(); |
173 | 173 | $synchronize->fromSqlString($sql); |
174 | 174 | |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | { |
184 | 184 | $App = $this->App(); |
185 | 185 | |
186 | - if(! $customfield){ |
|
186 | + if (!$customfield) { |
|
187 | 187 | throw new AppAccessException($App->translate('Access denied')); |
188 | 188 | } |
189 | 189 | |
190 | 190 | $set = $App->CustomFieldSet(); |
191 | 191 | $record = $set->request($customfield); |
192 | - $object = $record->object . 'Set'; |
|
192 | + $object = $record->object.'Set'; |
|
193 | 193 | $set->delete($set->id->is($customfield)); |
194 | 194 | |
195 | 195 | $recordSet = $App->$object(); |
196 | - if(method_exists($recordSet, 'useLang')){ |
|
196 | + if (method_exists($recordSet, 'useLang')) { |
|
197 | 197 | // This is necessary if the recordSet constructor uses a setLang(). |
198 | 198 | // We need to revert to multilang fields before synchronizing. |
199 | 199 | $recordSet->useLang(false); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $mysqlbackend = new ORMMySqlBackend($GLOBALS['babDB']); |
203 | 203 | $sql = $mysqlbackend->setToSql($recordSet); |
204 | 204 | |
205 | - require_once $GLOBALS['babInstallPath'] . 'utilit/devtools.php'; |
|
205 | + require_once $GLOBALS['babInstallPath'].'utilit/devtools.php'; |
|
206 | 206 | $synchronize = new \bab_synchronizeSql(); |
207 | 207 | $synchronize->fromSqlString($sql); |
208 | 208 |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | protected function getRecordClassName() |
58 | 58 | { |
59 | 59 | $class = $this->getClass(); |
60 | - if(strpos($class, 'Controller') !== false){ |
|
60 | + if (strpos($class, 'Controller') !== false) { |
|
61 | 61 | $App = $this->App(); |
62 | 62 | $componentName = strtoupper(str_replace('Controller', '', $class)); |
63 | 63 | $component = $App->getComponentByName($componentName); |
64 | - if($component){ |
|
64 | + if ($component) { |
|
65 | 65 | list (, $recordClassname) = explode($App->classPrefix, $component->getRecordClassName()); |
66 | 66 | return $recordClassname; |
67 | 67 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $App = $this->App(); |
83 | 83 | |
84 | 84 | $recordClassname = $this->getRecordClassName(); |
85 | - $recordSetClassname = $recordClassname . 'Set'; |
|
85 | + $recordSetClassname = $recordClassname.'Set'; |
|
86 | 86 | |
87 | 87 | $recordSet = $App->$recordSetClassname(); |
88 | 88 | return $recordSet; |
@@ -125,29 +125,29 @@ discard block |
||
125 | 125 | { |
126 | 126 | $canvas = bab_Widgets()->HtmlCanvas(); |
127 | 127 | $html = ''; |
128 | - if($actions instanceof WidgetAction){ |
|
128 | + if ($actions instanceof WidgetAction) { |
|
129 | 129 | $text = ''; |
130 | - if($showLabel){ |
|
130 | + if ($showLabel) { |
|
131 | 131 | $text = $actions->getTitle(); |
132 | 132 | } |
133 | - $html = '<li><a class="icon ' . $actions->getIcon() . '" href="' . $actions->url() . '">' . $text . '</a></li>'; |
|
133 | + $html = '<li><a class="icon '.$actions->getIcon().'" href="'.$actions->url().'">'.$text.'</a></li>'; |
|
134 | 134 | } |
135 | - elseif($actions instanceof WidgetLink){ |
|
136 | - $html = '<li>' . $actions->display($canvas) . '</li>'; |
|
135 | + elseif ($actions instanceof WidgetLink) { |
|
136 | + $html = '<li>'.$actions->display($canvas).'</li>'; |
|
137 | 137 | } |
138 | - elseif(is_array($actions)){ |
|
139 | - if(isset($actions['items'])){ |
|
138 | + elseif (is_array($actions)) { |
|
139 | + if (isset($actions['items'])) { |
|
140 | 140 | $items = $actions['items']; |
141 | 141 | } |
142 | - else{ |
|
142 | + else { |
|
143 | 143 | $items = $actions; |
144 | 144 | } |
145 | - foreach ($items as $action){ |
|
145 | + foreach ($items as $action) { |
|
146 | 146 | $html .= $this->createMenu($action, true, true); |
147 | 147 | } |
148 | - if(isset($actions['icon'])){ |
|
148 | + if (isset($actions['icon'])) { |
|
149 | 149 | |
150 | - $html = '<li class="dropdown">' . '<a href="#" class="' . $actions['icon'] . ' icon dropdown-toogle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' . ($actions['icon'] === 'actions-context-menu'/*\Func_Icons::ACTIONS_CONTEXT_MENU*/ ? '' : '<span class="caret"></span>') . '</a>' . '<ul class="dropdown-menu dropdown-menu-right ' . \Func_Icons::ICON_LEFT_SYMBOLIC . '">' . $html . '</ul>'; |
|
150 | + $html = '<li class="dropdown">'.'<a href="#" class="'.$actions['icon'].' icon dropdown-toogle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">'.($actions['icon'] === 'actions-context-menu'/*\Func_Icons::ACTIONS_CONTEXT_MENU*/ ? '' : '<span class="caret"></span>').'</a>'.'<ul class="dropdown-menu dropdown-menu-right '.\Func_Icons::ICON_LEFT_SYMBOLIC.'">'.$html.'</ul>'; |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | 'label' => $App->translate('Statistics') |
194 | 194 | ); |
195 | 195 | |
196 | - foreach ($methods as $index => $method){ |
|
197 | - try{ |
|
198 | - $methodName = $recordClassname . $method['method']; |
|
199 | - if($Ui->$methodName()){ |
|
196 | + foreach ($methods as $index => $method) { |
|
197 | + try { |
|
198 | + $methodName = $recordClassname.$method['method']; |
|
199 | + if ($Ui->$methodName()) { |
|
200 | 200 | $types[$index] = array( |
201 | 201 | 'classname' => $methodName, |
202 | 202 | 'icon' => $method['icon'], |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | ); |
205 | 205 | } |
206 | 206 | } |
207 | - catch (\Exception $e){ |
|
207 | + catch (\Exception $e) { |
|
208 | 208 | unset($types[$index]); |
209 | 209 | continue; |
210 | 210 | } |
@@ -225,13 +225,13 @@ discard block |
||
225 | 225 | |
226 | 226 | $availableFields = array(); |
227 | 227 | |
228 | - foreach ($recordSet->getFields() as $name => $field){ |
|
228 | + foreach ($recordSet->getFields() as $name => $field) { |
|
229 | 229 | $fieldName = $field->getName(); |
230 | 230 | $fieldDescription = $field->getDescription(); |
231 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
231 | + if (substr($fieldName, 0, 1) !== '_') { |
|
232 | 232 | $fieldDescription = $App->translate($fieldDescription); |
233 | 233 | } |
234 | - if(empty($fieldDescription)){ |
|
234 | + if (empty($fieldDescription)) { |
|
235 | 235 | $fieldDescription = $fieldName; |
236 | 236 | } |
237 | 237 | $availableFields[$name] = array( |
@@ -280,14 +280,14 @@ discard block |
||
280 | 280 | |
281 | 281 | $recordSet = $this->getEditRecordSet(); |
282 | 282 | |
283 | - if(isset($id)){ |
|
283 | + if (isset($id)) { |
|
284 | 284 | $record = $recordSet->request($id); |
285 | - if(! $record->isUpdatable()){ |
|
285 | + if (!$record->isUpdatable()) { |
|
286 | 286 | throw new AppAccessException($App->translate('You do not have access to this page')); |
287 | 287 | } |
288 | 288 | } |
289 | - else{ |
|
290 | - if(! $recordSet->isCreatable()){ |
|
289 | + else { |
|
290 | + if (!$recordSet->isCreatable()) { |
|
291 | 291 | throw new AppAccessException($App->translate('You do not have access to this page')); |
292 | 292 | } |
293 | 293 | $record = $recordSet->newRecord(); |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | $W = bab_Widgets(); |
316 | 316 | |
317 | 317 | $recordClassname = $this->getRecordClassName(); |
318 | - $editorClassname = $recordClassname . 'SectionEditor'; |
|
318 | + $editorClassname = $recordClassname.'SectionEditor'; |
|
319 | 319 | |
320 | 320 | /* @var $editor AppRecordEditor */ |
321 | 321 | $editor = $Ui->$editorClassname($record); |
322 | - if(! isset($itemId)){ |
|
323 | - $itemId = $this->getClass() . '_' . __FUNCTION__; |
|
322 | + if (!isset($itemId)) { |
|
323 | + $itemId = $this->getClass().'_'.__FUNCTION__; |
|
324 | 324 | } |
325 | 325 | $editor->setId($itemId); |
326 | 326 | $editor->setController($this); |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | */ |
350 | 350 | public function getModelViewDefaultId($itemId = null) |
351 | 351 | { |
352 | - if(! isset($itemId)){ |
|
353 | - $itemId = $this->getClass() . '_modelView'; |
|
352 | + if (!isset($itemId)) { |
|
353 | + $itemId = $this->getClass().'_modelView'; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | return $itemId; |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | |
379 | 379 | $itemId = $this->getModelViewDefaultId($itemId); |
380 | 380 | |
381 | - if(! isset($type)){ |
|
381 | + if (!isset($type)) { |
|
382 | 382 | $type = $this->getFilteredViewType($itemId); |
383 | 383 | } |
384 | 384 | |
@@ -386,24 +386,24 @@ discard block |
||
386 | 386 | |
387 | 387 | switch ($type) { |
388 | 388 | case 'cards': |
389 | - $tableviewClassname = $recordClassname . 'CardsView'; |
|
389 | + $tableviewClassname = $recordClassname.'CardsView'; |
|
390 | 390 | break; |
391 | 391 | |
392 | 392 | case 'map': |
393 | - $tableviewClassname = $recordClassname . 'MapView'; |
|
393 | + $tableviewClassname = $recordClassname.'MapView'; |
|
394 | 394 | break; |
395 | 395 | |
396 | 396 | case 'calendar': |
397 | - $tableviewClassname = $recordClassname . 'CalendarView'; |
|
397 | + $tableviewClassname = $recordClassname.'CalendarView'; |
|
398 | 398 | break; |
399 | 399 | |
400 | 400 | case 'statistics': |
401 | - $tableviewClassname = $recordClassname . 'StatisticsView'; |
|
401 | + $tableviewClassname = $recordClassname.'StatisticsView'; |
|
402 | 402 | break; |
403 | 403 | |
404 | 404 | case 'table': |
405 | 405 | default: |
406 | - $tableviewClassname = $recordClassname . 'TableView'; |
|
406 | + $tableviewClassname = $recordClassname.'TableView'; |
|
407 | 407 | break; |
408 | 408 | } |
409 | 409 | |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | |
417 | 417 | $tableview->setRecordSet($recordSet); |
418 | 418 | $tableview->addDefaultColumns($recordSet); |
419 | - if(isset($filter)){ |
|
419 | + if (isset($filter)) { |
|
420 | 420 | $tableview->setFilterValues($filter); |
421 | 421 | } |
422 | 422 | $filter = $tableview->getFilterValues(); |
423 | 423 | |
424 | - if(isset($filter['showTotal']) && $filter['showTotal']){ |
|
424 | + if (isset($filter['showTotal']) && $filter['showTotal']) { |
|
425 | 425 | $tableview->displaySubTotalRow(true); |
426 | 426 | } |
427 | 427 | |
@@ -435,13 +435,13 @@ discard block |
||
435 | 435 | |
436 | 436 | $tableview->setDataSource($records); |
437 | 437 | |
438 | - if(isset($columns)){ |
|
438 | + if (isset($columns)) { |
|
439 | 439 | $availableColumns = $tableview->getVisibleColumns(); |
440 | 440 | |
441 | 441 | $remainingColumns = array(); |
442 | - foreach ($availableColumns as $availableColumn){ |
|
442 | + foreach ($availableColumns as $availableColumn) { |
|
443 | 443 | $colPath = $availableColumn->getFieldPath(); |
444 | - if(isset($columns[$colPath]) && $columns[$colPath] == '1'){ |
|
444 | + if (isset($columns[$colPath]) && $columns[$colPath] == '1') { |
|
445 | 445 | $remainingColumns[] = $availableColumn; |
446 | 446 | } |
447 | 447 | } |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | $App = $this->App(); |
462 | 462 | $Ui = $App->Ui(); |
463 | 463 | $recordClassname = $this->getRecordClassName(); |
464 | - $editorClassname = $recordClassname . 'Editor'; |
|
464 | + $editorClassname = $recordClassname.'Editor'; |
|
465 | 465 | $editor = $Ui->$editorClassname(); |
466 | 466 | |
467 | - if(! isset($itemId)){ |
|
468 | - $itemId = $this->getClass() . '_' . __FUNCTION__; |
|
467 | + if (!isset($itemId)) { |
|
468 | + $itemId = $this->getClass().'_'.__FUNCTION__; |
|
469 | 469 | } |
470 | 470 | $editor->setId($itemId); |
471 | 471 | $editor->setHiddenValue('tg', $App->controllerTg); |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | $viewTypes = $this->getAvailableModelViewTypes(); |
510 | 510 | |
511 | - if(count($viewTypes) > 1){ |
|
511 | + if (count($viewTypes) > 1) { |
|
512 | 512 | $viewsBox = $W->Items(); |
513 | 513 | $viewsBox->setSizePolicy('pull-right'); |
514 | 514 | // $viewsBox->addClass('btn-group', \Func_Icons::ICON_LEFT_16); |
@@ -516,9 +516,9 @@ discard block |
||
516 | 516 | |
517 | 517 | $filteredViewType = $this->getFilteredViewType($tableView->getId()); |
518 | 518 | |
519 | - foreach ($viewTypes as $viewTypeId => $viewType){ |
|
519 | + foreach ($viewTypes as $viewTypeId => $viewType) { |
|
520 | 520 | $viewsBox->addItem($W->Link('', $proxy->setFilteredViewType($tableView->getId(), $viewTypeId)) |
521 | - ->addClass('icon', $viewType['icon'] . ($filteredViewType === $viewTypeId ? ' active' : '')) |
|
521 | + ->addClass('icon', $viewType['icon'].($filteredViewType === $viewTypeId ? ' active' : '')) |
|
522 | 522 | -> |
523 | 523 | // ->setSizePolicy('btn btn-xs btn-default ' . ($filteredViewType === $viewTypeId ? 'active' : '')) |
524 | 524 | setTitle($viewType['label']) |
@@ -526,14 +526,14 @@ discard block |
||
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
529 | - if(method_exists($proxy, 'exportSelect')){ |
|
529 | + if (method_exists($proxy, 'exportSelect')) { |
|
530 | 530 | $toolbar->addItem($W->Link($App->translate('Export'), $proxy->exportSelect($filter)) |
531 | 531 | ->addClass('icon', \Func_Icons::ACTIONS_DOCUMENT_DOWNLOAD) |
532 | 532 | ->setOpenMode(WidgetLink::OPEN_DIALOG) |
533 | 533 | ->setDialogClass('box gradient blue halfSizeDialog')); |
534 | 534 | } |
535 | 535 | |
536 | - if(method_exists($proxy, 'printList')){ |
|
536 | + if (method_exists($proxy, 'printList')) { |
|
537 | 537 | $toolbar->addItem($W->Link($App->translate('Print'), $proxy->printList($filter)) |
538 | 538 | ->addClass('icon', \Func_Icons::ACTIONS_DOCUMENT_PRINT) |
539 | 539 | ->setOpenMode(WidgetLink::OPEN_POPUP)); |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | $W = bab_Widgets(); |
552 | 552 | |
553 | 553 | $filterVisibility = $this->getFilterVisibility($itemId); |
554 | - $filterVisibility = ! $filterVisibility; |
|
555 | - $W->setUserConfiguration($itemId . '/filterVisibility', $filterVisibility); |
|
554 | + $filterVisibility = !$filterVisibility; |
|
555 | + $W->setUserConfiguration($itemId.'/filterVisibility', $filterVisibility); |
|
556 | 556 | |
557 | 557 | return true; |
558 | 558 | } |
@@ -564,10 +564,10 @@ discard block |
||
564 | 564 | protected function getFilterVisibility($itemId) |
565 | 565 | { |
566 | 566 | $W = bab_Widgets(); |
567 | - $filterVisibility = $W->getUserConfiguration($itemId . '/filterVisibility'); |
|
568 | - if(! isset($filterVisibility)){ |
|
567 | + $filterVisibility = $W->getUserConfiguration($itemId.'/filterVisibility'); |
|
568 | + if (!isset($filterVisibility)) { |
|
569 | 569 | $filterVisibility = false; |
570 | - $W->setUserConfiguration($itemId . '/filterVisibility', $filterVisibility); |
|
570 | + $W->setUserConfiguration($itemId.'/filterVisibility', $filterVisibility); |
|
571 | 571 | } |
572 | 572 | return $filterVisibility; |
573 | 573 | } |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | protected function getFilteredViewType($itemId) |
583 | 583 | { |
584 | 584 | $W = bab_Widgets(); |
585 | - $type = $W->getUserConfiguration($itemId . '/viewType'); |
|
586 | - if(! isset($type)){ |
|
585 | + $type = $W->getUserConfiguration($itemId.'/viewType'); |
|
586 | + if (!isset($type)) { |
|
587 | 587 | $type = 'table'; |
588 | 588 | } |
589 | 589 | return $type; |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | public function setFilteredViewType($itemId, $type = null) |
601 | 601 | { |
602 | 602 | $W = bab_Widgets(); |
603 | - $W->setUserConfiguration($itemId . '/viewType', $type); |
|
603 | + $W->setUserConfiguration($itemId.'/viewType', $type); |
|
604 | 604 | |
605 | 605 | return true; |
606 | 606 | } |
@@ -621,17 +621,17 @@ discard block |
||
621 | 621 | |
622 | 622 | $filterPanel = $view->advancedFilterPanel($filter); |
623 | 623 | |
624 | - if($this->getFilterVisibility($itemId)){ |
|
624 | + if ($this->getFilterVisibility($itemId)) { |
|
625 | 625 | $filterPanel->addClass('show-filter'); |
626 | 626 | } |
627 | - else{ |
|
627 | + else { |
|
628 | 628 | $filterPanel->addClass('hide-filter'); |
629 | 629 | } |
630 | 630 | |
631 | 631 | $toolbar = $this->toolbar($view); |
632 | 632 | $listToolbar = $this->listToolbar($view); |
633 | 633 | |
634 | - if($view->isColumnSelectionAllowed()){ |
|
634 | + if ($view->isColumnSelectionAllowed()) { |
|
635 | 635 | $App = $this->App(); |
636 | 636 | $columnSelectionMenu = $W->Link($App->translate('Table configuration'), $this->proxy() |
637 | 637 | ->modelViewColumnSettings($type, $itemId)) |
@@ -683,14 +683,14 @@ discard block |
||
683 | 683 | $tableModelViewId = $data['tableModelViewId']; |
684 | 684 | $sessionOnly = isset($data['inSession']) ? $data['inSession'] : false; |
685 | 685 | |
686 | - if(isset($data['pageLength'])){ |
|
687 | - $W->setUserConfiguration($tableModelViewId . '/pageLength', $data['pageLength'], 'widgets', $sessionOnly); |
|
686 | + if (isset($data['pageLength'])) { |
|
687 | + $W->setUserConfiguration($tableModelViewId.'/pageLength', $data['pageLength'], 'widgets', $sessionOnly); |
|
688 | 688 | } |
689 | - if(isset($data['displaySubTotalRow'])){ |
|
690 | - $W->setUserConfiguration($tableModelViewId . '/displaySubTotalRow', $data['displaySubTotalRow'], 'widgets', $sessionOnly); |
|
689 | + if (isset($data['displaySubTotalRow'])) { |
|
690 | + $W->setUserConfiguration($tableModelViewId.'/displaySubTotalRow', $data['displaySubTotalRow'], 'widgets', $sessionOnly); |
|
691 | 691 | } |
692 | - if(isset($data['columns'])){ |
|
693 | - $W->setUserConfiguration($tableModelViewId . '/columns', $data['columns'], 'widgets', $sessionOnly); |
|
692 | + if (isset($data['columns'])) { |
|
693 | + $W->setUserConfiguration($tableModelViewId.'/columns', $data['columns'], 'widgets', $sessionOnly); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | $this->addReloadSelector("#{$tableModelViewId}"); |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $tableModelViewId = $data['tableModelViewId']; |
706 | 706 | $sessionOnly = isset($data['inSession']) ? $data['inSession'] : false; |
707 | 707 | |
708 | - $W->deleteUserConfiguration($data['tableModelViewId'] . '/columns', 'widgets', $sessionOnly); |
|
708 | + $W->deleteUserConfiguration($data['tableModelViewId'].'/columns', 'widgets', $sessionOnly); |
|
709 | 709 | |
710 | 710 | $this->addReloadSelector("#{$tableModelViewId}"); |
711 | 711 | return true; |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | |
755 | 755 | $itemMenus = $this->getListItemMenus(); |
756 | 756 | |
757 | - foreach ($itemMenus as $itemMenuId => $itemMenu){ |
|
757 | + foreach ($itemMenus as $itemMenuId => $itemMenu) { |
|
758 | 758 | $page->addItemMenu($itemMenuId, $itemMenu['label'], $itemMenu['action']); |
759 | 759 | } |
760 | 760 | |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | $columns = $tableview->getVisibleColumns(); |
794 | 794 | $column = isset($columns[$col]) ? $columns[$col] : null; |
795 | 795 | |
796 | - if(! isset($column)){ |
|
796 | + if (!isset($column)) { |
|
797 | 797 | return true; |
798 | 798 | } |
799 | 799 | |
@@ -807,8 +807,8 @@ discard block |
||
807 | 807 | $col |
808 | 808 | ))); |
809 | 809 | |
810 | - $filter = $W->getUserConfiguration($key . '/filter', 'widgets', false); |
|
811 | - if(isset($filter[$col])){ |
|
810 | + $filter = $W->getUserConfiguration($key.'/filter', 'widgets', false); |
|
811 | + if (isset($filter[$col])) { |
|
812 | 812 | $widget->setValue($filter[$col]); |
813 | 813 | } |
814 | 814 | |
@@ -824,21 +824,21 @@ discard block |
||
824 | 824 | |
825 | 825 | $key = $data['key']; |
826 | 826 | |
827 | - $filter = $W->getUserConfiguration($key . '/filter', 'widgets', false); |
|
828 | - if(isset($data['moreCriteria']) && $data['moreCriteria']){ |
|
827 | + $filter = $W->getUserConfiguration($key.'/filter', 'widgets', false); |
|
828 | + if (isset($data['moreCriteria']) && $data['moreCriteria']) { |
|
829 | 829 | $filter = array(); |
830 | 830 | } |
831 | - foreach ($data['filter'] as $filterName => $filterValue){ |
|
831 | + foreach ($data['filter'] as $filterName => $filterValue) { |
|
832 | 832 | $filter[$filterName] = $filterValue; |
833 | 833 | } |
834 | - $W->setUserConfiguration($key . '/filter', $filter, 'widgets', false); |
|
834 | + $W->setUserConfiguration($key.'/filter', $filter, 'widgets', false); |
|
835 | 835 | |
836 | 836 | session_start(); |
837 | 837 | $_SESSION['modelViewMoreCriterias'][$key] = array(); |
838 | 838 | unset($_SESSION['modelViewMoreCriterias'][$key]); |
839 | 839 | session_write_close(); |
840 | 840 | |
841 | - $this->addReloadSelector('.depends-' . $key); |
|
841 | + $this->addReloadSelector('.depends-'.$key); |
|
842 | 842 | |
843 | 843 | return true; |
844 | 844 | } |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | $Ui = $App->Ui(); |
850 | 850 | |
851 | 851 | $page = $Ui->Page(); |
852 | - $page->addClass('depends-modelViewMoreCriterias-' . $key); |
|
852 | + $page->addClass('depends-modelViewMoreCriterias-'.$key); |
|
853 | 853 | |
854 | 854 | $page->setTitle($App->translate('Search')); |
855 | 855 | |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | $editor = $Ui->BasicEditor($itemId, $W->VBoxLayout()); |
870 | 870 | $editor->setReloadAction($this->proxy() |
871 | 871 | ->getDisplayListMoreCriteriaEditor($key, $editor->getId())); |
872 | - $editor->addClass('depends-modelViewMoreCriterias-' . $key); |
|
872 | + $editor->addClass('depends-modelViewMoreCriterias-'.$key); |
|
873 | 873 | $editor->addClass('widget-no-close'); |
874 | 874 | $editor->setIconFormat(); |
875 | 875 | $editor->isAjax = true; |
@@ -884,24 +884,24 @@ discard block |
||
884 | 884 | $columns = $tableview->getVisibleColumns(); |
885 | 885 | $filter = $tableview->getFilterValues(); |
886 | 886 | |
887 | - if(! isset($itemId)){ |
|
887 | + if (!isset($itemId)) { |
|
888 | 888 | $editor->setSaveAction($this->proxy() |
889 | 889 | ->saveDisplayListFilter(), $App->translate('Search')); |
890 | 890 | $editor->setCancelAction($this->proxy() |
891 | 891 | ->cancel()); |
892 | 892 | |
893 | 893 | $fields = array(); |
894 | - foreach ($filter as $fieldName => $value){ |
|
895 | - if(empty($value)){ |
|
894 | + foreach ($filter as $fieldName => $value) { |
|
895 | + if (empty($value)) { |
|
896 | 896 | continue; |
897 | 897 | } |
898 | - if(! isset($columns[$fieldName])){ |
|
898 | + if (!isset($columns[$fieldName])) { |
|
899 | 899 | continue; |
900 | 900 | } |
901 | 901 | |
902 | 902 | $column = $columns[$fieldName]; |
903 | 903 | |
904 | - if(! $column->isSearchable()){ |
|
904 | + if (!$column->isSearchable()) { |
|
905 | 905 | continue; |
906 | 906 | } |
907 | 907 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | $_SESSION['modelViewMoreCriterias'][$key] = $fields; |
912 | 912 | session_write_close(); |
913 | 913 | } |
914 | - else{ |
|
914 | + else { |
|
915 | 915 | $fields = $_SESSION['modelViewMoreCriterias'][$key]; |
916 | 916 | } |
917 | 917 | |
@@ -919,24 +919,24 @@ discard block |
||
919 | 919 | |
920 | 920 | $nbAlreadyAdded = 0; |
921 | 921 | |
922 | - foreach ($fields as $fieldName => $fieldValue){ |
|
923 | - if(! isset($columns[$fieldName])){ |
|
922 | + foreach ($fields as $fieldName => $fieldValue) { |
|
923 | + if (!isset($columns[$fieldName])) { |
|
924 | 924 | continue; |
925 | 925 | } |
926 | 926 | $column = $columns[$fieldName]; |
927 | 927 | |
928 | - if(! $column->isSearchable()){ |
|
928 | + if (!$column->isSearchable()) { |
|
929 | 929 | continue; |
930 | 930 | } |
931 | 931 | |
932 | 932 | $field = $column->getField(); |
933 | 933 | |
934 | - if($nbAlreadyAdded >= 2){ |
|
934 | + if ($nbAlreadyAdded >= 2) { |
|
935 | 935 | $nbAlreadyAdded = 0; |
936 | 936 | $alreadyFilteredBox = null; |
937 | 937 | } |
938 | 938 | |
939 | - if(! isset($alreadyFilteredBox)){ |
|
939 | + if (!isset($alreadyFilteredBox)) { |
|
940 | 940 | $editor->addItem($alreadyFilteredBox = $W->FlexItems() |
941 | 941 | ->setSizePolicy('customsection-field-box customsection-fieldsgroup-box')); |
942 | 942 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | ->setJustifyContent(WidgetFlexLayout::FLEX_JUSTIFY_CONTENT_SPACE_BETWEEN) |
957 | 957 | ->setAlignItems(WidgetFlexLayout::FLEX_ALIGN_CONTENT_CENTER)) |
958 | 958 | ->addClass('app-customsection-groupedfield app-displaylist-morecriteria-groupedfield')); |
959 | - $nbAlreadyAdded ++; |
|
959 | + $nbAlreadyAdded++; |
|
960 | 960 | |
961 | 961 | $alreadyAddedFilters[$fieldName] = $fieldName; |
962 | 962 | } |
@@ -966,26 +966,26 @@ discard block |
||
966 | 966 | '' |
967 | 967 | ); |
968 | 968 | |
969 | - foreach ($columns as $fieldName => $column){ |
|
970 | - if(! $column->isSearchable()){ |
|
969 | + foreach ($columns as $fieldName => $column) { |
|
970 | + if (!$column->isSearchable()) { |
|
971 | 971 | continue; |
972 | 972 | } |
973 | 973 | |
974 | 974 | $field = $column->getField(); |
975 | 975 | |
976 | - if(isset($alreadyAddedFilters[$fieldName])){ |
|
976 | + if (isset($alreadyAddedFilters[$fieldName])) { |
|
977 | 977 | continue; |
978 | 978 | } |
979 | 979 | |
980 | 980 | $label = $tableview->getFilterLabelWidget($fieldName, $field); |
981 | 981 | $label = trim($label->getText()); |
982 | - if(empty($label)){ |
|
982 | + if (empty($label)) { |
|
983 | 983 | continue; |
984 | 984 | } |
985 | 985 | $options[$fieldName] = $label; |
986 | 986 | } |
987 | 987 | |
988 | - if(count($options) > 1){ |
|
988 | + if (count($options) > 1) { |
|
989 | 989 | $editor->addItem($W->Html('<hr/>')); |
990 | 990 | $editor->addItem($W->FlexItems($W->LabelledWidget($App->translate('Add a new criteria'), $W->Select2() |
991 | 991 | ->setOptions($options), 'newField') |
@@ -1002,12 +1002,12 @@ discard block |
||
1002 | 1002 | { |
1003 | 1003 | session_start(); |
1004 | 1004 | $fields = isset($data['filter']) ? $data['filter'] : array(); |
1005 | - if(isset($data['newField']) && ! empty($data['newField'])){ |
|
1005 | + if (isset($data['newField']) && !empty($data['newField'])) { |
|
1006 | 1006 | $newField = $data['newField']; |
1007 | 1007 | unset($data['key']); |
1008 | 1008 | unset($data['moreCriteria']); |
1009 | 1009 | $fields[$newField] = ''; |
1010 | - $this->addReloadSelector('.depends-modelViewMoreCriterias-' . $key); |
|
1010 | + $this->addReloadSelector('.depends-modelViewMoreCriterias-'.$key); |
|
1011 | 1011 | } |
1012 | 1012 | $_SESSION['modelViewMoreCriterias'][$key] = $fields; |
1013 | 1013 | return true; |
@@ -1016,12 +1016,12 @@ discard block |
||
1016 | 1016 | public function removeMoreCriteriaField($key, $field) |
1017 | 1017 | { |
1018 | 1018 | $fields = $_SESSION['modelViewMoreCriterias'][$key]; |
1019 | - if(isset($fields[$field])){ |
|
1019 | + if (isset($fields[$field])) { |
|
1020 | 1020 | unset($fields[$field]); |
1021 | 1021 | session_start(); |
1022 | 1022 | $_SESSION['modelViewMoreCriterias'][$key] = $fields; |
1023 | 1023 | } |
1024 | - $this->addReloadSelector('.depends-modelViewMoreCriterias-' . $key); |
|
1024 | + $this->addReloadSelector('.depends-modelViewMoreCriterias-'.$key); |
|
1025 | 1025 | return true; |
1026 | 1026 | } |
1027 | 1027 | |
@@ -1077,17 +1077,17 @@ discard block |
||
1077 | 1077 | |
1078 | 1078 | switch ($format) { |
1079 | 1079 | case 'xlsx': |
1080 | - $tableview->downloadXlsx($filename . '.xlsx'); |
|
1080 | + $tableview->downloadXlsx($filename.'.xlsx'); |
|
1081 | 1081 | break; |
1082 | 1082 | case 'xls': |
1083 | - $tableview->downloadExcel($filename . '.xls'); |
|
1083 | + $tableview->downloadExcel($filename.'.xls'); |
|
1084 | 1084 | break; |
1085 | 1085 | case 'ssv': |
1086 | - $tableview->downloadCsv($filename . '.csv', ';', $inline, 'Windows-1252'); |
|
1086 | + $tableview->downloadCsv($filename.'.csv', ';', $inline, 'Windows-1252'); |
|
1087 | 1087 | break; |
1088 | 1088 | case 'csv': |
1089 | 1089 | default: |
1090 | - $tableview->downloadCsv($filename . '.csv', ',', $inline, \bab_charset::getIso()); |
|
1090 | + $tableview->downloadCsv($filename.'.csv', ',', $inline, \bab_charset::getIso()); |
|
1091 | 1091 | break; |
1092 | 1092 | } |
1093 | 1093 | } |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | $recordSet = $this->getRecordSet(); |
1154 | 1154 | |
1155 | 1155 | $record = $recordSet->request($id); |
1156 | - if(! $record->isReadable()){ |
|
1156 | + if (!$record->isReadable()) { |
|
1157 | 1157 | throw new AppAccessException($App->translate('You do not have access to this page')); |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | |
1162 | 1162 | $recordClassname = $this->getRecordClassName(); |
1163 | 1163 | |
1164 | - $viewClassname = $recordClassname . 'FullFrame'; |
|
1164 | + $viewClassname = $recordClassname.'FullFrame'; |
|
1165 | 1165 | |
1166 | 1166 | $fullFrame = $Ui->$viewClassname($record); |
1167 | 1167 | $fullFrame->setView($view); |
@@ -1173,10 +1173,10 @@ discard block |
||
1173 | 1173 | $mainMenu->setSizePolicy(\Func_Icons::ICON_LEFT_24); |
1174 | 1174 | |
1175 | 1175 | $page = $Ui->Page(); |
1176 | - if(isset($itemId)){ |
|
1176 | + if (isset($itemId)) { |
|
1177 | 1177 | $page->setId($itemId); |
1178 | 1178 | } |
1179 | - $page->addClass('depends-' . $this->getRecordClassName()); |
|
1179 | + $page->addClass('depends-'.$this->getRecordClassName()); |
|
1180 | 1180 | |
1181 | 1181 | $page->addToolbar($mainMenu); |
1182 | 1182 | |
@@ -1215,14 +1215,14 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | $editor = $this->recordEditor(); |
1217 | 1217 | |
1218 | - if(isset($id)){ |
|
1218 | + if (isset($id)) { |
|
1219 | 1219 | $record = $recordSet->request($id); |
1220 | - if(! $record->isUpdatable()){ |
|
1220 | + if (!$record->isUpdatable()) { |
|
1221 | 1221 | throw new AppAccessException($App->translate('You do not have access to this page')); |
1222 | 1222 | } |
1223 | 1223 | } |
1224 | - else{ |
|
1225 | - if(! $recordSet->isCreatable()){ |
|
1224 | + else { |
|
1225 | + if (!$recordSet->isCreatable()) { |
|
1226 | 1226 | throw new AppAccessException($App->translate('You do not have access to this page')); |
1227 | 1227 | } |
1228 | 1228 | $record = $recordSet->newRecord(); |
@@ -1257,15 +1257,15 @@ discard block |
||
1257 | 1257 | |
1258 | 1258 | $editor = $Ui->TagsEditor(); |
1259 | 1259 | |
1260 | - if(isset($id)){ |
|
1260 | + if (isset($id)) { |
|
1261 | 1261 | $record = $recordSet->request($id); |
1262 | - if(! $record->isUpdatable()){ |
|
1262 | + if (!$record->isUpdatable()) { |
|
1263 | 1263 | throw new AppAccessException($App->translate('You do not have access to this page')); |
1264 | 1264 | } |
1265 | 1265 | $editor->setRecord($record); |
1266 | 1266 | } |
1267 | - else{ |
|
1268 | - if(! $recordSet->isCreatable()){ |
|
1267 | + else { |
|
1268 | + if (!$recordSet->isCreatable()) { |
|
1269 | 1269 | throw new AppAccessException($App->translate('You do not have access to this page')); |
1270 | 1270 | } |
1271 | 1271 | $record = $recordSet->newRecord(); |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | |
1317 | 1317 | $recordTitle = $record->getRecordTitle(); |
1318 | 1318 | |
1319 | - $message = sprintf($App->translate('%s has been deleted'), $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"'); |
|
1319 | + $message = sprintf($App->translate('%s has been deleted'), $App->translate($recordSet->getDescription()).' "'.$recordTitle.'"'); |
|
1320 | 1320 | return $message; |
1321 | 1321 | } |
1322 | 1322 | |
@@ -1375,45 +1375,45 @@ discard block |
||
1375 | 1375 | $pk = $recordSet->getPrimaryKey(); |
1376 | 1376 | $message = null; |
1377 | 1377 | |
1378 | - if(! empty($data[$pk])){ |
|
1378 | + if (!empty($data[$pk])) { |
|
1379 | 1379 | $record = $recordSet->request($data[$pk]); |
1380 | 1380 | unset($data[$pk]); |
1381 | 1381 | |
1382 | - if(! $record->isUpdatable()){ |
|
1382 | + if (!$record->isUpdatable()) { |
|
1383 | 1383 | throw new AppAccessException('Access denied'); |
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | $message = $this->getModifedMessage($record); |
1387 | 1387 | } |
1388 | - else{ |
|
1388 | + else { |
|
1389 | 1389 | |
1390 | 1390 | $record = $recordSet->newRecord(); |
1391 | 1391 | |
1392 | - if(! $recordSet->isCreatable()){ |
|
1392 | + if (!$recordSet->isCreatable()) { |
|
1393 | 1393 | throw new AppAccessException('Access denied'); |
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | $message = $this->getCreatedMessage(); |
1397 | 1397 | } |
1398 | 1398 | |
1399 | - if(! isset($record)){ |
|
1399 | + if (!isset($record)) { |
|
1400 | 1400 | throw new AppSaveException($App->translate('The record does not exists')); |
1401 | 1401 | } |
1402 | 1402 | |
1403 | - if(! isset($data)){ |
|
1403 | + if (!isset($data)) { |
|
1404 | 1404 | throw new AppSaveException($App->translate('Nothing to save')); |
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | $record->setFormInputValues($data); |
1408 | 1408 | |
1409 | 1409 | $this->preSave($record, $data); |
1410 | - if($record->save()){ |
|
1410 | + if ($record->save()) { |
|
1411 | 1411 | $this->postSave($record, $data); |
1412 | - if(is_string($message)){ |
|
1412 | + if (is_string($message)) { |
|
1413 | 1413 | $this->addToast($message); |
1414 | 1414 | } |
1415 | 1415 | |
1416 | - $this->addReloadSelector('.depends-' . $this->getRecordClassName()); |
|
1416 | + $this->addReloadSelector('.depends-'.$this->getRecordClassName()); |
|
1417 | 1417 | return true; |
1418 | 1418 | } |
1419 | 1419 | |
@@ -1436,16 +1436,16 @@ discard block |
||
1436 | 1436 | |
1437 | 1437 | $record = $recordSet->request($id); |
1438 | 1438 | |
1439 | - if(! $record->isDeletable()){ |
|
1439 | + if (!$record->isDeletable()) { |
|
1440 | 1440 | throw new AppAccessException('Sorry, You are not allowed to perform this operation'); |
1441 | 1441 | } |
1442 | 1442 | $deletedMessage = $this->getDeletedMessage($record); |
1443 | 1443 | |
1444 | - if($record->delete()){ |
|
1444 | + if ($record->delete()) { |
|
1445 | 1445 | $this->addToast($deletedMessage); |
1446 | 1446 | } |
1447 | 1447 | |
1448 | - $this->addReloadSelector('.depends-' . $record->getClassName()); |
|
1448 | + $this->addReloadSelector('.depends-'.$record->getClassName()); |
|
1449 | 1449 | |
1450 | 1450 | return true; |
1451 | 1451 | } |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | $page->addClass('app-page-editor'); |
1470 | 1470 | $page->setTitle($App->translate('Deletion')); |
1471 | 1471 | |
1472 | - if(! isset($record)){ |
|
1472 | + if (!isset($record)) { |
|
1473 | 1473 | $page->addItem($W->Label($App->translate('This element does not exists.'))); |
1474 | 1474 | $page->addClass('alert', 'alert-warning'); |
1475 | 1475 | return $page; |
@@ -1482,7 +1482,7 @@ discard block |
||
1482 | 1482 | |
1483 | 1483 | $recordTitle = $record->getRecordTitle(); |
1484 | 1484 | |
1485 | - $subTitle = $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"'; |
|
1485 | + $subTitle = $App->translate($recordSet->getDescription()).' "'.$recordTitle.'"'; |
|
1486 | 1486 | $form->addItem($W->Title($subTitle, 5)); |
1487 | 1487 | |
1488 | 1488 | $form->addItem($W->Title($App->translate('Confirm delete?'), 6)); |
@@ -1491,7 +1491,7 @@ discard block |
||
1491 | 1491 | |
1492 | 1492 | $confirmedAction = $this->proxy()->delete($id); |
1493 | 1493 | $parameters = $confirmedAction->getParameters(); |
1494 | - foreach ($parameters as $key => $value){ |
|
1494 | + foreach ($parameters as $key => $value) { |
|
1495 | 1495 | $form->setHiddenValue($key, $value); |
1496 | 1496 | } |
1497 | 1497 | $form->addButton($W->SubmitButton() |
@@ -1521,20 +1521,20 @@ discard block |
||
1521 | 1521 | |
1522 | 1522 | $record = $recordSet->request($id); |
1523 | 1523 | |
1524 | - if(! $record->isRemovable()){ |
|
1524 | + if (!$record->isRemovable()) { |
|
1525 | 1525 | throw new AppAccessException('Sorry, You are not allowed to perform this operation'); |
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | $App = $this->App(); |
1529 | 1529 | $deletedMessage = $App->translate('The element has been moved to the trash'); |
1530 | 1530 | |
1531 | - if($recordSet->delete($recordSet->id->is($record->id), AppTraceableRecord::DELETED_STATUS_IN_TRASH)){ |
|
1532 | - if(is_string($deletedMessage)){ |
|
1531 | + if ($recordSet->delete($recordSet->id->is($record->id), AppTraceableRecord::DELETED_STATUS_IN_TRASH)) { |
|
1532 | + if (is_string($deletedMessage)) { |
|
1533 | 1533 | $this->addToast($deletedMessage); |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | 1536 | |
1537 | - $this->addReloadSelector('.depends-' . $record->getClassName()); |
|
1537 | + $this->addReloadSelector('.depends-'.$record->getClassName()); |
|
1538 | 1538 | |
1539 | 1539 | return true; |
1540 | 1540 | } |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | |
1563 | 1563 | $recordTitle = $record->getRecordTitle(); |
1564 | 1564 | |
1565 | - $subTitle = $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"'; |
|
1565 | + $subTitle = $App->translate($recordSet->getDescription()).' "'.$recordTitle.'"'; |
|
1566 | 1566 | $form->addItem($W->Title($subTitle, 5)); |
1567 | 1567 | |
1568 | 1568 | $form->addItem($W->Title($App->translate('Confirm delete?'), 6)); |
@@ -1571,7 +1571,7 @@ discard block |
||
1571 | 1571 | |
1572 | 1572 | $confirmedAction = $this->proxy()->remove($id); |
1573 | 1573 | $parameters = $confirmedAction->getParameters(); |
1574 | - foreach ($parameters as $key => $value){ |
|
1574 | + foreach ($parameters as $key => $value) { |
|
1575 | 1575 | $form->setHiddenValue($key, $value); |
1576 | 1576 | } |
1577 | 1577 | $form->addButton($W->SubmitButton() |
@@ -1602,12 +1602,12 @@ discard block |
||
1602 | 1602 | $records = $recordSet->select($recordSet->id->is($id), true); |
1603 | 1603 | |
1604 | 1604 | $record = null; |
1605 | - foreach ($records as $record){ |
|
1605 | + foreach ($records as $record) { |
|
1606 | 1606 | } |
1607 | - if(! isset($record)){ |
|
1607 | + if (!isset($record)) { |
|
1608 | 1608 | throw new AppAccessException('Sorry, You are not allowed to perform this operation'); |
1609 | 1609 | } |
1610 | - if(! $record->isRestorable()){ |
|
1610 | + if (!$record->isRestorable()) { |
|
1611 | 1611 | throw new AppAccessException('Sorry, You are not allowed to perform this operation'); |
1612 | 1612 | } |
1613 | 1613 | |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | $record->save(); |
1619 | 1619 | $this->addToast($deletedMessage); |
1620 | 1620 | |
1621 | - $this->addReloadSelector('.depends-' . $record->getClassName()); |
|
1621 | + $this->addReloadSelector('.depends-'.$record->getClassName()); |
|
1622 | 1622 | |
1623 | 1623 | return true; |
1624 | 1624 | } |
@@ -1638,9 +1638,9 @@ discard block |
||
1638 | 1638 | $records = $recordSet->select($recordSet->id->is($id), true); |
1639 | 1639 | |
1640 | 1640 | $record = null; |
1641 | - foreach ($records as $record){ |
|
1641 | + foreach ($records as $record) { |
|
1642 | 1642 | } |
1643 | - if(! isset($record)){ |
|
1643 | + if (!isset($record)) { |
|
1644 | 1644 | throw new AppAccessException('Sorry, You are not allowed to perform this operation'); |
1645 | 1645 | } |
1646 | 1646 | |
@@ -1653,12 +1653,12 @@ discard block |
||
1653 | 1653 | |
1654 | 1654 | $recordTitle = $record->getRecordTitle(); |
1655 | 1655 | |
1656 | - $subTitle = $App->translate($recordSet->getDescription()) . ' "' . $recordTitle . '"'; |
|
1656 | + $subTitle = $App->translate($recordSet->getDescription()).' "'.$recordTitle.'"'; |
|
1657 | 1657 | $form->addItem($W->Title($subTitle, 5)); |
1658 | 1658 | |
1659 | 1659 | $confirmedAction = $this->proxy()->restore($id); |
1660 | 1660 | $parameters = $confirmedAction->getParameters(); |
1661 | - foreach ($parameters as $key => $value){ |
|
1661 | + foreach ($parameters as $key => $value) { |
|
1662 | 1662 | $form->setHiddenValue($key, $value); |
1663 | 1663 | } |
1664 | 1664 | $form->addButton($W->SubmitButton() |
@@ -1684,12 +1684,12 @@ discard block |
||
1684 | 1684 | $view = $this->modelView($filter, $type, null, $itemId); |
1685 | 1685 | $view->setAjaxAction(); |
1686 | 1686 | |
1687 | - if(isset($filter)){ |
|
1687 | + if (isset($filter)) { |
|
1688 | 1688 | $view->setFilterValues($filter); |
1689 | 1689 | } |
1690 | 1690 | $filter = $view->getFilterValues(); |
1691 | 1691 | |
1692 | - if(isset($filter['showTotal']) && $filter['showTotal']){ |
|
1692 | + if (isset($filter['showTotal']) && $filter['showTotal']) { |
|
1693 | 1693 | $view->displaySubTotalRow(true); |
1694 | 1694 | } |
1695 | 1695 | |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | $page->addItem($trashView); |
1736 | 1736 | |
1737 | 1737 | $itemMenus = $this->getListItemMenus(); |
1738 | - foreach ($itemMenus as $itemMenuId => $itemMenu){ |
|
1738 | + foreach ($itemMenus as $itemMenuId => $itemMenu) { |
|
1739 | 1739 | $page->addItemMenu($itemMenuId, $itemMenu['label'], $itemMenu['action']); |
1740 | 1740 | } |
1741 | 1741 | $page->setCurrentItemMenu('displayTrash'); |
@@ -1761,16 +1761,16 @@ discard block |
||
1761 | 1761 | $registry = bab_getRegistryInstance(); |
1762 | 1762 | |
1763 | 1763 | $userId = '0'; |
1764 | - $registry->changeDirectory('/widgets/user/' . $userId . '/' . $id . '/filters'); |
|
1764 | + $registry->changeDirectory('/widgets/user/'.$userId.'/'.$id.'/filters'); |
|
1765 | 1765 | |
1766 | - while ($filterName = $registry->fetchChildKey()){ |
|
1766 | + while ($filterName = $registry->fetchChildKey()) { |
|
1767 | 1767 | $filters[] = $filterName; |
1768 | 1768 | } |
1769 | 1769 | |
1770 | 1770 | $userId = bab_getUserId(); |
1771 | - $registry->changeDirectory('/widgets/user/' . $userId . '/' . $id . '/filters'); |
|
1771 | + $registry->changeDirectory('/widgets/user/'.$userId.'/'.$id.'/filters'); |
|
1772 | 1772 | |
1773 | - while ($filterName = $registry->fetchChildKey()){ |
|
1773 | + while ($filterName = $registry->fetchChildKey()) { |
|
1774 | 1774 | $filters[] = $filterName; |
1775 | 1775 | } |
1776 | 1776 | |
@@ -1787,15 +1787,15 @@ discard block |
||
1787 | 1787 | { |
1788 | 1788 | $W = bab_Widgets(); |
1789 | 1789 | $tableview = $this->modelView(null, 'table'); |
1790 | - $W->setUserConfiguration($tableview->getId() . '/currentFilterName', $filterName, 'widgets', false); |
|
1790 | + $W->setUserConfiguration($tableview->getId().'/currentFilterName', $filterName, 'widgets', false); |
|
1791 | 1791 | |
1792 | 1792 | $registry = bab_getRegistryInstance(); |
1793 | 1793 | $userId = '0'; |
1794 | - $registry->changeDirectory('/widgets/user/' . $userId . '/' . $tableview->getId() . '/filters'); |
|
1794 | + $registry->changeDirectory('/widgets/user/'.$userId.'/'.$tableview->getId().'/filters'); |
|
1795 | 1795 | $filterValues = $registry->getValue($filterName); |
1796 | 1796 | |
1797 | - if(! $filterValues){ |
|
1798 | - $filterValues = $W->getUserConfiguration($tableview->getId() . '/filters/' . $filterName, 'widgets', false); |
|
1797 | + if (!$filterValues) { |
|
1798 | + $filterValues = $W->getUserConfiguration($tableview->getId().'/filters/'.$filterName, 'widgets', false); |
|
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | $tableview = $this->modelView($filterValues, 'table'); |
@@ -1811,7 +1811,7 @@ discard block |
||
1811 | 1811 | { |
1812 | 1812 | $W = bab_Widgets(); |
1813 | 1813 | $id = $this->getModelViewDefaultId(); |
1814 | - $filter = $W->getUserConfiguration($id . '/currentFilterName', 'widgets', false); |
|
1814 | + $filter = $W->getUserConfiguration($id.'/currentFilterName', 'widgets', false); |
|
1815 | 1815 | |
1816 | 1816 | return $filter; |
1817 | 1817 | } |
@@ -1821,12 +1821,12 @@ discard block |
||
1821 | 1821 | */ |
1822 | 1822 | public function resetFilters($name = null) |
1823 | 1823 | { |
1824 | - if(isset($name)){ |
|
1824 | + if (isset($name)) { |
|
1825 | 1825 | $W = bab_Widgets(); |
1826 | - $filter = $W->getUserConfiguration($tableview->getId() . '/filters/' . $name, 'widgets', false); |
|
1826 | + $filter = $W->getUserConfiguration($tableview->getId().'/filters/'.$name, 'widgets', false); |
|
1827 | 1827 | $filterValues = $filter['values']; |
1828 | 1828 | } |
1829 | - else{ |
|
1829 | + else { |
|
1830 | 1830 | $filterValues = null; |
1831 | 1831 | } |
1832 | 1832 | |
@@ -1853,7 +1853,7 @@ discard block |
||
1853 | 1853 | 'values' => $filterValues |
1854 | 1854 | ); |
1855 | 1855 | |
1856 | - $W->setUserConfiguration($tableview->getId() . '/filters/' . $name, $data, 'widgets', false); |
|
1856 | + $W->setUserConfiguration($tableview->getId().'/filters/'.$name, $data, 'widgets', false); |
|
1857 | 1857 | |
1858 | 1858 | return true; |
1859 | 1859 | } |
@@ -1870,7 +1870,7 @@ discard block |
||
1870 | 1870 | $Ui = $App->Ui(); |
1871 | 1871 | |
1872 | 1872 | $currentFilterName = $this->getCurrentFilterName(); |
1873 | - $filter = $W->getUserConfiguration($this->getModelViewDefaultId() . '/filters/' . $currentFilterName, 'widgets', false); |
|
1873 | + $filter = $W->getUserConfiguration($this->getModelViewDefaultId().'/filters/'.$currentFilterName, 'widgets', false); |
|
1874 | 1874 | |
1875 | 1875 | $page = $Ui->Page(); |
1876 | 1876 | |
@@ -1907,7 +1907,7 @@ discard block |
||
1907 | 1907 | $App = $this->App(); |
1908 | 1908 | $Ui = $App->Ui(); |
1909 | 1909 | |
1910 | - $filter = $W->getUserConfiguration($this->getModelViewDefaultId() . '/filters/' . $name, 'widgets', false); |
|
1910 | + $filter = $W->getUserConfiguration($this->getModelViewDefaultId().'/filters/'.$name, 'widgets', false); |
|
1911 | 1911 | |
1912 | 1912 | $page = $Ui->Page(); |
1913 | 1913 | |
@@ -1945,8 +1945,8 @@ discard block |
||
1945 | 1945 | $page->addItem($filtersBox); |
1946 | 1946 | |
1947 | 1947 | $filterNames = $this->getFilterNames(); |
1948 | - foreach ($filterNames as $filterName){ |
|
1949 | - $filter = $W->getUserConfiguration($this->getModelViewDefaultId() . '/filters/' . $filterName, 'widgets', false); |
|
1948 | + foreach ($filterNames as $filterName) { |
|
1949 | + $filter = $W->getUserConfiguration($this->getModelViewDefaultId().'/filters/'.$filterName, 'widgets', false); |
|
1950 | 1950 | |
1951 | 1951 | $filterBox = $W->HBoxItems() |
1952 | 1952 | ->setVerticalAlign('middle') |
@@ -1985,7 +1985,7 @@ discard block |
||
1985 | 1985 | $App = $this->App(); |
1986 | 1986 | $Ui = $App->Ui(); |
1987 | 1987 | |
1988 | - $filter = $W->getUserConfiguration($this->getModelViewDefaultId() . '/filters/' . $name, 'widgets', false); |
|
1988 | + $filter = $W->getUserConfiguration($this->getModelViewDefaultId().'/filters/'.$name, 'widgets', false); |
|
1989 | 1989 | |
1990 | 1990 | $page = $Ui->Page(); |
1991 | 1991 | |
@@ -2016,7 +2016,7 @@ discard block |
||
2016 | 2016 | $this->requireDeleteMethod(); |
2017 | 2017 | |
2018 | 2018 | $W = bab_Widgets(); |
2019 | - $W->deleteUserConfiguration($this->getModelViewDefaultId() . '/filters/' . $name, 'widgets', false); |
|
2019 | + $W->deleteUserConfiguration($this->getModelViewDefaultId().'/filters/'.$name, 'widgets', false); |
|
2020 | 2020 | |
2021 | 2021 | return true; |
2022 | 2022 | } |
@@ -2026,7 +2026,7 @@ discard block |
||
2026 | 2026 | $modelView = $this->modelView(); |
2027 | 2027 | $modelView->setHighlightedRows($ids); |
2028 | 2028 | |
2029 | - $this->addReloadSelector('.depends-' . $modelView->getId() . '-HighlightedRecords'); |
|
2029 | + $this->addReloadSelector('.depends-'.$modelView->getId().'-HighlightedRecords'); |
|
2030 | 2030 | |
2031 | 2031 | return true; |
2032 | 2032 | } |
@@ -2036,7 +2036,7 @@ discard block |
||
2036 | 2036 | $modelView = $this->modelView(); |
2037 | 2037 | $modelView->clearHighlightedRows(); |
2038 | 2038 | |
2039 | - $this->addReloadSelector('.depends-' . $modelView->getId() . '-HighlightedRecords'); |
|
2039 | + $this->addReloadSelector('.depends-'.$modelView->getId().'-HighlightedRecords'); |
|
2040 | 2040 | |
2041 | 2041 | return true; |
2042 | 2042 | } |
@@ -2055,34 +2055,34 @@ discard block |
||
2055 | 2055 | $box = $W->VBoxItems(); |
2056 | 2056 | |
2057 | 2057 | $isComponent = false; |
2058 | - if($component = $App->getCurrentComponent()){ |
|
2058 | + if ($component = $App->getCurrentComponent()) { |
|
2059 | 2059 | $Ui = $component->ui(); |
2060 | 2060 | $viewClassname = 'FullFrame'; |
2061 | 2061 | $isComponent = true; |
2062 | 2062 | } |
2063 | - else{ |
|
2063 | + else { |
|
2064 | 2064 | $Ui = $App->Ui(); |
2065 | 2065 | $recordClassname = $this->getRecordClassName(); |
2066 | - $viewClassname = $recordClassname . 'FullFrame'; |
|
2066 | + $viewClassname = $recordClassname.'FullFrame'; |
|
2067 | 2067 | } |
2068 | 2068 | |
2069 | - if($records->count() > 0){ |
|
2069 | + if ($records->count() > 0) { |
|
2070 | 2070 | $box->addItem($W->Link('', $this->proxy() |
2071 | 2071 | ->clearHighlightedRecords()) |
2072 | 2072 | ->setAjaxAction(null, false) |
2073 | 2073 | ->addClass('icon', \Func_Icons::ACTIONS_ARROW_RIGHT_DOUBLE, "app_closeHighlightButton") |
2074 | - ->setSizePolicy(\Func_Icons::ICON_LEFT_32 . ' pull-right')); |
|
2074 | + ->setSizePolicy(\Func_Icons::ICON_LEFT_32.' pull-right')); |
|
2075 | 2075 | |
2076 | - foreach ($records as $record){ |
|
2076 | + foreach ($records as $record) { |
|
2077 | 2077 | |
2078 | - if($isComponent){ |
|
2078 | + if ($isComponent) { |
|
2079 | 2079 | $fullFrame = $Ui->$viewClassname($record); |
2080 | - if(method_exists($record, getBlueprint)){ |
|
2080 | + if (method_exists($record, getBlueprint)) { |
|
2081 | 2081 | $view = $record->getBlueprint(); |
2082 | 2082 | } |
2083 | 2083 | $fullFrame->setView($view); |
2084 | 2084 | } |
2085 | - else{ |
|
2085 | + else { |
|
2086 | 2086 | $fullFrame = $Ui->$viewClassname($record->id, $view); |
2087 | 2087 | } |
2088 | 2088 | |
@@ -2091,7 +2091,7 @@ discard block |
||
2091 | 2091 | $box->addClass('box', 'shadow'); |
2092 | 2092 | } |
2093 | 2093 | |
2094 | - $box->addClass('depends-' . $modelView->getId() . '-HighlightedRecords'); |
|
2094 | + $box->addClass('depends-'.$modelView->getId().'-HighlightedRecords'); |
|
2095 | 2095 | $box->setReloadAction($this->proxy() |
2096 | 2096 | ->previewHighlightedRecords($view)); |
2097 | 2097 | return $box; |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | ->_AND_($customSectionSet->object->is($customSection->object))); |
65 | 65 | |
66 | 66 | $allViewFieldNames = array(); |
67 | - foreach ($allViewSections as $viewSection){ |
|
67 | + foreach ($allViewSections as $viewSection) { |
|
68 | 68 | $fields = $viewSection->getFields(); |
69 | - foreach ($fields as $field){ |
|
70 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
69 | + foreach ($fields as $field) { |
|
70 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | 74 | $box = $W->VBoxItems(); |
75 | - if(isset($itemId)){ |
|
75 | + if (isset($itemId)) { |
|
76 | 76 | $box->setId($itemId); |
77 | 77 | } |
78 | 78 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | \bab_Sort::asort($availableFields, 'description', \bab_Sort::CASE_INSENSITIVE); |
89 | 89 | |
90 | - foreach ($availableFields as $field){ |
|
90 | + foreach ($availableFields as $field) { |
|
91 | 91 | $fieldName = $field['name']; |
92 | 92 | $fieldDescription = $field['description']; |
93 | 93 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $field = $customSection->getField($fieldName); |
143 | 143 | |
144 | - if(! isset($field)){ |
|
144 | + if (!isset($field)) { |
|
145 | 145 | return null; |
146 | 146 | } |
147 | 147 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | |
158 | 158 | $field = $availableFields[$fieldName]; |
159 | 159 | $fieldDescription = $field['description']; |
160 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
160 | + if (substr($fieldName, 0, 1) !== '_') { |
|
161 | 161 | $fieldDescription = $App->translate($fieldDescription); |
162 | 162 | } |
163 | 163 | |
164 | - if(empty($field)){ |
|
164 | + if (empty($field)) { |
|
165 | 165 | // continue; |
166 | 166 | } |
167 | 167 | |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | $W = bab_Widgets(); |
263 | 263 | |
264 | 264 | $customSectionSet = $App->CustomContainerSet(); |
265 | - if(isset($id)){ |
|
265 | + if (isset($id)) { |
|
266 | 266 | $record = $customSectionSet->request($id); |
267 | 267 | } |
268 | - else{ |
|
268 | + else { |
|
269 | 269 | $record = $customSectionSet->newRecord(); |
270 | 270 | $record->object = $object; |
271 | 271 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $editor = new AppEditor($App); |
279 | 279 | $editor->setHiddenValue('tg', $App->controllerTg); |
280 | 280 | $editor->setHiddenValue('data[view]', $view); |
281 | - if($record->id){ |
|
281 | + if ($record->id) { |
|
282 | 282 | $editor->setHiddenValue('data[id]', $record->id); |
283 | 283 | } |
284 | 284 | $editor->setName('data'); |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | $record = $recordSet->request($id); |
357 | 357 | |
358 | 358 | $object = $record->object; |
359 | - if(empty($object)){ |
|
359 | + if (empty($object)) { |
|
360 | 360 | $object = $record->container()->object; |
361 | 361 | } |
362 | - if(strpos($object, $App->classPrefix) !== false){ |
|
362 | + if (strpos($object, $App->classPrefix) !== false) { |
|
363 | 363 | $object = str_replace($App->classPrefix, '', $object); |
364 | 364 | } |
365 | 365 | $object .= 'Set'; |
@@ -374,25 +374,25 @@ discard block |
||
374 | 374 | $manySets = $objectRecordSet->getHasManyRelations(); |
375 | 375 | $oneSets = $objectRecordSet->getHasOneRelations(); |
376 | 376 | |
377 | - if(! empty($record->visibilityCriteria)){ |
|
377 | + if (!empty($record->visibilityCriteria)) { |
|
378 | 378 | $arrCriteria = json_decode($record->visibilityCriteria, true); |
379 | 379 | |
380 | 380 | $data = array(); |
381 | - foreach ($arrCriteria as $fieldName => $operation){ |
|
381 | + foreach ($arrCriteria as $fieldName => $operation) { |
|
382 | 382 | $data['field'] = $fieldName; |
383 | - foreach ($operation as $condition => $value){ |
|
383 | + foreach ($operation as $condition => $value) { |
|
384 | 384 | $data['condition']['default'] = $condition; |
385 | 385 | $data['condition']['bool'] = $condition; |
386 | - if(is_array($value)){ |
|
387 | - foreach ($value as $key => $subValue){ |
|
388 | - foreach ($manySets as $manyFieldName => $manyRelation){ |
|
389 | - if($key . 'Set' == $manyRelation->getForeignSetClassName()){ |
|
390 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
391 | - if($subFieldName === '_foreignField'){ |
|
386 | + if (is_array($value)) { |
|
387 | + foreach ($value as $key => $subValue) { |
|
388 | + foreach ($manySets as $manyFieldName => $manyRelation) { |
|
389 | + if ($key.'Set' == $manyRelation->getForeignSetClassName()) { |
|
390 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
391 | + if ($subFieldName === '_foreignField') { |
|
392 | 392 | continue; |
393 | 393 | } |
394 | 394 | $data['field'] = "{$manyFieldName}/{$subFieldName}"; |
395 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
395 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
396 | 396 | $data['condition']['default'] = $subCondition; |
397 | 397 | $data['condition']['bool'] = $subCondition; |
398 | 398 | $value = $subConditionValue; |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | break; |
402 | 402 | } |
403 | 403 | } |
404 | - foreach ($oneSets as $oneFieldName => $oneRelation){ |
|
405 | - if($key . 'Set' == $oneRelation->getForeignSetClassName()){ |
|
406 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
407 | - if($subFieldName === '_foreignField'){ |
|
404 | + foreach ($oneSets as $oneFieldName => $oneRelation) { |
|
405 | + if ($key.'Set' == $oneRelation->getForeignSetClassName()) { |
|
406 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
407 | + if ($subFieldName === '_foreignField') { |
|
408 | 408 | continue; |
409 | 409 | } |
410 | 410 | $data['field'] = "{$oneFieldName}/{$subFieldName}"; |
411 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
411 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
412 | 412 | $data['condition']['default'] = $subCondition; |
413 | 413 | $data['condition']['bool'] = $subCondition; |
414 | 414 | $value = $subConditionValue; |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | protected function preSave(ORMRecord $record, $data) |
454 | 454 | { |
455 | 455 | parent::preSave($record, $data); |
456 | - if(! isset($record->id) || empty($record->id)){ |
|
456 | + if (!isset($record->id) || empty($record->id)) { |
|
457 | 457 | $set = $record->getParentSet(); |
458 | 458 | $nbContainers = $set->select($set->all(array( |
459 | 459 | $set->object->is($record->object), |
@@ -488,10 +488,10 @@ discard block |
||
488 | 488 | $record = $recordSet->request($data['id']); |
489 | 489 | |
490 | 490 | $object = $record->object; |
491 | - if(empty($object)){ |
|
491 | + if (empty($object)) { |
|
492 | 492 | $object = $record->container()->object; |
493 | 493 | } |
494 | - if(strpos($object, $App->classPrefix) !== false){ |
|
494 | + if (strpos($object, $App->classPrefix) !== false) { |
|
495 | 495 | $object = str_replace($App->classPrefix, '', $object); |
496 | 496 | } |
497 | 497 | $object .= 'Set'; |
@@ -502,14 +502,14 @@ discard block |
||
502 | 502 | $field = $data['field']; |
503 | 503 | $condition = $data['condition']; |
504 | 504 | |
505 | - if(strpos($field, '/') !== false){ |
|
505 | + if (strpos($field, '/') !== false) { |
|
506 | 506 | // The selected field is a hasMany or a hasOne relation |
507 | 507 | list ($selectedRelation, $selectedField) = explode('/', $field); |
508 | 508 | $classPrefix = $App->classPrefix; |
509 | 509 | |
510 | 510 | $manyRelations = $objectRecordSet->getHasManyRelations(); |
511 | - foreach ($manyRelations as $manyRelation){ |
|
512 | - if($selectedRelation != $manyRelation->getOwnerSetFieldName()){ |
|
511 | + foreach ($manyRelations as $manyRelation) { |
|
512 | + if ($selectedRelation != $manyRelation->getOwnerSetFieldName()) { |
|
513 | 513 | continue; |
514 | 514 | } |
515 | 515 | $foreignSetName = str_replace($classPrefix, '', $manyRelation->getForeignSetClassName()); |
@@ -517,13 +517,13 @@ discard block |
||
517 | 517 | |
518 | 518 | $visibilityCriteria = ''; |
519 | 519 | |
520 | - if($foreignSet){ |
|
520 | + if ($foreignSet) { |
|
521 | 521 | $selectedManyField = $foreignSet->$selectedField; |
522 | 522 | |
523 | - if($selectedManyField instanceof ORMBoolInterface){ |
|
523 | + if ($selectedManyField instanceof ORMBoolInterface) { |
|
524 | 524 | $condition = $condition['bool']; |
525 | 525 | } |
526 | - else{ |
|
526 | + else { |
|
527 | 527 | $condition = $condition['default']; |
528 | 528 | } |
529 | 529 | |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | } |
536 | 536 | |
537 | 537 | $oneRelations = $objectRecordSet->getHasOneRelations(); |
538 | - foreach ($oneRelations as $oneRelation){ |
|
538 | + foreach ($oneRelations as $oneRelation) { |
|
539 | 539 | /* @var $oneRelation ORMOneRelation*/ |
540 | - if($selectedRelation != $oneRelation->getOwnerSetFieldName()){ |
|
540 | + if ($selectedRelation != $oneRelation->getOwnerSetFieldName()) { |
|
541 | 541 | continue; |
542 | 542 | } |
543 | 543 | $foreignSetClassName = $oneRelation->getForeignSetClassName(); |
@@ -546,13 +546,13 @@ discard block |
||
546 | 546 | |
547 | 547 | $visibilityCriteria = ''; |
548 | 548 | |
549 | - if($foreignSet){ |
|
549 | + if ($foreignSet) { |
|
550 | 550 | $selectedOneField = $foreignSet->$selectedField; |
551 | 551 | |
552 | - if($selectedOneField instanceof ORMBoolInterface){ |
|
552 | + if ($selectedOneField instanceof ORMBoolInterface) { |
|
553 | 553 | $condition = $condition['bool']; |
554 | 554 | } |
555 | - else{ |
|
555 | + else { |
|
556 | 556 | $condition = $condition['default']; |
557 | 557 | } |
558 | 558 | |
@@ -562,20 +562,20 @@ discard block |
||
562 | 562 | break; |
563 | 563 | } |
564 | 564 | } |
565 | - else{ |
|
565 | + else { |
|
566 | 566 | |
567 | 567 | $field = $objectRecordSet->$field; |
568 | 568 | |
569 | - if($field instanceof ORMBoolInterface){ |
|
569 | + if ($field instanceof ORMBoolInterface) { |
|
570 | 570 | $condition = $condition['bool']; |
571 | 571 | } |
572 | - else{ |
|
572 | + else { |
|
573 | 573 | $condition = $condition['default']; |
574 | 574 | } |
575 | 575 | |
576 | 576 | $visibilityCriteria = ''; |
577 | 577 | |
578 | - if(! empty($condition)){ |
|
578 | + if (!empty($condition)) { |
|
579 | 579 | $criteria = $field->{$condition}($data['value']); |
580 | 580 | $visibilityCriteria = $criteria->toJson(); |
581 | 581 | } |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | |
611 | 611 | $containerBoxes = $W->Items(); |
612 | 612 | |
613 | - foreach ($customContainers as $customContainer){ |
|
613 | + foreach ($customContainers as $customContainer) { |
|
614 | 614 | |
615 | 615 | $menu = $W->HBoxItems($W->Link('', $customSectionCtrl->edit($customContainer->id)) |
616 | 616 | ->addClass('icon', \Func_Icons::ACTIONS_LIST_ADD) |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | $menu->setSizePolicy(\Func_Icons::ICON_LEFT_16); |
626 | 626 | |
627 | 627 | $hasVisibilityBox = $W->FlowItems()->addClass('widget-100'); |
628 | - if(! empty($customContainer->visibilityCriteria)){ |
|
628 | + if (!empty($customContainer->visibilityCriteria)) { |
|
629 | 629 | $hasVisibilityBox->addItem($W->HBoxItems($W->Label($App->translate('This container has a visibility condition'))) |
630 | 630 | ->setSizePolicy('alert alert-warning widget-100pc')); |
631 | 631 | } |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | ->addClass($customContainer->classname)); |
637 | 637 | } |
638 | 638 | |
639 | - if(isset($itemId)){ |
|
639 | + if (isset($itemId)) { |
|
640 | 640 | $containerBoxes->setId($itemId); |
641 | 641 | } |
642 | 642 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | $customSectionSet = $App->CustomSectionSet(); |
663 | 663 | |
664 | 664 | $containersValues = array(); |
665 | - foreach ($customContainers as $customContainer){ |
|
665 | + foreach ($customContainers as $customContainer) { |
|
666 | 666 | $values = $customContainer->getValues(); |
667 | 667 | unset($values['id']); |
668 | 668 | unset($values['uuid']); |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | unset($values['deleted']); |
676 | 676 | $values['customSections'] = array(); |
677 | 677 | $customSections = $customSectionSet->select($customSectionSet->container->is($customContainer->id)); |
678 | - foreach ($customSections as $customSection){ |
|
678 | + foreach ($customSections as $customSection) { |
|
679 | 679 | $customSectionValues = $customSection->getValues(); |
680 | 680 | unset($customSectionValues['id']); |
681 | 681 | unset($customSectionValues['uuid']); |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | } |
695 | 695 | |
696 | 696 | header('Content-type: application/json'); |
697 | - header('Content-Disposition: attachment; filename="' . $object . '.' . ($view === '' ? 'default' : $view) . '.json"' . "\n"); |
|
697 | + header('Content-Disposition: attachment; filename="'.$object.'.'.($view === '' ? 'default' : $view).'.json"'."\n"); |
|
698 | 698 | |
699 | 699 | $json = bab_json_encode($containersValues); |
700 | 700 | $json = bab_convertStringFromDatabase($json, \bab_charset::UTF_8); |
@@ -752,12 +752,12 @@ discard block |
||
752 | 752 | $files->push($containersfile['uid']); |
753 | 753 | |
754 | 754 | $data = null; |
755 | - foreach ($files as $f){ |
|
755 | + foreach ($files as $f) { |
|
756 | 756 | $data = file_get_contents($f->toString()); |
757 | 757 | break; |
758 | 758 | } |
759 | 759 | |
760 | - if(! isset($data)){ |
|
760 | + if (!isset($data)) { |
|
761 | 761 | $this->addError($App->translate('Unable to get file content')); |
762 | 762 | return true; |
763 | 763 | } |
@@ -773,13 +773,13 @@ discard block |
||
773 | 773 | $customContainerSet->delete($customContainerSet->view->is($view) |
774 | 774 | ->_AND_($customContainerSet->object->is($object))); |
775 | 775 | |
776 | - foreach ($containersValues as $containerValues){ |
|
776 | + foreach ($containersValues as $containerValues) { |
|
777 | 777 | $customContainer = $customContainerSet->newRecord(); |
778 | 778 | $customContainer->setValues($containerValues); |
779 | 779 | $customContainer->object = $object; |
780 | 780 | $customContainer->view = $view; |
781 | 781 | $customContainer->save(); |
782 | - foreach ($containerValues['customSections'] as $sectionValues){ |
|
782 | + foreach ($containerValues['customSections'] as $sectionValues) { |
|
783 | 783 | $customSection = $customSectionSet->newRecord(); |
784 | 784 | $sectionValues['fields'] = json_encode($sectionValues['fields']); |
785 | 785 | $customSection->setValues($sectionValues); |
@@ -913,9 +913,9 @@ discard block |
||
913 | 913 | |
914 | 914 | $rank = 0; |
915 | 915 | $currentContainerId = 0; |
916 | - foreach (array_keys($containers) as $containerFieldId){ |
|
916 | + foreach (array_keys($containers) as $containerFieldId) { |
|
917 | 917 | |
918 | - if(substr($containerFieldId, 0, 1) === '#'){ |
|
918 | + if (substr($containerFieldId, 0, 1) === '#') { |
|
919 | 919 | $currentContainerId = substr($containerFieldId, 1); |
920 | 920 | |
921 | 921 | $customContainer = $customContainerSet->request($customContainerSet->id->is($currentContainerId)); |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | $containersRawFields[$currentContainerId] = $customContainer->getRawFields(); |
925 | 925 | |
926 | 926 | $customContainer->rank = $rank; |
927 | - $rank ++; |
|
927 | + $rank++; |
|
928 | 928 | $customContainer->save(); |
929 | 929 | continue; |
930 | 930 | } |
@@ -932,18 +932,18 @@ discard block |
||
932 | 932 | $containersFields[$currentContainerId][] = $containerFieldId; |
933 | 933 | } |
934 | 934 | |
935 | - foreach ($containersFields as $containerId => $containerFieldIds){ |
|
936 | - foreach ($containerFieldIds as $containerFieldId){ |
|
935 | + foreach ($containersFields as $containerId => $containerFieldIds) { |
|
936 | + foreach ($containerFieldIds as $containerFieldId) { |
|
937 | 937 | list ($srcContainerId, $srcfieldId) = explode('.', $containerFieldId); |
938 | - if(! isset($containersRawFields[$srcContainerId][$srcfieldId])){ |
|
938 | + if (!isset($containersRawFields[$srcContainerId][$srcfieldId])) { |
|
939 | 939 | return true; |
940 | 940 | } |
941 | 941 | } |
942 | 942 | } |
943 | 943 | |
944 | - foreach ($containersFields as $containerId => $containerFieldIds){ |
|
944 | + foreach ($containersFields as $containerId => $containerFieldIds) { |
|
945 | 945 | $newRawFields = array(); |
946 | - foreach ($containerFieldIds as $containerFieldId){ |
|
946 | + foreach ($containerFieldIds as $containerFieldId) { |
|
947 | 947 | list ($srcContainerId, $srcfieldId) = explode('.', $containerFieldId); |
948 | 948 | $newRawFields[] = $containersRawFields[$srcContainerId][$srcfieldId]; |
949 | 949 | } |
@@ -264,8 +264,7 @@ discard block |
||
264 | 264 | $customSectionSet = $App->CustomContainerSet(); |
265 | 265 | if(isset($id)){ |
266 | 266 | $record = $customSectionSet->request($id); |
267 | - } |
|
268 | - else{ |
|
267 | + } else{ |
|
269 | 268 | $record = $customSectionSet->newRecord(); |
270 | 269 | $record->object = $object; |
271 | 270 | } |
@@ -522,8 +521,7 @@ discard block |
||
522 | 521 | |
523 | 522 | if($selectedManyField instanceof ORMBoolInterface){ |
524 | 523 | $condition = $condition['bool']; |
525 | - } |
|
526 | - else{ |
|
524 | + } else{ |
|
527 | 525 | $condition = $condition['default']; |
528 | 526 | } |
529 | 527 | |
@@ -551,8 +549,7 @@ discard block |
||
551 | 549 | |
552 | 550 | if($selectedOneField instanceof ORMBoolInterface){ |
553 | 551 | $condition = $condition['bool']; |
554 | - } |
|
555 | - else{ |
|
552 | + } else{ |
|
556 | 553 | $condition = $condition['default']; |
557 | 554 | } |
558 | 555 | |
@@ -561,15 +558,13 @@ discard block |
||
561 | 558 | } |
562 | 559 | break; |
563 | 560 | } |
564 | - } |
|
565 | - else{ |
|
561 | + } else{ |
|
566 | 562 | |
567 | 563 | $field = $objectRecordSet->$field; |
568 | 564 | |
569 | 565 | if($field instanceof ORMBoolInterface){ |
570 | 566 | $condition = $condition['bool']; |
571 | - } |
|
572 | - else{ |
|
567 | + } else{ |
|
573 | 568 | $condition = $condition['default']; |
574 | 569 | } |
575 | 570 |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | public function __construct(Func_App $app = null) |
41 | 41 | { |
42 | 42 | parent::__construct($app); |
43 | - if(! bab_isUserAdministrator()){ |
|
43 | + if (!bab_isUserAdministrator()) { |
|
44 | 44 | $action = WidgetAction::fromRequest(); |
45 | 45 | list (, $method) = explode('.', $action->getMethod()); |
46 | - if($method !== 'denied'){ |
|
46 | + if ($method !== 'denied') { |
|
47 | 47 | /** |
48 | 48 | * @var WidgetAction |
49 | 49 | */ |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $box->addClass('reload-configuration-page'); |
114 | 114 | $box->addClass('widget-100pc'); |
115 | 115 | |
116 | - if(! isset($itemId)){ |
|
116 | + if (!isset($itemId)) { |
|
117 | 117 | $this->resetCurrentTab(); |
118 | 118 | } |
119 | 119 | |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | $navBoxHtml = '<ul class="nav nav-tabs">'; |
124 | 124 | $htmlCanvas = $W->HtmlCanvas(); |
125 | 125 | |
126 | - foreach ($configurationItems as $tabId => $tab){ |
|
126 | + foreach ($configurationItems as $tabId => $tab) { |
|
127 | 127 | $tabLink = $W->Link($tab['tabTitle'], $this->proxy() |
128 | 128 | ->setDisplayTab($tabId)) |
129 | 129 | ->setOpenMode(WidgetLink::OPEN_DIALOG); |
130 | 130 | $tabLinkHtml = '<li role="configuration"'; |
131 | - if($tabId == $currentTab){ |
|
131 | + if ($tabId == $currentTab) { |
|
132 | 132 | $tabLinkHtml .= ' class="active"'; |
133 | 133 | } |
134 | 134 | $tabLinkHtml .= '>'; |
135 | - $tabLinkHtml .= $tabLink->display($htmlCanvas) . '</li>'; |
|
135 | + $tabLinkHtml .= $tabLink->display($htmlCanvas).'</li>'; |
|
136 | 136 | $navBoxHtml .= $tabLinkHtml; |
137 | 137 | } |
138 | 138 | |
@@ -161,19 +161,19 @@ discard block |
||
161 | 161 | ->addClass('icon-left icon-48x48 icon-left-48'); |
162 | 162 | $box->addItem($configBox); |
163 | 163 | |
164 | - if(! isset($configurationItems[$currentTab])){ |
|
164 | + if (!isset($configurationItems[$currentTab])) { |
|
165 | 165 | return $box; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $tab = $configurationItems[$currentTab]; |
169 | 169 | |
170 | - foreach ($tab['tabContent'] as $tabSection){ |
|
171 | - if(! isset($tabSection['sectionContent']) || empty($tabSection['sectionContent'])){ |
|
170 | + foreach ($tab['tabContent'] as $tabSection) { |
|
171 | + if (!isset($tabSection['sectionContent']) || empty($tabSection['sectionContent'])) { |
|
172 | 172 | continue; |
173 | 173 | } |
174 | 174 | $configBox->addItem($W->Section($tabSection['sectionName'], $sectionContentBox = $W->HBoxItems()) |
175 | 175 | ->setFoldable(true)); |
176 | - foreach ($tabSection['sectionContent'] as $tabSection){ |
|
176 | + foreach ($tabSection['sectionContent'] as $tabSection) { |
|
177 | 177 | $sectionContentBox->addItem($tabSection); |
178 | 178 | } |
179 | 179 | } |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | ); |
199 | 199 | |
200 | 200 | $definitions = $App->getComponentDefinitions(); |
201 | - foreach ($definitions as $packageName => $definition){ |
|
201 | + foreach ($definitions as $packageName => $definition) { |
|
202 | 202 | /* @var $definition AppComponentDefinition */ |
203 | - if(! method_exists($definition, 'getConfiguration')){ |
|
203 | + if (!method_exists($definition, 'getConfiguration')) { |
|
204 | 204 | continue; |
205 | 205 | } |
206 | 206 | $configurationItems[$packageName] = array( |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $customSection = $customSectionSet->request($customSectionSet->id->is($section)); |
61 | 61 | |
62 | 62 | $object = $customSection->container->object; |
63 | - if(strpos($object, $App->classPrefix) !== false){ |
|
63 | + if (strpos($object, $App->classPrefix) !== false) { |
|
64 | 64 | list (, $object) = explode($App->classPrefix, $object); |
65 | 65 | } |
66 | 66 | $objectCtrl = $App->Controller()->$object(false); |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | ->_AND_($customSectionSet->object->is($customSection->object))); |
70 | 70 | |
71 | 71 | $allViewFieldNames = array(); |
72 | - foreach ($allViewSections as $viewSection){ |
|
72 | + foreach ($allViewSections as $viewSection) { |
|
73 | 73 | $fields = $viewSection->getFields(); |
74 | - foreach ($fields as $field){ |
|
75 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
76 | - foreach ($field['fields'] as $subField){ |
|
77 | - $allViewFieldNames[$subField['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
74 | + foreach ($fields as $field) { |
|
75 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
76 | + foreach ($field['fields'] as $subField) { |
|
77 | + $allViewFieldNames[$subField['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | 82 | $box = $W->VBoxItems(); |
83 | - if(isset($itemId)){ |
|
83 | + if (isset($itemId)) { |
|
84 | 84 | $box->setId($itemId); |
85 | 85 | } |
86 | 86 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | \bab_Sort::asort($availableFields, 'description', \bab_Sort::CASE_INSENSITIVE); |
97 | 97 | |
98 | - foreach ($availableFields as $field){ |
|
98 | + foreach ($availableFields as $field) { |
|
99 | 99 | $fieldName = $field['name']; |
100 | 100 | $fieldDescription = $field['description']; |
101 | 101 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | $field = $customSection->getField($fieldName); |
152 | 152 | |
153 | - if(! isset($field)){ |
|
153 | + if (!isset($field)) { |
|
154 | 154 | return null; |
155 | 155 | } |
156 | 156 | |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | |
168 | 168 | $field = $availableFields[$fieldName]; |
169 | 169 | $fieldDescription = $field['description']; |
170 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
170 | + if (substr($fieldName, 0, 1) !== '_') { |
|
171 | 171 | $fieldDescription = $App->translate($fieldDescription); |
172 | 172 | } |
173 | 173 | |
174 | - if(empty($field)){ |
|
174 | + if (empty($field)) { |
|
175 | 175 | // continue; |
176 | 176 | } |
177 | 177 | |
@@ -241,12 +241,12 @@ discard block |
||
241 | 241 | |
242 | 242 | $groupField = $customSection->getField($fieldGroupName); |
243 | 243 | |
244 | - if(! isset($groupField)){ |
|
244 | + if (!isset($groupField)) { |
|
245 | 245 | return null; |
246 | 246 | } |
247 | 247 | |
248 | 248 | $field = $groupField['fields'][$fieldName]; |
249 | - if(! isset($field)){ |
|
249 | + if (!isset($field)) { |
|
250 | 250 | return null; |
251 | 251 | } |
252 | 252 | |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | |
263 | 263 | $field = $availableFields[$fieldName]; |
264 | 264 | $fieldDescription = $field['description']; |
265 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
265 | + if (substr($fieldName, 0, 1) !== '_') { |
|
266 | 266 | $fieldDescription = $App->translate($fieldDescription); |
267 | 267 | } |
268 | 268 | |
269 | - if(empty($field)){ |
|
269 | + if (empty($field)) { |
|
270 | 270 | // continue; |
271 | 271 | } |
272 | 272 | |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | |
350 | 350 | $customSection = $customSectionSet->request($customSectionSet->id->is($section)); |
351 | 351 | $fields = $customSection->getFields(); |
352 | - if(! isset($fields[$fieldGroupName])){ |
|
352 | + if (!isset($fields[$fieldGroupName])) { |
|
353 | 353 | throw new AppException($App->translate('This fields group does not seem to exist')); |
354 | 354 | } |
355 | 355 | |
356 | 356 | $object = $customSection->container->object; |
357 | - if(strpos($object, $App->classPrefix) !== false){ |
|
357 | + if (strpos($object, $App->classPrefix) !== false) { |
|
358 | 358 | list (, $object) = explode($App->classPrefix, $object); |
359 | 359 | } |
360 | 360 | |
@@ -364,18 +364,18 @@ discard block |
||
364 | 364 | ->_AND_($customSectionSet->object->is($customSection->object))); |
365 | 365 | |
366 | 366 | $allViewFieldNames = array(); |
367 | - foreach ($allViewSections as $viewSection){ |
|
367 | + foreach ($allViewSections as $viewSection) { |
|
368 | 368 | $fields = $viewSection->getFields(); |
369 | - foreach ($fields as $field){ |
|
370 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
371 | - foreach ($field['fields'] as $subField){ |
|
372 | - $allViewFieldNames[$subField['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
369 | + foreach ($fields as $field) { |
|
370 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
371 | + foreach ($field['fields'] as $subField) { |
|
372 | + $allViewFieldNames[$subField['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | 377 | $box = $W->VBoxItems(); |
378 | - if(isset($itemId)){ |
|
378 | + if (isset($itemId)) { |
|
379 | 379 | $box->setId($itemId); |
380 | 380 | } |
381 | 381 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | |
393 | 393 | \bab_Sort::asort($availableFields, 'description', \bab_Sort::CASE_INSENSITIVE); |
394 | 394 | |
395 | - foreach ($availableFields as $field){ |
|
395 | + foreach ($availableFields as $field) { |
|
396 | 396 | $fieldName = $field['name']; |
397 | 397 | $fieldDescription = $field['description']; |
398 | 398 | |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | $container = $customContainerSet->request($customContainerSet->id->is($container)); |
505 | 505 | |
506 | 506 | $customSectionSet = $App->CustomSectionSet(); |
507 | - if(isset($id)){ |
|
507 | + if (isset($id)) { |
|
508 | 508 | $record = $customSectionSet->request($id); |
509 | 509 | } |
510 | - else{ |
|
510 | + else { |
|
511 | 511 | $record = $customSectionSet->newRecord(); |
512 | 512 | $record->container = $container->id; |
513 | 513 | } |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | |
520 | 520 | $editor = new AppEditor($App); |
521 | 521 | $editor->setHiddenValue('tg', $App->controllerTg); |
522 | - if($record->id){ |
|
522 | + if ($record->id) { |
|
523 | 523 | $editor->setHiddenValue('data[id]', $record->id); |
524 | 524 | } |
525 | 525 | $editor->setName('data'); |
@@ -535,16 +535,16 @@ discard block |
||
535 | 535 | |
536 | 536 | $options = array(); |
537 | 537 | $rank = 1; |
538 | - foreach ($containers as $container){ |
|
538 | + foreach ($containers as $container) { |
|
539 | 539 | $options[$container->id] = sprintf('%d (%s)', $rank, $container->name); |
540 | - $rank ++; |
|
540 | + $rank++; |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | $containerSections = $customSectionSet->select($customSectionSet->container->is($container->id)) |
544 | 544 | ->orderDesc($customSectionSet->rank); |
545 | 545 | |
546 | 546 | $nbSections = 0; |
547 | - foreach ($containerSections as $containerSection){ |
|
547 | + foreach ($containerSections as $containerSection) { |
|
548 | 548 | $nbSections = $containerSection->rank + 1; |
549 | 549 | break; |
550 | 550 | } |
@@ -628,10 +628,10 @@ discard block |
||
628 | 628 | $record = $recordSet->request($id); |
629 | 629 | |
630 | 630 | $object = $record->object; |
631 | - if(empty($object)){ |
|
631 | + if (empty($object)) { |
|
632 | 632 | $object = $record->container()->object; |
633 | 633 | } |
634 | - if(strpos($object, $App->classPrefix) !== false){ |
|
634 | + if (strpos($object, $App->classPrefix) !== false) { |
|
635 | 635 | $object = str_replace($App->classPrefix, '', $object); |
636 | 636 | } |
637 | 637 | $object .= 'Set'; |
@@ -646,25 +646,25 @@ discard block |
||
646 | 646 | $manySets = $objectRecordSet->getHasManyRelations(); |
647 | 647 | $oneSets = $objectRecordSet->getHasOneRelations(); |
648 | 648 | |
649 | - if(! empty($record->visibilityCriteria)){ |
|
649 | + if (!empty($record->visibilityCriteria)) { |
|
650 | 650 | $arrCriteria = json_decode($record->visibilityCriteria, true); |
651 | 651 | |
652 | 652 | $data = array(); |
653 | - foreach ($arrCriteria as $fieldName => $operation){ |
|
653 | + foreach ($arrCriteria as $fieldName => $operation) { |
|
654 | 654 | $data['field'] = $fieldName; |
655 | - foreach ($operation as $condition => $value){ |
|
655 | + foreach ($operation as $condition => $value) { |
|
656 | 656 | $data['condition']['default'] = $condition; |
657 | 657 | $data['condition']['bool'] = $condition; |
658 | - if(is_array($value)){ |
|
659 | - foreach ($value as $key => $subValue){ |
|
660 | - foreach ($manySets as $manyFieldName => $manyRelation){ |
|
661 | - if($key . 'Set' == $manyRelation->getForeignSetClassName()){ |
|
662 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
663 | - if($subFieldName === '_foreignField'){ |
|
658 | + if (is_array($value)) { |
|
659 | + foreach ($value as $key => $subValue) { |
|
660 | + foreach ($manySets as $manyFieldName => $manyRelation) { |
|
661 | + if ($key.'Set' == $manyRelation->getForeignSetClassName()) { |
|
662 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
663 | + if ($subFieldName === '_foreignField') { |
|
664 | 664 | continue; |
665 | 665 | } |
666 | 666 | $data['field'] = "{$manyFieldName}/{$subFieldName}"; |
667 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
667 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
668 | 668 | $data['condition']['default'] = $subCondition; |
669 | 669 | $data['condition']['bool'] = $subCondition; |
670 | 670 | $value = $subConditionValue; |
@@ -673,14 +673,14 @@ discard block |
||
673 | 673 | break; |
674 | 674 | } |
675 | 675 | } |
676 | - foreach ($oneSets as $oneFieldName => $oneRelation){ |
|
677 | - if($key . 'Set' == $oneRelation->getForeignSetClassName()){ |
|
678 | - foreach ($subValue as $subFieldName => $subConditions){ |
|
679 | - if($subFieldName === '_foreignField'){ |
|
676 | + foreach ($oneSets as $oneFieldName => $oneRelation) { |
|
677 | + if ($key.'Set' == $oneRelation->getForeignSetClassName()) { |
|
678 | + foreach ($subValue as $subFieldName => $subConditions) { |
|
679 | + if ($subFieldName === '_foreignField') { |
|
680 | 680 | continue; |
681 | 681 | } |
682 | 682 | $data['field'] = "{$oneFieldName}/{$subFieldName}"; |
683 | - foreach ($subConditions as $subCondition => $subConditionValue){ |
|
683 | + foreach ($subConditions as $subCondition => $subConditionValue) { |
|
684 | 684 | $data['condition']['default'] = $subCondition; |
685 | 685 | $data['condition']['bool'] = $subCondition; |
686 | 686 | $value = $subConditionValue; |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | */ |
716 | 716 | public function save($data = null) |
717 | 717 | { |
718 | - if(! isset($data['id']) && isset($data['container']) && $data['container'] != 0 && ! isset($data['rank'])){ |
|
718 | + if (!isset($data['id']) && isset($data['container']) && $data['container'] != 0 && !isset($data['rank'])) { |
|
719 | 719 | $set = $this->getRecordSet(); |
720 | 720 | $data['rank'] = $set->select($set->container->is($data['container'])) |
721 | 721 | ->count(); |
@@ -748,11 +748,11 @@ discard block |
||
748 | 748 | $set->rank->greaterThanOrEqual($record->rank) |
749 | 749 | ))); |
750 | 750 | |
751 | - $position ++; |
|
752 | - foreach ($afterSections as $afterSection){ |
|
751 | + $position++; |
|
752 | + foreach ($afterSections as $afterSection) { |
|
753 | 753 | $afterSection->rank = $position; |
754 | 754 | $afterSection->save(); |
755 | - $position ++; |
|
755 | + $position++; |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | |
@@ -780,10 +780,10 @@ discard block |
||
780 | 780 | $record = $recordSet->request($data['id']); |
781 | 781 | |
782 | 782 | $object = $record->object; |
783 | - if(empty($object)){ |
|
783 | + if (empty($object)) { |
|
784 | 784 | $object = $record->container()->object; |
785 | 785 | } |
786 | - if(strpos($object, $App->classPrefix) !== false){ |
|
786 | + if (strpos($object, $App->classPrefix) !== false) { |
|
787 | 787 | $object = str_replace($App->classPrefix, '', $object); |
788 | 788 | } |
789 | 789 | $object .= 'Set'; |
@@ -793,14 +793,14 @@ discard block |
||
793 | 793 | $field = $data['field']; |
794 | 794 | $condition = $data['condition']; |
795 | 795 | |
796 | - if(strpos($field, '/') !== false){ |
|
796 | + if (strpos($field, '/') !== false) { |
|
797 | 797 | // The selected field is a hasMany or a hasOne relation |
798 | 798 | list ($selectedRelation, $selectedField) = explode('/', $field); |
799 | 799 | $classPrefix = $App->classPrefix; |
800 | 800 | |
801 | 801 | $manyRelations = $objectRecordSet->getHasManyRelations(); |
802 | - foreach ($manyRelations as $manyRelation){ |
|
803 | - if($selectedRelation != $manyRelation->getOwnerSetFieldName()){ |
|
802 | + foreach ($manyRelations as $manyRelation) { |
|
803 | + if ($selectedRelation != $manyRelation->getOwnerSetFieldName()) { |
|
804 | 804 | continue; |
805 | 805 | } |
806 | 806 | $foreignSetName = str_replace($classPrefix, '', $manyRelation->getForeignSetClassName()); |
@@ -808,13 +808,13 @@ discard block |
||
808 | 808 | |
809 | 809 | $visibilityCriteria = ''; |
810 | 810 | |
811 | - if($foreignSet){ |
|
811 | + if ($foreignSet) { |
|
812 | 812 | $selectedManyField = $foreignSet->$selectedField; |
813 | 813 | |
814 | - if($selectedManyField instanceof ORMBoolInterface){ |
|
814 | + if ($selectedManyField instanceof ORMBoolInterface) { |
|
815 | 815 | $condition = $condition['bool']; |
816 | 816 | } |
817 | - else{ |
|
817 | + else { |
|
818 | 818 | $condition = $condition['default']; |
819 | 819 | } |
820 | 820 | |
@@ -826,9 +826,9 @@ discard block |
||
826 | 826 | } |
827 | 827 | |
828 | 828 | $oneRelations = $objectRecordSet->getHasOneRelations(); |
829 | - foreach ($oneRelations as $oneRelation){ |
|
829 | + foreach ($oneRelations as $oneRelation) { |
|
830 | 830 | /* @var $oneRelation ORMOneRelation*/ |
831 | - if($selectedRelation != $oneRelation->getOwnerSetFieldName()){ |
|
831 | + if ($selectedRelation != $oneRelation->getOwnerSetFieldName()) { |
|
832 | 832 | continue; |
833 | 833 | } |
834 | 834 | $foreignSetClassName = $oneRelation->getForeignSetClassName(); |
@@ -837,13 +837,13 @@ discard block |
||
837 | 837 | |
838 | 838 | $visibilityCriteria = ''; |
839 | 839 | |
840 | - if($foreignSet){ |
|
840 | + if ($foreignSet) { |
|
841 | 841 | $selectedOneField = $foreignSet->$selectedField; |
842 | 842 | |
843 | - if($selectedOneField instanceof ORMBoolInterface){ |
|
843 | + if ($selectedOneField instanceof ORMBoolInterface) { |
|
844 | 844 | $condition = $condition['bool']; |
845 | 845 | } |
846 | - else{ |
|
846 | + else { |
|
847 | 847 | $condition = $condition['default']; |
848 | 848 | } |
849 | 849 | |
@@ -853,20 +853,20 @@ discard block |
||
853 | 853 | break; |
854 | 854 | } |
855 | 855 | } |
856 | - else{ |
|
856 | + else { |
|
857 | 857 | |
858 | 858 | $field = $objectRecordSet->$field; |
859 | 859 | |
860 | - if($field instanceof ORMBoolInterface){ |
|
860 | + if ($field instanceof ORMBoolInterface) { |
|
861 | 861 | $condition = $condition['bool']; |
862 | 862 | } |
863 | - else{ |
|
863 | + else { |
|
864 | 864 | $condition = $condition['default']; |
865 | 865 | } |
866 | 866 | |
867 | 867 | $visibilityCriteria = ''; |
868 | 868 | |
869 | - if(! empty($condition)){ |
|
869 | + if (!empty($condition)) { |
|
870 | 870 | $criteria = $field->{$condition}($data['value']); |
871 | 871 | $visibilityCriteria = $criteria->toJson(); |
872 | 872 | } |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | $customContainer = $customContainerSet->request($container); |
896 | 896 | |
897 | 897 | $object = $customContainer->object; |
898 | - if(strpos($object, $App->classPrefix) !== false){ |
|
898 | + if (strpos($object, $App->classPrefix) !== false) { |
|
899 | 899 | list (, $object) = explode($App->classPrefix, $object); |
900 | 900 | } |
901 | 901 | |
@@ -922,17 +922,17 @@ discard block |
||
922 | 922 | |
923 | 923 | $nbCol = 0; |
924 | 924 | |
925 | - foreach ($customSections as $customSection){ |
|
925 | + foreach ($customSections as $customSection) { |
|
926 | 926 | |
927 | - list (, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
927 | + list (,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
928 | 928 | |
929 | 929 | $currentColumn += $nbCol; |
930 | 930 | |
931 | - $sectionSection = $W->Section($customSection->name . ' (' . $customSection->rank . ')', $sectionBox = $W->VBoxItems($W->Hidden() |
|
932 | - ->setName('#' . $customSection->id))); |
|
931 | + $sectionSection = $W->Section($customSection->name.' ('.$customSection->rank.')', $sectionBox = $W->VBoxItems($W->Hidden() |
|
932 | + ->setName('#'.$customSection->id))); |
|
933 | 933 | $sectionSection->addClass('app-custom-section'); |
934 | 934 | $sectionSection->addClass($customSection->classname); |
935 | - $sectionSection->setSizePolicy($customSection->sizePolicy . ' widget-sameheight'); |
|
935 | + $sectionSection->setSizePolicy($customSection->sizePolicy.' widget-sameheight'); |
|
936 | 936 | |
937 | 937 | $row->addItem($sectionSection); |
938 | 938 | |
@@ -950,40 +950,40 @@ discard block |
||
950 | 950 | ->addClass('icon', \Func_Icons::ACTIONS_EDIT_DELETE) |
951 | 951 | ->setOpenMode(WidgetLink::OPEN_DIALOG) |
952 | 952 | ->setDialogClass('box red'))); |
953 | - if(! empty($customSection->visibilityCriteria)){ |
|
953 | + if (!empty($customSection->visibilityCriteria)) { |
|
954 | 954 | $sectionBox->addItem($W->HBoxItems($W->Label($App->translate('This section has a visibility condition'))) |
955 | 955 | ->setSizePolicy('alert alert-warning widget-100pc')); |
956 | 956 | } |
957 | 957 | $fields = $customSection->getFields(); |
958 | - if(count($fields) == 0){ |
|
958 | + if (count($fields) == 0) { |
|
959 | 959 | $sectionBox->addItem($W->HBoxItems($W->Label($App->translate('This section does not contain any field'))) |
960 | 960 | ->setSizePolicy('alert alert-warning')); |
961 | 961 | } |
962 | - foreach ($fields as $fieldId => $field){ |
|
963 | - if(empty($field)){ |
|
962 | + foreach ($fields as $fieldId => $field) { |
|
963 | + if (empty($field)) { |
|
964 | 964 | continue; |
965 | 965 | } |
966 | 966 | |
967 | 967 | $fieldName = $field['fieldname']; |
968 | 968 | |
969 | 969 | $isFieldsGroup = false; |
970 | - if(strpos($fieldName, '_fieldsGroup') !== false){ |
|
970 | + if (strpos($fieldName, '_fieldsGroup') !== false) { |
|
971 | 971 | $fieldName = '_fieldsGroup'; |
972 | 972 | $isFieldsGroup = true; |
973 | 973 | } |
974 | 974 | |
975 | 975 | $field = $availableFields[$fieldName]; |
976 | 976 | $fieldDescription = $field['description']; |
977 | - if(substr($fieldName, 0, 1) !== '_'){ |
|
977 | + if (substr($fieldName, 0, 1) !== '_') { |
|
978 | 978 | $fieldDescription = $App->translate($fieldDescription); |
979 | 979 | } |
980 | 980 | |
981 | - if(empty($field)){ |
|
981 | + if (empty($field)) { |
|
982 | 982 | continue; |
983 | 983 | } |
984 | 984 | |
985 | 985 | $fieldName = $field['name']; |
986 | - if($isFieldsGroup){ |
|
986 | + if ($isFieldsGroup) { |
|
987 | 987 | $fieldName = $fieldId; |
988 | 988 | } |
989 | 989 | |
@@ -994,20 +994,20 @@ discard block |
||
994 | 994 | ->setGrowable(true) |
995 | 995 | ->setWrap(WidgetFlexLayout::FLEX_WRAP_WRAP)) |
996 | 996 | ->setSizePolicy('maximum'), $btnBox = $W->HBoxItems($W->Hidden() |
997 | - ->setName($customSection->id . '.' . $fieldId) |
|
997 | + ->setName($customSection->id.'.'.$fieldId) |
|
998 | 998 | ->setValue($fieldName)) |
999 | 999 | ->addClass('widget-actions')) |
1000 | 1000 | ->setSizePolicy('widget-list-element widget-actions-target') |
1001 | 1001 | ->addClass(\Func_Icons::ICON_LEFT_16); |
1002 | - if(strpos($field['name'], '_fieldsGroup') !== false){ |
|
1002 | + if (strpos($field['name'], '_fieldsGroup') !== false) { |
|
1003 | 1003 | $btnBox->addItem($W->Link('', $customSectionCtrl->addDisplayFieldToGroup($customSection->id, $fieldName)) |
1004 | 1004 | ->addClass('icon', \Func_Icons::ACTIONS_LIST_ADD) |
1005 | 1005 | ->setOpenMode(WidgetLink::OPEN_DIALOG)); |
1006 | 1006 | $groupedFields = $fields[$fieldName]['fields']; |
1007 | - foreach ($groupedFields as $groupedField){ |
|
1007 | + foreach ($groupedFields as $groupedField) { |
|
1008 | 1008 | $groupedFieldDetails = $availableFields[$groupedField['fieldname']]; |
1009 | 1009 | $fieldGroupBox->addItem($flexField = $W->FlowItems($W->Hidden(null, array( |
1010 | - $customSection->id . '.fieldsGroups', |
|
1010 | + $customSection->id.'.fieldsGroups', |
|
1011 | 1011 | $fieldName, |
1012 | 1012 | $groupedField['fieldname'] |
1013 | 1013 | ), $groupedField['fieldname']), $W->Label($groupedFieldDetails['description']), $W->FlowItems($W->Link('', $customSectionCtrl->editGroupFieldDisplayField($customSection->id, $fieldName, $groupedField['fieldname'])) |
@@ -1035,23 +1035,23 @@ discard block |
||
1035 | 1035 | $sectionsBoxes[] = $sectionBox; |
1036 | 1036 | } |
1037 | 1037 | |
1038 | - if($currentColumn + $nbCol > 0){ |
|
1038 | + if ($currentColumn + $nbCol > 0) { |
|
1039 | 1039 | $sectionsSection->addItem($row); |
1040 | 1040 | } |
1041 | 1041 | |
1042 | - foreach ($sectionsBoxes as $sectionsBox){ |
|
1042 | + foreach ($sectionsBoxes as $sectionsBox) { |
|
1043 | 1043 | $sectionsBox->sortable(true, $sectionsBoxes); |
1044 | 1044 | $sectionsBox->setMetadata('samePlaceholderSize', true); |
1045 | 1045 | } |
1046 | 1046 | |
1047 | - foreach ($rows as $row){ |
|
1047 | + foreach ($rows as $row) { |
|
1048 | 1048 | $row->sortable(true, $rows); |
1049 | 1049 | $row->setMetadata('samePlaceholderSize', true); |
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | $form = $W->Form(); |
1053 | 1053 | |
1054 | - if(isset($itemId)){ |
|
1054 | + if (isset($itemId)) { |
|
1055 | 1055 | $form->setId($itemId); |
1056 | 1056 | } |
1057 | 1057 | $form->setHiddenValue('tg', $App->controllerTg); |
@@ -1078,7 +1078,7 @@ discard block |
||
1078 | 1078 | $customSections = $customSectionSet->select($customSectionSet->container->is($container)); |
1079 | 1079 | |
1080 | 1080 | $sectionsValues = array(); |
1081 | - foreach ($customSections as $customSection){ |
|
1081 | + foreach ($customSections as $customSection) { |
|
1082 | 1082 | $values = $customSection->getValues(); |
1083 | 1083 | unset($values['id']); |
1084 | 1084 | unset($values['createdBy']); |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | header('Content-type: application/json'); |
1095 | - header('Content-Disposition: attachment; filename="' . $container->object . '.' . ($container->view === '' ? 'default' : $container->view) . '.' . $container->name . '.json"' . "\n"); |
|
1095 | + header('Content-Disposition: attachment; filename="'.$container->object.'.'.($container->view === '' ? 'default' : $container->view).'.'.$container->name.'.json"'."\n"); |
|
1096 | 1096 | |
1097 | 1097 | $json = bab_json_encode($sectionsValues); |
1098 | 1098 | $json = bab_convertStringFromDatabase($json, \bab_charset::UTF_8); |
@@ -1144,12 +1144,12 @@ discard block |
||
1144 | 1144 | $files->push($sectionsfile['uid']); |
1145 | 1145 | |
1146 | 1146 | $data = null; |
1147 | - foreach ($files as $f){ |
|
1147 | + foreach ($files as $f) { |
|
1148 | 1148 | $data = file_get_contents($f->toString()); |
1149 | 1149 | break; |
1150 | 1150 | } |
1151 | 1151 | |
1152 | - if(! isset($data)){ |
|
1152 | + if (!isset($data)) { |
|
1153 | 1153 | $this->addError($App->translate('Unable to get file content')); |
1154 | 1154 | return true; |
1155 | 1155 | } |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | |
1162 | 1162 | $customSectionSet->delete($customSectionSet->container->is($container)); |
1163 | 1163 | |
1164 | - foreach ($sectionsValues as $sectionValues){ |
|
1164 | + foreach ($sectionsValues as $sectionValues) { |
|
1165 | 1165 | $customSection = $customSectionSet->newRecord(); |
1166 | 1166 | $customSection->setValues($sectionValues); |
1167 | 1167 | $customSection->container = $container; |
@@ -1239,59 +1239,59 @@ discard block |
||
1239 | 1239 | $ranks = array(); |
1240 | 1240 | $rank = 0; |
1241 | 1241 | |
1242 | - foreach ($sections as $key => $value){ |
|
1242 | + foreach ($sections as $key => $value) { |
|
1243 | 1243 | // Sections ids start with #, while section fields start with their original section id |
1244 | - if(substr($key, 0, 1) === '#'){ |
|
1244 | + if (substr($key, 0, 1) === '#') { |
|
1245 | 1245 | $currentSectionId = substr($key, 1); |
1246 | 1246 | $rawSectionData[$currentSectionId] = array(); |
1247 | - if(! isset($oldSectionId)){ |
|
1247 | + if (!isset($oldSectionId)) { |
|
1248 | 1248 | $oldSectionId = $currentSectionId; |
1249 | 1249 | } |
1250 | - if(isset($currentSection) && $oldSectionId != $currentSectionId){ |
|
1250 | + if (isset($currentSection) && $oldSectionId != $currentSectionId) { |
|
1251 | 1251 | $oldSectionId = $currentSectionId; |
1252 | 1252 | } |
1253 | 1253 | $ranks[$currentSectionId] = $rank; |
1254 | - $rank ++; |
|
1254 | + $rank++; |
|
1255 | 1255 | $currentSection = $customSectionSet->get($customSectionSet->id->is($currentSectionId)); |
1256 | 1256 | continue; |
1257 | 1257 | } |
1258 | - if(! isset($currentSection)){ |
|
1258 | + if (!isset($currentSection)) { |
|
1259 | 1259 | continue; |
1260 | 1260 | } |
1261 | 1261 | list ($fieldSectionId, $fieldName) = explode('.', $key); |
1262 | - if($fieldSectionId == $currentSectionId){ |
|
1262 | + if ($fieldSectionId == $currentSectionId) { |
|
1263 | 1263 | $field = $currentSection->getField($fieldName); |
1264 | - if(strpos($fieldName, '_fieldsGroup') !== false){ |
|
1264 | + if (strpos($fieldName, '_fieldsGroup') !== false) { |
|
1265 | 1265 | $rawSectionData[$currentSectionId][$fieldName]['block'] = $field['block']; |
1266 | 1266 | $rawSectionData[$currentSectionId][$fieldName]['fieldname'] = '_fieldsGroup'; |
1267 | 1267 | $rawSectionData[$currentSectionId][$fieldName]['parameters'] = $field['parameters']; |
1268 | - foreach ($sections[$currentSection->id . '.fieldsGroups'][$fieldName] as $subKey => $subValue){ |
|
1268 | + foreach ($sections[$currentSection->id.'.fieldsGroups'][$fieldName] as $subKey => $subValue) { |
|
1269 | 1269 | $rawSectionData[$currentSectionId][$fieldName]['fields'][$subKey] = $field['fields'][$subKey]; |
1270 | 1270 | } |
1271 | 1271 | } |
1272 | - elseif($fieldName != 'fieldsGroups'){ |
|
1272 | + elseif ($fieldName != 'fieldsGroups') { |
|
1273 | 1273 | $rawSectionData[$currentSectionId][$fieldName] = $field; |
1274 | 1274 | } |
1275 | 1275 | } |
1276 | - else{ |
|
1276 | + else { |
|
1277 | 1277 | $field = null; |
1278 | 1278 | $tmpSection = $customSectionSet->get($customSectionSet->id->is($fieldSectionId)); |
1279 | - if($tmpSection){ |
|
1279 | + if ($tmpSection) { |
|
1280 | 1280 | $field = $tmpSection->getField($fieldName); |
1281 | 1281 | } |
1282 | - if(isset($field)){ |
|
1282 | + if (isset($field)) { |
|
1283 | 1283 | $rawSectionData[$currentSectionId][$fieldName] = $field; |
1284 | 1284 | } |
1285 | 1285 | } |
1286 | 1286 | } |
1287 | 1287 | |
1288 | - foreach ($rawSectionData as $sectionId => $fields){ |
|
1288 | + foreach ($rawSectionData as $sectionId => $fields) { |
|
1289 | 1289 | $section = $customSectionSet->get($customSectionSet->id->is($sectionId)); |
1290 | - if($section){ |
|
1290 | + if ($section) { |
|
1291 | 1291 | $section->fields = json_encode($fields); |
1292 | 1292 | $section->rank = isset($ranks[$sectionId]) ? $ranks[$sectionId] : 0; |
1293 | 1293 | $section->save(); |
1294 | - $rank ++; |
|
1294 | + $rank++; |
|
1295 | 1295 | } |
1296 | 1296 | } |
1297 | 1297 |
@@ -506,8 +506,7 @@ discard block |
||
506 | 506 | $customSectionSet = $App->CustomSectionSet(); |
507 | 507 | if(isset($id)){ |
508 | 508 | $record = $customSectionSet->request($id); |
509 | - } |
|
510 | - else{ |
|
509 | + } else{ |
|
511 | 510 | $record = $customSectionSet->newRecord(); |
512 | 511 | $record->container = $container->id; |
513 | 512 | } |
@@ -813,8 +812,7 @@ discard block |
||
813 | 812 | |
814 | 813 | if($selectedManyField instanceof ORMBoolInterface){ |
815 | 814 | $condition = $condition['bool']; |
816 | - } |
|
817 | - else{ |
|
815 | + } else{ |
|
818 | 816 | $condition = $condition['default']; |
819 | 817 | } |
820 | 818 | |
@@ -842,8 +840,7 @@ discard block |
||
842 | 840 | |
843 | 841 | if($selectedOneField instanceof ORMBoolInterface){ |
844 | 842 | $condition = $condition['bool']; |
845 | - } |
|
846 | - else{ |
|
843 | + } else{ |
|
847 | 844 | $condition = $condition['default']; |
848 | 845 | } |
849 | 846 | |
@@ -852,15 +849,13 @@ discard block |
||
852 | 849 | } |
853 | 850 | break; |
854 | 851 | } |
855 | - } |
|
856 | - else{ |
|
852 | + } else{ |
|
857 | 853 | |
858 | 854 | $field = $objectRecordSet->$field; |
859 | 855 | |
860 | 856 | if($field instanceof ORMBoolInterface){ |
861 | 857 | $condition = $condition['bool']; |
862 | - } |
|
863 | - else{ |
|
858 | + } else{ |
|
864 | 859 | $condition = $condition['default']; |
865 | 860 | } |
866 | 861 | |
@@ -1268,12 +1263,10 @@ discard block |
||
1268 | 1263 | foreach ($sections[$currentSection->id . '.fieldsGroups'][$fieldName] as $subKey => $subValue){ |
1269 | 1264 | $rawSectionData[$currentSectionId][$fieldName]['fields'][$subKey] = $field['fields'][$subKey]; |
1270 | 1265 | } |
1271 | - } |
|
1272 | - elseif($fieldName != 'fieldsGroups'){ |
|
1266 | + } elseif($fieldName != 'fieldsGroups'){ |
|
1273 | 1267 | $rawSectionData[$currentSectionId][$fieldName] = $field; |
1274 | 1268 | } |
1275 | - } |
|
1276 | - else{ |
|
1269 | + } else{ |
|
1277 | 1270 | $field = null; |
1278 | 1271 | $tmpSection = $customSectionSet->get($customSectionSet->id->is($fieldSectionId)); |
1279 | 1272 | if($tmpSection){ |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | use Capwelton\LibApp\Func_App; |
40 | 40 | use Capwelton\LibApp\AppComponent; |
41 | 41 | use Capwelton\LibOrm\Exceptions\ORMException; |
42 | -require_once $GLOBALS['babInstallPath'] . 'utilit/controller.class.php'; |
|
43 | -require_once $GLOBALS['babInstallPath'] . 'utilit/json.php'; |
|
42 | +require_once $GLOBALS['babInstallPath'].'utilit/controller.class.php'; |
|
43 | +require_once $GLOBALS['babInstallPath'].'utilit/json.php'; |
|
44 | 44 | |
45 | -require_once dirname(__FILE__) . '/../functions.php'; |
|
45 | +require_once dirname(__FILE__).'/../functions.php'; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @method self proxy() |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function addReloadSelector($reloadSelector, $withSSE = false, $for = null) |
75 | 75 | { |
76 | 76 | $this->reloadSelectors[$reloadSelector] = $reloadSelector; |
77 | - if($withSSE){ |
|
77 | + if ($withSSE) { |
|
78 | 78 | $sseRecordSet = $this->getSSERecordSet(); |
79 | 79 | $sseRecordSet->newReloadSelector($reloadSelector, $for); |
80 | 80 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | public function getSSERecordSet() |
93 | 93 | { |
94 | - if(isset($this->SSERecordSet)){ |
|
94 | + if (isset($this->SSERecordSet)) { |
|
95 | 95 | return $this->SSERecordSet; |
96 | 96 | } |
97 | 97 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | public function __call($name, $arguments = array()) |
131 | 131 | { |
132 | 132 | $component = $this->App()->getComponentByName($name); |
133 | - if($component){ |
|
133 | + if ($component) { |
|
134 | 134 | return call_user_func_array(array( |
135 | 135 | $component, |
136 | 136 | 'controller' |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function isAjaxRequest() |
175 | 175 | { |
176 | - if(! isset($this->isAjaxRequest)){ |
|
176 | + if (!isset($this->isAjaxRequest)) { |
|
177 | 177 | $this->isAjaxRequest = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); |
178 | 178 | } |
179 | 179 | return $this->isAjaxRequest; |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function requireCredential($message = null) |
187 | 187 | { |
188 | - if($this->isAjaxRequest()){ |
|
188 | + if ($this->isAjaxRequest()) { |
|
189 | 189 | $authType = 'Basic'; |
190 | 190 | } |
191 | - else{ |
|
191 | + else { |
|
192 | 192 | $authType = ''; |
193 | 193 | } |
194 | 194 | |
195 | - if(! isset($message)){ |
|
195 | + if (!isset($message)) { |
|
196 | 196 | $message = $this->App()->translate('You must be logged in to access this page.'); |
197 | 197 | } |
198 | 198 | |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | list ($prefix) = explode('_', __CLASS__); |
217 | 217 | $functionalityName = ucwords($prefix); |
218 | 218 | /** @var Func_App */ |
219 | - $App = @\bab_functionality::get('App/' . $functionalityName); |
|
219 | + $App = @\bab_functionality::get('App/'.$functionalityName); |
|
220 | 220 | |
221 | - if(!$App){ |
|
222 | - throw new AppException('Faild to autodetect functionality App/' . $functionalityName . ', the getInstance method is deprecated, use $App->ControllerProxy() instead'); |
|
221 | + if (!$App) { |
|
222 | + throw new AppException('Faild to autodetect functionality App/'.$functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | $controller = $App->ControllerProxy($classname, $proxy); |
@@ -237,44 +237,44 @@ discard block |
||
237 | 237 | static function getProxyInstance(Func_App $App, $classname) |
238 | 238 | { |
239 | 239 | $class = new \ReflectionClass($classname); |
240 | - $proxyClassname = $class->getShortName() . self::PROXY_CLASS_SUFFIX; |
|
240 | + $proxyClassname = $class->getShortName().self::PROXY_CLASS_SUFFIX; |
|
241 | 241 | $finalProxyClassname = $class->getNamespaceName()."\\".$proxyClassname; |
242 | - if(! class_exists($finalProxyClassname)){ |
|
242 | + if (!class_exists($finalProxyClassname)) { |
|
243 | 243 | $classStr = ""; |
244 | - if($class->getNamespaceName() != ""){ |
|
244 | + if ($class->getNamespaceName() != "") { |
|
245 | 245 | $classStr .= " namespace ".$class->getNamespaceName()."; "; |
246 | 246 | } |
247 | - $classStr .= 'class ' . $proxyClassname . ' extends ' . $class->getShortName() . ' {' . "\n"; |
|
247 | + $classStr .= 'class '.$proxyClassname.' extends '.$class->getShortName().' {'."\n"; |
|
248 | 248 | $methods = $class->getMethods(); |
249 | 249 | |
250 | 250 | $classStr .= ' public function __construct($App) { |
251 | 251 | $this->setApp($App); |
252 | 252 | }' . "\n"; |
253 | 253 | |
254 | - foreach ($methods as $method){ |
|
255 | - if($method->name === '__construct' || ! $method->isPublic() || $method->isStatic() || $method->isFinal() || $method->name === 'setApp' || $method->name === 'App' || $method->name === 'setCrm' || $method->name === 'Crm'){ |
|
254 | + foreach ($methods as $method) { |
|
255 | + if ($method->name === '__construct' || !$method->isPublic() || $method->isStatic() || $method->isFinal() || $method->name === 'setApp' || $method->name === 'App' || $method->name === 'setCrm' || $method->name === 'Crm') { |
|
256 | 256 | continue; |
257 | 257 | } |
258 | 258 | |
259 | - $classStr .= ' public function ' . $method->name . '('; |
|
259 | + $classStr .= ' public function '.$method->name.'('; |
|
260 | 260 | $parameters = $method->getParameters(); |
261 | 261 | $parametersStr = array(); |
262 | - foreach ($parameters as $parameter){ |
|
262 | + foreach ($parameters as $parameter) { |
|
263 | 263 | |
264 | - if($parameter->isDefaultValueAvailable()){ |
|
265 | - $parametersStr[] = '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true); |
|
264 | + if ($parameter->isDefaultValueAvailable()) { |
|
265 | + $parametersStr[] = '$'.$parameter->name.' = '.var_export($parameter->getDefaultValue(), true); |
|
266 | 266 | } |
267 | - else{ |
|
268 | - $parametersStr[] = '$' . $parameter->name; |
|
267 | + else { |
|
268 | + $parametersStr[] = '$'.$parameter->name; |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | $classStr .= implode(', ', $parametersStr); |
272 | - $classStr .= ') {' . "\n"; |
|
273 | - $classStr .= ' $args = func_get_args();' . "\n"; |
|
274 | - $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);' . "\n"; |
|
275 | - $classStr .= ' }' . "\n"; |
|
272 | + $classStr .= ') {'."\n"; |
|
273 | + $classStr .= ' $args = func_get_args();'."\n"; |
|
274 | + $classStr .= ' return $this->getMethodAction(__FUNCTION__, $args);'."\n"; |
|
275 | + $classStr .= ' }'."\n"; |
|
276 | 276 | } |
277 | - $classStr .= '}' . "\n"; |
|
277 | + $classStr .= '}'."\n"; |
|
278 | 278 | // We define the proxy class |
279 | 279 | eval($classStr); |
280 | 280 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | protected function getObjectName($classname) |
313 | 313 | { |
314 | 314 | list ($objectname) = explode('Controller', $classname); |
315 | - if($this->App()->getComponentByName($objectname)){ |
|
315 | + if ($this->App()->getComponentByName($objectname)) { |
|
316 | 316 | return strtolower($objectname); |
317 | 317 | } |
318 | 318 | list (, $objectname) = explode('Ctrl', $classname); |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | |
335 | 335 | $reflector = new \ReflectionClass(get_class($this)); |
336 | 336 | $parent = $reflector->getParentClass(); |
337 | - if($parent){ |
|
337 | + if ($parent) { |
|
338 | 338 | $parentMethod = $parent->getMethod('__construct'); |
339 | 339 | $docComment = $parentMethod->getDocComment(); |
340 | - if(strpos($docComment, '@isComponentController') !== false){ |
|
340 | + if (strpos($docComment, '@isComponentController') !== false) { |
|
341 | 341 | $fullClassName = $parent->getName(); |
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | 345 | $rc = new \ReflectionClass($fullClassName); |
346 | 346 | |
347 | - if(! $rc->hasMethod($methodName)){ |
|
348 | - throw new \bab_InvalidActionException($fullClassName . '::' . $methodName); |
|
347 | + if (!$rc->hasMethod($methodName)) { |
|
348 | + throw new \bab_InvalidActionException($fullClassName.'::'.$methodName); |
|
349 | 349 | } |
350 | 350 | $method = new \ReflectionMethod($fullClassName, $methodName); |
351 | 351 | |
@@ -354,32 +354,32 @@ discard block |
||
354 | 354 | $parameters = $method->getParameters(); |
355 | 355 | $actionParams = array(); |
356 | 356 | $argNumber = 0; |
357 | - foreach ($parameters as $parameter){ |
|
357 | + foreach ($parameters as $parameter) { |
|
358 | 358 | $parameterName = $parameter->getName(); |
359 | - if(isset($args[$argNumber])){ |
|
359 | + if (isset($args[$argNumber])) { |
|
360 | 360 | $actionParams[$parameterName] = $args[$argNumber]; |
361 | 361 | } |
362 | - elseif($parameter->isDefaultValueAvailable()){ |
|
362 | + elseif ($parameter->isDefaultValueAvailable()) { |
|
363 | 363 | $actionParams[$parameterName] = $parameter->getDefaultValue(); |
364 | 364 | } |
365 | - else{ |
|
365 | + else { |
|
366 | 366 | $actionParams[$parameterName] = null; |
367 | 367 | } |
368 | - $argNumber ++; |
|
368 | + $argNumber++; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $action = new WidgetAction(); |
372 | 372 | |
373 | - $action->setMethod($this->getControllerTg(), $objectName . '.' . $methodName, $actionParams); |
|
373 | + $action->setMethod($this->getControllerTg(), $objectName.'.'.$methodName, $actionParams); |
|
374 | 374 | |
375 | 375 | $docComment = $method->getDocComment(); |
376 | - if(strpos($docComment, '@ajax') !== false){ |
|
376 | + if (strpos($docComment, '@ajax') !== false) { |
|
377 | 377 | $action->setAjax(true); |
378 | 378 | } |
379 | - if(strpos($docComment, '@requireSaveMethod') !== false && method_exists($action, 'setRequireSaveMethod')){ |
|
379 | + if (strpos($docComment, '@requireSaveMethod') !== false && method_exists($action, 'setRequireSaveMethod')) { |
|
380 | 380 | $action->setRequireSaveMethod(true); |
381 | 381 | } |
382 | - if(strpos($docComment, '@requireDeleteMethod') !== false && method_exists($action, 'setRequireDeleteMethod')){ |
|
382 | + if (strpos($docComment, '@requireDeleteMethod') !== false && method_exists($action, 'setRequireDeleteMethod')) { |
|
383 | 383 | $action->setRequireDeleteMethod(true); |
384 | 384 | } |
385 | 385 | |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | |
409 | 409 | $action->setParameters($actionParams); |
410 | 410 | |
411 | - list (, , $file) = explode('/', $App->controllerTg); |
|
411 | + list (,, $file) = explode('/', $App->controllerTg); |
|
412 | 412 | |
413 | - $action->setParameter('addon', $App->getAddonName() . '.' . $file); |
|
413 | + $action->setParameter('addon', $App->getAddonName().'.'.$file); |
|
414 | 414 | $action->setParameter('idx', $idx); |
415 | 415 | |
416 | 416 | return $action; |
@@ -428,44 +428,44 @@ discard block |
||
428 | 428 | |
429 | 429 | $method = $action->getMethod(); |
430 | 430 | |
431 | - if(! isset($method) || '' === $method){ |
|
431 | + if (!isset($method) || '' === $method) { |
|
432 | 432 | return false; |
433 | 433 | } |
434 | 434 | |
435 | 435 | list ($objectName,) = explode('.', $method); |
436 | 436 | |
437 | - if(! method_exists($this, $objectName)){ |
|
437 | + if (!method_exists($this, $objectName)) { |
|
438 | 438 | /* @var $component AppComponent */ |
439 | 439 | $component = $this->app->getComponentByName($objectName); |
440 | - if($component){ |
|
440 | + if ($component) { |
|
441 | 441 | $this->app->setCurrentComponent($component); |
442 | 442 | $objectController = $component->controller(false); |
443 | 443 | } |
444 | - else{ |
|
444 | + else { |
|
445 | 445 | header('HTTP/1.0 400 Bad Request'); |
446 | 446 | throw new AppUnknownActionException($action); |
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
450 | - if(! isset($component)){ |
|
450 | + if (!isset($component)) { |
|
451 | 451 | $objectController = $this->{$objectName}(false); |
452 | - if(! ($objectController instanceof AppController)){ |
|
452 | + if (!($objectController instanceof AppController)) { |
|
453 | 453 | return false; |
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | - try{ |
|
457 | + try { |
|
458 | 458 | $returnedValue = $objectController->execAction($action); |
459 | 459 | } |
460 | - catch (AppAccessException $e){ |
|
460 | + catch (AppAccessException $e) { |
|
461 | 461 | |
462 | - if(! bab_isUserLogged() && $e->requireCredential){ |
|
462 | + if (!bab_isUserLogged() && $e->requireCredential) { |
|
463 | 463 | bab_requireCredential($e->getMessage()); |
464 | 464 | } |
465 | - else{ |
|
466 | - if($this->isAjaxRequest()){ |
|
465 | + else { |
|
466 | + if ($this->isAjaxRequest()) { |
|
467 | 467 | |
468 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
468 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
469 | 469 | |
470 | 470 | die(bab_json_encode(array( |
471 | 471 | 'exception' => 'app_AccessException', |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | $this->accessPage($e); |
477 | 477 | } |
478 | 478 | } |
479 | - catch (AppSaveException $e){ |
|
479 | + catch (AppSaveException $e) { |
|
480 | 480 | |
481 | - if($this->isAjaxRequest()){ |
|
482 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
481 | + if ($this->isAjaxRequest()) { |
|
482 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
483 | 483 | header('Cache-Control: no-cache, must-revalidate'); |
484 | 484 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
485 | 485 | header('Content-type: application/json'); |
@@ -491,32 +491,32 @@ discard block |
||
491 | 491 | ))); |
492 | 492 | } |
493 | 493 | } |
494 | - catch (AppDeletedRecordException $e){ |
|
494 | + catch (AppDeletedRecordException $e) { |
|
495 | 495 | $this->deletedItemPage($action, $e); |
496 | 496 | } |
497 | - catch (AppNotFoundException $e){ |
|
497 | + catch (AppNotFoundException $e) { |
|
498 | 498 | $this->notFoundPage($action, $e); |
499 | 499 | } |
500 | - catch (ORMException $e){ |
|
500 | + catch (ORMException $e) { |
|
501 | 501 | $this->errorPage($e); |
502 | 502 | } |
503 | - catch (\Exception $e){ |
|
503 | + catch (\Exception $e) { |
|
504 | 504 | $this->unexpectedErrorPage($e); |
505 | 505 | } |
506 | 506 | |
507 | 507 | $W = bab_Widgets(); |
508 | 508 | |
509 | - if($returnedValue instanceof WidgetDisplayableInterface){ |
|
509 | + if ($returnedValue instanceof WidgetDisplayableInterface) { |
|
510 | 510 | |
511 | - if($returnedValue instanceof WidgetBabPage && ! $this->isAjaxRequest()){ |
|
511 | + if ($returnedValue instanceof WidgetBabPage && !$this->isAjaxRequest()) { |
|
512 | 512 | |
513 | 513 | // If the action returned a page, we display it. |
514 | 514 | $returnedValue->displayHtml(); |
515 | 515 | } |
516 | - else{ |
|
516 | + else { |
|
517 | 517 | |
518 | 518 | $htmlCanvas = $W->HtmlCanvas(); |
519 | - if(self::$acceptJson){ |
|
519 | + if (self::$acceptJson) { |
|
520 | 520 | $itemId = $returnedValue->getId(); |
521 | 521 | $returnArray = array( |
522 | 522 | $itemId => $returnedValue->display($htmlCanvas) |
@@ -526,18 +526,18 @@ discard block |
||
526 | 526 | header('Content-type: application/json'); |
527 | 527 | die(bab_json_encode($returnArray)); |
528 | 528 | } |
529 | - else{ |
|
529 | + else { |
|
530 | 530 | header('Cache-Control: no-cache, must-revalidate'); |
531 | 531 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
532 | 532 | header('Content-type: text/html'); |
533 | - if($returnedValue instanceof WidgetPage && method_exists($returnedValue, 'getPageTitle')){ |
|
533 | + if ($returnedValue instanceof WidgetPage && method_exists($returnedValue, 'getPageTitle')) { |
|
534 | 534 | $pageTitle = $returnedValue->getPageTitle(); |
535 | 535 | |
536 | - if(method_exists($htmlCanvas, 'sendPageTitle')){ |
|
536 | + if (method_exists($htmlCanvas, 'sendPageTitle')) { |
|
537 | 537 | $htmlCanvas->sendPageTitle($pageTitle); |
538 | 538 | } |
539 | - else{ |
|
540 | - header('X-Cto-PageTitle: ' . $pageTitle); |
|
539 | + else { |
|
540 | + header('X-Cto-PageTitle: '.$pageTitle); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | $html = $returnedValue->display($htmlCanvas); |
@@ -545,15 +545,15 @@ discard block |
||
545 | 545 | } |
546 | 546 | } |
547 | 547 | } |
548 | - elseif(is_array($returnedValue)){ |
|
548 | + elseif (is_array($returnedValue)) { |
|
549 | 549 | |
550 | 550 | $htmlCanvas = $W->HtmlCanvas(); |
551 | 551 | $returnedArray = array(); |
552 | - foreach ($returnedValue as $key => &$item){ |
|
553 | - if($item instanceof WidgetDisplayableInterface){ |
|
552 | + foreach ($returnedValue as $key => &$item) { |
|
553 | + if ($item instanceof WidgetDisplayableInterface) { |
|
554 | 554 | $returnedArray[$item->getId()] = $item->display($htmlCanvas); |
555 | 555 | } |
556 | - else{ |
|
556 | + else { |
|
557 | 557 | $returnedArray[$key] = $item; |
558 | 558 | } |
559 | 559 | } |
@@ -562,9 +562,9 @@ discard block |
||
562 | 562 | header('Content-type: application/json'); |
563 | 563 | die(bab_convertStringFromDatabase(bab_json_encode($returnedArray), \bab_charset::UTF_8)); |
564 | 564 | } |
565 | - elseif(true === $returnedValue || is_string($returnedValue)){ |
|
565 | + elseif (true === $returnedValue || is_string($returnedValue)) { |
|
566 | 566 | |
567 | - if($this->isAjaxRequest()){ |
|
567 | + if ($this->isAjaxRequest()) { |
|
568 | 568 | $body = bab_getBody(); |
569 | 569 | $json = array(); |
570 | 570 | $json['messages'] = array(); |
@@ -572,21 +572,21 @@ discard block |
||
572 | 572 | unset($body->messages['toasts']); |
573 | 573 | $messages = $body->messages; |
574 | 574 | $errors = $body->errors; |
575 | - foreach ($messages as $message){ |
|
575 | + foreach ($messages as $message) { |
|
576 | 576 | $json['messages'][] = array( |
577 | 577 | 'level' => 'info', |
578 | 578 | 'content' => $message, |
579 | 579 | 'time' => 4000 |
580 | 580 | ); |
581 | 581 | } |
582 | - foreach ($errors as $message){ |
|
582 | + foreach ($errors as $message) { |
|
583 | 583 | $json['messages'][] = array( |
584 | 584 | 'level' => 'danger', |
585 | 585 | 'content' => $message |
586 | 586 | ); |
587 | 587 | } |
588 | 588 | $json['toasts'] = $toasts; |
589 | - if($objectController->getReloadSelectors()){ |
|
589 | + if ($objectController->getReloadSelectors()) { |
|
590 | 590 | $json['reloadSelector'] = implode(',', $objectController->getReloadSelectors()); |
591 | 591 | } |
592 | 592 | echo bab_json_encode($json); |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | |
600 | 600 | private function deletedItemPage(WidgetAction $action, AppDeletedRecordException $e) |
601 | 601 | { |
602 | - if($this->isAjaxRequest()){ |
|
603 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
602 | + if ($this->isAjaxRequest()) { |
|
603 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
604 | 604 | header('Cache-Control: no-cache, must-revalidate'); |
605 | 605 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
606 | 606 | header('Content-type: application/json'); |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | 'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8') |
613 | 613 | ))); |
614 | 614 | } |
615 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); |
|
615 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); |
|
616 | 616 | |
617 | 617 | $App = app_App(); |
618 | 618 | $W = bab_Widgets(); |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | ->setAlignItems(WidgetFlexLayout::FLEX_ALIGN_ITEMS_CENTER)); |
635 | 635 | $section->addItems($W->Title($App->translate('Error'), 1), $W->Title(sprintf($App->translate('This %s has been deleted'), $e->getObjectTitle()))); |
636 | 636 | |
637 | - if($e instanceof AppDeletedRecordException){ |
|
637 | + if ($e instanceof AppDeletedRecordException) { |
|
638 | 638 | $section->addItems($e->getDeletedBy(), $e->getDeletedOn()); |
639 | 639 | } |
640 | 640 | |
@@ -643,8 +643,8 @@ discard block |
||
643 | 643 | |
644 | 644 | private function notFoundPage(WidgetAction $action, AppNotFoundException $e) |
645 | 645 | { |
646 | - if($this->isAjaxRequest()){ |
|
647 | - $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle() . ' (' . $e->getId() . ')'); |
|
646 | + if ($this->isAjaxRequest()) { |
|
647 | + $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle().' ('.$e->getId().')'); |
|
648 | 648 | $json = array( |
649 | 649 | 'messages' => array( |
650 | 650 | array( |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | echo bab_json_encode($json); |
657 | 657 | die(); |
658 | 658 | } |
659 | - header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); |
|
659 | + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404); |
|
660 | 660 | header('Cache-Control: no-cache, must-revalidate'); |
661 | 661 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
662 | 662 | |
@@ -685,8 +685,8 @@ discard block |
||
685 | 685 | |
686 | 686 | private function unexpectedErrorPage(\Exception $e) |
687 | 687 | { |
688 | - if($this->isAjaxRequest()){ |
|
689 | - $message = sprintf(app_translate('An unexpected error occured') . ':' . '%s', $e->getMessage()); |
|
688 | + if ($this->isAjaxRequest()) { |
|
689 | + $message = sprintf(app_translate('An unexpected error occured').':'.'%s', $e->getMessage()); |
|
690 | 690 | $json = array( |
691 | 691 | 'messages' => array( |
692 | 692 | array( |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | echo bab_json_encode($json); |
699 | 699 | die(); |
700 | 700 | } |
701 | - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500); |
|
701 | + header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500); |
|
702 | 702 | header('Cache-Control: no-cache, must-revalidate'); |
703 | 703 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
704 | 704 | |
@@ -722,25 +722,25 @@ discard block |
||
722 | 722 | ->addClass('widget-50pc alert alert-danger') |
723 | 723 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)); |
724 | 724 | |
725 | - $logCode = '#' . hrtime(true); |
|
725 | + $logCode = '#'.hrtime(true); |
|
726 | 726 | $message = addcslashes($e->getMessage(), "\000..\037\177..\377\\"); |
727 | 727 | $trace = addcslashes($e->getTraceAsString(), "\000..\037\177..\377\\"); |
728 | 728 | |
729 | - error_log(sprintf('Error %s : %s', $logCode, $message) . PHP_EOL . $trace); |
|
729 | + error_log(sprintf('Error %s : %s', $logCode, $message).PHP_EOL.$trace); |
|
730 | 730 | |
731 | 731 | $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))); |
732 | 732 | |
733 | - if(bab_isUserAdministrator()){ |
|
733 | + if (bab_isUserAdministrator()) { |
|
734 | 734 | $contentBox->addItem($W->Section('Stack trace', $stackTraceBox = $W->FlexItems($W->Label($message) |
735 | 735 | ->addClass('widget-description')) |
736 | 736 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)) |
737 | 737 | ->setFoldable(true, true)); |
738 | 738 | $traces = explode("\n", $e->getTraceAsString()); |
739 | - foreach ($traces as $trace){ |
|
739 | + foreach ($traces as $trace) { |
|
740 | 740 | $stackTraceBox->addItem($W->Label($trace)); |
741 | 741 | } |
742 | 742 | } |
743 | - else{ |
|
743 | + else { |
|
744 | 744 | $section->addItem($W->Label($App->translate('Please contact the administrator'))); |
745 | 745 | } |
746 | 746 | |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | |
750 | 750 | private function errorPage(\Exception $e) |
751 | 751 | { |
752 | - if($this->isAjaxRequest()){ |
|
753 | - $message = sprintf(app_translate('An unexpected error occured') . ':' . '%s', $e->getMessage()); |
|
752 | + if ($this->isAjaxRequest()) { |
|
753 | + $message = sprintf(app_translate('An unexpected error occured').':'.'%s', $e->getMessage()); |
|
754 | 754 | $json = array( |
755 | 755 | 'messages' => array( |
756 | 756 | array( |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | echo bab_json_encode($json); |
763 | 763 | die(); |
764 | 764 | } |
765 | - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500); |
|
765 | + header($_SERVER['SERVER_PROTOCOL'].' 500 Internal server error', true, 500); |
|
766 | 766 | header('Cache-Control: no-cache, must-revalidate'); |
767 | 767 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
768 | 768 | |
@@ -786,25 +786,25 @@ discard block |
||
786 | 786 | ->addClass('widget-50pc alert alert-danger') |
787 | 787 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)); |
788 | 788 | |
789 | - $logCode = '#' . hrtime(true); |
|
789 | + $logCode = '#'.hrtime(true); |
|
790 | 790 | $message = addcslashes($e->getMessage(), "\000..\037\177..\377\\"); |
791 | 791 | $trace = addcslashes($e->getTraceAsString(), "\000..\037\177..\377\\"); |
792 | 792 | |
793 | - error_log(sprintf('Error %s : %s', $logCode, $message) . PHP_EOL . $trace); |
|
793 | + error_log(sprintf('Error %s : %s', $logCode, $message).PHP_EOL.$trace); |
|
794 | 794 | |
795 | 795 | $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))); |
796 | 796 | |
797 | - if(bab_isUserAdministrator()){ |
|
797 | + if (bab_isUserAdministrator()) { |
|
798 | 798 | $contentBox->addItem($W->Section('Stack trace', $stackTraceBox = $W->FlexItems($W->Label($message) |
799 | 799 | ->addClass('widget-description')) |
800 | 800 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)) |
801 | 801 | ->setFoldable(true, true)); |
802 | 802 | $traces = explode("\n", $e->getTraceAsString()); |
803 | - foreach ($traces as $trace){ |
|
803 | + foreach ($traces as $trace) { |
|
804 | 804 | $stackTraceBox->addItem($W->Label($trace)); |
805 | 805 | } |
806 | 806 | } |
807 | - else{ |
|
807 | + else { |
|
808 | 808 | $section->addItem($W->Label($App->translate('Please contact the administrator'))); |
809 | 809 | } |
810 | 810 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | private function accessPage(\Exception $e) |
815 | 815 | { |
816 | - if($this->isAjaxRequest()){ |
|
816 | + if ($this->isAjaxRequest()) { |
|
817 | 817 | $message = $e->getMessage(); |
818 | 818 | $json = array( |
819 | 819 | 'messages' => array( |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | echo bab_json_encode($json); |
827 | 827 | die(); |
828 | 828 | } |
829 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
|
829 | + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden', true, 403); |
|
830 | 830 | header('Cache-Control: no-cache, must-revalidate'); |
831 | 831 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
832 | 832 | |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | */ |
864 | 864 | public function requireSaveMethod() |
865 | 865 | { |
866 | - if('GET' === $_SERVER['REQUEST_METHOD']){ |
|
866 | + if ('GET' === $_SERVER['REQUEST_METHOD']) { |
|
867 | 867 | throw new AppException('Method not allowed'); |
868 | 868 | } |
869 | 869 | |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | */ |
879 | 879 | public function requireDeleteMethod() |
880 | 880 | { |
881 | - if('GET' === $_SERVER['REQUEST_METHOD']){ |
|
881 | + if ('GET' === $_SERVER['REQUEST_METHOD']) { |
|
882 | 882 | throw new AppException('Method not allowed'); |
883 | 883 | } |
884 | 884 | |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | 'position' => $position |
911 | 911 | ); |
912 | 912 | $babBody = bab_getBody(); |
913 | - if(! isset($babBody->messages['toasts'])){ |
|
913 | + if (!isset($babBody->messages['toasts'])) { |
|
914 | 914 | $babBody->messages['toasts'] = array(); |
915 | 915 | } |
916 | 916 | $babBody->messages['toasts'][] = $toast; |
@@ -187,8 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | if($this->isAjaxRequest()){ |
189 | 189 | $authType = 'Basic'; |
190 | - } |
|
191 | - else{ |
|
190 | + } else{ |
|
192 | 191 | $authType = ''; |
193 | 192 | } |
194 | 193 | |
@@ -263,8 +262,7 @@ discard block |
||
263 | 262 | |
264 | 263 | if($parameter->isDefaultValueAvailable()){ |
265 | 264 | $parametersStr[] = '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true); |
266 | - } |
|
267 | - else{ |
|
265 | + } else{ |
|
268 | 266 | $parametersStr[] = '$' . $parameter->name; |
269 | 267 | } |
270 | 268 | } |
@@ -358,11 +356,9 @@ discard block |
||
358 | 356 | $parameterName = $parameter->getName(); |
359 | 357 | if(isset($args[$argNumber])){ |
360 | 358 | $actionParams[$parameterName] = $args[$argNumber]; |
361 | - } |
|
362 | - elseif($parameter->isDefaultValueAvailable()){ |
|
359 | + } elseif($parameter->isDefaultValueAvailable()){ |
|
363 | 360 | $actionParams[$parameterName] = $parameter->getDefaultValue(); |
364 | - } |
|
365 | - else{ |
|
361 | + } else{ |
|
366 | 362 | $actionParams[$parameterName] = null; |
367 | 363 | } |
368 | 364 | $argNumber ++; |
@@ -440,8 +436,7 @@ discard block |
||
440 | 436 | if($component){ |
441 | 437 | $this->app->setCurrentComponent($component); |
442 | 438 | $objectController = $component->controller(false); |
443 | - } |
|
444 | - else{ |
|
439 | + } else{ |
|
445 | 440 | header('HTTP/1.0 400 Bad Request'); |
446 | 441 | throw new AppUnknownActionException($action); |
447 | 442 | } |
@@ -456,13 +451,11 @@ discard block |
||
456 | 451 | |
457 | 452 | try{ |
458 | 453 | $returnedValue = $objectController->execAction($action); |
459 | - } |
|
460 | - catch (AppAccessException $e){ |
|
454 | + } catch (AppAccessException $e){ |
|
461 | 455 | |
462 | 456 | if(! bab_isUserLogged() && $e->requireCredential){ |
463 | 457 | bab_requireCredential($e->getMessage()); |
464 | - } |
|
465 | - else{ |
|
458 | + } else{ |
|
466 | 459 | if($this->isAjaxRequest()){ |
467 | 460 | |
468 | 461 | header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
@@ -475,8 +468,7 @@ discard block |
||
475 | 468 | } |
476 | 469 | $this->accessPage($e); |
477 | 470 | } |
478 | - } |
|
479 | - catch (AppSaveException $e){ |
|
471 | + } catch (AppSaveException $e){ |
|
480 | 472 | |
481 | 473 | if($this->isAjaxRequest()){ |
482 | 474 | header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); |
@@ -490,17 +482,13 @@ discard block |
||
490 | 482 | 'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8') |
491 | 483 | ))); |
492 | 484 | } |
493 | - } |
|
494 | - catch (AppDeletedRecordException $e){ |
|
485 | + } catch (AppDeletedRecordException $e){ |
|
495 | 486 | $this->deletedItemPage($action, $e); |
496 | - } |
|
497 | - catch (AppNotFoundException $e){ |
|
487 | + } catch (AppNotFoundException $e){ |
|
498 | 488 | $this->notFoundPage($action, $e); |
499 | - } |
|
500 | - catch (ORMException $e){ |
|
489 | + } catch (ORMException $e){ |
|
501 | 490 | $this->errorPage($e); |
502 | - } |
|
503 | - catch (\Exception $e){ |
|
491 | + } catch (\Exception $e){ |
|
504 | 492 | $this->unexpectedErrorPage($e); |
505 | 493 | } |
506 | 494 | |
@@ -512,8 +500,7 @@ discard block |
||
512 | 500 | |
513 | 501 | // If the action returned a page, we display it. |
514 | 502 | $returnedValue->displayHtml(); |
515 | - } |
|
516 | - else{ |
|
503 | + } else{ |
|
517 | 504 | |
518 | 505 | $htmlCanvas = $W->HtmlCanvas(); |
519 | 506 | if(self::$acceptJson){ |
@@ -525,8 +512,7 @@ discard block |
||
525 | 512 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
526 | 513 | header('Content-type: application/json'); |
527 | 514 | die(bab_json_encode($returnArray)); |
528 | - } |
|
529 | - else{ |
|
515 | + } else{ |
|
530 | 516 | header('Cache-Control: no-cache, must-revalidate'); |
531 | 517 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
532 | 518 | header('Content-type: text/html'); |
@@ -535,8 +521,7 @@ discard block |
||
535 | 521 | |
536 | 522 | if(method_exists($htmlCanvas, 'sendPageTitle')){ |
537 | 523 | $htmlCanvas->sendPageTitle($pageTitle); |
538 | - } |
|
539 | - else{ |
|
524 | + } else{ |
|
540 | 525 | header('X-Cto-PageTitle: ' . $pageTitle); |
541 | 526 | } |
542 | 527 | } |
@@ -544,16 +529,14 @@ discard block |
||
544 | 529 | die($html); |
545 | 530 | } |
546 | 531 | } |
547 | - } |
|
548 | - elseif(is_array($returnedValue)){ |
|
532 | + } elseif(is_array($returnedValue)){ |
|
549 | 533 | |
550 | 534 | $htmlCanvas = $W->HtmlCanvas(); |
551 | 535 | $returnedArray = array(); |
552 | 536 | foreach ($returnedValue as $key => &$item){ |
553 | 537 | if($item instanceof WidgetDisplayableInterface){ |
554 | 538 | $returnedArray[$item->getId()] = $item->display($htmlCanvas); |
555 | - } |
|
556 | - else{ |
|
539 | + } else{ |
|
557 | 540 | $returnedArray[$key] = $item; |
558 | 541 | } |
559 | 542 | } |
@@ -561,8 +544,7 @@ discard block |
||
561 | 544 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
562 | 545 | header('Content-type: application/json'); |
563 | 546 | die(bab_convertStringFromDatabase(bab_json_encode($returnedArray), \bab_charset::UTF_8)); |
564 | - } |
|
565 | - elseif(true === $returnedValue || is_string($returnedValue)){ |
|
547 | + } elseif(true === $returnedValue || is_string($returnedValue)){ |
|
566 | 548 | |
567 | 549 | if($this->isAjaxRequest()){ |
568 | 550 | $body = bab_getBody(); |
@@ -739,8 +721,7 @@ discard block |
||
739 | 721 | foreach ($traces as $trace){ |
740 | 722 | $stackTraceBox->addItem($W->Label($trace)); |
741 | 723 | } |
742 | - } |
|
743 | - else{ |
|
724 | + } else{ |
|
744 | 725 | $section->addItem($W->Label($App->translate('Please contact the administrator'))); |
745 | 726 | } |
746 | 727 | |
@@ -803,8 +784,7 @@ discard block |
||
803 | 784 | foreach ($traces as $trace){ |
804 | 785 | $stackTraceBox->addItem($W->Label($trace)); |
805 | 786 | } |
806 | - } |
|
807 | - else{ |
|
787 | + } else{ |
|
808 | 788 | $section->addItem($W->Label($App->translate('Please contact the administrator'))); |
809 | 789 | } |
810 | 790 |