Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  
   3  /**

   4   * XHTML 1.1 Tables Module, fully defines accessible table elements.

   5   */
   6  class HTMLPurifier_HTMLModule_Tables extends HTMLPurifier_HTMLModule
   7  {
   8      /**

   9       * @type string

  10       */
  11      public $name = 'Tables';
  12  
  13      /**

  14       * @param HTMLPurifier_Config $config

  15       */
  16      public function setup($config)
  17      {
  18          $this->addElement('caption', false, 'Inline', 'Common');
  19  
  20          $this->addElement(
  21              'table',
  22              'Block',
  23              new HTMLPurifier_ChildDef_Table(),
  24              'Common',
  25              array(
  26                  'border' => 'Pixels',
  27                  'cellpadding' => 'Length',
  28                  'cellspacing' => 'Length',
  29                  'frame' => 'Enum#void,above,below,hsides,lhs,rhs,vsides,box,border',
  30                  'rules' => 'Enum#none,groups,rows,cols,all',
  31                  'summary' => 'Text',
  32                  'width' => 'Length'
  33              )
  34          );
  35  
  36          // common attributes

  37          $cell_align = array(
  38              'align' => 'Enum#left,center,right,justify,char',
  39              'charoff' => 'Length',
  40              'valign' => 'Enum#top,middle,bottom,baseline',
  41          );
  42  
  43          $cell_t = array_merge(
  44              array(
  45                  'abbr' => 'Text',
  46                  'colspan' => 'Number',
  47                  'rowspan' => 'Number',
  48                  // Apparently, as of HTML5 this attribute only applies

  49                  // to 'th' elements.

  50                  'scope' => 'Enum#row,col,rowgroup,colgroup',
  51              ),
  52              $cell_align
  53          );
  54          $this->addElement('td', false, 'Flow', 'Common', $cell_t);
  55          $this->addElement('th', false, 'Flow', 'Common', $cell_t);
  56  
  57          $this->addElement('tr', false, 'Required: td | th', 'Common', $cell_align);
  58  
  59          $cell_col = array_merge(
  60              array(
  61                  'span' => 'Number',
  62                  'width' => 'MultiLength',
  63              ),
  64              $cell_align
  65          );
  66          $this->addElement('col', false, 'Empty', 'Common', $cell_col);
  67          $this->addElement('colgroup', false, 'Optional: col', 'Common', $cell_col);
  68  
  69          $this->addElement('tbody', false, 'Required: tr', 'Common', $cell_align);
  70          $this->addElement('thead', false, 'Required: tr', 'Common', $cell_align);
  71          $this->addElement('tfoot', false, 'Required: tr', 'Common', $cell_align);
  72      }
  73  }
  74  
  75  // vim: et sw=4 sts=4