1 | <?php |
||||||
2 | //------------------------------------------------------------------------- |
||||||
3 | // OVIDENTIA http://www.ovidentia.org |
||||||
4 | // Ovidentia is free software; you can redistribute it and/or modify |
||||||
5 | // it under the terms of the GNU General Public License as published by |
||||||
6 | // the Free Software Foundation; either version 2, or (at your option) |
||||||
7 | // any later version. |
||||||
8 | // |
||||||
9 | // This program is distributed in the hope that it will be useful, but |
||||||
10 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
12 | // See the GNU General Public License for more details. |
||||||
13 | // |
||||||
14 | // You should have received a copy of the GNU General Public License |
||||||
15 | // along with this program; if not, write to the Free Software |
||||||
16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
||||||
17 | // USA. |
||||||
18 | //------------------------------------------------------------------------- |
||||||
19 | /** |
||||||
20 | * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
||||||
21 | * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr}) |
||||||
22 | */ |
||||||
23 | |||||||
24 | namespace Capwelton\LibApp\Ui; |
||||||
25 | |||||||
26 | /** |
||||||
27 | * Creates a generic form fragment for the specified set. |
||||||
28 | * |
||||||
29 | * @param ORMRecordSet $set |
||||||
30 | * @return WidgetItem |
||||||
31 | */ |
||||||
32 | |||||||
33 | use Capwelton\LibApp\Set\AppRecordSet; |
||||||
34 | use Capwelton\Widgets\Widgets\Abstracts\WidgetBoxLayout; |
||||||
0 ignored issues
–
show
|
|||||||
35 | use Capwelton\Widgets\Widgets\Abstracts\WidgetInputWidget; |
||||||
0 ignored issues
–
show
The type
Capwelton\Widgets\Widget...racts\WidgetInputWidget was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
36 | use Capwelton\Widgets\Widgets\Abstracts\WidgetItem; |
||||||
0 ignored issues
–
show
The type
Capwelton\Widgets\Widgets\Abstracts\WidgetItem was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
37 | use Capwelton\Widgets\Widgets\Form\WidgetCheckBox; |
||||||
0 ignored issues
–
show
The type
Capwelton\Widgets\Widgets\Form\WidgetCheckBox was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
38 | use Capwelton\Widgets\Widgets\Interfaces\WidgetDisplayableInterface; |
||||||
0 ignored issues
–
show
The type
Capwelton\Widgets\Widget...getDisplayableInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
39 | use Capwelton\Widgets\Widgets\Helpers\WidgetSizePolicy; |
||||||
0 ignored issues
–
show
The type
Capwelton\Widgets\Widgets\Helpers\WidgetSizePolicy was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
40 | use Capwelton\Widgets\Widgets\Item\WidgetLabel; |
||||||
0 ignored issues
–
show
The type
Capwelton\Widgets\Widgets\Item\WidgetLabel was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
41 | use Capwelton\LibOrm\ORMRecordSet; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\ORMRecordSet was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
42 | use Capwelton\LibOrm\Field\ORMDateField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMDateField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
43 | use Capwelton\LibOrm\Field\ORMTimeField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMTimeField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
44 | use Capwelton\LibOrm\Field\ORMStringField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMStringField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
45 | use Capwelton\LibOrm\Field\ORMEnumField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMEnumField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
46 | use Capwelton\LibOrm\Field\ORMIntField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMIntField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
47 | use Capwelton\LibOrm\Field\ORMTextField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMTextField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
48 | use Capwelton\LibOrm\MySql\ORMMySqlIterator; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\MySql\ORMMySqlIterator was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
49 | use Capwelton\LibOrm\Field\ORMField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
50 | use Capwelton\LibOrm\Field\ORMDatetimeField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMDatetimeField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
51 | use Capwelton\LibOrm\Field\ORMSetField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMSetField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
52 | use Capwelton\LibOrm\Field\ORMUserField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMUserField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
53 | use Capwelton\LibOrm\Field\ORMCurrencyField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMCurrencyField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
54 | use Capwelton\LibOrm\Field\ORMBoolField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMBoolField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
55 | use Capwelton\LibOrm\Field\ORMEmailField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMEmailField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
56 | use Capwelton\LibOrm\Field\ORMFileField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMFileField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
57 | use Capwelton\LibOrm\Field\ORMPkField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMPkField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
58 | use Capwelton\LibOrm\Field\ORMFkField; |
||||||
0 ignored issues
–
show
The type
Capwelton\LibOrm\Field\ORMFkField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
59 | |||||||
60 | function app_genericSetEditor(ORMRecordSet $set) |
||||||
61 | { |
||||||
62 | $O = \bab_functionality::get('LibOrm'); |
||||||
63 | $O->init(); |
||||||
0 ignored issues
–
show
The method
init() does not exist on bab_functionality . It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App or Func_LibOrm .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
64 | $W = \bab_Widgets(); |
||||||
65 | $layout = $W->VBoxLayout(); |
||||||
66 | $layout->setVerticalSpacing(1, 'em'); |
||||||
67 | |||||||
68 | |||||||
69 | $fields = $set->getFields(); |
||||||
70 | |||||||
71 | foreach ($fields as $field) { |
||||||
72 | $description = $field->getDescription(); |
||||||
73 | if (empty($description)) { |
||||||
74 | $description = $field->getName(); |
||||||
75 | } |
||||||
76 | $fieldLabel = $W->Label($description . ':'); |
||||||
77 | |||||||
78 | if ($field instanceof ORMDateField) { |
||||||
79 | $widget = $W->DatePicker(); |
||||||
80 | } else if ($field instanceof ORMTimeField) { |
||||||
81 | $widget = $W->LineEdit()->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
||||||
82 | } else if ($field instanceof ORMStringField) { |
||||||
83 | $widget = $W->LineEdit()->setSize(min(array(80, $field->getMaxLength()))); |
||||||
84 | } else if ($field instanceof ORMEnumField) { |
||||||
85 | $widget = $W->Select(); |
||||||
86 | $widget->addOption('', ''); |
||||||
87 | foreach ($field->getValues() as $key => $text) { |
||||||
88 | $widget->addOption($key, $text); |
||||||
89 | } |
||||||
90 | } else if ($field instanceof ORMIntField) { |
||||||
91 | $widget = $W->LineEdit()->setSize(9); |
||||||
92 | } else if ($field instanceof ORMTextField) { |
||||||
93 | $widget = $W->TextEdit()->setColumns(80)->setLines(5); |
||||||
94 | } else if ($field instanceof ORMRecordSet) { |
||||||
95 | $widget = app_genericSetEditor($field); |
||||||
96 | $widget->addClass('sub-form'); |
||||||
97 | } else { |
||||||
98 | $widget = null; |
||||||
99 | } |
||||||
100 | if (isset($widget)) { |
||||||
101 | $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
||||||
102 | } |
||||||
103 | } |
||||||
104 | |||||||
105 | return $layout; |
||||||
106 | } |
||||||
107 | |||||||
108 | |||||||
109 | |||||||
110 | /** |
||||||
111 | * Creates a generic form fragment for the specified set. |
||||||
112 | * |
||||||
113 | * @param ORMRecordSet $set |
||||||
114 | * @return WidgetItem |
||||||
115 | */ |
||||||
116 | function app_genericSetFilterForm(ORMRecordSet $set) |
||||||
117 | { |
||||||
118 | $O = \bab_functionality::get('LibOrm'); |
||||||
119 | $O->init(); |
||||||
120 | $W = \bab_Widgets(); |
||||||
121 | $layout = $W->FlowLayout(); |
||||||
122 | $layout->setVerticalSpacing(1, 'em')->setHorizontalSpacing(1, 'em'); |
||||||
123 | |||||||
124 | |||||||
125 | $fields = $set->getFields(); |
||||||
126 | |||||||
127 | foreach ($fields as $field) { |
||||||
128 | $description = $field->getDescription(); |
||||||
129 | if (empty($description)) { |
||||||
130 | $description = $field->getName(); |
||||||
131 | } |
||||||
132 | $fieldLabel = $W->Label($description . ':'); |
||||||
133 | |||||||
134 | if ($field instanceof ORMDateField) { |
||||||
135 | $widget = $W->PeriodPicker(); |
||||||
136 | } else if ($field instanceof ORMTimeField) { |
||||||
137 | $widget = $W->TimePicker(); |
||||||
138 | } else if ($field instanceof ORMStringField) { |
||||||
139 | $widget = $W->LineEdit()->setSize(min(array(15, $field->getMaxLength()))); |
||||||
140 | } else if ($field instanceof ORMEnumField) { |
||||||
141 | $widget = $W->Select(); |
||||||
142 | $widget->addOption('', ''); |
||||||
143 | foreach ($field->getValues() as $key => $text) { |
||||||
144 | $widget->addOption($key, $text); |
||||||
145 | } |
||||||
146 | } else if ($field instanceof ORMIntField) { |
||||||
147 | $widget = $W->LineEdit()->setSize(9); |
||||||
148 | } else if ($field instanceof ORMTextField) { |
||||||
149 | $widget = $widget = $W->LineEdit()->setSize(15); |
||||||
0 ignored issues
–
show
|
|||||||
150 | } else if ($field instanceof ORMRecordSet) { |
||||||
151 | $widget = app_genericSetFilterForm($field); |
||||||
152 | $widget->addClass('sub-form'); |
||||||
153 | } else { |
||||||
154 | $widget = null; |
||||||
155 | } |
||||||
156 | if (isset($widget)) { |
||||||
157 | $layout->addItem($W->VBoxLayout()->addItem($fieldLabel)->addItem($widget)); |
||||||
158 | } |
||||||
159 | } |
||||||
160 | |||||||
161 | return $layout; |
||||||
0 ignored issues
–
show
|
|||||||
162 | } |
||||||
163 | |||||||
164 | |||||||
165 | /** |
||||||
166 | * Associates a label to an input widget. |
||||||
167 | * |
||||||
168 | * @param string $labelText |
||||||
169 | * @param WidgetInputWidget $widget |
||||||
170 | * @return WidgetBoxLayout |
||||||
171 | */ |
||||||
172 | function app_LabelledWidget($labelText, WidgetDisplayableInterface $widget) |
||||||
173 | { |
||||||
174 | $W = \bab_Widgets(); |
||||||
175 | |||||||
176 | $label = $W->Label($labelText); |
||||||
177 | if ($widget instanceof WidgetInputWidget) { |
||||||
178 | $label->setAssociatedWidget($widget); |
||||||
179 | } |
||||||
180 | |||||||
181 | if ($widget instanceof WidgetCheckBox) { |
||||||
182 | $layout = $W->HBoxItems( |
||||||
183 | $widget->setSizePolicy(WidgetSizePolicy::MINIMUM), |
||||||
184 | $label |
||||||
185 | )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
||||||
0 ignored issues
–
show
0.5 of type double is incompatible with the type integer expected by parameter $spacing of Widget_Layout::setHorizontalSpacing() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
186 | } else { |
||||||
187 | $layout = $W->VBoxItems( |
||||||
188 | $label, |
||||||
189 | $widget |
||||||
190 | )->setVerticalSpacing(0.5, 'em'); |
||||||
0 ignored issues
–
show
0.5 of type double is incompatible with the type integer expected by parameter $spacing of Widget_Layout::setVerticalSpacing() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
191 | } |
||||||
192 | |||||||
193 | return $layout; |
||||||
0 ignored issues
–
show
|
|||||||
194 | } |
||||||
195 | |||||||
196 | |||||||
197 | |||||||
198 | function app_LabelledCheckbox($labelText, $checkboxName, $options = null) |
||||||
199 | { |
||||||
200 | $W = \bab_Widgets(); |
||||||
201 | |||||||
202 | $label = $W->Label($labelText)->colon(false); |
||||||
203 | $checkbox = $W->Checkbox()->setName($checkboxName); |
||||||
204 | $label->setAssociatedWidget($checkbox); |
||||||
205 | if (isset($options)) { |
||||||
206 | $label->setSizePolicy(WidgetSizePolicy::FIXED)->setCanvasOptions($options); |
||||||
207 | } |
||||||
208 | |||||||
209 | $layout = $W->HBoxItems( |
||||||
210 | $checkbox->setSizePolicy(WidgetSizePolicy::MINIMUM), |
||||||
211 | $label |
||||||
212 | )->setVerticalAlign('middle')->setHorizontalSpacing(0.5, 'em'); |
||||||
0 ignored issues
–
show
0.5 of type double is incompatible with the type integer expected by parameter $spacing of Widget_Layout::setHorizontalSpacing() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
213 | |||||||
214 | return $layout; |
||||||
215 | } |
||||||
216 | |||||||
217 | |||||||
218 | |||||||
219 | |||||||
220 | function app_LabelledOrmSelect(ORMMySqlIterator $iterator, $fieldName, $selectName, $label, $hidden = false, $groupFieldName = null) |
||||||
221 | { |
||||||
222 | $W = \bab_Widgets(); |
||||||
223 | |||||||
224 | if (isset($groupFieldName)) { |
||||||
225 | $groupPathElements = explode('/', $groupFieldName); |
||||||
226 | } |
||||||
227 | |||||||
228 | $select = $W->Select()->setName($selectName); |
||||||
229 | |||||||
230 | $select->addOption('', ''); |
||||||
231 | |||||||
232 | $nbOptions = 0; |
||||||
233 | foreach ($iterator as $record) { |
||||||
234 | if (isset($record->code)) { |
||||||
235 | $optionText = $record->code . ' - ' . $record->$fieldName; |
||||||
236 | } else { |
||||||
237 | $optionText = $record->$fieldName; |
||||||
238 | } |
||||||
239 | if (isset($groupFieldName)) { |
||||||
240 | $group = $record; |
||||||
241 | foreach ($groupPathElements as $groupPathElement) { |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
242 | $group = $group->$groupPathElement; |
||||||
243 | } |
||||||
244 | $select->addOption($record->id, $optionText, $group); |
||||||
245 | } else { |
||||||
246 | $select->addOption($record->id, $optionText); |
||||||
247 | } |
||||||
248 | $nbOptions++; |
||||||
249 | $lastId = $record->id; |
||||||
250 | } |
||||||
251 | |||||||
252 | if ($nbOptions == 1) { |
||||||
253 | $select->setValue($lastId); |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
254 | } |
||||||
255 | |||||||
256 | |||||||
257 | return app_LabelledWidget($label, $select); |
||||||
258 | } |
||||||
259 | |||||||
260 | |||||||
261 | function app_OrmWidget(ORMField $field) |
||||||
262 | { |
||||||
263 | $W = \bab_Widgets(); |
||||||
264 | if ($field instanceof ORMDateField) { |
||||||
265 | $widget = $W->DatePicker(); |
||||||
266 | } else if ($field instanceof ORMTimeField) { |
||||||
267 | $widget = $W->TimeEdit(); //->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
||||||
268 | } else if ($field instanceof ORMDatetimeField) { |
||||||
269 | $widget = $W->DateTimePicker(); //->setMaxSize(5)->setSize(5)->addClass('widget-timepicker'); |
||||||
270 | } else if ($field instanceof ORMEnumField) { |
||||||
271 | $widget = $W->Select(); |
||||||
272 | //// $widget = $W->MultiSelect()->setSingleSelect(); |
||||||
273 | $widget->addOption('', ''); |
||||||
274 | $values = $field->getValues(); |
||||||
275 | foreach ($values as $key => $value) { |
||||||
276 | $widget->addOption($key, $value); |
||||||
277 | } |
||||||
278 | } else if ($field instanceof ORMSetField) { |
||||||
279 | $widget = $W->MultiSelect()->setSelectedList(2); |
||||||
280 | $values = $field->getValues(); |
||||||
281 | foreach ($values as $key => $value) { |
||||||
282 | $widget->addOption($key, $value); |
||||||
283 | } |
||||||
284 | } else if ($field instanceof ORMUserField) { |
||||||
285 | $widget = $W->SuggestUser() |
||||||
286 | ->setMinChars(0) |
||||||
287 | ->setSizePolicy(\Func_Icons::ICON_LEFT_16); |
||||||
288 | } else if ($field instanceof ORMCurrencyField) { |
||||||
289 | $widget = $W->LineEdit()->setSize(6)->addClass('widget-input-currency'); |
||||||
290 | } else if ($field instanceof ORMBoolField) { |
||||||
291 | $widget = $W->CheckBox()->setCheckedValue('1'); |
||||||
292 | } else if ($field instanceof ORMIntField) { |
||||||
293 | $widget = $W->LineEdit() |
||||||
294 | ->setSize(6)->addClass('widget-input-numeric'); |
||||||
295 | } else if ($field instanceof ORMEmailField) { |
||||||
296 | $widget = $W->EmailLineEdit() |
||||||
297 | ->setMaxSize($field->getMaxLength()); |
||||||
298 | } else if ($field instanceof ORMFileField) { |
||||||
299 | $widget = $W->FilePicker(); |
||||||
300 | } else if ($field instanceof ORMStringField) { |
||||||
301 | $widget = $W->LineEdit() |
||||||
302 | ->setMaxSize($field->getMaxLength()); |
||||||
303 | } else if ($field instanceof ORMTextField) { |
||||||
304 | $widget = $W->TextEdit() |
||||||
305 | ->addClass('widget-autoresize'); |
||||||
306 | } else if ($field instanceof ORMPkField) { |
||||||
307 | $widget = $W->Hidden(); |
||||||
308 | } else if ($field instanceof ORMFkField) { |
||||||
309 | |||||||
310 | $fieldName = $field->getName(); |
||||||
311 | /** @var AppRecordSet $parentSet */ |
||||||
312 | $parentSet = clone $field->getParentSet(); |
||||||
313 | $parentSet->join($fieldName); |
||||||
314 | $set = $parentSet->$fieldName; |
||||||
315 | $records = $set->select(); |
||||||
316 | $pkName = $set->getPrimaryKey(); |
||||||
317 | if($set->fieldExist("name")){ |
||||||
318 | $displayField = $set->name->getName(); |
||||||
319 | }else if(method_exists($set,"getDisplayNameField")){ |
||||||
320 | $displayField = $set->getDisplayNameField()->getName(); |
||||||
321 | }else{ |
||||||
322 | $displayField = $pkName; |
||||||
323 | } |
||||||
324 | $records->orderAsc($set->$displayField); |
||||||
325 | if($records->count() > 50){ |
||||||
326 | $widget = bab_Widgets()->select2(); |
||||||
0 ignored issues
–
show
The method
select2() does not exist on Func_Widgets .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
327 | $widget->setDataSource($set->getController()->search()); |
||||||
328 | }else{ |
||||||
329 | $widget = $W->Select(); |
||||||
330 | $widget->addOption('', ''); |
||||||
331 | foreach ($records as $record) { |
||||||
332 | $widget->addOption($record->$pkName, $record->$displayField); |
||||||
333 | } |
||||||
334 | } |
||||||
335 | } else if ($field instanceof ORMRecordSet) { |
||||||
336 | $widget = $W->Select(); |
||||||
337 | //// $widget = $W->MultiSelect()->setSingleSelect(); |
||||||
338 | // $fieldName = $field->getName(); |
||||||
339 | // $parentSet = $field->getParentSet(); |
||||||
340 | // $parentSet->join($fieldName); |
||||||
341 | // $set = $parentSet->$fieldName; |
||||||
342 | $records = $field->select(); |
||||||
343 | $records->orderAsc($field->name); |
||||||
344 | $pkName = $field->getPrimaryKey(); |
||||||
345 | $widget->addOption('', ''); |
||||||
346 | foreach ($records as $record) { |
||||||
347 | $widget->addOption($record->$pkName, $record->name); |
||||||
348 | } |
||||||
349 | } else { |
||||||
350 | $widget = $W->LineEdit(); |
||||||
351 | } |
||||||
352 | $widget->setName($field->getName()); |
||||||
353 | return $widget; |
||||||
354 | } |
||||||
355 | |||||||
356 | |||||||
357 | |||||||
358 | function app_LabelledOrmWidget(ORMField $field, $label = null, $hidden = false) |
||||||
359 | { |
||||||
360 | $W = \bab_Widgets(); |
||||||
361 | |||||||
362 | if ($hidden) { |
||||||
363 | $widget = $W->Hidden(); |
||||||
364 | $widget->setName($field->getName()); |
||||||
365 | return $widget; |
||||||
366 | } |
||||||
367 | |||||||
368 | if (is_null($label)) { |
||||||
369 | $label = $field->getDescription(); |
||||||
370 | } |
||||||
371 | |||||||
372 | $widget = app_OrmWidget($field); |
||||||
373 | |||||||
374 | return app_LabelledWidget($label, $widget); |
||||||
375 | } |
||||||
376 | |||||||
377 | |||||||
378 | |||||||
379 | |||||||
380 | |||||||
381 | |||||||
382 | /** |
||||||
383 | * |
||||||
384 | * |
||||||
385 | * @param ORMField $field |
||||||
386 | * @param string $value ISO date time |
||||||
387 | */ |
||||||
388 | function app_dateTime(ORMField $field, $value) { |
||||||
389 | |||||||
390 | $W = \bab_functionality::get('Widgets'); |
||||||
391 | $name = $field->getName(); |
||||||
392 | $label = $W->Label($field->getDescription()); |
||||||
0 ignored issues
–
show
The method
Label() does not exist on bab_functionality . It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App or Func_Widgets .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
393 | |||||||
394 | $frame = app_dateTimeField($name, $label, $value); |
||||||
395 | |||||||
396 | return $W->VBoxItems( |
||||||
0 ignored issues
–
show
The method
VBoxItems() does not exist on bab_functionality . It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App or Func_Widgets .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
397 | $label, |
||||||
398 | $frame |
||||||
399 | ); |
||||||
400 | |||||||
401 | } |
||||||
402 | |||||||
403 | |||||||
404 | /** |
||||||
405 | * |
||||||
406 | * |
||||||
407 | * @param string $fieldName |
||||||
408 | * @param WidgetLabel $label |
||||||
409 | * @param string $value ISO date time |
||||||
410 | */ |
||||||
411 | function app_dateTimeField($fieldName, WidgetLabel $label, $value = null) |
||||||
412 | { |
||||||
413 | $W = \bab_functionality::get('Widgets'); |
||||||
414 | |||||||
415 | $datepart = $W->DatePicker()->setAssociatedLabel($label)->setName('date'); |
||||||
0 ignored issues
–
show
The method
DatePicker() does not exist on bab_functionality . It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App or Func_Widgets .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
416 | $timepart = $W->TimePicker()->setName('time'); |
||||||
0 ignored issues
–
show
The method
TimePicker() does not exist on bab_functionality . It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App or Func_Widgets .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
417 | |||||||
418 | if (isset($value)) { |
||||||
419 | |||||||
420 | $value = explode(' ', $value); |
||||||
421 | |||||||
422 | $datepart->setValue($value[0]); |
||||||
423 | $timepart->setValue($value[1]); |
||||||
424 | } |
||||||
425 | |||||||
426 | $datetime = $W->Frame(null, $W->HBoxLayout())->setName($fieldName) |
||||||
0 ignored issues
–
show
The method
HBoxLayout() does not exist on bab_functionality . It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App or Func_Widgets .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The method
Frame() does not exist on bab_functionality . It seems like you code against a sub-type of bab_functionality such as Capwelton\LibApp\Func_App or Func_Widgets .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
427 | ->addItem($datepart) |
||||||
428 | ->addItem($timepart); |
||||||
429 | |||||||
430 | return $datetime; |
||||||
431 | } |
||||||
432 | |||||||
433 | |||||||
434 | |||||||
435 | |||||||
436 | |||||||
437 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths