Add support for scope attribute on td and th.
[htmlpurifier.git] / library / HTMLPurifier / HTMLModule / Tables.php
blob45c42bb3e44b9bdc825e1dbe3f445aaf306f1879
1 <?php
3 /**
4 * XHTML 1.1 Tables Module, fully defines accessible table elements.
5 */
6 class HTMLPurifier_HTMLModule_Tables extends HTMLPurifier_HTMLModule
9 public $name = 'Tables';
11 public function setup($config) {
13 $this->addElement('caption', false, 'Inline', 'Common');
15 $this->addElement('table', 'Block',
16 new HTMLPurifier_ChildDef_Table(), 'Common',
17 array(
18 'border' => 'Pixels',
19 'cellpadding' => 'Length',
20 'cellspacing' => 'Length',
21 'frame' => 'Enum#void,above,below,hsides,lhs,rhs,vsides,box,border',
22 'rules' => 'Enum#none,groups,rows,cols,all',
23 'summary' => 'Text',
24 'width' => 'Length'
28 // common attributes
29 $cell_align = array(
30 'align' => 'Enum#left,center,right,justify,char',
31 'charoff' => 'Length',
32 'valign' => 'Enum#top,middle,bottom,baseline',
35 $cell_t = array_merge(
36 array(
37 'abbr' => 'Text',
38 'colspan' => 'Number',
39 'rowspan' => 'Number',
40 // Apparently, as of HTML5 this attribute only applies
41 // to 'th' elements.
42 'scope' => 'Enum#row,col,rowgroup,colgroup',
44 $cell_align
46 $this->addElement('td', false, 'Flow', 'Common', $cell_t);
47 $this->addElement('th', false, 'Flow', 'Common', $cell_t);
49 $this->addElement('tr', false, 'Required: td | th', 'Common', $cell_align);
51 $cell_col = array_merge(
52 array(
53 'span' => 'Number',
54 'width' => 'MultiLength',
56 $cell_align
58 $this->addElement('col', false, 'Empty', 'Common', $cell_col);
59 $this->addElement('colgroup', false, 'Optional: col', 'Common', $cell_col);
61 $this->addElement('tbody', false, 'Required: tr', 'Common', $cell_align);
62 $this->addElement('thead', false, 'Required: tr', 'Common', $cell_align);
63 $this->addElement('tfoot', false, 'Required: tr', 'Common', $cell_align);
69 // vim: et sw=4 sts=4