Edit.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * XHTML 1.1 Edit Module, defines editing-related elements. Text Extension
  4. * Module.
  5. */
  6. class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule
  7. {
  8. public $name = 'Edit';
  9. public function setup($config) {
  10. $contents = 'Chameleon: #PCDATA | Inline ! #PCDATA | Flow';
  11. $attr = array(
  12. 'cite' => 'URI',
  13. // 'datetime' => 'Datetime', // not implemented
  14. );
  15. $this->addElement('del', 'Inline', $contents, 'Common', $attr);
  16. $this->addElement('ins', 'Inline', $contents, 'Common', $attr);
  17. }
  18. // HTML 4.01 specifies that ins/del must not contain block
  19. // elements when used in an inline context, chameleon is
  20. // a complicated workaround to acheive this effect
  21. // Inline context ! Block context (exclamation mark is
  22. // separator, see getChildDef for parsing)
  23. public $defines_child_def = true;
  24. public function getChildDef($def) {
  25. if ($def->content_model_type != 'chameleon') return false;
  26. $value = explode('!', $def->content_model);
  27. return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]);
  28. }
  29. }
  30. // vim: et sw=4 sts=4