3 require_once 'HTMLPurifier/HTMLModule.php';
4 require_once 'HTMLPurifier/ChildDef/Table.php';
7 * XHTML 1.1 Tables Module, fully defines accessible table elements.
9 class HTMLPurifier_HTMLModule_Tables
extends HTMLPurifier_HTMLModule
13 var $elements = array('caption', 'table', 'td', 'th', 'tr', 'col',
14 'colgroup', 'tbody', 'thead', 'tfoot');
15 var $content_sets = array('Block' => 'table');
17 function HTMLPurifier_HTMLModule_Tables() {
18 foreach ($this->elements
as $e) {
19 $this->info
[$e] = new HTMLPurifier_ElementDef();
20 $this->info
[$e]->attr
= array(0 => array('Common'));
21 $attr =& $this->info
[$e]->attr
;
22 if ($e == 'caption') continue;
24 $attr['border'] = 'Pixels';
25 $attr['cellpadding'] = 'Length';
26 $attr['cellspacing'] = 'Length';
27 $attr['frame'] = new HTMLPurifier_AttrDef_Enum(array(
28 'void', 'above', 'below', 'hsides', 'lhs', 'rhs',
29 'vsides', 'box', 'border'
31 $attr['rules'] = new HTMLPurifier_AttrDef_Enum(array(
32 'none', 'groups', 'rows', 'cols', 'all'
34 $attr['summary'] = 'Text';
35 $attr['width'] = 'Length';
38 if ($e == 'col' ||
$e == 'colgroup') {
39 $attr['span'] = 'Number';
40 $attr['width'] = 'MultiLength';
42 if ($e == 'td' ||
$e == 'th') {
43 $attr['abbr'] = 'Text';
44 $attr['colspan'] = 'Number';
45 $attr['rowspan'] = 'Number';
47 $attr['align'] = new HTMLPurifier_AttrDef_Enum(array(
48 'left', 'center', 'right', 'justify', 'char'
50 $attr['valign'] = new HTMLPurifier_AttrDef_Enum(array(
51 'top', 'middle', 'bottom', 'baseline'
53 $attr['charoff'] = 'Length';
55 $this->info
['caption']->content_model
= '#PCDATA | Inline';
56 $this->info
['caption']->content_model_type
= 'optional';
58 // Is done directly because it doesn't leverage substitution
59 // mechanisms. True model is:
60 // 'caption?, ( col* | colgroup* ), (( thead?, tfoot?, tbody+ ) | ( tr+ ))'
61 $this->info
['table']->child
= new HTMLPurifier_ChildDef_Table();
63 $this->info
['td']->content_model
=
64 $this->info
['th']->content_model
= '#PCDATA | Flow';
65 $this->info
['td']->content_model_type
=
66 $this->info
['th']->content_model_type
= 'optional';
68 $this->info
['tr']->content_model
= 'td | th';
69 $this->info
['tr']->content_model_type
= 'required';
71 $this->info
['col']->content_model_type
= 'empty';
73 $this->info
['colgroup']->content_model
= 'col';
74 $this->info
['colgroup']->content_model_type
= 'optional';
76 $this->info
['tbody']->content_model
=
77 $this->info
['thead']->content_model
=
78 $this->info
['tfoot']->content_model
= 'tr';
79 $this->info
['tbody']->content_model_type
=
80 $this->info
['thead']->content_model_type
=
81 $this->info
['tfoot']->content_model_type
= 'required';