|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace kalanis\kw_forms\Form; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use ArrayAccess; |
|
7
|
|
|
use kalanis\kw_forms\Controls; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
trait TControl |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Get simple form input |
|
14
|
|
|
* @param string $type |
|
15
|
|
|
* @param string $alias |
|
16
|
|
|
* @param string $label |
|
17
|
|
|
* @param string|null $value |
|
18
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
19
|
|
|
* @return Controls\Input |
|
20
|
|
|
*/ |
|
21
|
2 |
|
public function addInput(string $type, string $alias, string $label = '', ?string $value = null, $attributes = []): Controls\Input |
|
22
|
|
|
{ |
|
23
|
2 |
|
$input = new Controls\Input(); |
|
24
|
2 |
|
$input->set($type, $alias, $value, $label)->addAttributes($attributes); |
|
25
|
2 |
|
$this->addControlDefaultKey($input); |
|
26
|
2 |
|
return $input; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Add input for text |
|
31
|
|
|
* @param string $alias |
|
32
|
|
|
* @param string $label |
|
33
|
|
|
* @param string|int|float|null $value |
|
34
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
35
|
|
|
* @return Controls\Text |
|
36
|
|
|
*/ |
|
37
|
5 |
|
public function addText(string $alias, string $label = '', $value = null, $attributes = []): Controls\Text |
|
38
|
|
|
{ |
|
39
|
5 |
|
$text = new Controls\Text(); |
|
40
|
5 |
|
$text->set($alias, $value, $label)->addAttributes($attributes); |
|
41
|
5 |
|
$this->addControlDefaultKey($text); |
|
42
|
5 |
|
return $text; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Add input for email |
|
47
|
|
|
* @param string $alias |
|
48
|
|
|
* @param string $label |
|
49
|
|
|
* @param string|int|float|null $value |
|
50
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
51
|
|
|
* @return Controls\Email |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function addEmail(string $alias, string $label = '', $value = null, $attributes = []): Controls\Email |
|
54
|
|
|
{ |
|
55
|
1 |
|
$mail = new Controls\Email(); |
|
56
|
1 |
|
$mail->set($alias, $value, $label)->addAttributes($attributes); |
|
57
|
1 |
|
$this->addControlDefaultKey($mail); |
|
58
|
1 |
|
return $mail; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Add input for password |
|
63
|
|
|
* @param string $alias |
|
64
|
|
|
* @param string $label |
|
65
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
66
|
|
|
* @return Controls\Password |
|
67
|
|
|
*/ |
|
68
|
1 |
|
public function addPassword(string $alias, string $label = '', $attributes = []): Controls\Password |
|
69
|
|
|
{ |
|
70
|
1 |
|
$pass = new Controls\Password(); |
|
71
|
1 |
|
$pass->set($alias, $label)->addAttributes($attributes); |
|
72
|
1 |
|
$this->addControlDefaultKey($pass); |
|
73
|
1 |
|
return $pass; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Add hidden form input |
|
78
|
|
|
* @param string $alias |
|
79
|
|
|
* @param string|null $value |
|
80
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
81
|
|
|
* @return Controls\Hidden |
|
82
|
|
|
*/ |
|
83
|
2 |
|
public function addHidden(string $alias, ?string $value = null, $attributes = []): Controls\Hidden |
|
84
|
|
|
{ |
|
85
|
2 |
|
$hidden = new Controls\Hidden(); |
|
86
|
2 |
|
$hidden->set($alias, $value)->addAttributes($attributes); |
|
87
|
2 |
|
$this->addControlDefaultKey($hidden); |
|
88
|
2 |
|
return $hidden; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Add input for pick a date |
|
93
|
|
|
* @param string $alias |
|
94
|
|
|
* @param string $label |
|
95
|
|
|
* @param string|null $value |
|
96
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
97
|
|
|
* @return Controls\DatePicker |
|
98
|
|
|
*/ |
|
99
|
1 |
|
public function addDatePicker(string $alias, string $label = '', ?string $value = null, $attributes = []): Controls\DatePicker |
|
100
|
|
|
{ |
|
101
|
1 |
|
$date = new Controls\DatePicker(); |
|
102
|
1 |
|
$date->set($alias, $value, $label)->addAttributes($attributes); |
|
103
|
1 |
|
$this->addControlDefaultKey($date); |
|
104
|
1 |
|
return $date; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Add input for pick a date and time |
|
109
|
|
|
* @param string $alias |
|
110
|
|
|
* @param string $label |
|
111
|
|
|
* @param string|null $value |
|
112
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
113
|
|
|
* @return Controls\DateTimePicker |
|
114
|
|
|
*/ |
|
115
|
1 |
|
public function addDateTimePicker(string $alias, string $label = '', ?string $value = null, $attributes = []): Controls\DateTimePicker |
|
116
|
|
|
{ |
|
117
|
1 |
|
$date = new Controls\DateTimePicker(); |
|
118
|
1 |
|
$date->set($alias, $value, $label)->addAttributes($attributes); |
|
119
|
1 |
|
$this->addControlDefaultKey($date); |
|
120
|
1 |
|
return $date; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Add input for pick a date rage |
|
125
|
|
|
* @param string $alias |
|
126
|
|
|
* @param string $label |
|
127
|
|
|
* @param string|null $value |
|
128
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
129
|
|
|
* @return Controls\DateRange |
|
130
|
|
|
*/ |
|
131
|
1 |
|
public function addDateRange(string $alias, string $label = '', ?string $value = null, $attributes = []): Controls\DateRange |
|
132
|
|
|
{ |
|
133
|
1 |
|
$date = new Controls\DateRange(); |
|
134
|
1 |
|
$date->set($alias, $value, $label)->addAttributes($attributes); |
|
135
|
1 |
|
$this->addControlDefaultKey($date); |
|
136
|
1 |
|
return $date; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Add description as control |
|
141
|
|
|
* @param string $alias |
|
142
|
|
|
* @param string $label |
|
143
|
|
|
* @param string|int|float|bool|null $value |
|
144
|
|
|
* @return Controls\Description |
|
145
|
|
|
*/ |
|
146
|
1 |
|
public function addDescription(string $alias, string $label = '', $value = null): Controls\Description |
|
147
|
|
|
{ |
|
148
|
1 |
|
$desc = new Controls\Description(); |
|
149
|
1 |
|
$desc->setEntry($alias, $value, $label); |
|
150
|
1 |
|
$this->addControlDefaultKey($desc); |
|
151
|
1 |
|
return $desc; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Add html code as control |
|
156
|
|
|
* @param string $alias |
|
157
|
|
|
* @param string $label |
|
158
|
|
|
* @param string|int|float|bool|null $value |
|
159
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
160
|
|
|
* @return Controls\Html |
|
161
|
|
|
*/ |
|
162
|
1 |
|
public function addHtml(string $alias, string $label = '', $value = null, $attributes = []): Controls\Html |
|
163
|
|
|
{ |
|
164
|
1 |
|
$html = new Controls\Html(); |
|
165
|
1 |
|
$html->setEntry($alias, $value, $label)->addAttributes($attributes); |
|
166
|
1 |
|
$this->addControlDefaultKey($html); |
|
167
|
1 |
|
return $html; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* Add textarea input |
|
172
|
|
|
* @param string $alias |
|
173
|
|
|
* @param string $label |
|
174
|
|
|
* @param string|int|float|null $value |
|
175
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
176
|
|
|
* @return Controls\Textarea |
|
177
|
|
|
*/ |
|
178
|
1 |
|
public function addTextarea(string $alias, string $label = '', $value = null, $attributes = []): Controls\Textarea |
|
179
|
|
|
{ |
|
180
|
1 |
|
$text = new Controls\Textarea(); |
|
181
|
1 |
|
$text->set($alias, $value, $label)->addAttributes($attributes); |
|
182
|
1 |
|
$this->addControlDefaultKey($text); |
|
183
|
1 |
|
return $text; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* Add select input |
|
188
|
|
|
* @param string $alias |
|
189
|
|
|
* @param string $label |
|
190
|
|
|
* @param string|int|float|null $value |
|
191
|
|
|
* @param iterable<string, string|int|float|Controls\SelectOptgroup|Controls\SelectOption> $children |
|
192
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
193
|
|
|
* @return Controls\Select |
|
194
|
|
|
*/ |
|
195
|
1 |
|
public function addSelect(string $alias, string $label = '', $value = null, iterable $children = [], $attributes = []): Controls\Select |
|
196
|
|
|
{ |
|
197
|
1 |
|
$select = new Controls\Select(); |
|
198
|
1 |
|
$select->set($alias, $value, $label, $children)->addAttributes($attributes); |
|
199
|
1 |
|
$this->addControlDefaultKey($select); |
|
200
|
1 |
|
return $select; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* Add select list input |
|
205
|
|
|
* @param string $alias |
|
206
|
|
|
* @param string $label |
|
207
|
|
|
* @param iterable<string, string|Controls\SelectOption> $children |
|
208
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
209
|
|
|
* @return Controls\SelectList |
|
210
|
|
|
*/ |
|
211
|
1 |
|
public function addSelectList(string $alias, string $label = '', iterable $children = [], $attributes = []): Controls\SelectList |
|
212
|
|
|
{ |
|
213
|
1 |
|
$select = new Controls\SelectList(); |
|
214
|
1 |
|
$select->set($alias, $label, $children)->addAttributes($attributes); |
|
215
|
1 |
|
$this->addControlDefaultKey($select); |
|
216
|
1 |
|
return $select; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Add a bunch of radios |
|
221
|
|
|
* @param string $alias |
|
222
|
|
|
* @param string $label |
|
223
|
|
|
* @param string|int|float|null $value |
|
224
|
|
|
* @param iterable<string, string|int|Controls\Radio> $children |
|
225
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
226
|
|
|
* @return Controls\RadioSet |
|
227
|
|
|
*/ |
|
228
|
1 |
|
public function addRadios(string $alias, string $label = '', $value = null, iterable $children = [], $attributes = []): Controls\RadioSet |
|
229
|
|
|
{ |
|
230
|
1 |
|
$radio = new Controls\RadioSet(); |
|
231
|
1 |
|
$radio->set($alias, $value, $label, $children)->addAttributes($attributes); |
|
232
|
1 |
|
$this->addControlDefaultKey($radio); |
|
233
|
1 |
|
return $radio; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* Add input type checkbox |
|
238
|
|
|
* @param string $alias |
|
239
|
|
|
* @param string $label |
|
240
|
|
|
* @param string|boolean|null $checked |
|
241
|
|
|
* @param string|int|float|null $value |
|
242
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
243
|
|
|
* @return Controls\Checkbox |
|
244
|
|
|
*/ |
|
245
|
1 |
|
public function addCheckbox(string $alias, string $label = '', $checked = null, $value = '1', $attributes = []): Controls\Checkbox |
|
246
|
|
|
{ |
|
247
|
1 |
|
$check = new Controls\Checkbox(); |
|
248
|
1 |
|
$check->set($alias, $value, $label)->addAttributes($attributes); |
|
249
|
1 |
|
$check->setValue($checked); |
|
250
|
1 |
|
$this->addControlDefaultKey($check); |
|
251
|
1 |
|
return $check; |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* Add input type checkbox switch |
|
256
|
|
|
* @param string $alias |
|
257
|
|
|
* @param string $label |
|
258
|
|
|
* @param string|boolean|null $checked |
|
259
|
|
|
* @param string|int|float|null $value |
|
260
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
261
|
|
|
* @return Controls\CheckboxSwitch |
|
262
|
|
|
*/ |
|
263
|
1 |
|
public function addCheckboxSwitch(string $alias, string $label = '', $checked = null, $value = 1, $attributes = []): Controls\CheckboxSwitch |
|
264
|
|
|
{ |
|
265
|
1 |
|
$switch = new Controls\CheckboxSwitch(); |
|
266
|
1 |
|
$switch->set($alias, $value, $label)->addAttributes($attributes); |
|
267
|
1 |
|
$switch->setValue(strval($checked)); |
|
268
|
1 |
|
$this->addControlDefaultKey($switch); |
|
269
|
1 |
|
return $switch; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
/** |
|
273
|
|
|
* Add group of checkboxes |
|
274
|
|
|
* @param string $alias |
|
275
|
|
|
* @param string $label |
|
276
|
|
|
* @param array<string, string|int|float|bool> $checked |
|
277
|
|
|
* @param iterable<string, string|Controls\Checkbox> $children |
|
278
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
279
|
|
|
* @return Controls\Checkboxes |
|
280
|
|
|
*/ |
|
281
|
1 |
|
public function addCheckboxes(string $alias, string $label = '', array $checked = [], iterable $children = [], $attributes = []): Controls\Checkboxes |
|
282
|
|
|
{ |
|
283
|
1 |
|
$check = new Controls\Checkboxes(); |
|
284
|
1 |
|
$check->set($alias, $checked, $label, $children)->addAttributes($attributes); |
|
285
|
1 |
|
$this->addControlDefaultKey($check); |
|
286
|
1 |
|
return $check; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* Add input type file |
|
291
|
|
|
* @param string $alias |
|
292
|
|
|
* @param string $label |
|
293
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
294
|
|
|
* @return Controls\File |
|
295
|
|
|
*/ |
|
296
|
1 |
|
public function addFile(string $alias, string $label = '', $attributes = []): Controls\File |
|
297
|
|
|
{ |
|
298
|
1 |
|
$file = new Controls\File(); |
|
299
|
1 |
|
$file->set($alias, $label)->addAttributes($attributes); |
|
300
|
1 |
|
$this->setAttribute('enctype', 'multipart/form-data'); |
|
301
|
1 |
|
$this->addControlDefaultKey($file); |
|
302
|
1 |
|
return $file; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
/** |
|
306
|
|
|
* Add group of inputs type file |
|
307
|
|
|
* @param string $alias |
|
308
|
|
|
* @param string $label |
|
309
|
|
|
* @param iterable<string|int, string> $inputs |
|
310
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
311
|
|
|
* @return Controls\Files |
|
312
|
|
|
*/ |
|
313
|
2 |
|
public function addFiles(string $alias, string $label = '', iterable $inputs = [], $attributes = []): Controls\Files |
|
314
|
|
|
{ |
|
315
|
2 |
|
$file = new Controls\Files(); |
|
316
|
2 |
|
$file->set($alias, $inputs, $label, $attributes); |
|
|
|
|
|
|
317
|
2 |
|
$this->setAttribute('enctype', 'multipart/form-data'); |
|
318
|
2 |
|
$this->addControlDefaultKey($file); |
|
319
|
2 |
|
return $file; |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
/** |
|
323
|
|
|
* Add input type Simple Button |
|
324
|
|
|
* @param string $alias |
|
325
|
|
|
* @param string $label |
|
326
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
327
|
|
|
* @return Controls\Button |
|
328
|
|
|
*/ |
|
329
|
1 |
|
public function addButton(string $alias, string $label = '', $attributes = []): Controls\Button |
|
330
|
|
|
{ |
|
331
|
1 |
|
$button = new Controls\Button(); |
|
332
|
1 |
|
$button->set($alias, $label)->addAttributes($attributes); |
|
333
|
1 |
|
$this->addControlDefaultKey($button); |
|
334
|
1 |
|
return $button; |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
/** |
|
338
|
|
|
* Add input type Reset |
|
339
|
|
|
* @param string $alias |
|
340
|
|
|
* @param string $label |
|
341
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
342
|
|
|
* @return Controls\Reset |
|
343
|
|
|
*/ |
|
344
|
1 |
|
public function addReset(string $alias, string $label = '', $attributes = []): Controls\Reset |
|
345
|
|
|
{ |
|
346
|
1 |
|
$reset = new Controls\Reset(); |
|
347
|
1 |
|
$reset->set($alias, $label)->addAttributes($attributes); |
|
348
|
1 |
|
$this->addControlDefaultKey($reset); |
|
349
|
1 |
|
return $reset; |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
/** |
|
353
|
|
|
* Add input type Submit |
|
354
|
|
|
* @param string $alias |
|
355
|
|
|
* @param string $label |
|
356
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
357
|
|
|
* @return Controls\Submit |
|
358
|
|
|
*/ |
|
359
|
2 |
|
public function addSubmit(string $alias, string $label = '', $attributes = []): Controls\Submit |
|
360
|
|
|
{ |
|
361
|
2 |
|
$submit = new Controls\Submit(); |
|
362
|
2 |
|
$submit->set($alias, $label)->addAttributes($attributes); |
|
363
|
2 |
|
$this->addControlDefaultKey($submit); |
|
364
|
2 |
|
return $submit; |
|
365
|
|
|
} |
|
366
|
|
|
|
|
367
|
|
|
/** |
|
368
|
|
|
* Add input type Submit |
|
369
|
|
|
* @param string $alias |
|
370
|
|
|
* @param ArrayAccess $cookie |
|
371
|
|
|
* @param string $errorMessage |
|
372
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
373
|
|
|
* @return Controls\Security\Csrf |
|
374
|
|
|
* @codeCoverageIgnore link adapter remote resource |
|
375
|
|
|
*/ |
|
376
|
|
|
public function addCsrf(string $alias, ArrayAccess &$cookie, string $errorMessage, $attributes = []): Controls\Security\Csrf |
|
377
|
|
|
{ |
|
378
|
|
|
$csrf = new Controls\Security\Csrf(); |
|
379
|
|
|
$csrf->setHidden($alias, $cookie, $errorMessage)->addAttributes($attributes); |
|
380
|
|
|
$this->addControlDefaultKey($csrf); |
|
381
|
|
|
return $csrf; |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
/** |
|
385
|
|
|
* Add input type Submit |
|
386
|
|
|
* @param string $alias |
|
387
|
|
|
* @param ArrayAccess $cookie |
|
388
|
|
|
* @param string $errorMessage |
|
389
|
|
|
* @param array<string, string|array<string>>|string $attributes |
|
390
|
|
|
* @return Controls\Security\MultiSend |
|
391
|
|
|
*/ |
|
392
|
1 |
|
public function addMultiSend(string $alias, ArrayAccess &$cookie, string $errorMessage, $attributes = []): Controls\Security\MultiSend |
|
393
|
|
|
{ |
|
394
|
1 |
|
$csrf = new Controls\Security\MultiSend(); |
|
395
|
1 |
|
$csrf->setHidden($alias, $cookie, $errorMessage)->addAttributes($attributes); |
|
396
|
1 |
|
$this->addControlDefaultKey($csrf); |
|
397
|
1 |
|
return $csrf; |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
/** |
|
401
|
|
|
* Add empty captcha |
|
402
|
|
|
* @param string $alias |
|
403
|
|
|
* @return Controls\Security\Captcha\Disabled |
|
404
|
|
|
*/ |
|
405
|
1 |
|
public function addCaptchaDisabled(string $alias): Controls\Security\Captcha\Disabled |
|
406
|
|
|
{ |
|
407
|
1 |
|
$captcha = new Controls\Security\Captcha\Disabled(); |
|
408
|
1 |
|
$captcha->setEntry($alias); |
|
409
|
1 |
|
$this->addControlDefaultKey($captcha); |
|
410
|
1 |
|
return $captcha; |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
/** |
|
414
|
|
|
* Add simple image-to-text captcha |
|
415
|
|
|
* @param string $alias |
|
416
|
|
|
* @param ArrayAccess $session |
|
417
|
|
|
* @param string $errorMessage |
|
418
|
|
|
* @return Controls\Security\Captcha\Text |
|
419
|
|
|
*/ |
|
420
|
1 |
|
public function addCaptchaText(string $alias, ArrayAccess &$session, string $errorMessage = 'Captcha mismatch'): Controls\Security\Captcha\Text |
|
421
|
|
|
{ |
|
422
|
1 |
|
$captcha = new Controls\Security\Captcha\Text(); |
|
423
|
1 |
|
$captcha->set($alias, $session, $errorMessage); |
|
424
|
1 |
|
$this->addControlDefaultKey($captcha); |
|
425
|
1 |
|
return $captcha; |
|
426
|
|
|
} |
|
427
|
|
|
|
|
428
|
|
|
/** |
|
429
|
|
|
* Add captcha check with mathematical operation |
|
430
|
|
|
* @param string $alias |
|
431
|
|
|
* @param ArrayAccess $session |
|
432
|
|
|
* @param string $errorMessage |
|
433
|
|
|
* @return Controls\Security\Captcha\Numerical |
|
434
|
|
|
*/ |
|
435
|
1 |
|
public function addCaptchaMath(string $alias, ArrayAccess &$session, string $errorMessage = 'Captcha mismatch'): Controls\Security\Captcha\Numerical |
|
436
|
|
|
{ |
|
437
|
1 |
|
$captcha = new Controls\Security\Captcha\Numerical(); |
|
438
|
1 |
|
$captcha->set($alias, $session, $errorMessage); |
|
439
|
1 |
|
$this->addControlDefaultKey($captcha); |
|
440
|
1 |
|
return $captcha; |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
/** |
|
444
|
|
|
* Add captcha check with colourful text fill |
|
445
|
|
|
* @param string $alias |
|
446
|
|
|
* @param ArrayAccess $session |
|
447
|
|
|
* @param string $errorMessage |
|
448
|
|
|
* @return Controls\Security\Captcha\ColourfulText |
|
449
|
|
|
*/ |
|
450
|
1 |
|
public function addCaptchaColour(string $alias, ArrayAccess &$session, string $errorMessage = 'Captcha mismatch'): Controls\Security\Captcha\ColourfulText |
|
451
|
|
|
{ |
|
452
|
1 |
|
$captcha = new Controls\Security\Captcha\ColourfulText(); |
|
453
|
1 |
|
$captcha->set($alias, $session, $errorMessage); |
|
454
|
1 |
|
$this->addControlDefaultKey($captcha); |
|
455
|
1 |
|
return $captcha; |
|
456
|
|
|
} |
|
457
|
|
|
|
|
458
|
|
|
/** |
|
459
|
|
|
* Add captcha check via service ReCaptcha-NoCaptcha |
|
460
|
|
|
* @param string $alias |
|
461
|
|
|
* @param string $errorMessage |
|
462
|
|
|
* @return Controls\Security\Captcha\NoCaptcha |
|
463
|
|
|
*/ |
|
464
|
1 |
|
public function addNocaptcha(string $alias, string $errorMessage = 'The NoCAPTCHA has not been entered correctly. Please try it again.'): Controls\Security\Captcha\NoCaptcha |
|
465
|
|
|
{ |
|
466
|
1 |
|
$recaptcha = new Controls\Security\Captcha\NoCaptcha(); |
|
467
|
1 |
|
$recaptcha->set($alias, $errorMessage); |
|
468
|
1 |
|
$this->addControlDefaultKey($recaptcha); |
|
469
|
1 |
|
return $recaptcha; |
|
470
|
|
|
} |
|
471
|
|
|
|
|
472
|
|
|
abstract public function addControlDefaultKey(Controls\AControl $control): void; |
|
473
|
|
|
|
|
474
|
|
|
abstract public function setAttribute(string $name, string $value): void; |
|
475
|
|
|
} |
|
476
|
|
|
|