@@ -14,7 +14,7 @@ |
||
14 | 14 | public function __construct($label, $attributes) |
15 | 15 | { |
16 | 16 | parent::__construct($label, $attributes); |
17 | - $this->Attributes()->set('type','range'); |
|
17 | + $this->Attributes()->set('type', 'range'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | public function __construct($label, $attributes = []) |
15 | 15 | { |
16 | 16 | parent::__construct($label, $attributes); |
17 | - $this->Attributes()->set('type','url'); |
|
17 | + $this->Attributes()->set('type', 'url'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -113,7 +113,7 @@ |
||
113 | 113 | { |
114 | 114 | $item = new Captcha($label,$attributes); |
115 | 115 | //$this->Request->getSession()->set(md5($item->Attributes()->get('name')), $item->Attributes()->get('capresponse')); |
116 | - // $this->Request->Session->set(md5($item->Attributes()->get('name')),$item->Attributes()->get('capresponse')); |
|
116 | + // $this->Request->Session->set(md5($item->Attributes()->get('name')),$item->Attributes()->get('capresponse')); |
|
117 | 117 | $this->Form->append($item); |
118 | 118 | } |
119 | 119 | return $this; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function __construct(CoreController $App) |
65 | 65 | { |
66 | 66 | $this->Request = $App->Request(); |
67 | - $formErrors = $App->get('errors',[]); |
|
67 | + $formErrors = $App->get('errors', []); |
|
68 | 68 | is_array($formErrors) OR $formErrors = [$formErrors]; |
69 | 69 | $this->Errors = new Collection($formErrors); |
70 | 70 | } |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * @param array $attributes |
75 | 75 | * @return $this |
76 | 76 | */ |
77 | - public function addAudio($label,$attributes=[]) |
|
77 | + public function addAudio($label, $attributes = []) |
|
78 | 78 | { |
79 | - if($this->Form instanceof form) |
|
79 | + if ($this->Form instanceof form) |
|
80 | 80 | { |
81 | - $item = new Audio($label,$attributes); |
|
82 | - $item->Attributes()->set('accept','audio/*'); |
|
81 | + $item = new Audio($label, $attributes); |
|
82 | + $item->Attributes()->set('accept', 'audio/*'); |
|
83 | 83 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
84 | - $this->Form->Attributes()->set('enctype','multipart/form-data'); |
|
84 | + $this->Form->Attributes()->set('enctype', 'multipart/form-data'); |
|
85 | 85 | $this->Form->append($item); |
86 | 86 | } |
87 | 87 | return $this; |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | * @param array $attributes |
93 | 93 | * @return $this |
94 | 94 | */ |
95 | - public function addButton($label,$attributes=[]) |
|
95 | + public function addButton($label, $attributes = []) |
|
96 | 96 | { |
97 | - if($this->Form instanceof form) |
|
97 | + if ($this->Form instanceof form) |
|
98 | 98 | { |
99 | - $item = new Button($label,$attributes); |
|
99 | + $item = new Button($label, $attributes); |
|
100 | 100 | $this->Form->append($item); |
101 | 101 | } |
102 | 102 | return $this; |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | * @param array $attributes |
108 | 108 | * @return $this |
109 | 109 | */ |
110 | - public function addCaptcha($label,$attributes=[]) |
|
110 | + public function addCaptcha($label, $attributes = []) |
|
111 | 111 | { |
112 | - if($this->Form instanceof form) |
|
112 | + if ($this->Form instanceof form) |
|
113 | 113 | { |
114 | - $item = new Captcha($label,$attributes); |
|
114 | + $item = new Captcha($label, $attributes); |
|
115 | 115 | //$this->Request->getSession()->set(md5($item->Attributes()->get('name')), $item->Attributes()->get('capresponse')); |
116 | 116 | // $this->Request->Session->set(md5($item->Attributes()->get('name')),$item->Attributes()->get('capresponse')); |
117 | 117 | $this->Form->append($item); |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | * @param array $attributes |
126 | 126 | * @return $this |
127 | 127 | */ |
128 | - public function addCheckbox($label,$options = [],$attributes=[]) |
|
128 | + public function addCheckbox($label, $options = [], $attributes = []) |
|
129 | 129 | { |
130 | - if($this->Form instanceof form) |
|
130 | + if ($this->Form instanceof form) |
|
131 | 131 | { |
132 | - $item = new Checkbox($label,$options ,$attributes); |
|
132 | + $item = new Checkbox($label, $options, $attributes); |
|
133 | 133 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
134 | 134 | $this->Form->append($item); |
135 | 135 | } |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | * @param array $attributes |
142 | 142 | * @return $this |
143 | 143 | */ |
144 | - public function addColor($label,$attributes=[]) |
|
144 | + public function addColor($label, $attributes = []) |
|
145 | 145 | { |
146 | - if($this->Form instanceof form) |
|
146 | + if ($this->Form instanceof form) |
|
147 | 147 | { |
148 | - $item = new Color($label,$attributes); |
|
148 | + $item = new Color($label, $attributes); |
|
149 | 149 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
150 | 150 | $this->Form->append($item); |
151 | 151 | } |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * @param array $attributes |
158 | 158 | * @return $this |
159 | 159 | */ |
160 | - public function addCountries($label,$attributes=[]) |
|
160 | + public function addCountries($label, $attributes = []) |
|
161 | 161 | { |
162 | - if($this->Form instanceof form) |
|
162 | + if ($this->Form instanceof form) |
|
163 | 163 | { |
164 | - $item = new Country($label,$attributes); |
|
164 | + $item = new Country($label, $attributes); |
|
165 | 165 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
166 | 166 | $this->Form->append($item); |
167 | 167 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param array $attributes |
173 | 173 | * @return $this |
174 | 174 | */ |
175 | - public function addDatalist($label, $options=[], $attributes = []) |
|
175 | + public function addDatalist($label, $options = [], $attributes = []) |
|
176 | 176 | { |
177 | 177 | if ($this->Form instanceof form) { |
178 | 178 | $item = new Datalist($label, $options, $attributes); |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | * @param array $attributes |
188 | 188 | * @return $this |
189 | 189 | */ |
190 | - public function addDate($label,$attributes=[]) |
|
190 | + public function addDate($label, $attributes = []) |
|
191 | 191 | { |
192 | - if($this->Form instanceof form) |
|
192 | + if ($this->Form instanceof form) |
|
193 | 193 | { |
194 | - $item = new Date($label,$attributes); |
|
194 | + $item = new Date($label, $attributes); |
|
195 | 195 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
196 | 196 | $this->Form->append($item); |
197 | 197 | } |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | * @param array $attributes |
204 | 204 | * @return $this |
205 | 205 | */ |
206 | - public function addDatetime($label,$attributes=[]) |
|
206 | + public function addDatetime($label, $attributes = []) |
|
207 | 207 | { |
208 | - if($this->Form instanceof form) |
|
208 | + if ($this->Form instanceof form) |
|
209 | 209 | { |
210 | - $item = new Datetime($label,$attributes); |
|
210 | + $item = new Datetime($label, $attributes); |
|
211 | 211 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
212 | 212 | $this->Form->append($item); |
213 | 213 | } |
@@ -219,11 +219,11 @@ discard block |
||
219 | 219 | * @param array $attributes |
220 | 220 | * @return $this |
221 | 221 | */ |
222 | - public function addDatetimeLocal($label,$attributes=[]) |
|
222 | + public function addDatetimeLocal($label, $attributes = []) |
|
223 | 223 | { |
224 | - if($this->Form instanceof form) |
|
224 | + if ($this->Form instanceof form) |
|
225 | 225 | { |
226 | - $item = new DatetimeLocal($label,$attributes); |
|
226 | + $item = new DatetimeLocal($label, $attributes); |
|
227 | 227 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
228 | 228 | $this->Form->append($item); |
229 | 229 | } |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | * @param array $attributes |
235 | 235 | * @return $this |
236 | 236 | */ |
237 | - public function addEditor($label,$attributes=[]) |
|
237 | + public function addEditor($label, $attributes = []) |
|
238 | 238 | { |
239 | - if($this->Form instanceof form) |
|
239 | + if ($this->Form instanceof form) |
|
240 | 240 | { |
241 | - $item = new Editor($label,$attributes); |
|
241 | + $item = new Editor($label, $attributes); |
|
242 | 242 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
243 | 243 | $this->Form->append($item); |
244 | 244 | } |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | * @param array $attributes |
250 | 250 | * @return $this |
251 | 251 | */ |
252 | - public function addEmail($label,$attributes=[]) |
|
252 | + public function addEmail($label, $attributes = []) |
|
253 | 253 | { |
254 | - if($this->Form instanceof form) |
|
254 | + if ($this->Form instanceof form) |
|
255 | 255 | { |
256 | - $item = new Email($label,$attributes); |
|
256 | + $item = new Email($label, $attributes); |
|
257 | 257 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
258 | 258 | $this->Form->append($item); |
259 | 259 | } |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | * @param array $attributes |
264 | 264 | * @return $this |
265 | 265 | */ |
266 | - public function addFieldset($attributes=[]) |
|
266 | + public function addFieldset($attributes = []) |
|
267 | 267 | { |
268 | - if($this->Form instanceof form) |
|
268 | + if ($this->Form instanceof form) |
|
269 | 269 | { |
270 | - if($this->Fieldset instanceof fieldsetGenerator) |
|
270 | + if ($this->Fieldset instanceof fieldsetGenerator) |
|
271 | 271 | $this->Form->append($this->Fieldset->Close()); |
272 | 272 | $this->Fieldset = new fieldsetGenerator($attributes); |
273 | 273 | $this->Fieldset->Attributes()->set('name', $this->Form->Attributes()->get('name')); |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | * @param array $attributes |
281 | 281 | * @return $this |
282 | 282 | */ |
283 | - public function addFile($label,$attributes=[]) |
|
283 | + public function addFile($label, $attributes = []) |
|
284 | 284 | { |
285 | - if($this->Form instanceof form) |
|
285 | + if ($this->Form instanceof form) |
|
286 | 286 | { |
287 | - $item = new File($label,$attributes); |
|
288 | - $this->Form->Attributes()->set('enctype','multipart/form-data'); |
|
287 | + $item = new File($label, $attributes); |
|
288 | + $this->Form->Attributes()->set('enctype', 'multipart/form-data'); |
|
289 | 289 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
290 | 290 | $this->Form->append($item); |
291 | 291 | } |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | * @param array $attributes |
298 | 298 | * @return $this |
299 | 299 | */ |
300 | - public function addHidden($label,$attributes=[]) |
|
300 | + public function addHidden($label, $attributes = []) |
|
301 | 301 | { |
302 | - if($this->Form instanceof form) |
|
302 | + if ($this->Form instanceof form) |
|
303 | 303 | { |
304 | - $item = new Hidden($label,$attributes); |
|
304 | + $item = new Hidden($label, $attributes); |
|
305 | 305 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
306 | 306 | $this->Form->append($item); |
307 | 307 | } |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function addHtml($html) |
316 | 316 | { |
317 | - if($this->Form instanceof form) |
|
317 | + if ($this->Form instanceof form) |
|
318 | 318 | { |
319 | - if(gettype($html) === 'string') |
|
319 | + if (gettype($html) === 'string') |
|
320 | 320 | $this->Form->append($html); |
321 | 321 | } |
322 | 322 | return $this; |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | * @param array $attributes |
328 | 328 | * @return $this |
329 | 329 | */ |
330 | - public function addImage($label,$attributes=[]) |
|
330 | + public function addImage($label, $attributes = []) |
|
331 | 331 | { |
332 | - if($this->Form instanceof form) |
|
332 | + if ($this->Form instanceof form) |
|
333 | 333 | { |
334 | - $item = new Image($label,$attributes); |
|
335 | - $this->Form->Attributes()->set('enctype','multipart/form-data'); |
|
334 | + $item = new Image($label, $attributes); |
|
335 | + $this->Form->Attributes()->set('enctype', 'multipart/form-data'); |
|
336 | 336 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
337 | 337 | $this->Form->append($item); |
338 | 338 | } |
@@ -344,11 +344,11 @@ discard block |
||
344 | 344 | * @param array $attributes |
345 | 345 | * @return $this |
346 | 346 | */ |
347 | - public function addMonth($label,$attributes=[]) |
|
347 | + public function addMonth($label, $attributes = []) |
|
348 | 348 | { |
349 | - if($this->Form instanceof form) |
|
349 | + if ($this->Form instanceof form) |
|
350 | 350 | { |
351 | - $item = new Month($label,$attributes); |
|
351 | + $item = new Month($label, $attributes); |
|
352 | 352 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
353 | 353 | $this->Form->append($item); |
354 | 354 | } |
@@ -360,11 +360,11 @@ discard block |
||
360 | 360 | * @param array $attributes |
361 | 361 | * @return $this |
362 | 362 | */ |
363 | - public function addNumber($label,$attributes=[]) |
|
363 | + public function addNumber($label, $attributes = []) |
|
364 | 364 | { |
365 | - if($this->Form instanceof form) |
|
365 | + if ($this->Form instanceof form) |
|
366 | 366 | { |
367 | - $item = new Number($label,$attributes); |
|
367 | + $item = new Number($label, $attributes); |
|
368 | 368 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
369 | 369 | $this->Form->append($item); |
370 | 370 | } |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | * @param array $attributes |
376 | 376 | * @return $this |
377 | 377 | */ |
378 | - public function addPassword($label,$attributes=[]) |
|
378 | + public function addPassword($label, $attributes = []) |
|
379 | 379 | { |
380 | - if($this->Form instanceof form) |
|
380 | + if ($this->Form instanceof form) |
|
381 | 381 | { |
382 | - $item = new Password($label,$attributes); |
|
382 | + $item = new Password($label, $attributes); |
|
383 | 383 | $item->Attributes()->set('value', ''); |
384 | 384 | $this->Form->append($item); |
385 | 385 | } |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | * @param array $attributes |
392 | 392 | * @return $this |
393 | 393 | */ |
394 | - public function addPhone($label,$attributes=[]) |
|
394 | + public function addPhone($label, $attributes = []) |
|
395 | 395 | { |
396 | - if($this->Form instanceof form) |
|
396 | + if ($this->Form instanceof form) |
|
397 | 397 | { |
398 | - $item = new Phone($label,$attributes); |
|
398 | + $item = new Phone($label, $attributes); |
|
399 | 399 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
400 | 400 | $this->Form->append($item); |
401 | 401 | } |
@@ -408,11 +408,11 @@ discard block |
||
408 | 408 | * @param array $attributes |
409 | 409 | * @return $this |
410 | 410 | */ |
411 | - public function addRadio($label,$options=[],$attributes=[]) |
|
411 | + public function addRadio($label, $options = [], $attributes = []) |
|
412 | 412 | { |
413 | - if($this->Form instanceof form) |
|
413 | + if ($this->Form instanceof form) |
|
414 | 414 | { |
415 | - $item = new Radio($label,$options,$attributes); |
|
415 | + $item = new Radio($label, $options, $attributes); |
|
416 | 416 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
417 | 417 | $this->Form->append($item); |
418 | 418 | } |
@@ -424,11 +424,11 @@ discard block |
||
424 | 424 | * @param array $attributes |
425 | 425 | * @return $this |
426 | 426 | */ |
427 | - public function addRange($label,$attributes=[]) |
|
427 | + public function addRange($label, $attributes = []) |
|
428 | 428 | { |
429 | - if($this->Form instanceof form) |
|
429 | + if ($this->Form instanceof form) |
|
430 | 430 | { |
431 | - $item = new Range($label,$attributes); |
|
431 | + $item = new Range($label, $attributes); |
|
432 | 432 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
433 | 433 | $this->Form->append($item); |
434 | 434 | } |
@@ -440,11 +440,11 @@ discard block |
||
440 | 440 | * @param array $attributes |
441 | 441 | * @return $this |
442 | 442 | */ |
443 | - public function addReset($label,$attributes=[]) |
|
443 | + public function addReset($label, $attributes = []) |
|
444 | 444 | { |
445 | - if($this->Form instanceof form) |
|
445 | + if ($this->Form instanceof form) |
|
446 | 446 | { |
447 | - $item = new Reset($label,$attributes); |
|
447 | + $item = new Reset($label, $attributes); |
|
448 | 448 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
449 | 449 | $this->Form->append($item); |
450 | 450 | } |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | * @param array $attributes |
457 | 457 | * @return $this |
458 | 458 | */ |
459 | - public function addSearch($label,$attributes=[]) |
|
459 | + public function addSearch($label, $attributes = []) |
|
460 | 460 | { |
461 | - if($this->Form instanceof form) |
|
461 | + if ($this->Form instanceof form) |
|
462 | 462 | { |
463 | - $item = new Search($label,$attributes); |
|
463 | + $item = new Search($label, $attributes); |
|
464 | 464 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
465 | 465 | $this->Form->append($item); |
466 | 466 | } |
@@ -472,11 +472,11 @@ discard block |
||
472 | 472 | * @param array $attributes |
473 | 473 | * @return $this |
474 | 474 | */ |
475 | - public function addSelect($label,array $options = [],$attributes=[]) |
|
475 | + public function addSelect($label, array $options = [], $attributes = []) |
|
476 | 476 | { |
477 | - if($this->Form instanceof form) |
|
477 | + if ($this->Form instanceof form) |
|
478 | 478 | { |
479 | - $item = new Select($label,$options,$attributes); |
|
479 | + $item = new Select($label, $options, $attributes); |
|
480 | 480 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
481 | 481 | $this->Form->append($item); |
482 | 482 | } |
@@ -487,11 +487,11 @@ discard block |
||
487 | 487 | * @param array $attributes |
488 | 488 | * @return $this |
489 | 489 | */ |
490 | - public function addSubmit($label,$attributes=[]) |
|
490 | + public function addSubmit($label, $attributes = []) |
|
491 | 491 | { |
492 | - if($this->Form instanceof form) |
|
492 | + if ($this->Form instanceof form) |
|
493 | 493 | { |
494 | - $item = new Submit($label,$attributes); |
|
494 | + $item = new Submit($label, $attributes); |
|
495 | 495 | $this->Form->append($item); |
496 | 496 | } |
497 | 497 | return $this; |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * @param array $attributes |
503 | 503 | * @return $this |
504 | 504 | */ |
505 | - public function addText($label,$attributes=[]) |
|
505 | + public function addText($label, $attributes = []) |
|
506 | 506 | { |
507 | - if($this->Form instanceof form) |
|
507 | + if ($this->Form instanceof form) |
|
508 | 508 | { |
509 | - $item = new Text($label,$attributes); |
|
509 | + $item = new Text($label, $attributes); |
|
510 | 510 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
511 | 511 | $this->Form->append($item); |
512 | 512 | } |
@@ -518,11 +518,11 @@ discard block |
||
518 | 518 | * @param array $attributes |
519 | 519 | * @return $this |
520 | 520 | */ |
521 | - public function addTextarea($label,$attributes=[]) |
|
521 | + public function addTextarea($label, $attributes = []) |
|
522 | 522 | { |
523 | - if($this->Form instanceof form) |
|
523 | + if ($this->Form instanceof form) |
|
524 | 524 | { |
525 | - $item = new Textarea($label,$attributes); |
|
525 | + $item = new Textarea($label, $attributes); |
|
526 | 526 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
527 | 527 | $this->Form->append($item); |
528 | 528 | } |
@@ -534,11 +534,11 @@ discard block |
||
534 | 534 | * @param array $attributes |
535 | 535 | * @return $this |
536 | 536 | */ |
537 | - public function addTime($label,$attributes=[]) |
|
537 | + public function addTime($label, $attributes = []) |
|
538 | 538 | { |
539 | - if($this->Form instanceof form) |
|
539 | + if ($this->Form instanceof form) |
|
540 | 540 | { |
541 | - $item = new Time($label,$attributes); |
|
541 | + $item = new Time($label, $attributes); |
|
542 | 542 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
543 | 543 | $this->Form->append($item); |
544 | 544 | } |
@@ -550,11 +550,11 @@ discard block |
||
550 | 550 | * @param array $attributes |
551 | 551 | * @return $this |
552 | 552 | */ |
553 | - public function addUrl($label,$attributes=[]) |
|
553 | + public function addUrl($label, $attributes = []) |
|
554 | 554 | { |
555 | - if($this->Form instanceof form) |
|
555 | + if ($this->Form instanceof form) |
|
556 | 556 | { |
557 | - $item = new Url($label,$attributes); |
|
557 | + $item = new Url($label, $attributes); |
|
558 | 558 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
559 | 559 | $this->Form->append($item); |
560 | 560 | } |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | * @param array $attributes |
567 | 567 | * @return $this |
568 | 568 | */ |
569 | - public function addVideo($label,$attributes=[]) |
|
569 | + public function addVideo($label, $attributes = []) |
|
570 | 570 | { |
571 | - if($this->Form instanceof form) |
|
571 | + if ($this->Form instanceof form) |
|
572 | 572 | { |
573 | - $item = new Video($label,$attributes); |
|
574 | - $this->Form->Attributes()->set('enctype','multipart/form-data'); |
|
573 | + $item = new Video($label, $attributes); |
|
574 | + $this->Form->Attributes()->set('enctype', 'multipart/form-data'); |
|
575 | 575 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
576 | 576 | $this->Form->append($item); |
577 | 577 | } |
@@ -582,11 +582,11 @@ discard block |
||
582 | 582 | * @param array $attributes |
583 | 583 | * @return $this |
584 | 584 | */ |
585 | - public function addWeek($label,$attributes=[]) |
|
585 | + public function addWeek($label, $attributes = []) |
|
586 | 586 | { |
587 | - if($this->Form instanceof form) |
|
587 | + if ($this->Form instanceof form) |
|
588 | 588 | { |
589 | - $item = new Week($label,$attributes); |
|
589 | + $item = new Week($label, $attributes); |
|
590 | 590 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
591 | 591 | $this->Form->append($item); |
592 | 592 | } |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | * @param array $attributes |
599 | 599 | * @return $this |
600 | 600 | */ |
601 | - public function addYesNo($label,$attributes=[]) |
|
601 | + public function addYesNo($label, $attributes = []) |
|
602 | 602 | { |
603 | - if($this->Form instanceof form) |
|
603 | + if ($this->Form instanceof form) |
|
604 | 604 | { |
605 | - $item = new YesNo($label,$attributes); |
|
605 | + $item = new YesNo($label, $attributes); |
|
606 | 606 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
607 | 607 | $this->Form->append($item); |
608 | 608 | } |
@@ -612,16 +612,16 @@ discard block |
||
612 | 612 | * @param bool $print |
613 | 613 | * @return null|string |
614 | 614 | */ |
615 | - public function Close($print=true) |
|
615 | + public function Close($print = true) |
|
616 | 616 | { |
617 | 617 | $html = null; |
618 | 618 | if ($this->Form instanceof form) |
619 | 619 | { |
620 | - if($this->Fieldset instanceof fieldsetGenerator) |
|
620 | + if ($this->Fieldset instanceof fieldsetGenerator) |
|
621 | 621 | $this->Form->append($this->Fieldset->Close()); |
622 | 622 | $html = $this->Form->RenderHtml(); |
623 | 623 | $this->Form = null; |
624 | - if($print) |
|
624 | + if ($print) |
|
625 | 625 | print_r($html); |
626 | 626 | } |
627 | 627 | return $html; |
@@ -638,11 +638,11 @@ discard block |
||
638 | 638 | * @param null $default |
639 | 639 | * @return mixed |
640 | 640 | */ |
641 | - private function getDefaultValue(FormElement $element,$default=null) |
|
641 | + private function getDefaultValue(FormElement $element, $default = null) |
|
642 | 642 | { |
643 | 643 | $name = $element->Attributes()->get('name'); |
644 | 644 | $method = strtoupper($this->Request->getMethod()); |
645 | - switch($method){ |
|
645 | + switch ($method) { |
|
646 | 646 | case 'POST': |
647 | 647 | case 'PUT': |
648 | 648 | case 'DELETE': |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | $Request = $this->Request->query; |
654 | 654 | break; |
655 | 655 | } |
656 | - if(!$value = $Request->get($name, $default)) |
|
656 | + if (!$value = $Request->get($name, $default)) |
|
657 | 657 | $value = $element->Attributes()->get('value', $default); |
658 | 658 | return $value; |
659 | 659 | } |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | */ |
664 | 664 | public function Open($attributes = []) |
665 | 665 | { |
666 | - if($this->Form instanceof form) |
|
666 | + if ($this->Form instanceof form) |
|
667 | 667 | $this->Close(); |
668 | 668 | $this->Form = new form($attributes); |
669 | 669 | return $this; |
@@ -267,8 +267,9 @@ discard block |
||
267 | 267 | { |
268 | 268 | if($this->Form instanceof form) |
269 | 269 | { |
270 | - if($this->Fieldset instanceof fieldsetGenerator) |
|
271 | - $this->Form->append($this->Fieldset->Close()); |
|
270 | + if($this->Fieldset instanceof fieldsetGenerator) { |
|
271 | + $this->Form->append($this->Fieldset->Close()); |
|
272 | + } |
|
272 | 273 | $this->Fieldset = new fieldsetGenerator($attributes); |
273 | 274 | $this->Fieldset->Attributes()->set('name', $this->Form->Attributes()->get('name')); |
274 | 275 | $this->Form->append($this->Fieldset->Open()); |
@@ -316,8 +317,9 @@ discard block |
||
316 | 317 | { |
317 | 318 | if($this->Form instanceof form) |
318 | 319 | { |
319 | - if(gettype($html) === 'string') |
|
320 | - $this->Form->append($html); |
|
320 | + if(gettype($html) === 'string') { |
|
321 | + $this->Form->append($html); |
|
322 | + } |
|
321 | 323 | } |
322 | 324 | return $this; |
323 | 325 | } |
@@ -617,12 +619,14 @@ discard block |
||
617 | 619 | $html = null; |
618 | 620 | if ($this->Form instanceof form) |
619 | 621 | { |
620 | - if($this->Fieldset instanceof fieldsetGenerator) |
|
621 | - $this->Form->append($this->Fieldset->Close()); |
|
622 | + if($this->Fieldset instanceof fieldsetGenerator) { |
|
623 | + $this->Form->append($this->Fieldset->Close()); |
|
624 | + } |
|
622 | 625 | $html = $this->Form->RenderHtml(); |
623 | 626 | $this->Form = null; |
624 | - if($print) |
|
625 | - print_r($html); |
|
627 | + if($print) { |
|
628 | + print_r($html); |
|
629 | + } |
|
626 | 630 | } |
627 | 631 | return $html; |
628 | 632 | } |
@@ -653,8 +657,9 @@ discard block |
||
653 | 657 | $Request = $this->Request->query; |
654 | 658 | break; |
655 | 659 | } |
656 | - if(!$value = $Request->get($name, $default)) |
|
657 | - $value = $element->Attributes()->get('value', $default); |
|
660 | + if(!$value = $Request->get($name, $default)) { |
|
661 | + $value = $element->Attributes()->get('value', $default); |
|
662 | + } |
|
658 | 663 | return $value; |
659 | 664 | } |
660 | 665 | /** |
@@ -663,8 +668,9 @@ discard block |
||
663 | 668 | */ |
664 | 669 | public function Open($attributes = []) |
665 | 670 | { |
666 | - if($this->Form instanceof form) |
|
667 | - $this->Close(); |
|
671 | + if($this->Form instanceof form) { |
|
672 | + $this->Close(); |
|
673 | + } |
|
668 | 674 | $this->Form = new form($attributes); |
669 | 675 | return $this; |
670 | 676 | } |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function __construct($attributes) |
27 | 27 | { |
28 | - if(!$attributes instanceof AttributesBuilder) |
|
29 | - $attributes = new AttributesBuilder($attributes); |
|
28 | + if (!$attributes instanceof AttributesBuilder) |
|
29 | + $attributes = new AttributesBuilder($attributes); |
|
30 | 30 | $this->attributes = $attributes; |
31 | - if($this->attributes->has('legend')) |
|
31 | + if ($this->attributes->has('legend')) |
|
32 | 32 | { |
33 | 33 | $this->attributes->Ignore('legend'); |
34 | 34 | $this->legend = $this->attributes->get('legend'); |
35 | - if($this->attributes->has('legend-attributes')) |
|
35 | + if ($this->attributes->has('legend-attributes')) |
|
36 | 36 | { |
37 | 37 | $this->attributes->Ignore('legend-attributes'); |
38 | 38 | $this->legendAttributes = new AttributesBuilder($this->attributes->get('legend-attributes')); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | $html = '<fieldset'; |
56 | 56 | $html .= $this->attributes->RenderHtml(); |
57 | 57 | $html .= '>'; |
58 | - if($this->legend) |
|
58 | + if ($this->legend) |
|
59 | 59 | { |
60 | 60 | $html .= '<legend'; |
61 | - if($this->legendAttributes instanceof AttributesBuilder) |
|
61 | + if ($this->legendAttributes instanceof AttributesBuilder) |
|
62 | 62 | $html .= $this->legendAttributes->RenderHtml(); |
63 | 63 | $html .= '>'; |
64 | 64 | $html .= $this->legend; |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function Close() |
75 | 75 | { |
76 | - $html = ''; |
|
77 | - if($this->isOpened) |
|
76 | + $html = ''; |
|
77 | + if ($this->isOpened) |
|
78 | 78 | $html .= '</fieldset>'; |
79 | 79 | return $html; |
80 | 80 | } |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function __construct($attributes) |
27 | 27 | { |
28 | - if(!$attributes instanceof AttributesBuilder) |
|
29 | - $attributes = new AttributesBuilder($attributes); |
|
28 | + if(!$attributes instanceof AttributesBuilder) { |
|
29 | + $attributes = new AttributesBuilder($attributes); |
|
30 | + } |
|
30 | 31 | $this->attributes = $attributes; |
31 | 32 | if($this->attributes->has('legend')) |
32 | 33 | { |
@@ -58,8 +59,9 @@ discard block |
||
58 | 59 | if($this->legend) |
59 | 60 | { |
60 | 61 | $html .= '<legend'; |
61 | - if($this->legendAttributes instanceof AttributesBuilder) |
|
62 | - $html .= $this->legendAttributes->RenderHtml(); |
|
62 | + if($this->legendAttributes instanceof AttributesBuilder) { |
|
63 | + $html .= $this->legendAttributes->RenderHtml(); |
|
64 | + } |
|
63 | 65 | $html .= '>'; |
64 | 66 | $html .= $this->legend; |
65 | 67 | $html .= '</legend>'; |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | public function Close() |
75 | 77 | { |
76 | 78 | $html = ''; |
77 | - if($this->isOpened) |
|
78 | - $html .= '</fieldset>'; |
|
79 | + if($this->isOpened) { |
|
80 | + $html .= '</fieldset>'; |
|
81 | + } |
|
79 | 82 | return $html; |
80 | 83 | } |
81 | 84 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use KeyNormalizer; |
17 | 17 | |
18 | 18 | private $attributes; |
19 | - private $ignore ; |
|
19 | + private $ignore; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * AttributesBuilder constructor. |
@@ -28,17 +28,17 @@ discard block |
||
28 | 28 | { |
29 | 29 | $this->attributes = new Collection(); |
30 | 30 | $this->ignore = new Collection(); |
31 | - if($attributes) |
|
31 | + if ($attributes) |
|
32 | 32 | { |
33 | 33 | is_array($attributes) or $attributes = array($attributes); |
34 | - $attributes = array_change_key_case($attributes,CASE_LOWER); |
|
35 | - $attributes = $this->array_map_keys([$this,'normalize'],$attributes); |
|
34 | + $attributes = array_change_key_case($attributes, CASE_LOWER); |
|
35 | + $attributes = $this->array_map_keys([$this, 'normalize'], $attributes); |
|
36 | 36 | $this->attributes->add($attributes); |
37 | 37 | } |
38 | - if($ignore) |
|
38 | + if ($ignore) |
|
39 | 39 | { |
40 | 40 | is_array($ignore) or $ignore = array($ignore); |
41 | - $ignore = array_map([$this,'normalize'],$ignore); |
|
41 | + $ignore = array_map([$this, 'normalize'], $ignore); |
|
42 | 42 | $this->ignore->add($ignore); |
43 | 43 | } |
44 | 44 | return $this; |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | public function createElementID($key) |
52 | 52 | { |
53 | 53 | $key = ucfirst($this->normalize($key)); |
54 | - if(strpos($key,'input')!==0) |
|
54 | + if (strpos($key, 'input') !== 0) |
|
55 | 55 | $key = 'input'.$key; |
56 | - $this->set('id',$key); |
|
56 | + $this->set('id', $key); |
|
57 | 57 | return $this; |
58 | 58 | } |
59 | 59 | |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | { |
66 | 66 | $token or $token = microtime(true); |
67 | 67 | $token = $this->normalize($token); |
68 | - if(strpos($token,'form-')!==0) |
|
68 | + if (strpos($token, 'form-') !== 0) |
|
69 | 69 | $token = 'form-'.$token; |
70 | - $this->set('name',md5($token)); |
|
70 | + $this->set('name', md5($token)); |
|
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function add(array $attributes) |
79 | 79 | { |
80 | 80 | is_array($attributes) or $attributes = array($attributes); |
81 | - $attributes = $this->array_map_keys([$this,'normalize'],$attributes); |
|
81 | + $attributes = $this->array_map_keys([$this, 'normalize'], $attributes); |
|
82 | 82 | $this->attributes->add($attributes); |
83 | 83 | return $this; |
84 | 84 | } |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | * @param null $default |
89 | 89 | * @return mixed |
90 | 90 | */ |
91 | - public function get($key,$default=null) |
|
91 | + public function get($key, $default = null) |
|
92 | 92 | { |
93 | 93 | $key = $this->normalize($key); |
94 | - return $this->attributes->get($key,$default); |
|
94 | + return $this->attributes->get($key, $default); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | public function Ignore($ignore) |
111 | 111 | { |
112 | 112 | is_array($ignore) or $ignore = array($ignore); |
113 | - $ignore = array_merge($this->ignore->all(), array_map([$this,'normalize'],$ignore)); |
|
113 | + $ignore = array_merge($this->ignore->all(), array_map([$this, 'normalize'], $ignore)); |
|
114 | 114 | $this->ignore->replace($ignore); |
115 | 115 | return $this; |
116 | 116 | } |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | * @param $value |
132 | 132 | * @return $this |
133 | 133 | */ |
134 | - public function set($key,$value) |
|
134 | + public function set($key, $value) |
|
135 | 135 | { |
136 | 136 | $key = $this->normalize($key); |
137 | - $this->attributes->set($key,$value); |
|
137 | + $this->attributes->set($key, $value); |
|
138 | 138 | return $this; |
139 | 139 | } |
140 | 140 | |
@@ -152,23 +152,23 @@ discard block |
||
152 | 152 | public function RenderHtml() |
153 | 153 | { |
154 | 154 | $output = []; |
155 | - if($attributes = $this->attributes->all()) |
|
155 | + if ($attributes = $this->attributes->all()) |
|
156 | 156 | { |
157 | 157 | AttributesMapper::filter($this); |
158 | 158 | $filtered = array_keys($attributes); |
159 | - if($ignore = $this->ignore->all()) |
|
159 | + if ($ignore = $this->ignore->all()) |
|
160 | 160 | $filtered = array_diff($filtered, $ignore); |
161 | 161 | $attributes = array_intersect_key($attributes, array_flip($filtered)); |
162 | - foreach($attributes as $key=>$value) |
|
162 | + foreach ($attributes as $key=>$value) |
|
163 | 163 | { |
164 | - if(is_array($value)): |
|
165 | - $output[]= $key.'="'.implode(' ',array_values($value)).'"'; |
|
164 | + if (is_array($value)): |
|
165 | + $output[] = $key.'="'.implode(' ', array_values($value)).'"'; |
|
166 | 166 | else: |
167 | - if(is_numeric($key)) $output[]= $value; |
|
168 | - else $output[]= $key.'="'.$value.'"'; |
|
167 | + if (is_numeric($key)) $output[] = $value; |
|
168 | + else $output[] = $key.'="'.$value.'"'; |
|
169 | 169 | endif; |
170 | 170 | } |
171 | 171 | } |
172 | - return count($output) ? ' ' . implode(' ', $output) : ''; |
|
172 | + return count($output) ? ' '.implode(' ', $output) : ''; |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | \ No newline at end of file |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | public function createElementID($key) |
52 | 52 | { |
53 | 53 | $key = ucfirst($this->normalize($key)); |
54 | - if(strpos($key,'input')!==0) |
|
55 | - $key = 'input'.$key; |
|
54 | + if(strpos($key,'input')!==0) { |
|
55 | + $key = 'input'.$key; |
|
56 | + } |
|
56 | 57 | $this->set('id',$key); |
57 | 58 | return $this; |
58 | 59 | } |
@@ -65,8 +66,9 @@ discard block |
||
65 | 66 | { |
66 | 67 | $token or $token = microtime(true); |
67 | 68 | $token = $this->normalize($token); |
68 | - if(strpos($token,'form-')!==0) |
|
69 | - $token = 'form-'.$token; |
|
69 | + if(strpos($token,'form-')!==0) { |
|
70 | + $token = 'form-'.$token; |
|
71 | + } |
|
70 | 72 | $this->set('name',md5($token)); |
71 | 73 | return $this; |
72 | 74 | } |
@@ -156,16 +158,21 @@ discard block |
||
156 | 158 | { |
157 | 159 | AttributesMapper::filter($this); |
158 | 160 | $filtered = array_keys($attributes); |
159 | - if($ignore = $this->ignore->all()) |
|
160 | - $filtered = array_diff($filtered, $ignore); |
|
161 | + if($ignore = $this->ignore->all()) { |
|
162 | + $filtered = array_diff($filtered, $ignore); |
|
163 | + } |
|
161 | 164 | $attributes = array_intersect_key($attributes, array_flip($filtered)); |
162 | 165 | foreach($attributes as $key=>$value) |
163 | 166 | { |
164 | 167 | if(is_array($value)): |
165 | 168 | $output[]= $key.'="'.implode(' ',array_values($value)).'"'; |
166 | - else: |
|
169 | + else { |
|
170 | + : |
|
167 | 171 | if(is_numeric($key)) $output[]= $value; |
168 | - else $output[]= $key.'="'.$value.'"'; |
|
172 | + } |
|
173 | + else { |
|
174 | + $output[]= $key.'="'.$value.'"'; |
|
175 | + } |
|
169 | 176 | endif; |
170 | 177 | } |
171 | 178 | } |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | * @param string $item |
25 | 25 | * @param AttributesBuilder|array $attributes |
26 | 26 | */ |
27 | - public function __construct(string $item, $attributes=[]) |
|
27 | + public function __construct(string $item, $attributes = []) |
|
28 | 28 | { |
29 | 29 | $this->item = $item; |
30 | - if(!$attributes instanceof AttributesBuilder) |
|
31 | - $attributes = new AttributesBuilder($attributes); |
|
30 | + if (!$attributes instanceof AttributesBuilder) |
|
31 | + $attributes = new AttributesBuilder($attributes); |
|
32 | 32 | $this->attributes = $attributes; |
33 | - $this->attributes->set('type','label'); |
|
33 | + $this->attributes->set('type', 'label'); |
|
34 | 34 | return $this; |
35 | 35 | } |
36 | 36 | |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | public function getItemID() |
57 | 57 | { |
58 | 58 | |
59 | - if(!$this->attributes->has('for')) |
|
59 | + if (!$this->attributes->has('for')) |
|
60 | 60 | { |
61 | 61 | $this->attributes->createElementID($this->item); |
62 | 62 | $id = $this->attributes->get('id'); |
63 | - $this->attributes->set('for',$id); |
|
63 | + $this->attributes->set('for', $id); |
|
64 | 64 | return $id; |
65 | 65 | } |
66 | 66 | return $this->attributes->get('for'); |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function RenderHtml() |
72 | 72 | { |
73 | - $this->attributes->Ignore(['id','label','type']); |
|
74 | - $label = null; |
|
73 | + $this->attributes->Ignore(['id', 'label', 'type']); |
|
74 | + $label = null; |
|
75 | 75 | $type = $this->attributes->get('fieldtype'); |
76 | - $this->attributes->set('for',$this->attributes->get('for',$this->attributes->get('id'))); |
|
76 | + $this->attributes->set('for', $this->attributes->get('for', $this->attributes->get('id'))); |
|
77 | 77 | switch ($type): |
78 | 78 | case 'hidden': |
79 | 79 | case 'submit': |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | break; |
83 | 83 | default: |
84 | 84 | $label .= '<label'.$this->attributes->RenderHtml().'>'; |
85 | - $label .= htmlspecialchars(trim($this->item,': '),ENT_COMPAT,'UTF-8'); |
|
85 | + $label .= htmlspecialchars(trim($this->item, ': '), ENT_COMPAT, 'UTF-8'); |
|
86 | 86 | // $label .= $this->RenderErrors($label); |
87 | 87 | $label .= ': </label>'; |
88 | 88 | break; |
@@ -27,8 +27,9 @@ |
||
27 | 27 | public function __construct(string $item, $attributes=[]) |
28 | 28 | { |
29 | 29 | $this->item = $item; |
30 | - if(!$attributes instanceof AttributesBuilder) |
|
31 | - $attributes = new AttributesBuilder($attributes); |
|
30 | + if(!$attributes instanceof AttributesBuilder) { |
|
31 | + $attributes = new AttributesBuilder($attributes); |
|
32 | + } |
|
32 | 33 | $this->attributes = $attributes; |
33 | 34 | $this->attributes->set('type','label'); |
34 | 35 | return $this; |
@@ -11,25 +11,25 @@ discard block |
||
11 | 11 | |
12 | 12 | class AttributesMapper |
13 | 13 | { |
14 | - const COMMON = ['accesskey','class','contenteditable', 'contextmenu','dir','draggable','dropzone','hidden','id','lang','spellcheck','style','tabindex','title','translate']; |
|
15 | - const EVENTS = ['onblur','onchange','oncontextmenu','onfocus','oninput','oninvalid','onreset','onsearch','onselect','onsubmit','onkeydown','onkeypress','onkeyup','onclick','ondblclick','ondrag','ondragend','ondragenter','ondragleave','ondragover','ondragstart','ondrop','onmousedown','onmousemove','onmouseout','onmouseover','onmouseup','onmousewheel','onscroll','onwheel']; |
|
16 | - const BUTTON = ['autofocus','disabled','form','formaction','formenctype','formmethod','formnovalidate','formtarget','framename','name','type','value']; |
|
17 | - const CHECKBOX = ['autofocus','checked','defaultChecked','defaultvalue','disabled','form','indeterminate','name','required','type','value']; |
|
18 | - const COLOR = ['autocomplete','autofocus','defaultvalue','disabled','form','list','name','type','value']; |
|
19 | - const DATE = ['autocomplete','autofocus','defaultvalue','disabled','form','list','max','min','name','readonly','required','step','type','value']; |
|
20 | - const FIELDSET = ['disabled','form','name','legend','legend-attributes']; |
|
21 | - const FILE = ['accept','autofocus','defaultvalue','disabled','files','form','multiple','name','required','type','value', 'data-max-size']; |
|
22 | - const FORM = ['accept','accept-charset','action','autocomplete','enctype','method','name','novalidate','target']; |
|
23 | - const HIDDEN = ['form','name','type','value']; |
|
24 | - const IMAGE = ['alt','autofocus','defaultvalue','disabled','form','formaction','formenctype','formmethod','formnovalidate','formtarget','height','name','src','type','value','width']; |
|
25 | - const LABEL = ['for','form']; |
|
26 | - const OPTGROUP = ['disabled','label']; |
|
27 | - const OPTION = ['disabled','label','value','selected']; |
|
28 | - const RANGE = ['autocomplete','autofocus','defaultvalue','disabled','form','list','max','min','name','step','type','value']; |
|
29 | - const RESET = ['autofocus','defaultvalue','disabled','form','name','type','value']; |
|
30 | - const SELECT = ['autofocus','disabled','form','multiple','name','required','size','selected','optgroup-attributes','option-attributes','value']; |
|
31 | - const TEXT = ['autocomplete','autofocus','defaultvalue','disabled','form','list','minlength','maxlength','name','pattern','placeholder','readonly','required','size','type','value']; |
|
32 | - const TEXTAREA = ['autofocus','cols','dirname','disabled','form','maxlength','name','placeholder','readonly','required','rows','wrap','value']; |
|
14 | + const COMMON = ['accesskey', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone', 'hidden', 'id', 'lang', 'spellcheck', 'style', 'tabindex', 'title', 'translate']; |
|
15 | + const EVENTS = ['onblur', 'onchange', 'oncontextmenu', 'onfocus', 'oninput', 'oninvalid', 'onreset', 'onsearch', 'onselect', 'onsubmit', 'onkeydown', 'onkeypress', 'onkeyup', 'onclick', 'ondblclick', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onscroll', 'onwheel']; |
|
16 | + const BUTTON = ['autofocus', 'disabled', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'framename', 'name', 'type', 'value']; |
|
17 | + const CHECKBOX = ['autofocus', 'checked', 'defaultChecked', 'defaultvalue', 'disabled', 'form', 'indeterminate', 'name', 'required', 'type', 'value']; |
|
18 | + const COLOR = ['autocomplete', 'autofocus', 'defaultvalue', 'disabled', 'form', 'list', 'name', 'type', 'value']; |
|
19 | + const DATE = ['autocomplete', 'autofocus', 'defaultvalue', 'disabled', 'form', 'list', 'max', 'min', 'name', 'readonly', 'required', 'step', 'type', 'value']; |
|
20 | + const FIELDSET = ['disabled', 'form', 'name', 'legend', 'legend-attributes']; |
|
21 | + const FILE = ['accept', 'autofocus', 'defaultvalue', 'disabled', 'files', 'form', 'multiple', 'name', 'required', 'type', 'value', 'data-max-size']; |
|
22 | + const FORM = ['accept', 'accept-charset', 'action', 'autocomplete', 'enctype', 'method', 'name', 'novalidate', 'target']; |
|
23 | + const HIDDEN = ['form', 'name', 'type', 'value']; |
|
24 | + const IMAGE = ['alt', 'autofocus', 'defaultvalue', 'disabled', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'name', 'src', 'type', 'value', 'width']; |
|
25 | + const LABEL = ['for', 'form']; |
|
26 | + const OPTGROUP = ['disabled', 'label']; |
|
27 | + const OPTION = ['disabled', 'label', 'value', 'selected']; |
|
28 | + const RANGE = ['autocomplete', 'autofocus', 'defaultvalue', 'disabled', 'form', 'list', 'max', 'min', 'name', 'step', 'type', 'value']; |
|
29 | + const RESET = ['autofocus', 'defaultvalue', 'disabled', 'form', 'name', 'type', 'value']; |
|
30 | + const SELECT = ['autofocus', 'disabled', 'form', 'multiple', 'name', 'required', 'size', 'selected', 'optgroup-attributes', 'option-attributes', 'value']; |
|
31 | + const TEXT = ['autocomplete', 'autofocus', 'defaultvalue', 'disabled', 'form', 'list', 'minlength', 'maxlength', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'size', 'type', 'value']; |
|
32 | + const TEXTAREA = ['autofocus', 'cols', 'dirname', 'disabled', 'form', 'maxlength', 'name', 'placeholder', 'readonly', 'required', 'rows', 'wrap', 'value']; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @param AttributesBuilder $Attributes |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public static function filter(AttributesBuilder $Attributes) |
39 | 39 | { |
40 | - $aAttributes = array_change_key_case($Attributes->All(),CASE_LOWER); |
|
41 | - $Type = $Attributes->get('type','text'); |
|
40 | + $aAttributes = array_change_key_case($Attributes->All(), CASE_LOWER); |
|
41 | + $Type = $Attributes->get('type', 'text'); |
|
42 | 42 | $AcceptedAttributes = array_merge(self::EVENTS, self::COMMON); |
43 | 43 | switch ($Type): |
44 | 44 | case 'date': |
@@ -48,28 +48,28 @@ discard block |
||
48 | 48 | case 'number': |
49 | 49 | case 'time': |
50 | 50 | case 'week': |
51 | - if($Type === 'number') $AcceptedAttributes[]='placeholder'; |
|
52 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::DATE); |
|
51 | + if ($Type === 'number') $AcceptedAttributes[] = 'placeholder'; |
|
52 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::DATE); |
|
53 | 53 | break; |
54 | 54 | case 'color': |
55 | 55 | $AcceptedAttributes = array_merge($AcceptedAttributes, self::COLOR); |
56 | 56 | break; |
57 | 57 | case 'file': |
58 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::FILE); |
|
58 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::FILE); |
|
59 | 59 | break; |
60 | 60 | case 'image': |
61 | 61 | case 'video': |
62 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::IMAGE); |
|
62 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::IMAGE); |
|
63 | 63 | break; |
64 | 64 | case 'radio': |
65 | 65 | case 'checkbox': |
66 | - $tmpAttributesList=self::CHECKBOX; |
|
67 | - if($Type === 'radio') |
|
66 | + $tmpAttributesList = self::CHECKBOX; |
|
67 | + if ($Type === 'radio') |
|
68 | 68 | { |
69 | - $bannedIndex = array_search('indeterminate', $tmpAttributesList,true); |
|
70 | - if(isset($tmpAttributesList[$bannedIndex])) unset($tmpAttributesList[$bannedIndex]); |
|
69 | + $bannedIndex = array_search('indeterminate', $tmpAttributesList, true); |
|
70 | + if (isset($tmpAttributesList[$bannedIndex])) unset($tmpAttributesList[$bannedIndex]); |
|
71 | 71 | } |
72 | - $AcceptedAttributes = array_merge($AcceptedAttributes,array_values($tmpAttributesList)); |
|
72 | + $AcceptedAttributes = array_merge($AcceptedAttributes, array_values($tmpAttributesList)); |
|
73 | 73 | break; |
74 | 74 | |
75 | 75 | case 'submit': |
@@ -78,61 +78,61 @@ discard block |
||
78 | 78 | break; |
79 | 79 | |
80 | 80 | case 'reset': |
81 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::RESET); |
|
81 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::RESET); |
|
82 | 82 | break; |
83 | 83 | case 'range': |
84 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::RANGE); |
|
84 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::RANGE); |
|
85 | 85 | break; |
86 | 86 | case 'textarea': |
87 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::TEXTAREA); |
|
87 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::TEXTAREA); |
|
88 | 88 | break; |
89 | 89 | case 'optgroup': |
90 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::OPTGROUP); |
|
90 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::OPTGROUP); |
|
91 | 91 | break; |
92 | 92 | case 'option': |
93 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::OPTION); |
|
93 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::OPTION); |
|
94 | 94 | break; |
95 | 95 | case 'label': |
96 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::LABEL); |
|
96 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::LABEL); |
|
97 | 97 | break; |
98 | 98 | case 'select': |
99 | - $AcceptedAttributes[]='placeholder'; |
|
100 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::SELECT); |
|
99 | + $AcceptedAttributes[] = 'placeholder'; |
|
100 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::SELECT); |
|
101 | 101 | break; |
102 | 102 | case 'form': |
103 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::FORM); |
|
103 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::FORM); |
|
104 | 104 | break; |
105 | 105 | case 'fieldset': |
106 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::FIELDSET); |
|
106 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::FIELDSET); |
|
107 | 107 | break; |
108 | 108 | case 'hidden': |
109 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::HIDDEN); |
|
109 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::HIDDEN); |
|
110 | 110 | break; |
111 | 111 | default: |
112 | - if($Type === 'email') $AcceptedAttributes[]='multiple'; |
|
113 | - $AcceptedAttributes = array_merge($AcceptedAttributes,self::TEXT); |
|
112 | + if ($Type === 'email') $AcceptedAttributes[] = 'multiple'; |
|
113 | + $AcceptedAttributes = array_merge($AcceptedAttributes, self::TEXT); |
|
114 | 114 | break; |
115 | 115 | endswitch; |
116 | 116 | |
117 | 117 | $AcceptedAttributes = array_unique($AcceptedAttributes); |
118 | 118 | $attributesKeys = array_keys($aAttributes); |
119 | - $ignore = array_diff($attributesKeys,$AcceptedAttributes); |
|
119 | + $ignore = array_diff($attributesKeys, $AcceptedAttributes); |
|
120 | 120 | foreach ($ignore as $key=>$attribute) |
121 | 121 | { |
122 | - if(is_numeric($attribute)) |
|
122 | + if (is_numeric($attribute)) |
|
123 | 123 | { |
124 | 124 | unset($ignore[$key]); |
125 | 125 | $attribute = $aAttributes[$attribute]; |
126 | 126 | $ignore[$key] = $attribute; |
127 | 127 | } |
128 | - if(substr($attribute,0,5)==='data-') |
|
128 | + if (substr($attribute, 0, 5) === 'data-') |
|
129 | 129 | { |
130 | 130 | $AcceptedAttributes[] += $attribute; |
131 | 131 | unset($ignore[$key]); |
132 | 132 | continue; |
133 | 133 | } |
134 | 134 | } |
135 | - if($ignore) $Attributes->Ignore($ignore); |
|
135 | + if ($ignore) $Attributes->Ignore($ignore); |
|
136 | 136 | return $ignore; |
137 | 137 | } |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -48,7 +48,9 @@ discard block |
||
48 | 48 | case 'number': |
49 | 49 | case 'time': |
50 | 50 | case 'week': |
51 | - if($Type === 'number') $AcceptedAttributes[]='placeholder'; |
|
51 | + if($Type === 'number') { |
|
52 | + $AcceptedAttributes[]='placeholder'; |
|
53 | + } |
|
52 | 54 | $AcceptedAttributes = array_merge($AcceptedAttributes,self::DATE); |
53 | 55 | break; |
54 | 56 | case 'color': |
@@ -67,7 +69,9 @@ discard block |
||
67 | 69 | if($Type === 'radio') |
68 | 70 | { |
69 | 71 | $bannedIndex = array_search('indeterminate', $tmpAttributesList,true); |
70 | - if(isset($tmpAttributesList[$bannedIndex])) unset($tmpAttributesList[$bannedIndex]); |
|
72 | + if(isset($tmpAttributesList[$bannedIndex])) { |
|
73 | + unset($tmpAttributesList[$bannedIndex]); |
|
74 | + } |
|
71 | 75 | } |
72 | 76 | $AcceptedAttributes = array_merge($AcceptedAttributes,array_values($tmpAttributesList)); |
73 | 77 | break; |
@@ -109,7 +113,9 @@ discard block |
||
109 | 113 | $AcceptedAttributes = array_merge($AcceptedAttributes,self::HIDDEN); |
110 | 114 | break; |
111 | 115 | default: |
112 | - if($Type === 'email') $AcceptedAttributes[]='multiple'; |
|
116 | + if($Type === 'email') { |
|
117 | + $AcceptedAttributes[]='multiple'; |
|
118 | + } |
|
113 | 119 | $AcceptedAttributes = array_merge($AcceptedAttributes,self::TEXT); |
114 | 120 | break; |
115 | 121 | endswitch; |
@@ -132,7 +138,9 @@ discard block |
||
132 | 138 | continue; |
133 | 139 | } |
134 | 140 | } |
135 | - if($ignore) $Attributes->Ignore($ignore); |
|
141 | + if($ignore) { |
|
142 | + $Attributes->Ignore($ignore); |
|
143 | + } |
|
136 | 144 | return $ignore; |
137 | 145 | } |
138 | 146 | } |
139 | 147 | \ No newline at end of file |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | */ |
18 | 18 | private function normalize($keys) |
19 | 19 | { |
20 | - if(is_array($keys)) return false; |
|
21 | - foreach (array(' ', ' ', '\n', '\t', '\r', '"','\'','_') as $strip) |
|
20 | + if (is_array($keys)) return false; |
|
21 | + foreach (array(' ', ' ', '\n', '\t', '\r', '"', '\'', '_') as $strip) |
|
22 | 22 | $keys = str_replace($strip, '', (string) $keys); |
23 | 23 | $keys = trim(preg_replace('/\W+/', '-', $keys), '-'); |
24 | - $keys = strtolower(str_ireplace('input','',$keys)); |
|
24 | + $keys = strtolower(str_ireplace('input', '', $keys)); |
|
25 | 25 | return $keys; |
26 | 26 | } |
27 | 27 | |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | * @param array $array |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - private function array_map_keys (callable $callable, array $array) : array |
|
33 | + private function array_map_keys(callable $callable, array $array) : array |
|
34 | 34 | { |
35 | 35 | $map = []; |
36 | 36 | foreach ($array as $key => $value) |
37 | 37 | { |
38 | - $key = call_user_func($callable,$key); |
|
38 | + $key = call_user_func($callable, $key); |
|
39 | 39 | $map[$key] = $value; |
40 | 40 | } |
41 | 41 | return $map; |
@@ -17,9 +17,12 @@ |
||
17 | 17 | */ |
18 | 18 | private function normalize($keys) |
19 | 19 | { |
20 | - if(is_array($keys)) return false; |
|
21 | - foreach (array(' ', ' ', '\n', '\t', '\r', '"','\'','_') as $strip) |
|
22 | - $keys = str_replace($strip, '', (string) $keys); |
|
20 | + if(is_array($keys)) { |
|
21 | + return false; |
|
22 | + } |
|
23 | + foreach (array(' ', ' ', '\n', '\t', '\r', '"','\'','_') as $strip) { |
|
24 | + $keys = str_replace($strip, '', (string) $keys); |
|
25 | + } |
|
23 | 26 | $keys = trim(preg_replace('/\W+/', '-', $keys), '-'); |
24 | 27 | $keys = strtolower(str_ireplace('input','',$keys)); |
25 | 28 | return $keys; |
@@ -12,40 +12,40 @@ |
||
12 | 12 | interface FormGeneratorInterface |
13 | 13 | { |
14 | 14 | /* COMMON METHODS */ |
15 | - public function Open($attributes=[]); |
|
15 | + public function Open($attributes = []); |
|
16 | 16 | public function Close(); |
17 | - public function addFieldset($attributes=[]); |
|
17 | + public function addFieldset($attributes = []); |
|
18 | 18 | |
19 | 19 | /* INPUT TYPES */ |
20 | - public function addAudio($label,$attributes=[]); |
|
21 | - public function addButton($label,$attributes=[]); |
|
22 | - public function addCaptcha($label,$attributes=[]); |
|
23 | - public function addCheckbox($label,$options=[],$attributes=[]); |
|
24 | - public function addColor($label,$attributes=[]); |
|
25 | - public function addCountry($label,$attributes=[]); |
|
26 | - public function addDate($label,$attributes=[]); |
|
27 | - public function addDatetime($label,$attributes=[]); |
|
28 | - public function addDatetimeLocal($label,$attributes=[]); |
|
29 | - public function addEmail($label,$attributes=[]); |
|
30 | - public function addFile($label,$attributes=[]); |
|
31 | - public function addHidden($label,$attributes=[]); |
|
32 | - public function addImage($label,$attributes=[]); |
|
33 | - public function addMonth($label,$attributes=[]); |
|
34 | - public function addNumber($label,$attributes=[]); |
|
35 | - public function addPassword($label,$attributes=[]); |
|
36 | - public function addPhone($label,$attributes=[]); |
|
37 | - public function addRadio($label,$options=[],$attributes=[]); |
|
38 | - public function addRange($label,$attributes=[]); |
|
39 | - public function addReset($label,$attributes=[]); |
|
40 | - public function addSearch($label,$attributes=[]); |
|
41 | - public function addSelect($label,$options=[],$attributes=[]); |
|
42 | - public function addSubmit($label,$attributes=[]); |
|
43 | - public function addText($label,$attributes=[]); |
|
44 | - public function addTextarea($label,$attributes=[]); |
|
45 | - public function addTextEditor($label,$attributes=[]); |
|
46 | - public function addTime($label,$attributes=[]); |
|
47 | - public function addUrl($label,$attributes=[]); |
|
48 | - public function addVideo($label,$attributes=[]); |
|
49 | - public function addWeek($label,$attributes=[]); |
|
50 | - public function addYesNo($label,$attributes=[]); |
|
20 | + public function addAudio($label, $attributes = []); |
|
21 | + public function addButton($label, $attributes = []); |
|
22 | + public function addCaptcha($label, $attributes = []); |
|
23 | + public function addCheckbox($label, $options = [], $attributes = []); |
|
24 | + public function addColor($label, $attributes = []); |
|
25 | + public function addCountry($label, $attributes = []); |
|
26 | + public function addDate($label, $attributes = []); |
|
27 | + public function addDatetime($label, $attributes = []); |
|
28 | + public function addDatetimeLocal($label, $attributes = []); |
|
29 | + public function addEmail($label, $attributes = []); |
|
30 | + public function addFile($label, $attributes = []); |
|
31 | + public function addHidden($label, $attributes = []); |
|
32 | + public function addImage($label, $attributes = []); |
|
33 | + public function addMonth($label, $attributes = []); |
|
34 | + public function addNumber($label, $attributes = []); |
|
35 | + public function addPassword($label, $attributes = []); |
|
36 | + public function addPhone($label, $attributes = []); |
|
37 | + public function addRadio($label, $options = [], $attributes = []); |
|
38 | + public function addRange($label, $attributes = []); |
|
39 | + public function addReset($label, $attributes = []); |
|
40 | + public function addSearch($label, $attributes = []); |
|
41 | + public function addSelect($label, $options = [], $attributes = []); |
|
42 | + public function addSubmit($label, $attributes = []); |
|
43 | + public function addText($label, $attributes = []); |
|
44 | + public function addTextarea($label, $attributes = []); |
|
45 | + public function addTextEditor($label, $attributes = []); |
|
46 | + public function addTime($label, $attributes = []); |
|
47 | + public function addUrl($label, $attributes = []); |
|
48 | + public function addVideo($label, $attributes = []); |
|
49 | + public function addWeek($label, $attributes = []); |
|
50 | + public function addYesNo($label, $attributes = []); |
|
51 | 51 | } |
52 | 52 | \ No newline at end of file |