2006-11-22 18:55:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Definition that allows a set of elements, and allows no children.
|
|
|
|
* @note This is a hack to reuse code from HTMLPurifier_ChildDef_Required,
|
|
|
|
* really, one shouldn't inherit from the other. Only altered behavior
|
|
|
|
* is to overload a returned false with an array. Thus, it will never
|
|
|
|
* return false.
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_ChildDef_Optional extends HTMLPurifier_ChildDef_Required
|
|
|
|
{
|
2007-11-25 02:24:39 +00:00
|
|
|
public $allow_empty = true;
|
|
|
|
public $type = 'optional';
|
2008-01-05 00:10:43 +00:00
|
|
|
public function validateChildren($tokens_of_children, $config, $context) {
|
2006-11-22 18:55:15 +00:00
|
|
|
$result = parent::validateChildren($tokens_of_children, $config, $context);
|
2008-12-03 01:13:47 +00:00
|
|
|
// we assume that $tokens_of_children is not modified
|
2007-10-02 01:19:46 +00:00
|
|
|
if ($result === false) {
|
|
|
|
if (empty($tokens_of_children)) return true;
|
2008-12-03 01:13:47 +00:00
|
|
|
elseif ($this->whitespace) return $tokens_of_children;
|
2007-10-02 01:19:46 +00:00
|
|
|
else return array();
|
|
|
|
}
|
2006-11-22 18:55:15 +00:00
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|