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