You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 line
1.4KB

  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. /**
  9. * @type string
  10. */
  11. public $name = 'Edit';
  12. /**
  13. * @param HTMLPurifier_Config $config
  14. */
  15. public function setup($config)
  16. {
  17. $contents = 'Chameleon: #PCDATA | Inline ! #PCDATA | Flow';
  18. $attr = array(
  19. 'cite' => 'URI',
  20. // 'datetime' => 'Datetime', // not implemented
  21. );
  22. $this->addElement('del', 'Inline', $contents, 'Common', $attr);
  23. $this->addElement('ins', 'Inline', $contents, 'Common', $attr);
  24. }
  25. // HTML 4.01 specifies that ins/del must not contain block
  26. // elements when used in an inline context, chameleon is
  27. // a complicated workaround to acheive this effect
  28. // Inline context ! Block context (exclamation mark is
  29. // separator, see getChildDef for parsing)
  30. /**
  31. * @type bool
  32. */
  33. public $defines_child_def = true;
  34. /**
  35. * @param HTMLPurifier_ElementDef $def
  36. * @return HTMLPurifier_ChildDef_Chameleon
  37. */
  38. public function getChildDef($def)
  39. {
  40. if ($def->content_model_type != 'chameleon') {
  41. return false;
  42. }
  43. $value = explode('!', $def->content_model);
  44. return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]);
  45. }
  46. }
  47. // vim: et sw=4 sts=4