您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

88 行
3.4KB

  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. /**
  17. * @type string
  18. */
  19. public $name = 'Text';
  20. /**
  21. * @type array
  22. */
  23. public $content_sets = array(
  24. 'Flow' => 'Heading | Block | Inline'
  25. );
  26. /**
  27. * @param HTMLPurifier_Config $config
  28. */
  29. public function setup($config)
  30. {
  31. // Inline Phrasal -------------------------------------------------
  32. $this->addElement('abbr', 'Inline', 'Inline', 'Common');
  33. $this->addElement('acronym', 'Inline', 'Inline', 'Common');
  34. $this->addElement('cite', 'Inline', 'Inline', 'Common');
  35. $this->addElement('dfn', 'Inline', 'Inline', 'Common');
  36. $this->addElement('kbd', 'Inline', 'Inline', 'Common');
  37. $this->addElement('q', 'Inline', 'Inline', 'Common', array('cite' => 'URI'));
  38. $this->addElement('samp', 'Inline', 'Inline', 'Common');
  39. $this->addElement('var', 'Inline', 'Inline', 'Common');
  40. $em = $this->addElement('em', 'Inline', 'Inline', 'Common');
  41. $em->formatting = true;
  42. $strong = $this->addElement('strong', 'Inline', 'Inline', 'Common');
  43. $strong->formatting = true;
  44. $code = $this->addElement('code', 'Inline', 'Inline', 'Common');
  45. $code->formatting = true;
  46. // Inline Structural ----------------------------------------------
  47. $this->addElement('span', 'Inline', 'Inline', 'Common');
  48. $this->addElement('br', 'Inline', 'Empty', 'Core');
  49. // Block Phrasal --------------------------------------------------
  50. $this->addElement('address', 'Block', 'Inline', 'Common');
  51. $this->addElement('blockquote', 'Block', 'Optional: Heading | Block | List', 'Common', array('cite' => 'URI'));
  52. $pre = $this->addElement('pre', 'Block', 'Inline', 'Common');
  53. $pre->excludes = $this->makeLookup(
  54. 'img',
  55. 'big',
  56. 'small',
  57. 'object',
  58. 'applet',
  59. 'font',
  60. 'basefont'
  61. );
  62. $this->addElement('h1', 'Heading', 'Inline', 'Common');
  63. $this->addElement('h2', 'Heading', 'Inline', 'Common');
  64. $this->addElement('h3', 'Heading', 'Inline', 'Common');
  65. $this->addElement('h4', 'Heading', 'Inline', 'Common');
  66. $this->addElement('h5', 'Heading', 'Inline', 'Common');
  67. $this->addElement('h6', 'Heading', 'Inline', 'Common');
  68. // Block Structural -----------------------------------------------
  69. $p = $this->addElement('p', 'Block', 'Inline', 'Common');
  70. $p->autoclose = array_flip(
  71. array("address", "blockquote", "center", "dir", "div", "dl", "fieldset", "ol", "p", "ul")
  72. );
  73. $this->addElement('div', 'Block', 'Flow', 'Common');
  74. }
  75. }
  76. // vim: et sw=4 sts=4