Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  
   3  /**
   4   * XHTML 1.1 Edit Module, defines editing-related elements. Text Extension
   5   * Module.
   6   */
   7  class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule
   8  {
   9  
  10      /**
  11       * @type string
  12       */
  13      public $name = 'Edit';
  14  
  15      /**
  16       * @param HTMLPurifier_Config $config
  17       */
  18      public function setup($config)
  19      {
  20          $contents = 'Chameleon: #PCDATA | Inline ! #PCDATA | Flow';
  21          $attr = array(
  22              'cite' => 'URI',
  23              // 'datetime' => 'Datetime', // not implemented
  24          );
  25          $this->addElement('del', 'Inline', $contents, 'Common', $attr);
  26          $this->addElement('ins', 'Inline', $contents, 'Common', $attr);
  27      }
  28  
  29      // HTML 4.01 specifies that ins/del must not contain block
  30      // elements when used in an inline context, chameleon is
  31      // a complicated workaround to acheive this effect
  32  
  33      // Inline context ! Block context (exclamation mark is
  34      // separator, see getChildDef for parsing)
  35  
  36      /**
  37       * @type bool
  38       */
  39      public $defines_child_def = true;
  40  
  41      /**
  42       * @param HTMLPurifier_ElementDef $def
  43       * @return HTMLPurifier_ChildDef_Chameleon
  44       */
  45      public function getChildDef($def)
  46      {
  47          if ($def->content_model_type != 'chameleon') {
  48              return false;
  49          }
  50          $value = explode('!', $def->content_model);
  51          return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]);
  52      }
  53  }
  54  
  55  // vim: et sw=4 sts=4