Text.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * XHTML 1.1 Text Module, defines basic text containers. Core Module.
  4. * @note In the normative XML Schema specification, this module
  5. * is further abstracted into the following modules:
  6. * - Block Phrasal (address, blockquote, pre, h1, h2, h3, h4, h5, h6)
  7. * - Block Structural (div, p)
  8. * - Inline Phrasal (abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var)
  9. * - Inline Structural (br, span)
  10. * This module, functionally, does not distinguish between these
  11. * sub-modules, but the code is internally structured to reflect
  12. * these distinctions.
  13. */
  14. class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule
  15. {
  16. public $name = 'Text';
  17. public $content_sets = array(
  18. 'Flow' => 'Heading | Block | Inline'
  19. );
  20. public function setup($config) {
  21. // Inline Phrasal -------------------------------------------------
  22. $this->addElement('abbr', 'Inline', 'Inline', 'Common');
  23. $this->addElement('acronym', 'Inline', 'Inline', 'Common');
  24. $this->addElement('cite', 'Inline', 'Inline', 'Common');
  25. $this->addElement('dfn', 'Inline', 'Inline', 'Common');
  26. $this->addElement('kbd', 'Inline', 'Inline', 'Common');
  27. $this->addElement('q', 'Inline', 'Inline', 'Common', array('cite' => 'URI'));
  28. $this->addElement('samp', 'Inline', 'Inline', 'Common');
  29. $this->addElement('var', 'Inline', 'Inline', 'Common');
  30. $em = $this->addElement('em', 'Inline', 'Inline', 'Common');
  31. $em->formatting = true;
  32. $strong = $this->addElement('strong', 'Inline', 'Inline', 'Common');
  33. $strong->formatting = true;
  34. $code = $this->addElement('code', 'Inline', 'Inline', 'Common');
  35. $code->formatting = true;
  36. // Inline Structural ----------------------------------------------
  37. $this->addElement('span', 'Inline', 'Inline', 'Common');
  38. $this->addElement('br', 'Inline', 'Empty', 'Core');
  39. // Block Phrasal --------------------------------------------------
  40. $this->addElement('address', 'Block', 'Inline', 'Common');
  41. $this->addElement('blockquote', 'Block', 'Optional: Heading | Block | List', 'Common', array('cite' => 'URI') );
  42. $pre = $this->addElement('pre', 'Block', 'Inline', 'Common');
  43. $pre->excludes = $this->makeLookup(
  44. 'img', 'big', 'small', 'object', 'applet', 'font', 'basefont' );
  45. $this->addElement('h1', 'Heading', 'Inline', 'Common');
  46. $this->addElement('h2', 'Heading', 'Inline', 'Common');
  47. $this->addElement('h3', 'Heading', 'Inline', 'Common');
  48. $this->addElement('h4', 'Heading', 'Inline', 'Common');
  49. $this->addElement('h5', 'Heading', 'Inline', 'Common');
  50. $this->addElement('h6', 'Heading', 'Inline', 'Common');
  51. // Block Structural -----------------------------------------------
  52. $p = $this->addElement('p', 'Block', 'Inline', 'Common');
  53. $p->autoclose = array_flip(array("address", "blockquote", "center", "dir", "div", "dl", "fieldset", "ol", "p", "ul"));
  54. $this->addElement('div', 'Block', 'Flow', 'Common');
  55. }
  56. }
  57. // vim: et sw=4 sts=4