@@ -46,72 +46,72 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * @param Func_App $App |
48 | 48 | */ |
49 | - public function __construct(Func_App $App) |
|
50 | - { |
|
51 | - parent::__construct($App); |
|
52 | - |
|
53 | - $this->setDescription('Custom field'); |
|
54 | - |
|
55 | - $this->setPrimaryKey('id'); |
|
56 | - |
|
57 | - $this->addFields( |
|
58 | - ORM_StringField('name') |
|
59 | - ->setDescription('Name of field used for display'), |
|
60 | - ORM_StringField('fieldname') |
|
61 | - ->setDescription('Name of field used in table, not modifiable'), |
|
62 | - ORM_TextField('description') |
|
63 | - ->setDescription('Optional description'), |
|
64 | - ORM_EnumField('object', $this->getObjects()) |
|
65 | - ->setDescription('Name of object in App ex : Article, Contact, Organization...'), |
|
66 | - ORM_EnumField('fieldtype', $this->getFieldTypes()) |
|
67 | - ->setDescription('Name of ORM field ex : Enum, String, Text, Bool...'), |
|
68 | - ORM_TextField('enumvalues') |
|
69 | - ->setDescription('serialized array of values for enum fields'), |
|
70 | - ORM_BoolField('mandatory') |
|
71 | - ->setDescription('Mandatory') |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * List of objects where custom fields are applicable. |
|
79 | - * |
|
80 | - * @return string[] |
|
81 | - */ |
|
82 | - public function getObjects() |
|
83 | - { |
|
84 | - $App = $this->App(); |
|
85 | - |
|
86 | - $arr = array(); |
|
87 | - |
|
88 | - if (isset($App->Article)) { |
|
89 | - $arr['Article'] = $App->translate('Products database'); |
|
90 | - } |
|
91 | - |
|
92 | - return $arr; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * list of ORM fields to use for a custom field |
|
97 | - */ |
|
98 | - public function getFieldTypes() |
|
99 | - { |
|
100 | - $App = $this->App(); |
|
101 | - |
|
102 | - return array( |
|
103 | - 'String' => $App->translate('Line edit'), |
|
104 | - 'Text' => $App->translate('Text edit'), |
|
105 | - 'Bool' => $App->translate('Checkbox'), |
|
106 | - 'Int' => $App->translate('Integer number'), |
|
107 | - 'Decimal' => $App->translate('Decimal number'), |
|
108 | - 'Date' => $App->translate('Date'), |
|
109 | - 'DateTime' => $App->translate('Date and time'), |
|
110 | - 'Enum' => $App->translate('Selection list'), |
|
111 | - 'Url' => $App->translate('Url'), |
|
112 | - 'Email' => $App->translate('Email address'), |
|
113 | - ); |
|
114 | - } |
|
49 | + public function __construct(Func_App $App) |
|
50 | + { |
|
51 | + parent::__construct($App); |
|
52 | + |
|
53 | + $this->setDescription('Custom field'); |
|
54 | + |
|
55 | + $this->setPrimaryKey('id'); |
|
56 | + |
|
57 | + $this->addFields( |
|
58 | + ORM_StringField('name') |
|
59 | + ->setDescription('Name of field used for display'), |
|
60 | + ORM_StringField('fieldname') |
|
61 | + ->setDescription('Name of field used in table, not modifiable'), |
|
62 | + ORM_TextField('description') |
|
63 | + ->setDescription('Optional description'), |
|
64 | + ORM_EnumField('object', $this->getObjects()) |
|
65 | + ->setDescription('Name of object in App ex : Article, Contact, Organization...'), |
|
66 | + ORM_EnumField('fieldtype', $this->getFieldTypes()) |
|
67 | + ->setDescription('Name of ORM field ex : Enum, String, Text, Bool...'), |
|
68 | + ORM_TextField('enumvalues') |
|
69 | + ->setDescription('serialized array of values for enum fields'), |
|
70 | + ORM_BoolField('mandatory') |
|
71 | + ->setDescription('Mandatory') |
|
72 | + ); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * List of objects where custom fields are applicable. |
|
79 | + * |
|
80 | + * @return string[] |
|
81 | + */ |
|
82 | + public function getObjects() |
|
83 | + { |
|
84 | + $App = $this->App(); |
|
85 | + |
|
86 | + $arr = array(); |
|
87 | + |
|
88 | + if (isset($App->Article)) { |
|
89 | + $arr['Article'] = $App->translate('Products database'); |
|
90 | + } |
|
91 | + |
|
92 | + return $arr; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * list of ORM fields to use for a custom field |
|
97 | + */ |
|
98 | + public function getFieldTypes() |
|
99 | + { |
|
100 | + $App = $this->App(); |
|
101 | + |
|
102 | + return array( |
|
103 | + 'String' => $App->translate('Line edit'), |
|
104 | + 'Text' => $App->translate('Text edit'), |
|
105 | + 'Bool' => $App->translate('Checkbox'), |
|
106 | + 'Int' => $App->translate('Integer number'), |
|
107 | + 'Decimal' => $App->translate('Decimal number'), |
|
108 | + 'Date' => $App->translate('Date'), |
|
109 | + 'DateTime' => $App->translate('Date and time'), |
|
110 | + 'Enum' => $App->translate('Selection list'), |
|
111 | + 'Url' => $App->translate('Url'), |
|
112 | + 'Email' => $App->translate('Email address'), |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * @return ORM_Criteria |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | case 'Bool': |
176 | 176 | $field = ORM_BoolField($this->fieldname); |
177 | 177 | $field->setOutputOptions( |
178 | - $this->App()->translate('No'), |
|
178 | + $this->App()->translate('No'), |
|
179 | 179 | $this->App()->translate('Yes') |
180 | 180 | ); |
181 | 181 | break; |
@@ -192,80 +192,80 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | |
195 | - /** |
|
196 | - * @return string[] |
|
197 | - */ |
|
198 | - public function getEnumValues() |
|
199 | - { |
|
200 | - return unserialize($this->enumvalues); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * @return Widget_LabelledWidget |
|
206 | - */ |
|
207 | - public function getWidget() |
|
208 | - { |
|
209 | - $W = bab_Widgets(); |
|
210 | - $App = $this->App(); |
|
211 | - |
|
212 | - switch ($this->fieldtype) { |
|
213 | - case 'Text': |
|
214 | - $widget = $W->TextEdit()->setLines(3)->setColumns(70); |
|
215 | - break; |
|
216 | - |
|
217 | - case 'Bool': |
|
218 | - $widget = $W->Checkbox(); |
|
219 | - break; |
|
220 | - |
|
221 | - case 'Enum': |
|
222 | - $options = array('' => '') + $this->getEnumValues(); |
|
223 | - $widget = $W->Select()->setOptions($options); |
|
224 | - break; |
|
225 | - |
|
226 | - case 'Date': |
|
227 | - $widget = $W->DatePicker(); |
|
228 | - break; |
|
229 | - |
|
230 | - case 'DateTime': |
|
231 | - $widget = $W->DateTimePicker(); |
|
232 | - break; |
|
233 | - |
|
234 | - case 'Int': |
|
235 | - $widget = $W->RegExpLineEdit(); |
|
236 | - $widget->setRegExp(Widget_RegExpLineEdit::INT_FORMAT) |
|
237 | - ->setSubmitMessage(sprintf($App->translate('The field %s should be a integer number'), $this->name)) |
|
238 | - ->setSize(10); |
|
239 | - break; |
|
240 | - |
|
241 | - case 'Decimal': |
|
242 | - $widget = $W->RegExpLineEdit(); |
|
243 | - $widget->setRegExp(Widget_RegExpLineEdit::FLOAT_FORMAT) |
|
244 | - ->setSubmitMessage(sprintf($App->translate('The field %s should be a decimal number'), $this->name)) |
|
245 | - ->setSize(10); |
|
246 | - break; |
|
247 | - |
|
248 | - case 'Url': |
|
249 | - $widget = $W->UrlLineEdit(); |
|
250 | - break; |
|
251 | - |
|
252 | - case 'Email': |
|
253 | - $widget = $W->EmailLineEdit(); |
|
254 | - break; |
|
255 | - |
|
256 | - default: |
|
257 | - case 'String': |
|
258 | - $widget = $W->LineEdit()->setSize(70)->setMaxSize(255); |
|
259 | - break; |
|
260 | - } |
|
261 | - |
|
262 | - $labelledItem = $W->LabelledWidget($this->name, $widget, null); |
|
263 | - $labelledItem->setName($this->fieldname); |
|
264 | - |
|
265 | - if (!empty($this->description)) { |
|
266 | - $labelledItem->setDescription($this->description); |
|
267 | - } |
|
268 | - |
|
269 | - return $labelledItem; |
|
270 | - } |
|
195 | + /** |
|
196 | + * @return string[] |
|
197 | + */ |
|
198 | + public function getEnumValues() |
|
199 | + { |
|
200 | + return unserialize($this->enumvalues); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * @return Widget_LabelledWidget |
|
206 | + */ |
|
207 | + public function getWidget() |
|
208 | + { |
|
209 | + $W = bab_Widgets(); |
|
210 | + $App = $this->App(); |
|
211 | + |
|
212 | + switch ($this->fieldtype) { |
|
213 | + case 'Text': |
|
214 | + $widget = $W->TextEdit()->setLines(3)->setColumns(70); |
|
215 | + break; |
|
216 | + |
|
217 | + case 'Bool': |
|
218 | + $widget = $W->Checkbox(); |
|
219 | + break; |
|
220 | + |
|
221 | + case 'Enum': |
|
222 | + $options = array('' => '') + $this->getEnumValues(); |
|
223 | + $widget = $W->Select()->setOptions($options); |
|
224 | + break; |
|
225 | + |
|
226 | + case 'Date': |
|
227 | + $widget = $W->DatePicker(); |
|
228 | + break; |
|
229 | + |
|
230 | + case 'DateTime': |
|
231 | + $widget = $W->DateTimePicker(); |
|
232 | + break; |
|
233 | + |
|
234 | + case 'Int': |
|
235 | + $widget = $W->RegExpLineEdit(); |
|
236 | + $widget->setRegExp(Widget_RegExpLineEdit::INT_FORMAT) |
|
237 | + ->setSubmitMessage(sprintf($App->translate('The field %s should be a integer number'), $this->name)) |
|
238 | + ->setSize(10); |
|
239 | + break; |
|
240 | + |
|
241 | + case 'Decimal': |
|
242 | + $widget = $W->RegExpLineEdit(); |
|
243 | + $widget->setRegExp(Widget_RegExpLineEdit::FLOAT_FORMAT) |
|
244 | + ->setSubmitMessage(sprintf($App->translate('The field %s should be a decimal number'), $this->name)) |
|
245 | + ->setSize(10); |
|
246 | + break; |
|
247 | + |
|
248 | + case 'Url': |
|
249 | + $widget = $W->UrlLineEdit(); |
|
250 | + break; |
|
251 | + |
|
252 | + case 'Email': |
|
253 | + $widget = $W->EmailLineEdit(); |
|
254 | + break; |
|
255 | + |
|
256 | + default: |
|
257 | + case 'String': |
|
258 | + $widget = $W->LineEdit()->setSize(70)->setMaxSize(255); |
|
259 | + break; |
|
260 | + } |
|
261 | + |
|
262 | + $labelledItem = $W->LabelledWidget($this->name, $widget, null); |
|
263 | + $labelledItem->setName($this->fieldname); |
|
264 | + |
|
265 | + if (!empty($this->description)) { |
|
266 | + $labelledItem->setDescription($this->description); |
|
267 | + } |
|
268 | + |
|
269 | + return $labelledItem; |
|
270 | + } |
|
271 | 271 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | |
25 | -require_once APP_CTRL_PATH . '/record.ctrl.php'; |
|
25 | +require_once APP_CTRL_PATH.'/record.ctrl.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | foreach ($allViewSections as $viewSection) { |
59 | 59 | $fields = $viewSection->getFields(); |
60 | 60 | foreach ($fields as $field) { |
61 | - $allViewFieldNames[$field['fieldname']] = $viewSection->view . ',' . $viewSection->rank . ',' . $viewSection->id; |
|
61 | + $allViewFieldNames[$field['fieldname']] = $viewSection->view.','.$viewSection->rank.','.$viewSection->id; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | bab_Sort::asort($availableFields, 'description', bab_Sort::CASE_INSENSITIVE); |
82 | 82 | |
83 | 83 | foreach ($availableFields as $field) { |
84 | - $fieldName = $field['name']; |
|
84 | + $fieldName = $field['name']; |
|
85 | 85 | $fieldDescription = $field['description']; |
86 | 86 | |
87 | 87 | $used = isset($allViewFieldNames[$fieldName]); |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | $recordSet = $this->getRecordSet(); |
391 | 391 | $record = $recordSet->request($id); |
392 | 392 | |
393 | - $object = $record->object . 'Set'; |
|
393 | + $object = $record->object.'Set'; |
|
394 | 394 | |
395 | 395 | $objectRecordSet = $App->$object(); |
396 | 396 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | $recordSet = $this->getRecordSet(); |
465 | 465 | $record = $recordSet->request($data['id']); |
466 | 466 | |
467 | - $object = $record->object . 'Set'; |
|
467 | + $object = $record->object.'Set'; |
|
468 | 468 | |
469 | 469 | $objectRecordSet = $App->$object(); |
470 | 470 | |
@@ -536,17 +536,17 @@ discard block |
||
536 | 536 | $nbCol = 0; |
537 | 537 | foreach ($customSections as $customSection) { |
538 | 538 | |
539 | - list(, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
539 | + list(,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
540 | 540 | |
541 | 541 | $currentColumn += $nbCol; |
542 | 542 | |
543 | 543 | $sectionSection = $W->Section( |
544 | - $customSection->name . ' (' . $customSection->rank . ')', |
|
545 | - $sectionBox = $W->VBoxItems($W->Hidden()->setName('#' . $customSection->id)) |
|
544 | + $customSection->name.' ('.$customSection->rank.')', |
|
545 | + $sectionBox = $W->VBoxItems($W->Hidden()->setName('#'.$customSection->id)) |
|
546 | 546 | ); |
547 | 547 | $sectionSection->addClass('app-custom-section'); |
548 | 548 | $sectionSection->addClass($customSection->classname); |
549 | - $sectionSection->setSizePolicy($customSection->sizePolicy . ' widget-sameheight'); |
|
549 | + $sectionSection->setSizePolicy($customSection->sizePolicy.' widget-sameheight'); |
|
550 | 550 | |
551 | 551 | $row->addItem($sectionSection); |
552 | 552 | |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | $fieldItem = $W->HBoxItems( |
589 | 589 | $W->Label($fieldDescription)->setSizePolicy('maximum')->addClass('icon', Func_Icons::ACTIONS_ZOOM_FIT_HEIGHT), |
590 | 590 | $W->HBoxItems( |
591 | - $W->Hidden()->setName($customSection->id . '.' . $fieldId)->setValue($field['name']), |
|
591 | + $W->Hidden()->setName($customSection->id.'.'.$fieldId)->setValue($field['name']), |
|
592 | 592 | $W->Link('', $customSectionCtrl->editDisplayField($customSection->id, $field['name'])) |
593 | 593 | ->addClass('icon', Func_Icons::ACTIONS_DOCUMENT_EDIT) |
594 | 594 | ->setOpenMode(Widget_Link::OPEN_DIALOG), |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | } |
666 | 666 | |
667 | 667 | header('Content-type: application/json'); |
668 | - header('Content-Disposition: attachment; filename="' . $object . '.' . ($view === '' ? 'default' : $view) . '.json"'."\n"); |
|
668 | + header('Content-Disposition: attachment; filename="'.$object.'.'.($view === '' ? 'default' : $view).'.json"'."\n"); |
|
669 | 669 | |
670 | 670 | $json = bab_json_encode($sectionsValues); |
671 | 671 | $json = bab_convertStringFromDatabase($json, bab_charset::UTF_8); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function __construct(Func_App $app, $id = null, Widget_Layout $layout = null) |
116 | 116 | { |
117 | 117 | parent::__construct($app); |
118 | - // We simulate inheritance from Widget_VBoxLayout. |
|
118 | + // We simulate inheritance from Widget_VBoxLayout. |
|
119 | 119 | $W = $this->widgets = bab_Widgets(); |
120 | 120 | |
121 | 121 | $this->buttonsLayout = $this->buttonsLayout(); |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | $cancelLabel = isset($this->cancelLabel) ? $this->cancelLabel : $App->translate('Cancel'); |
323 | 323 | $this->addButton( |
324 | 324 | $W->SubmitButton(/*'cancel'*/) |
325 | - ->addClass('widget-close-dialog') |
|
325 | + ->addClass('widget-close-dialog') |
|
326 | 326 | ->setAction($this->cancelAction) |
327 | - ->setLabel($cancelLabel) |
|
327 | + ->setLabel($cancelLabel) |
|
328 | 328 | ); |
329 | 329 | } |
330 | 330 | } |
@@ -1170,21 +1170,21 @@ discard block |
||
1170 | 1170 | |
1171 | 1171 | |
1172 | 1172 | |
1173 | - protected function addCustomFields(app_RecordSet $recordSet) |
|
1174 | - { |
|
1175 | - $customFields = $recordSet->getCustomFields(); |
|
1173 | + protected function addCustomFields(app_RecordSet $recordSet) |
|
1174 | + { |
|
1175 | + $customFields = $recordSet->getCustomFields(); |
|
1176 | 1176 | |
1177 | 1177 | foreach ($customFields as $customField) { |
1178 | 1178 | $fieldname = $customField->fieldname; |
1179 | 1179 | $this->addColumn( |
1180 | 1180 | widget_TableModelViewColumn($recordSet->$fieldname, $customField->name) |
1181 | - ->setSortable(true) |
|
1182 | - ->setExportable(true) |
|
1183 | - ->setSearchable($customField->searchable) |
|
1184 | - ->setVisible($customField->visible) |
|
1181 | + ->setSortable(true) |
|
1182 | + ->setExportable(true) |
|
1183 | + ->setSearchable($customField->searchable) |
|
1184 | + ->setVisible($customField->visible) |
|
1185 | 1185 | ); |
1186 | 1186 | } |
1187 | - } |
|
1187 | + } |
|
1188 | 1188 | |
1189 | 1189 | |
1190 | 1190 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | bab_Widgets()->includePhpClass('widget_InputWidget'); |
27 | 27 | bab_Widgets()->includePhpClass('widget_TableModelView'); |
28 | 28 | |
29 | -require_once dirname(__FILE__) . '/ui.helpers.php'; |
|
29 | +require_once dirname(__FILE__).'/ui.helpers.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @return Widget_Form |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | continue; |
675 | 675 | } |
676 | 676 | |
677 | - list(, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
677 | + list(,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
678 | 678 | |
679 | 679 | if ($currentColumn + $nbCol > 12) { |
680 | 680 | $this->addItem($row); |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | $parameters = $displayField['parameters']; |
703 | 703 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; |
704 | 704 | $label = isset($parameters['label']) && $parameters['label'] !== '__' ? $parameters['label'] : ''; |
705 | - $displayFieldMethod = '_' . $displayFieldName; |
|
705 | + $displayFieldMethod = '_'.$displayFieldName; |
|
706 | 706 | |
707 | 707 | if (method_exists($this, $displayFieldMethod)) { |
708 | 708 | $widget = $this->$displayFieldMethod($customSection, $label); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | $parameters = $displayField['parameters']; |
761 | 761 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; |
762 | 762 | $label = isset($parameters['label']) && $parameters['label'] !== '__' ? $parameters['label'] : ''; |
763 | - $displayFieldMethod = '_' . $displayFieldName; |
|
763 | + $displayFieldMethod = '_'.$displayFieldName; |
|
764 | 764 | |
765 | 765 | if (method_exists($this, $displayFieldMethod)) { |
766 | 766 | $widget = $this->$displayFieldMethod($customSection, $label); |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | $row = $W->Items()->setSizePolicy('row'); |
1043 | 1043 | foreach ($customSections as $customSection) { |
1044 | 1044 | |
1045 | - list(, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
1045 | + list(,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
1046 | 1046 | |
1047 | 1047 | if ($currentColumn + $nbCol > 12) { |
1048 | 1048 | $this->addItem($row); |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | $parameters = $displayField['parameters']; |
1070 | 1070 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; |
1071 | 1071 | $label = isset($parameters['label']) ? $parameters['label'] : ''; |
1072 | - $displayFieldMethod = '_' . $displayFieldName; |
|
1072 | + $displayFieldMethod = '_'.$displayFieldName; |
|
1073 | 1073 | |
1074 | 1074 | if (method_exists($this, $displayFieldMethod)) { |
1075 | 1075 | $value = $this->$displayFieldMethod($customSection, $label); |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | // we try to select one according to the classname prefix. |
1162 | 1162 | list($prefix) = explode('_', get_class($this)); |
1163 | 1163 | $functionalityName = ucwords($prefix); |
1164 | - $this->app = @bab_functionality::get('App/' . $functionalityName); |
|
1164 | + $this->app = @bab_functionality::get('App/'.$functionalityName); |
|
1165 | 1165 | if (!$this->app) { |
1166 | 1166 | $this->app = @bab_functionality::get('App'); |
1167 | 1167 | } |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | $this->setCurrentPage(isset($filter['pageNumber']) ? $filter['pageNumber'] : $pageNumber); |
1223 | 1223 | |
1224 | 1224 | if (isset($name)) { |
1225 | - $this->sortParameterName = $name . '[filter][sort]'; |
|
1225 | + $this->sortParameterName = $name.'[filter][sort]'; |
|
1226 | 1226 | } else { |
1227 | 1227 | $this->sortParameterName = 'filter[sort]'; |
1228 | 1228 | } |
@@ -1373,11 +1373,11 @@ discard block |
||
1373 | 1373 | |
1374 | 1374 | foreach ($columns as $fieldName => $column) { |
1375 | 1375 | $field = $column->getField(); |
1376 | - if (! $column->isSearchable()) { |
|
1376 | + if (!$column->isSearchable()) { |
|
1377 | 1377 | continue; |
1378 | 1378 | } |
1379 | 1379 | |
1380 | - if (! ($field instanceof ORM_Field)) { |
|
1380 | + if (!($field instanceof ORM_Field)) { |
|
1381 | 1381 | $field = null; |
1382 | 1382 | } |
1383 | 1383 | |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | |
1395 | 1395 | $formItem = $this->handleFilterLabel($label, $input); |
1396 | 1396 | $formItem->setSizePolicy('col-lg-2 col-md-3 col-sm-6 col-xs-12'); |
1397 | - $formItem->addClass('field_' . $fieldName); |
|
1397 | + $formItem->addClass('field_'.$fieldName); |
|
1398 | 1398 | |
1399 | 1399 | $mainSearch = (method_exists($column, 'isMainSearch') && $column->isMainSearch()); |
1400 | 1400 | |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | } |
1408 | 1408 | |
1409 | 1409 | |
1410 | - if (! $this->submit) { |
|
1410 | + if (!$this->submit) { |
|
1411 | 1411 | $this->submit = $W->SubmitButton(); |
1412 | 1412 | $this->submit->setLabel(widget_translate('Filter')); |
1413 | 1413 | } |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | // $this->setCurrentPage(isset($filter['pageNumber']) ? $filter['pageNumber'] : $pageNumber); |
1481 | 1481 | |
1482 | 1482 | if (isset($name)) { |
1483 | - $this->sortParameterName = $name . '[filter][sort]'; |
|
1483 | + $this->sortParameterName = $name.'[filter][sort]'; |
|
1484 | 1484 | } else { |
1485 | 1485 | $this->sortParameterName = 'filter[sort]'; |
1486 | 1486 | } |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | |
1546 | 1546 | $tableview->setCurrentPage(isset($filterValues['pageNumber']) ? $filterValues['pageNumber'] : 0); |
1547 | 1547 | |
1548 | - $tableview->sortParameterName = $name . '[filter][sort]'; |
|
1548 | + $tableview->sortParameterName = $name.'[filter][sort]'; |
|
1549 | 1549 | |
1550 | 1550 | if (isset($filterValues['sort'])) { |
1551 | 1551 | $tableview->setSortField($filterValues['sort']); |
@@ -1844,7 +1844,7 @@ discard block |
||
1844 | 1844 | continue; |
1845 | 1845 | } |
1846 | 1846 | |
1847 | - list(, , $nbCol) = explode('-', $customSection->sizePolicy); |
|
1847 | + list(,, $nbCol) = explode('-', $customSection->sizePolicy); |
|
1848 | 1848 | |
1849 | 1849 | if ($currentColumn + $nbCol > 12) { |
1850 | 1850 | $this->addItem($row); |
@@ -1886,7 +1886,7 @@ discard block |
||
1886 | 1886 | $classname = isset($parameters['classname']) ? $parameters['classname'] : ''; |
1887 | 1887 | $label = isset($parameters['label']) ? $parameters['label'] : null; |
1888 | 1888 | |
1889 | - $displayFieldMethod = '_' . $displayFieldName; |
|
1889 | + $displayFieldMethod = '_'.$displayFieldName; |
|
1890 | 1890 | if (method_exists($this, $displayFieldMethod)) { |
1891 | 1891 | $item = $this->$displayFieldMethod($customSection, $label); |
1892 | 1892 | } else { |
@@ -1916,7 +1916,7 @@ discard block |
||
1916 | 1916 | } |
1917 | 1917 | } |
1918 | 1918 | |
1919 | - if ($currentColumn + $nbCol> 0) { |
|
1919 | + if ($currentColumn + $nbCol > 0) { |
|
1920 | 1920 | $this->addItem($row); |
1921 | 1921 | } |
1922 | 1922 | } |
@@ -2030,7 +2030,7 @@ discard block |
||
2030 | 2030 | |
2031 | 2031 | $displayable = $field->output($value); |
2032 | 2032 | |
2033 | - switch(true) { |
|
2033 | + switch (true) { |
|
2034 | 2034 | case ($field instanceof ORM_TextField): |
2035 | 2035 | $displayable = $W->RichText($displayable)->setRenderingOptions(BAB_HTML_ALL ^ BAB_HTML_P); |
2036 | 2036 | break; |
@@ -94,7 +94,7 @@ |
||
94 | 94 | public function hasNoAccess(app_RecordSet $recordSet, $accessType, $user = null) |
95 | 95 | { |
96 | 96 | $criterion = $this->getAccessCriterion($recordSet, $accessType, $user); |
97 | - if (! $criterion instanceof ORM_FalseCriterion) { |
|
97 | + if (!$criterion instanceof ORM_FalseCriterion) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | return true; |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | -require_once dirname(__FILE__). '/functions.php'; |
|
27 | +require_once dirname(__FILE__).'/functions.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | function LibApp_upgrade($sVersionBase, $sVersionIni) |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @copyright Copyright (c) 2018 by CANTICO ({@link http://www.cantico.fr}) |
22 | 22 | */ |
23 | 23 | |
24 | -require_once dirname(__FILE__) . '/define.php'; |
|
25 | -require_once dirname(__FILE__) . '/functions.php'; |
|
24 | +require_once dirname(__FILE__).'/define.php'; |
|
25 | +require_once dirname(__FILE__).'/functions.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | $this->addonName = 'libapp'; |
56 | 56 | $this->addonPrefix = 'app'; |
57 | 57 | |
58 | - $this->classPrefix = $this->addonPrefix . '_'; |
|
59 | - $this->controllerTg = 'addon/' . $this->addonName . '/main'; |
|
58 | + $this->classPrefix = $this->addonPrefix.'_'; |
|
59 | + $this->controllerTg = 'addon/'.$this->addonName.'/main'; |
|
60 | 60 | |
61 | 61 | $addon = bab_getAddonInfosInstance($this->addonName); |
62 | 62 | $this->phpPath = $addon->getPhpPath(); |
63 | 63 | $this->recordSetPath = $this->phpPath; |
64 | 64 | $this->ctrlPath = $this->phpPath; |
65 | - $this->uiPath = $this->phpPath . 'ui/'; |
|
65 | + $this->uiPath = $this->phpPath.'ui/'; |
|
66 | 66 | |
67 | 67 | $babDB = bab_getDB(); |
68 | 68 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | public function getRecordSetPathname($class) |
110 | 110 | { |
111 | 111 | // $App->MyRecordSet() -> myrecord.class.php |
112 | - $file = strtolower(substr($class, strlen($this->classPrefix), -3)) . '.class.php'; |
|
113 | - return $this->recordSetPath . $file; |
|
112 | + $file = strtolower(substr($class, strlen($this->classPrefix), -3)).'.class.php'; |
|
113 | + return $this->recordSetPath.$file; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | public function getRecordPathname($class) |
123 | 123 | { |
124 | 124 | // $App->MyRecord() -> myrecord.class.php |
125 | - $file = strtolower(substr($class, strlen($this->classPrefix))) . '.class.php'; |
|
126 | - return $this->recordSetPath . $file; |
|
125 | + $file = strtolower(substr($class, strlen($this->classPrefix))).'.class.php'; |
|
126 | + return $this->recordSetPath.$file; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | if (substr($method, 0, 7) === 'include' && substr($method, -3) === 'Set') { |
226 | 226 | $incl = $method; |
227 | - $classNameMethod = substr($method, strlen('include')) . 'ClassName'; |
|
227 | + $classNameMethod = substr($method, strlen('include')).'ClassName'; |
|
228 | 228 | |
229 | 229 | |
230 | 230 | $classname = $this->$classNameMethod(); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | // We need to revert to multilang fields before synchronizing. |
247 | 247 | $set->useLang(false); |
248 | 248 | } |
249 | - $sql .= $mysqlbackend->setToSql($set) . "\n"; |
|
249 | + $sql .= $mysqlbackend->setToSql($set)."\n"; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | if (substr($method, 0, strlen('include')) === 'include' && substr($method, -strlen('Set')) === 'Set') { |
279 | 279 | $incl = $method; |
280 | - $classNameMethod = substr($method, strlen('include')) . 'ClassName'; |
|
280 | + $classNameMethod = substr($method, strlen('include')).'ClassName'; |
|
281 | 281 | |
282 | 282 | $classname = $this->$classNameMethod(); |
283 | 283 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | |
292 | 292 | if (class_exists($classname) && method_exists($this, $call)) { |
293 | 293 | $set = $this->$call(); |
294 | - $sql .= $mysqlbackend->setToSql($set) . "\n"; |
|
294 | + $sql .= $mysqlbackend->setToSql($set)."\n"; |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | public function includeBase() |
307 | 307 | { |
308 | - require_once APP_PHP_PATH . 'base.class.php'; |
|
308 | + require_once APP_PHP_PATH.'base.class.php'; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function includeRecordSet() |
315 | 315 | { |
316 | - require_once APP_SET_PATH . 'record.class.php'; |
|
316 | + require_once APP_SET_PATH.'record.class.php'; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function includeTraceableRecordSet() |
324 | 324 | { |
325 | - require_once APP_SET_PATH . 'traceablerecord.class.php'; |
|
325 | + require_once APP_SET_PATH.'traceablerecord.class.php'; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | { |
335 | 335 | static $accessManager = null; |
336 | 336 | if (!isset($accessManager)) { |
337 | - require_once APP_SET_PATH . 'accessmanager.class.php'; |
|
337 | + require_once APP_SET_PATH.'accessmanager.class.php'; |
|
338 | 338 | $accessManager = new app_AccessManager($this); |
339 | 339 | } |
340 | 340 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public function includeLogSet() |
354 | 354 | { |
355 | - require_once APP_SET_PATH . 'log.class.php'; |
|
355 | + require_once APP_SET_PATH.'log.class.php'; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function LogSetClassName() |
370 | 370 | { |
371 | - return $this->LogClassName() . 'Set'; |
|
371 | + return $this->LogClassName().'Set'; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function includeLinkSet() |
392 | 392 | { |
393 | - require_once APP_SET_PATH . 'link.class.php'; |
|
393 | + require_once APP_SET_PATH.'link.class.php'; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | */ |
407 | 407 | public function LinkSetClassName() |
408 | 408 | { |
409 | - return $this->LinkClassName() . 'Set'; |
|
409 | + return $this->LinkClassName().'Set'; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function getRecordSetByRef($recordClassname) |
431 | 431 | { |
432 | - $classSet = $recordClassname . 'Set'; |
|
432 | + $classSet = $recordClassname.'Set'; |
|
433 | 433 | $set = $this->$classSet(); |
434 | 434 | return $set; |
435 | 435 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | { |
467 | 467 | $fullClassName = get_class($record); |
468 | 468 | list(, $className) = explode('_', $fullClassName); |
469 | - return $className . ':' . $record->id; |
|
469 | + return $className.':'.$record->id; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | |
@@ -557,16 +557,16 @@ discard block |
||
557 | 557 | */ |
558 | 558 | public function mailTo($addr, $subject = null, $body = null) |
559 | 559 | { |
560 | - $mailTo = 'mailto:' . $addr; |
|
560 | + $mailTo = 'mailto:'.$addr; |
|
561 | 561 | $parameters = array(); |
562 | 562 | if (isset($subject)) { |
563 | - $parameters[] = 'subject=' . $subject; |
|
563 | + $parameters[] = 'subject='.$subject; |
|
564 | 564 | } |
565 | 565 | if (isset($body)) { |
566 | - $parameters[] = 'body=' . $body; |
|
566 | + $parameters[] = 'body='.$body; |
|
567 | 567 | } |
568 | 568 | if (!empty($parameters)) { |
569 | - $mailTo .= '?' . implode('&', $parameters); |
|
569 | + $mailTo .= '?'.implode('&', $parameters); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | return $mailTo; |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } |
618 | 618 | |
619 | 619 | $number = number_format($number, $decimals, ',', ' '); |
620 | - return str_replace(' ', bab_nbsp(), $number . ' ' . $prefix . $unitSymbol); |
|
620 | + return str_replace(' ', bab_nbsp(), $number.' '.$prefix.$unitSymbol); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | } |
638 | 638 | |
639 | 639 | if (!isset($format)) { |
640 | - $format = bab_registry::get('/' . $this->addonName . '/numberFormat', $PhoneNumber->getDefaultFormat()); |
|
640 | + $format = bab_registry::get('/'.$this->addonName.'/numberFormat', $PhoneNumber->getDefaultFormat()); |
|
641 | 641 | } |
642 | 642 | $phoneNumberUtil = $PhoneNumber->PhoneNumberUtil(); |
643 | 643 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | */ |
659 | 659 | public function includeController() |
660 | 660 | { |
661 | - require_once APP_PHP_PATH . '/controller.class.php'; |
|
661 | + require_once APP_PHP_PATH.'/controller.class.php'; |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public function includeRecordController() |
669 | 669 | { |
670 | - require_once APP_CTRL_PATH . '/record.ctrl.php'; |
|
670 | + require_once APP_CTRL_PATH.'/record.ctrl.php'; |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | */ |
708 | 708 | public function includeUi() |
709 | 709 | { |
710 | - require_once APP_UI_PATH . 'ui.class.php'; |
|
710 | + require_once APP_UI_PATH.'ui.class.php'; |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | public function Ui() |
720 | 720 | { |
721 | 721 | $this->includeUi(); |
722 | - return bab_getInstance($this->classPrefix . 'Ui');//->setApp($this); |
|
722 | + return bab_getInstance($this->classPrefix.'Ui'); //->setApp($this); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | /** |
@@ -747,29 +747,29 @@ discard block |
||
747 | 747 | |
748 | 748 | case substr($name, -strlen('SetClassName')) === 'SetClassName': |
749 | 749 | $setName = substr($name, 0, strlen($name) - strlen('ClassName')); |
750 | - return $this->classPrefix . $setName; |
|
750 | + return $this->classPrefix.$setName; |
|
751 | 751 | |
752 | 752 | case substr($name, -strlen('ClassName')) === 'ClassName': |
753 | 753 | $recordName = substr($name, 0, strlen($name) - strlen('ClassName')); |
754 | - return $this->classPrefix . $recordName; |
|
754 | + return $this->classPrefix.$recordName; |
|
755 | 755 | |
756 | 756 | case substr($name, 0, strlen('include')) === 'include' && substr($name, -strlen('Set')) === 'Set': |
757 | 757 | $fileNameBase = strtolower(substr(substr($name, 0, strlen($name) - strlen('Set')), strlen('include'))); |
758 | - require_once APP_SET_PATH . $fileNameBase . '.class.php'; |
|
758 | + require_once APP_SET_PATH.$fileNameBase.'.class.php'; |
|
759 | 759 | return; |
760 | 760 | |
761 | 761 | case substr($name, -strlen('Set')) === 'Set': |
762 | - $includeMethod = 'include' . $name; |
|
762 | + $includeMethod = 'include'.$name; |
|
763 | 763 | $this->$includeMethod(); |
764 | - $setClassNameMethod = $name . 'ClassName'; |
|
764 | + $setClassNameMethod = $name.'ClassName'; |
|
765 | 765 | $className = $this->$setClassNameMethod(); |
766 | 766 | $set = new $className($this); |
767 | 767 | return $set; |
768 | 768 | |
769 | 769 | //case method_exists($this, $name . 'Set'): |
770 | 770 | default: |
771 | - $setName = $name . 'Set'; |
|
772 | - $recordClassNameMethod = $name . 'ClassName'; |
|
771 | + $setName = $name.'Set'; |
|
772 | + $recordClassNameMethod = $name.'ClassName'; |
|
773 | 773 | $recordClassName = $this->$recordClassNameMethod(); |
774 | 774 | if (isset($arguments[0])) { |
775 | 775 | if ($arguments[0] instanceof $recordClassName) { |
@@ -540,10 +540,10 @@ |
||
540 | 540 | /** |
541 | 541 | * Match records created by the specified user or the current connected user if none specified. |
542 | 542 | * |
543 | - * @param int|null $userId |
|
544 | - * |
|
545 | - * @return ORM_IsCriterion |
|
546 | - */ |
|
543 | + * @param int|null $userId |
|
544 | + * |
|
545 | + * @return ORM_IsCriterion |
|
546 | + */ |
|
547 | 547 | public function isOwn($userId = null) |
548 | 548 | { |
549 | 549 | if (!isset($userId)) { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | return parent::delete($criteria); |
244 | 244 | } |
245 | 245 | |
246 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; |
|
246 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; |
|
247 | 247 | $now = BAB_DateTime::now()->getIsoDateTime(); |
248 | 248 | |
249 | 249 | $records = $this->select($criteria); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | return parent::save($record); |
280 | 280 | } |
281 | 281 | |
282 | - require_once $GLOBALS['babInstallPath'] . '/utilit/dateTime.php'; |
|
282 | + require_once $GLOBALS['babInstallPath'].'/utilit/dateTime.php'; |
|
283 | 283 | |
284 | 284 | $now = BAB_DateTime::now()->getIsoDateTime(); |
285 | 285 | |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | */ |
310 | 310 | private function uuid() |
311 | 311 | { |
312 | - return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', |
|
313 | - mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), |
|
314 | - mt_rand( 0, 0x0fff ) | 0x4000, |
|
315 | - mt_rand( 0, 0x3fff ) | 0x8000, |
|
316 | - mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); |
|
312 | + return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', |
|
313 | + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), |
|
314 | + mt_rand(0, 0x0fff) | 0x4000, |
|
315 | + mt_rand(0, 0x3fff) | 0x8000, |
|
316 | + mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | |
404 | 404 | $linkSet->hasOne('sourceId', get_class($this)); |
405 | 405 | |
406 | - $criteria = $linkSet->targetClass->is(get_class($target)) |
|
406 | + $criteria = $linkSet->targetClass->is(get_class($target)) |
|
407 | 407 | ->_AND_($linkSet->targetId->is($target->id)) |
408 | 408 | ->_AND_($linkSet->sourceClass->is($this->getRecordClassName())); |
409 | 409 | if (isset($linkType)) { |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | |
434 | 434 | $linkSet->hasOne('targetId', get_class($this)); |
435 | 435 | |
436 | - $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
436 | + $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
437 | 437 | ->_AND_($linkSet->sourceId->is($source->id)) |
438 | 438 | ->_AND_($linkSet->targetClass->is($this->getRecordClassName())); |
439 | 439 | if (isset($linkType)) { |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $sourcesCriteria[] = $linkSet->sourceClass->is($sourceClass)->_AND_($linkSet->sourceId->in($sourceIds)); |
478 | 478 | } |
479 | 479 | |
480 | - $criteria = $linkSet->all( |
|
480 | + $criteria = $linkSet->all( |
|
481 | 481 | $linkSet->targetClass->is($this->getRecordClassName()), |
482 | 482 | $linkSet->any($sourcesCriteria) |
483 | 483 | ); |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | $targetsCriteria[] = $linkSet->targetClass->is($targetClass)->_AND_($linkSet->targetId->in($targetIds)); |
523 | 523 | } |
524 | 524 | |
525 | - $criteria = $linkSet->all( |
|
525 | + $criteria = $linkSet->all( |
|
526 | 526 | $linkSet->sourceClass->is($this->getRecordClassName()), |
527 | 527 | $linkSet->any($targetsCriteria) |
528 | 528 | ); |
@@ -575,10 +575,10 @@ discard block |
||
575 | 575 | */ |
576 | 576 | class app_TraceableRecord extends app_Record |
577 | 577 | { |
578 | - const DELETED_STATUS_EXISTING = 0; // Normal status of a record |
|
579 | - const DELETED_STATUS_DELETED = 1; // Record is deleted by retrievable by admin |
|
580 | - const DELETED_STATUS_IN_TRASH = 2; // Record is deleted by retrievable by authorized users |
|
581 | - const DELETED_STATUS_DRAFT = 3; // Status is in draft (not yet created) |
|
578 | + const DELETED_STATUS_EXISTING = 0; // Normal status of a record |
|
579 | + const DELETED_STATUS_DELETED = 1; // Record is deleted by retrievable by admin |
|
580 | + const DELETED_STATUS_IN_TRASH = 2; // Record is deleted by retrievable by authorized users |
|
581 | + const DELETED_STATUS_DRAFT = 3; // Status is in draft (not yet created) |
|
582 | 582 | |
583 | 583 | public static function getDeletedStatuses() |
584 | 584 | { |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | { |
612 | 612 | $linkSet = $this->App()->LinkSet(); |
613 | 613 | |
614 | - $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
614 | + $criteria = $linkSet->sourceClass->is(get_class($source)) |
|
615 | 615 | ->_AND_($linkSet->sourceId->is($source->id)) |
616 | 616 | ->_AND_($linkSet->targetClass->is(get_class($this))) |
617 | 617 | ->_AND_($linkSet->targetId->is($this->id)); |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | { |
642 | 642 | $linkSet = $this->App()->LinkSet(); |
643 | 643 | |
644 | - $criteria = $linkSet->targetClass->is(get_class($target)) |
|
644 | + $criteria = $linkSet->targetClass->is(get_class($target)) |
|
645 | 645 | ->_AND_($linkSet->targetId->is($target->id)) |
646 | 646 | ->_AND_($linkSet->sourceClass->is(get_class($this))) |
647 | 647 | ->_AND_($linkSet->sourceId->is($this->id)); |
@@ -72,205 +72,205 @@ |
||
72 | 72 | |
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * @param string $sourceClass |
|
77 | - */ |
|
78 | - public function joinSource($sourceClass) |
|
79 | - { |
|
80 | - if (get_class($this->sourceId) !== $sourceClass . 'Set') { |
|
81 | - $this->hasOne('sourceId', $sourceClass . 'Set'); |
|
82 | - $this->join('sourceId'); |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param string $targetClass |
|
89 | - */ |
|
90 | - public function joinTarget($targetClass = null) |
|
91 | - { |
|
92 | - if (get_class($this->targetId) !== $targetClass . 'Set') { |
|
93 | - $this->hasOne('targetId', $targetClass . 'Set'); |
|
94 | - $this->join('targetId'); |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - public function sourceIsA($recordClass) |
|
101 | - { |
|
102 | - return $this->sourceClass->is($recordClass); |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * |
|
107 | - * @return ORM_Iterator |
|
108 | - */ |
|
109 | - public function selectForSource(app_Record $object, $targetClass = null, $linkType = null) |
|
110 | - { |
|
111 | - $criteria = $this->sourceId->is($object->id) |
|
75 | + /** |
|
76 | + * @param string $sourceClass |
|
77 | + */ |
|
78 | + public function joinSource($sourceClass) |
|
79 | + { |
|
80 | + if (get_class($this->sourceId) !== $sourceClass . 'Set') { |
|
81 | + $this->hasOne('sourceId', $sourceClass . 'Set'); |
|
82 | + $this->join('sourceId'); |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param string $targetClass |
|
89 | + */ |
|
90 | + public function joinTarget($targetClass = null) |
|
91 | + { |
|
92 | + if (get_class($this->targetId) !== $targetClass . 'Set') { |
|
93 | + $this->hasOne('targetId', $targetClass . 'Set'); |
|
94 | + $this->join('targetId'); |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + public function sourceIsA($recordClass) |
|
101 | + { |
|
102 | + return $this->sourceClass->is($recordClass); |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * |
|
107 | + * @return ORM_Iterator |
|
108 | + */ |
|
109 | + public function selectForSource(app_Record $object, $targetClass = null, $linkType = null) |
|
110 | + { |
|
111 | + $criteria = $this->sourceId->is($object->id) |
|
112 | 112 | ->_AND_($this->sourceClass->is(get_class($object))); |
113 | 113 | |
114 | - if (isset($targetClass)) { |
|
115 | - $this->joinTarget($targetClass); |
|
116 | - $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
117 | - } |
|
118 | - |
|
119 | - if (isset($linkType)) { |
|
120 | - if (is_array($linkType)) { |
|
121 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
122 | - } else { |
|
123 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
124 | - } |
|
125 | - } |
|
126 | - |
|
127 | - if (is_a($this->targetId, 'app_TraceableRecordSet')) { |
|
128 | - $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); |
|
129 | - } |
|
130 | - |
|
131 | - return $this->select($criteria); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * |
|
137 | - * @return ORM_Iterator |
|
138 | - */ |
|
139 | - public function selectForSources($objects, $targetClass, $linkType = null) |
|
140 | - { |
|
141 | - $sourceClass = null; |
|
142 | - $sourceIds = array(); |
|
143 | - |
|
144 | - foreach ($objects as $obj) { |
|
145 | - if (is_null($sourceClass)) { |
|
146 | - $sourceClass = get_class($obj); |
|
147 | - } |
|
148 | - $sourceIds[] = $obj->id; |
|
149 | - } |
|
150 | - $criteria = $this->sourceId->in($sourceIds) |
|
151 | - ->_AND_($this->sourceClass->is($sourceClass)); |
|
152 | - |
|
153 | - if (isset($targetClass)) { |
|
154 | - $this->joinTarget($targetClass); |
|
155 | - $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
156 | - } |
|
157 | - |
|
158 | - if (isset($linkType)) { |
|
159 | - if (is_array($linkType)) { |
|
160 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
161 | - } else { |
|
162 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
163 | - } |
|
164 | - } |
|
165 | - return $this->select($criteria); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * |
|
171 | - * @return ORM_Iterator |
|
172 | - */ |
|
173 | - public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null) |
|
174 | - { |
|
175 | - $criteria = $this->targetId->is($object->id) |
|
176 | - ->_AND_($this->targetClass->is(get_class($object))); |
|
177 | - |
|
178 | - if (isset($sourceClass)) { |
|
179 | - $this->joinSource($sourceClass); |
|
180 | - $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
181 | - } |
|
182 | - |
|
183 | - if (isset($linkType)) { |
|
184 | - if (is_array($linkType)) { |
|
185 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
186 | - } else { |
|
187 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - return $this->select($criteria); |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * |
|
197 | - * @return ORM_Iterator |
|
198 | - */ |
|
199 | - public function selectForTargets($objects, $sourceClass = null, $linkType = null) |
|
200 | - { |
|
201 | - $targetClass = null; |
|
202 | - $targetIds = array(); |
|
203 | - |
|
204 | - foreach ($objects as $obj) { |
|
205 | - if (is_null($targetClass)) { |
|
206 | - $targetClass = get_class($obj); |
|
207 | - } |
|
208 | - $targetIds[] = $obj->id; |
|
209 | - } |
|
210 | - $criteria = $this->targetId->in($targetIds) |
|
211 | - ->_AND_($this->targetClass->is($targetClass)); |
|
212 | - |
|
213 | - if (isset($sourceClass)) { |
|
214 | - $this->joinSource($sourceClass); |
|
215 | - $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
216 | - } |
|
217 | - |
|
218 | - if (isset($linkType)) { |
|
219 | - if (is_array($linkType)) { |
|
220 | - $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
221 | - } else { |
|
222 | - $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
223 | - } |
|
224 | - } |
|
225 | - |
|
226 | - return $this->select($criteria); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * delete all links to an object |
|
233 | - * |
|
234 | - * @param app_Record $object |
|
235 | - * @param string $targetClass if target class is set, links will be deleted only for target classes |
|
236 | - * @param bool $deleteTarget if set to true, the target will be deleted to |
|
237 | - */ |
|
238 | - public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null) |
|
239 | - { |
|
240 | - $set = clone $this; |
|
241 | - $App = $object->App(); |
|
242 | - |
|
243 | - $criteria = $set->sourceId->is($object->id)->_AND_( |
|
244 | - $set->sourceClass->is(get_class($object)) |
|
245 | - ); |
|
246 | - |
|
247 | - if (null !== $targetClass) { |
|
248 | - $criteria = $criteria->_AND_( |
|
249 | - $set->targetClass->is($targetClass) |
|
250 | - ); |
|
251 | - } |
|
252 | - if (null !== $linkType) { |
|
253 | - $criteria = $criteria->_AND_( |
|
254 | - $set->type->is($linkType) |
|
255 | - ); |
|
256 | - } |
|
257 | - |
|
258 | - if ($deleteTarget) { |
|
259 | - foreach($set->select($criteria) as $link) { |
|
260 | - |
|
261 | - $className = $link->targetClass.'Set'; |
|
262 | - |
|
263 | - // remove prefix |
|
264 | - |
|
265 | - $className = mb_substr($className, 1 + mb_strpos($className, '_')); |
|
266 | - $targetSet = $App->$className(); |
|
267 | - |
|
268 | - $targetSet->delete($targetSet->id->is($link->targetId)); |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - return $set->delete($criteria); |
|
273 | - } |
|
114 | + if (isset($targetClass)) { |
|
115 | + $this->joinTarget($targetClass); |
|
116 | + $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
117 | + } |
|
118 | + |
|
119 | + if (isset($linkType)) { |
|
120 | + if (is_array($linkType)) { |
|
121 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
122 | + } else { |
|
123 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
124 | + } |
|
125 | + } |
|
126 | + |
|
127 | + if (is_a($this->targetId, 'app_TraceableRecordSet')) { |
|
128 | + $criteria = $criteria->_AND_($this->targetId->deleted->is(false)); |
|
129 | + } |
|
130 | + |
|
131 | + return $this->select($criteria); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * |
|
137 | + * @return ORM_Iterator |
|
138 | + */ |
|
139 | + public function selectForSources($objects, $targetClass, $linkType = null) |
|
140 | + { |
|
141 | + $sourceClass = null; |
|
142 | + $sourceIds = array(); |
|
143 | + |
|
144 | + foreach ($objects as $obj) { |
|
145 | + if (is_null($sourceClass)) { |
|
146 | + $sourceClass = get_class($obj); |
|
147 | + } |
|
148 | + $sourceIds[] = $obj->id; |
|
149 | + } |
|
150 | + $criteria = $this->sourceId->in($sourceIds) |
|
151 | + ->_AND_($this->sourceClass->is($sourceClass)); |
|
152 | + |
|
153 | + if (isset($targetClass)) { |
|
154 | + $this->joinTarget($targetClass); |
|
155 | + $criteria = $criteria->_AND_($this->targetClass->is($targetClass)); |
|
156 | + } |
|
157 | + |
|
158 | + if (isset($linkType)) { |
|
159 | + if (is_array($linkType)) { |
|
160 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
161 | + } else { |
|
162 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
163 | + } |
|
164 | + } |
|
165 | + return $this->select($criteria); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * |
|
171 | + * @return ORM_Iterator |
|
172 | + */ |
|
173 | + public function selectForTarget(app_Record $object, $sourceClass = null, $linkType = null) |
|
174 | + { |
|
175 | + $criteria = $this->targetId->is($object->id) |
|
176 | + ->_AND_($this->targetClass->is(get_class($object))); |
|
177 | + |
|
178 | + if (isset($sourceClass)) { |
|
179 | + $this->joinSource($sourceClass); |
|
180 | + $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
181 | + } |
|
182 | + |
|
183 | + if (isset($linkType)) { |
|
184 | + if (is_array($linkType)) { |
|
185 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
186 | + } else { |
|
187 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + return $this->select($criteria); |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * |
|
197 | + * @return ORM_Iterator |
|
198 | + */ |
|
199 | + public function selectForTargets($objects, $sourceClass = null, $linkType = null) |
|
200 | + { |
|
201 | + $targetClass = null; |
|
202 | + $targetIds = array(); |
|
203 | + |
|
204 | + foreach ($objects as $obj) { |
|
205 | + if (is_null($targetClass)) { |
|
206 | + $targetClass = get_class($obj); |
|
207 | + } |
|
208 | + $targetIds[] = $obj->id; |
|
209 | + } |
|
210 | + $criteria = $this->targetId->in($targetIds) |
|
211 | + ->_AND_($this->targetClass->is($targetClass)); |
|
212 | + |
|
213 | + if (isset($sourceClass)) { |
|
214 | + $this->joinSource($sourceClass); |
|
215 | + $criteria = $criteria->_AND_($this->sourceClass->is($sourceClass)); |
|
216 | + } |
|
217 | + |
|
218 | + if (isset($linkType)) { |
|
219 | + if (is_array($linkType)) { |
|
220 | + $criteria = $criteria->_AND_($this->type->in($linkType)); |
|
221 | + } else { |
|
222 | + $criteria = $criteria->_AND_($this->type->is($linkType)); |
|
223 | + } |
|
224 | + } |
|
225 | + |
|
226 | + return $this->select($criteria); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * delete all links to an object |
|
233 | + * |
|
234 | + * @param app_Record $object |
|
235 | + * @param string $targetClass if target class is set, links will be deleted only for target classes |
|
236 | + * @param bool $deleteTarget if set to true, the target will be deleted to |
|
237 | + */ |
|
238 | + public function deleteForSource(app_Record $object, $targetClass = null, $deleteTarget = false, $linkType = null) |
|
239 | + { |
|
240 | + $set = clone $this; |
|
241 | + $App = $object->App(); |
|
242 | + |
|
243 | + $criteria = $set->sourceId->is($object->id)->_AND_( |
|
244 | + $set->sourceClass->is(get_class($object)) |
|
245 | + ); |
|
246 | + |
|
247 | + if (null !== $targetClass) { |
|
248 | + $criteria = $criteria->_AND_( |
|
249 | + $set->targetClass->is($targetClass) |
|
250 | + ); |
|
251 | + } |
|
252 | + if (null !== $linkType) { |
|
253 | + $criteria = $criteria->_AND_( |
|
254 | + $set->type->is($linkType) |
|
255 | + ); |
|
256 | + } |
|
257 | + |
|
258 | + if ($deleteTarget) { |
|
259 | + foreach($set->select($criteria) as $link) { |
|
260 | + |
|
261 | + $className = $link->targetClass.'Set'; |
|
262 | + |
|
263 | + // remove prefix |
|
264 | + |
|
265 | + $className = mb_substr($className, 1 + mb_strpos($className, '_')); |
|
266 | + $targetSet = $App->$className(); |
|
267 | + |
|
268 | + $targetSet->delete($targetSet->id->is($link->targetId)); |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + return $set->delete($criteria); |
|
273 | + } |
|
274 | 274 | |
275 | 275 | |
276 | 276 | /** |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function joinSource($sourceClass) |
79 | 79 | { |
80 | - if (get_class($this->sourceId) !== $sourceClass . 'Set') { |
|
81 | - $this->hasOne('sourceId', $sourceClass . 'Set'); |
|
80 | + if (get_class($this->sourceId) !== $sourceClass.'Set') { |
|
81 | + $this->hasOne('sourceId', $sourceClass.'Set'); |
|
82 | 82 | $this->join('sourceId'); |
83 | 83 | } |
84 | 84 | } |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function joinTarget($targetClass = null) |
91 | 91 | { |
92 | - if (get_class($this->targetId) !== $targetClass . 'Set') { |
|
93 | - $this->hasOne('targetId', $targetClass . 'Set'); |
|
92 | + if (get_class($this->targetId) !== $targetClass.'Set') { |
|
93 | + $this->hasOne('targetId', $targetClass.'Set'); |
|
94 | 94 | $this->join('targetId'); |
95 | 95 | } |
96 | 96 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | if ($deleteTarget) { |
259 | - foreach($set->select($criteria) as $link) { |
|
259 | + foreach ($set->select($criteria) as $link) { |
|
260 | 260 | |
261 | 261 | $className = $link->targetClass.'Set'; |
262 | 262 |