HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/HTMLModule/Legacy.php
Go to the documentation of this file.
00001 <?php
00002 
00019 class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
00020 {
00021 
00022     public $name = 'Legacy';
00023 
00024     public function setup($config) {
00025 
00026         $this->addElement('basefont', 'Inline', 'Empty', false, array(
00027             'color' => 'Color',
00028             'face' => 'Text', // extremely broad, we should
00029             'size' => 'Text', // tighten it
00030             'id' => 'ID'
00031         ));
00032         $this->addElement('center', 'Block', 'Flow', 'Common');
00033         $this->addElement('dir', 'Block', 'Required: li', 'Common', array(
00034             'compact' => 'Bool#compact'
00035         ));
00036         $this->addElement('font', 'Inline', 'Inline', array('Core', 'I18N'), array(
00037             'color' => 'Color',
00038             'face' => 'Text', // extremely broad, we should
00039             'size' => 'Text', // tighten it
00040         ));
00041         $this->addElement('menu', 'Block', 'Required: li', 'Common', array(
00042             'compact' => 'Bool#compact'
00043         ));
00044 
00045         $s = $this->addElement('s', 'Inline', 'Inline', 'Common');
00046         $s->formatting = true;
00047 
00048         $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common');
00049         $strike->formatting = true;
00050 
00051         $u = $this->addElement('u', 'Inline', 'Inline', 'Common');
00052         $u->formatting = true;
00053 
00054         // setup modifications to old elements
00055 
00056         $align = 'Enum#left,right,center,justify';
00057 
00058         $address = $this->addBlankElement('address');
00059         $address->content_model = 'Inline | #PCDATA | p';
00060         $address->content_model_type = 'optional';
00061         $address->child = false;
00062 
00063         $blockquote = $this->addBlankElement('blockquote');
00064         $blockquote->content_model = 'Flow | #PCDATA';
00065         $blockquote->content_model_type = 'optional';
00066         $blockquote->child = false;
00067 
00068         $br = $this->addBlankElement('br');
00069         $br->attr['clear'] = 'Enum#left,all,right,none';
00070 
00071         $caption = $this->addBlankElement('caption');
00072         $caption->attr['align'] = 'Enum#top,bottom,left,right';
00073 
00074         $div = $this->addBlankElement('div');
00075         $div->attr['align'] = $align;
00076 
00077         $dl = $this->addBlankElement('dl');
00078         $dl->attr['compact'] = 'Bool#compact';
00079 
00080         for ($i = 1; $i <= 6; $i++) {
00081             $h = $this->addBlankElement("h$i");
00082             $h->attr['align'] = $align;
00083         }
00084 
00085         $hr = $this->addBlankElement('hr');
00086         $hr->attr['align'] = $align;
00087         $hr->attr['noshade'] = 'Bool#noshade';
00088         $hr->attr['size'] = 'Pixels';
00089         $hr->attr['width'] = 'Length';
00090 
00091         $img = $this->addBlankElement('img');
00092         $img->attr['align'] = 'IAlign';
00093         $img->attr['border'] = 'Pixels';
00094         $img->attr['hspace'] = 'Pixels';
00095         $img->attr['vspace'] = 'Pixels';
00096 
00097         // figure out this integer business
00098 
00099         $li = $this->addBlankElement('li');
00100         $li->attr['value'] = new HTMLPurifier_AttrDef_Integer();
00101         $li->attr['type']  = 'Enum#s:1,i,I,a,A,disc,square,circle';
00102 
00103         $ol = $this->addBlankElement('ol');
00104         $ol->attr['compact'] = 'Bool#compact';
00105         $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer();
00106         $ol->attr['type'] = 'Enum#s:1,i,I,a,A';
00107 
00108         $p = $this->addBlankElement('p');
00109         $p->attr['align'] = $align;
00110 
00111         $pre = $this->addBlankElement('pre');
00112         $pre->attr['width'] = 'Number';
00113 
00114         // script omitted
00115 
00116         $table = $this->addBlankElement('table');
00117         $table->attr['align'] = 'Enum#left,center,right';
00118         $table->attr['bgcolor'] = 'Color';
00119 
00120         $tr = $this->addBlankElement('tr');
00121         $tr->attr['bgcolor'] = 'Color';
00122 
00123         $th = $this->addBlankElement('th');
00124         $th->attr['bgcolor'] = 'Color';
00125         $th->attr['height'] = 'Length';
00126         $th->attr['nowrap'] = 'Bool#nowrap';
00127         $th->attr['width'] = 'Length';
00128 
00129         $td = $this->addBlankElement('td');
00130         $td->attr['bgcolor'] = 'Color';
00131         $td->attr['height'] = 'Length';
00132         $td->attr['nowrap'] = 'Bool#nowrap';
00133         $td->attr['width'] = 'Length';
00134 
00135         $ul = $this->addBlankElement('ul');
00136         $ul->attr['compact'] = 'Bool#compact';
00137         $ul->attr['type'] = 'Enum#square,disc,circle';
00138 
00139         // "safe" modifications to "unsafe" elements
00140         // WARNING: If you want to add support for an unsafe, legacy
00141         // attribute, make a new TrustedLegacy module with the trusted
00142         // bit set appropriately
00143 
00144         $form = $this->addBlankElement('form');
00145         $form->content_model = 'Flow | #PCDATA';
00146         $form->content_model_type = 'optional';
00147         $form->attr['target'] = 'FrameTarget';
00148 
00149         $input = $this->addBlankElement('input');
00150         $input->attr['align'] = 'IAlign';
00151 
00152         $legend = $this->addBlankElement('legend');
00153         $legend->attr['align'] = 'LAlign';
00154 
00155     }
00156 
00157 }
00158 
00159 // vim: et sw=4 sts=4