PageRenderTime 58ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/vjCommentPlugin/lib/tools/htmlpurifier/library/HTMLPurifier/ChildDef/Optional.php

https://bitbucket.org/Kudlaty/360kdw
PHP | 26 lines | 15 code | 2 blank | 9 comment | 3 complexity | 6b324d68260f872dc1a9312608af70bf MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * Definition that allows a set of elements, and allows no children.
  4. * @note This is a hack to reuse code from HTMLPurifier_ChildDef_Required,
  5. * really, one shouldn't inherit from the other. Only altered behavior
  6. * is to overload a returned false with an array. Thus, it will never
  7. * return false.
  8. */
  9. class HTMLPurifier_ChildDef_Optional extends HTMLPurifier_ChildDef_Required
  10. {
  11. public $allow_empty = true;
  12. public $type = 'optional';
  13. public function validateChildren($tokens_of_children, $config, $context) {
  14. $result = parent::validateChildren($tokens_of_children, $config, $context);
  15. // we assume that $tokens_of_children is not modified
  16. if ($result === false) {
  17. if (empty($tokens_of_children)) return true;
  18. elseif ($this->whitespace) return $tokens_of_children;
  19. else return array();
  20. }
  21. return $result;
  22. }
  23. }
  24. // vim: et sw=4 sts=4