ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Input.php
Go to the documentation of this file.
1<?php
2
8{
12 protected $pixels;
13
14 public function __construct()
15 {
16 $this->pixels = new HTMLPurifier_AttrDef_HTML_Pixels();
17 }
18
25 public function transform($attr, $config, $context)
26 {
27 if (!isset($attr['type'])) {
28 $t = 'text';
29 } else {
30 $t = strtolower($attr['type']);
31 }
32 if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') {
33 unset($attr['checked']);
34 }
35 if (isset($attr['maxlength']) && $t !== 'text' && $t !== 'password') {
36 unset($attr['maxlength']);
37 }
38 if (isset($attr['size']) && $t !== 'text' && $t !== 'password') {
39 $result = $this->pixels->validate($attr['size'], $config, $context);
40 if ($result === false) {
41 unset($attr['size']);
42 } else {
43 $attr['size'] = $result;
44 }
45 }
46 if (isset($attr['src']) && $t !== 'image') {
47 unset($attr['src']);
48 }
49 if (!isset($attr['value']) && ($t === 'radio' || $t === 'checkbox')) {
50 $attr['value'] = '';
51 }
52 return $attr;
53 }
54}
55
56// vim: et sw=4 sts=4
$result
Validates an integer representation of pixels according to the HTML spec.
Definition: Pixels.php:7
Performs miscellaneous cross attribute validation and filtering for input elements.
Definition: Input.php:8
transform($attr, $config, $context)
Definition: Input.php:25
$pixels
@type HTMLPurifier_AttrDef_HTML_Pixels
Definition: Input.php:12
Processes an entire attribute array for corrections needing multiple values.