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
// unimplemented aliases
48
$this->info['ContentType'] = new HTMLPurifier_AttrDef_Text();
50
// number is really a positive integer (one or more digits)
51
// FIXME: ^^ not always, see start and value of list items
52
$this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true);
57
* @param $type String type name
58
* @return Object AttrDef for type
62
// determine if there is any extra info tacked on
63
if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2);
66
if (!isset($this->info[$type])) {
67
trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
71
return $this->info[$type]->make($string);
76
* Sets a new implementation for a type
77
* @param $type String type name
78
* @param $impl Object AttrDef for type
80
function set($type, $impl) {
81
$this->info[$type] = $impl;