Tables.php 2.3 KB

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