|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00006 class HTMLPurifier_AttrTypes 00007 { 00011 protected $info = array(); 00012 00017 public function __construct() { 00018 // pseudo-types, must be instantiated via shorthand 00019 $this->info['Enum'] = new HTMLPurifier_AttrDef_Enum(); 00020 $this->info['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool(); 00021 00022 $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text(); 00023 $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID(); 00024 $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length(); 00025 $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength(); 00026 $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens(); 00027 $this->info['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels(); 00028 $this->info['Text'] = new HTMLPurifier_AttrDef_Text(); 00029 $this->info['URI'] = new HTMLPurifier_AttrDef_URI(); 00030 $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang(); 00031 $this->info['Color'] = new HTMLPurifier_AttrDef_HTML_Color(); 00032 00033 // unimplemented aliases 00034 $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text(); 00035 $this->info['ContentTypes'] = new HTMLPurifier_AttrDef_Text(); 00036 $this->info['Charsets'] = new HTMLPurifier_AttrDef_Text(); 00037 $this->info['Character'] = new HTMLPurifier_AttrDef_Text(); 00038 00039 // "proprietary" types 00040 $this->info['Class'] = new HTMLPurifier_AttrDef_HTML_Class(); 00041 00042 // number is really a positive integer (one or more digits) 00043 // FIXME: ^^ not always, see start and value of list items 00044 $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true); 00045 } 00046 00052 public function get($type) { 00053 00054 // determine if there is any extra info tacked on 00055 if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2); 00056 else $string = ''; 00057 00058 if (!isset($this->info[$type])) { 00059 trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR); 00060 return; 00061 } 00062 00063 return $this->info[$type]->make($string); 00064 00065 } 00066 00072 public function set($type, $impl) { 00073 $this->info[$type] = $impl; 00074 } 00075 } 00076 00077 // vim: et sw=4 sts=4