1: <?php
2:
3: 4: 5:
6: class HTMLPurifier_AttrTypes
7: {
8: 9: 10:
11: protected $info = array();
12:
13: 14: 15: 16:
17: public function __construct() {
18:
19: $this->info['Enum'] = new HTMLPurifier_AttrDef_Enum();
20: $this->info['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool();
21:
22: $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text();
23: $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID();
24: $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length();
25: $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength();
26: $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens();
27: $this->info['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels();
28: $this->info['Text'] = new HTMLPurifier_AttrDef_Text();
29: $this->info['URI'] = new HTMLPurifier_AttrDef_URI();
30: $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang();
31: $this->info['Color'] = new HTMLPurifier_AttrDef_HTML_Color();
32:
33:
34: $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text();
35: $this->info['ContentTypes'] = new HTMLPurifier_AttrDef_Text();
36: $this->info['Charsets'] = new HTMLPurifier_AttrDef_Text();
37: $this->info['Character'] = new HTMLPurifier_AttrDef_Text();
38:
39:
40: $this->info['Class'] = new HTMLPurifier_AttrDef_HTML_Class();
41:
42:
43:
44: $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true);
45: }
46:
47: 48: 49: 50: 51:
52: public function get($type) {
53:
54:
55: if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2);
56: else $string = '';
57:
58: if (!isset($this->info[$type])) {
59: trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
60: return;
61: }
62:
63: return $this->info[$type]->make($string);
64:
65: }
66:
67: 68: 69: 70: 71:
72: public function set($type, $impl) {
73: $this->info[$type] = $impl;
74: }
75: }
76:
77:
78: