List.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * XHTML 1.1 List Module, defines list-oriented elements. Core Module.
  4. */
  5. class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule
  6. {
  7. /**
  8. * @type string
  9. */
  10. public $name = 'List';
  11. // According to the abstract schema, the List content set is a fully formed
  12. // one or more expr, but it invariably occurs in an optional declaration
  13. // so we're not going to do that subtlety. It might cause trouble
  14. // if a user defines "List" and expects that multiple lists are
  15. // allowed to be specified, but then again, that's not very intuitive.
  16. // Furthermore, the actual XML Schema may disagree. Regardless,
  17. // we don't have support for such nested expressions without using
  18. // the incredibly inefficient and draconic Custom ChildDef.
  19. /**
  20. * @type array
  21. */
  22. public $content_sets = array('Flow' => 'List');
  23. /**
  24. * @param HTMLPurifier_Config $config
  25. */
  26. public function setup($config)
  27. {
  28. $ol = $this->addElement('ol', 'List', new HTMLPurifier_ChildDef_List(), 'Common');
  29. $ul = $this->addElement('ul', 'List', new HTMLPurifier_ChildDef_List(), 'Common');
  30. // XXX The wrap attribute is handled by MakeWellFormed. This is all
  31. // quite unsatisfactory, because we generated this
  32. // *specifically* for lists, and now a big chunk of the handling
  33. // is done properly by the List ChildDef. So actually, we just
  34. // want enough information to make autoclosing work properly,
  35. // and then hand off the tricky stuff to the ChildDef.
  36. $ol->wrap = 'li';
  37. $ul->wrap = 'li';
  38. $this->addElement('dl', 'List', 'Required: dt | dd', 'Common');
  39. $this->addElement('li', false, 'Flow', 'Common');
  40. $this->addElement('dd', false, 'Flow', 'Common');
  41. $this->addElement('dt', false, 'Inline', 'Common');
  42. }
  43. }
  44. // vim: et sw=4 sts=4