3 require_once 'HTMLPurifier/AttrDef/Lang.php';
4 require_once 'HTMLPurifier/AttrDef/Enum.php';
5 require_once 'HTMLPurifier/AttrDef/HTML/Bool.php';
6 require_once 'HTMLPurifier/AttrDef/HTML/ID.php';
7 require_once 'HTMLPurifier/AttrDef/HTML/Length.php';
8 require_once 'HTMLPurifier/AttrDef/HTML/MultiLength.php';
9 require_once 'HTMLPurifier/AttrDef/HTML/Nmtokens.php';
10 require_once 'HTMLPurifier/AttrDef/HTML/Pixels.php';
11 require_once 'HTMLPurifier/AttrDef/HTML/Color.php';
12 require_once 'HTMLPurifier/AttrDef/Integer.php';
13 require_once 'HTMLPurifier/AttrDef/Text.php';
14 require_once 'HTMLPurifier/AttrDef/URI.php';
17 * Provides lookup array of attribute types to HTMLPurifier_AttrDef objects
19 class HTMLPurifier_AttrTypes
22 * Lookup array of attribute string identifiers to concrete implementations
28 * Constructs the info array, supplying default implementations for attribute
31 function HTMLPurifier_AttrTypes() {
32 // pseudo-types, must be instantiated via shorthand
33 $this->info
['Enum'] = new HTMLPurifier_AttrDef_Enum();
34 $this->info
['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool();
36 $this->info
['CDATA'] = new HTMLPurifier_AttrDef_Text();
37 $this->info
['ID'] = new HTMLPurifier_AttrDef_HTML_ID();
38 $this->info
['Length'] = new HTMLPurifier_AttrDef_HTML_Length();
39 $this->info
['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength();
40 $this->info
['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens();
41 $this->info
['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels();
42 $this->info
['Text'] = new HTMLPurifier_AttrDef_Text();
43 $this->info
['URI'] = new HTMLPurifier_AttrDef_URI();
44 $this->info
['LanguageCode'] = new HTMLPurifier_AttrDef_Lang();
45 $this->info
['Color'] = new HTMLPurifier_AttrDef_HTML_Color();
47 // number is really a positive integer (one or more digits)
48 // FIXME: ^^ not always, see start and value of list items
49 $this->info
['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true);
54 * @param $type String type name
55 * @return Object AttrDef for type
59 // determine if there is any extra info tacked on
60 if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2);
63 if (!isset($this->info
[$type])) {
64 trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR
);
68 return $this->info
[$type]->make($string);
73 * Sets a new implementation for a type
74 * @param $type String type name
75 * @param $impl Object AttrDef for type
77 function set($type, $impl) {
78 $this->info
[$type] = $impl;