Tables.php 2.2 KB

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