|
1
|
|
|
<?php |
|
2
|
|
|
namespace EWW\Dpf\Domain\Model; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
class DocumentFormField extends AbstractFormElement |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
protected $value; |
|
21
|
|
|
|
|
22
|
|
|
protected $inputField; |
|
23
|
|
|
|
|
24
|
|
|
protected $selectOptions; |
|
25
|
|
|
|
|
26
|
|
|
protected $inputOptions; |
|
27
|
|
|
|
|
28
|
|
|
protected $fillOutService; |
|
29
|
|
|
|
|
30
|
|
|
protected $defaultInputOption; |
|
31
|
|
|
|
|
32
|
|
|
protected $hasDefaultValue = false; |
|
33
|
|
|
|
|
34
|
|
|
protected $validation; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $dataType; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var int |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $gndFieldUid; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* consent |
|
48
|
|
|
* |
|
49
|
|
|
* @var boolean |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $consent; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @var int |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $maxInputLength; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Embargo field option |
|
60
|
|
|
* |
|
61
|
|
|
* @var bool |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $embargo = false; |
|
64
|
|
|
|
|
65
|
|
|
public function getValue() |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->value; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function setValue($value, $defaultValue = '') |
|
71
|
|
|
{ |
|
72
|
|
|
|
|
73
|
|
|
$this->hasDefaultValue = !empty($defaultValue); |
|
74
|
|
|
|
|
75
|
|
|
if (empty($value)) { |
|
76
|
|
|
switch ($this->inputField) { |
|
77
|
|
|
case \EWW\Dpf\Domain\Model\MetadataObject::select: |
|
78
|
|
|
if (!empty($defaultValue)) { |
|
79
|
|
|
$this->value = $this->defaultInputOption; |
|
80
|
|
|
} else { |
|
81
|
|
|
$this->value = ''; |
|
82
|
|
|
} |
|
83
|
|
|
break; |
|
84
|
|
|
|
|
85
|
|
|
case \EWW\Dpf\Domain\Model\MetadataObject::checkbox: |
|
86
|
|
|
if (!empty($defaultValue)) { |
|
87
|
|
|
$this->value = 'yes'; |
|
88
|
|
|
} else { |
|
89
|
|
|
$this->value = ''; |
|
90
|
|
|
} |
|
91
|
|
|
break; |
|
92
|
|
|
|
|
93
|
|
|
default: |
|
94
|
|
|
$this->value = $defaultValue; |
|
95
|
|
|
break; |
|
96
|
|
|
} |
|
97
|
|
|
} else { |
|
98
|
|
|
$this->value = $value; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function getInputField() |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->inputField; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function setInputField($inputField) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->inputField = $inputField; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* |
|
114
|
|
|
* @return array |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getInputOptions() |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->inputOptions; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* |
|
123
|
|
|
* @param \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList |
|
124
|
|
|
*/ |
|
125
|
|
|
public function setInputOptions(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList = null) |
|
126
|
|
|
{ |
|
127
|
|
|
|
|
128
|
|
|
$this->inputOptions = array(); |
|
129
|
|
|
|
|
130
|
|
|
if ($inputOptionList) { |
|
131
|
|
|
$this->inputOptions[''] = ''; |
|
132
|
|
|
foreach ($inputOptionList->getInputOptions() as $option => $label) { |
|
133
|
|
|
$this->inputOptions[$option] = $label; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
$this->defaultInputOption = trim($inputOptionList->getDefaultValue()); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* Returns the fillOutService |
|
143
|
|
|
* |
|
144
|
|
|
* @return string $fillOutService |
|
145
|
|
|
*/ |
|
146
|
|
|
public function getFillOutService() |
|
147
|
|
|
{ |
|
148
|
|
|
return $this->fillOutService; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Sets the fillOutService |
|
153
|
|
|
* |
|
154
|
|
|
* @param string $fillOutService |
|
155
|
|
|
* @return void |
|
156
|
|
|
*/ |
|
157
|
|
|
public function setFillOutService($fillOutService) |
|
158
|
|
|
{ |
|
159
|
|
|
$this->fillOutService = $fillOutService; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Returns the consent |
|
164
|
|
|
* |
|
165
|
|
|
* @return boolean $consent |
|
166
|
|
|
*/ |
|
167
|
|
|
public function getConsent() |
|
168
|
|
|
{ |
|
169
|
|
|
return $this->consent; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Sets the consent |
|
174
|
|
|
* |
|
175
|
|
|
* @param boolean $consent |
|
176
|
|
|
* @return void |
|
177
|
|
|
*/ |
|
178
|
|
|
public function setConsent($consent) |
|
179
|
|
|
{ |
|
180
|
|
|
$this->consent = $consent; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
public function getHasDefaultValue() |
|
184
|
|
|
{ |
|
185
|
|
|
return $this->hasDefaultValue; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
public function getValidation() |
|
189
|
|
|
{ |
|
190
|
|
|
return $this->validation; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
public function setValidation($validation) |
|
194
|
|
|
{ |
|
195
|
|
|
$this->validation = $validation; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* Gets the data type of the field, e.g. DATE |
|
200
|
|
|
* |
|
201
|
|
|
* @return string |
|
202
|
|
|
*/ |
|
203
|
|
|
public function getDataType() |
|
204
|
|
|
{ |
|
205
|
|
|
return $this->dataType; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* Sets the data type of the field, e.g. DATE |
|
210
|
|
|
* |
|
211
|
|
|
* @param string $dataType |
|
212
|
|
|
* @return void |
|
213
|
|
|
*/ |
|
214
|
|
|
public function setDataType($dataType) |
|
215
|
|
|
{ |
|
216
|
|
|
$this->dataType = $dataType; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Gets the uid of the field which is |
|
221
|
|
|
* linked with the gnd field |
|
222
|
|
|
* |
|
223
|
|
|
* @return int |
|
224
|
|
|
*/ |
|
225
|
|
|
public function getGndFieldUid() { |
|
226
|
|
|
return $this->gndFieldUid; |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* Sets the uid of the field which is |
|
231
|
|
|
* linked with the gnd field |
|
232
|
|
|
* |
|
233
|
|
|
* @param int $fieldId |
|
234
|
|
|
* @return void |
|
235
|
|
|
*/ |
|
236
|
|
|
public function setGndFieldUid($fieldId) { |
|
237
|
|
|
$this->gndFieldUid = $fieldId; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* Gets the max length of characters for the input field. |
|
242
|
|
|
* |
|
243
|
|
|
* @return int |
|
244
|
|
|
*/ |
|
245
|
|
|
public function getMaxInputLength() { |
|
246
|
|
|
return $this->maxInputLength; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* Sets the max length of characters for the input field. |
|
251
|
|
|
* |
|
252
|
|
|
* @return int |
|
253
|
|
|
*/ |
|
254
|
|
|
public function setMaxInputLength($maxInputLength) { |
|
255
|
|
|
$this->maxInputLength = $maxInputLength; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
/** |
|
259
|
|
|
* @return bool |
|
260
|
|
|
*/ |
|
261
|
|
|
public function getEmbargo(): bool |
|
262
|
|
|
{ |
|
263
|
|
|
return $this->embargo; |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
/** |
|
267
|
|
|
* @param bool $embargo |
|
268
|
|
|
*/ |
|
269
|
|
|
public function setEmbargo(bool $embargo) |
|
270
|
|
|
{ |
|
271
|
|
|
$this->embargo = $embargo; |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
|
|
275
|
|
|
|
|
276
|
|
|
} |
|
277
|
|
|
|