ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
Input.php
Go to the documentation of this file.
1 <?php
2 
8 
9  protected $pixels;
10 
11  public function __construct() {
12  $this->pixels = new HTMLPurifier_AttrDef_HTML_Pixels();
13  }
14 
15  public function transform($attr, $config, $context) {
16  if (!isset($attr['type'])) $t = 'text';
17  else $t = strtolower($attr['type']);
18  if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') {
19  unset($attr['checked']);
20  }
21  if (isset($attr['maxlength']) && $t !== 'text' && $t !== 'password') {
22  unset($attr['maxlength']);
23  }
24  if (isset($attr['size']) && $t !== 'text' && $t !== 'password') {
25  $result = $this->pixels->validate($attr['size'], $config, $context);
26  if ($result === false) unset($attr['size']);
27  else $attr['size'] = $result;
28  }
29  if (isset($attr['src']) && $t !== 'image') {
30  unset($attr['src']);
31  }
32  if (!isset($attr['value']) && ($t === 'radio' || $t === 'checkbox')) {
33  $attr['value'] = '';
34  }
35  return $attr;
36  }
37 
38 }
39 
40 // vim: et sw=4 sts=4