1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
// ------------------------------------------------------------------------- |
4
|
|
|
// OVIDENTIA http://www.ovidentia.org |
5
|
|
|
// Ovidentia is free software; you can redistribute it and/or modify |
6
|
|
|
// it under the terms of the GNU General Public License as published by |
7
|
|
|
// the Free Software Foundation; either version 2, or (at your option) |
8
|
|
|
// any later version. |
9
|
|
|
// |
10
|
|
|
// This program is distributed in the hope that it will be useful, but |
11
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
// See the GNU General Public License for more details. |
14
|
|
|
// |
15
|
|
|
// You should have received a copy of the GNU General Public License |
16
|
|
|
// along with this program; if not, write to the Free Software |
17
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
18
|
|
|
// USA. |
19
|
|
|
// ------------------------------------------------------------------------- |
20
|
|
|
/** |
21
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
22
|
|
|
* @copyright Copyright (c) 2022 by SI4YOU ({@link https://www.siforyou.com}) |
23
|
|
|
*/ |
24
|
|
|
namespace Capwelton\LibApp\Set; |
25
|
|
|
|
26
|
|
|
use Capwelton\LibOrm\Field\ORMEnumField; |
|
|
|
|
27
|
|
|
use Capwelton\Widgets\Widgets\Form\WidgetLabelledWidget; |
|
|
|
|
28
|
|
|
use Capwelton\Widgets\Widgets\Form\WidgetRegExpLineEdit; |
|
|
|
|
29
|
|
|
use Capwelton\LibOrm\Field\ORMField; |
|
|
|
|
30
|
|
|
|
31
|
|
|
use function Capwelton\LibOrm\ORM_BoolField; |
|
|
|
|
32
|
|
|
use function Capwelton\LibOrm\ORM_DecimalField; |
|
|
|
|
33
|
|
|
use function Capwelton\LibOrm\ORM_EnumField; |
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @property string $name |
37
|
|
|
* @property string $fieldname |
38
|
|
|
* @property string $description |
39
|
|
|
* @property string $object |
40
|
|
|
* @property string $fieldtype |
41
|
|
|
* @property string $enumvalues |
42
|
|
|
* @property bool $mandatory |
43
|
|
|
* |
44
|
|
|
* @method Func_App App() |
45
|
|
|
*/ |
46
|
|
|
class AppCustomField extends AppTraceableRecord |
47
|
|
|
{ |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return ORMField |
51
|
|
|
*/ |
52
|
|
|
public function getORMField() |
53
|
|
|
{ |
54
|
|
|
switch ($this->fieldtype) { |
55
|
|
|
case 'Enum': |
56
|
|
|
$field = ORM_EnumField($this->fieldname, $this->getEnumValues()); |
57
|
|
|
break; |
58
|
|
|
|
59
|
|
|
case 'Decimal': |
60
|
|
|
$field = ORM_DecimalField($this->fieldname, 2); |
61
|
|
|
break; |
62
|
|
|
|
63
|
|
|
case 'Bool': |
64
|
|
|
$field = ORM_BoolField($this->fieldname); |
65
|
|
|
$field->setOutputOptions($this->App() |
66
|
|
|
->translate('No'), $this->App() |
67
|
|
|
->translate('Yes')); |
68
|
|
|
break; |
69
|
|
|
|
70
|
|
|
default: |
71
|
|
|
$function = 'Capwelton\LibOrm\ORM_' . $this->fieldtype . 'Field'; |
72
|
|
|
$field = $function($this->fieldname); |
73
|
|
|
break; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$field->setDescription($this->description); |
77
|
|
|
|
78
|
|
|
return $field; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string[] |
83
|
|
|
*/ |
84
|
|
|
public function getEnumValues() |
85
|
|
|
{ |
86
|
|
|
return unserialize($this->enumvalues); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return WidgetLabelledWidget |
91
|
|
|
*/ |
92
|
|
|
public function getWidget() |
93
|
|
|
{ |
94
|
|
|
$W = bab_Widgets(); |
95
|
|
|
$App = $this->App(); |
96
|
|
|
|
97
|
|
|
switch ($this->fieldtype) { |
98
|
|
|
case 'Text': |
99
|
|
|
$widget = $W->TextEdit() |
100
|
|
|
->setLines(3) |
101
|
|
|
->setColumns(70); |
102
|
|
|
break; |
103
|
|
|
|
104
|
|
|
case 'Bool': |
105
|
|
|
$widget = $W->Checkbox(); |
106
|
|
|
break; |
107
|
|
|
|
108
|
|
|
case 'Enum': |
109
|
|
|
$options = array( |
110
|
|
|
'' => '' |
111
|
|
|
) + $this->getEnumValues(); |
112
|
|
|
$widget = $W->Select()->setOptions($options); |
113
|
|
|
break; |
114
|
|
|
|
115
|
|
|
case 'Date': |
116
|
|
|
$widget = $W->DatePicker(); |
117
|
|
|
break; |
118
|
|
|
|
119
|
|
|
case 'DateTime': |
120
|
|
|
$widget = $W->DateTimePicker(); |
121
|
|
|
break; |
122
|
|
|
|
123
|
|
|
case 'Int': |
124
|
|
|
$widget = $W->RegExpLineEdit(); |
125
|
|
|
$widget->setRegExp(WidgetRegExpLineEdit::INT_FORMAT) |
126
|
|
|
->setSubmitMessage(sprintf($App->translate('The field %s should be a integer number'), $this->name)) |
127
|
|
|
->setSize(10); |
128
|
|
|
break; |
129
|
|
|
|
130
|
|
|
case 'Decimal': |
131
|
|
|
$widget = $W->RegExpLineEdit(); |
132
|
|
|
$widget->setRegExp(WidgetRegExpLineEdit::FLOAT_FORMAT) |
133
|
|
|
->setSubmitMessage(sprintf($App->translate('The field %s should be a decimal number'), $this->name)) |
134
|
|
|
->setSize(10); |
135
|
|
|
break; |
136
|
|
|
|
137
|
|
|
case 'Url': |
138
|
|
|
$widget = $W->UrlLineEdit(); |
139
|
|
|
break; |
140
|
|
|
|
141
|
|
|
case 'Email': |
142
|
|
|
$widget = $W->EmailLineEdit(); |
143
|
|
|
break; |
144
|
|
|
|
145
|
|
|
default: |
146
|
|
|
case 'String': |
147
|
|
|
$widget = $W->LineEdit() |
148
|
|
|
->setSize(70) |
149
|
|
|
->setMaxSize(255); |
150
|
|
|
break; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
$labelledItem = $W->LabelledWidget($this->name, $widget, null); |
154
|
|
|
$labelledItem->setName($this->fieldname); |
155
|
|
|
|
156
|
|
|
if(! empty($this->description)){ |
157
|
|
|
$labelledItem->setDescription($this->description); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
return $labelledItem; |
|
|
|
|
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|
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