ChildDef.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Defines allowed child nodes and validates tokens against it.
  4. */
  5. abstract class HTMLPurifier_ChildDef
  6. {
  7. /**
  8. * Type of child definition, usually right-most part of class name lowercase.
  9. * Used occasionally in terms of context.
  10. */
  11. public $type;
  12. /**
  13. * Bool that indicates whether or not an empty array of children is okay
  14. *
  15. * This is necessary for redundant checking when changes affecting
  16. * a child node may cause a parent node to now be disallowed.
  17. */
  18. public $allow_empty;
  19. /**
  20. * Lookup array of all elements that this definition could possibly allow
  21. */
  22. public $elements = array();
  23. /**
  24. * Get lookup of tag names that should not close this element automatically.
  25. * All other elements will do so.
  26. */
  27. public function getAllowedElements($config) {
  28. return $this->elements;
  29. }
  30. /**
  31. * Validates nodes according to definition and returns modification.
  32. *
  33. * @param $tokens_of_children Array of HTMLPurifier_Token
  34. * @param $config HTMLPurifier_Config object
  35. * @param $context HTMLPurifier_Context object
  36. * @return bool true to leave nodes as is
  37. * @return bool false to remove parent node
  38. * @return array of replacement child tokens
  39. */
  40. abstract public function validateChildren($tokens_of_children, $config, $context);
  41. }
  42. // vim: et sw=4 sts=4