]>
Commit | Line | Data |
---|---|---|
d4949327 NL |
1 | <?php\r |
2 | \r | |
3 | /**\r | |
4 | * Definition that allows a set of elements, and allows no children.\r | |
5 | * @note This is a hack to reuse code from HTMLPurifier_ChildDef_Required,\r | |
6 | * really, one shouldn't inherit from the other. Only altered behavior\r | |
7 | * is to overload a returned false with an array. Thus, it will never\r | |
8 | * return false.\r | |
9 | */\r | |
10 | class HTMLPurifier_ChildDef_Optional extends HTMLPurifier_ChildDef_Required\r | |
11 | {\r | |
12 | /**\r | |
13 | * @type bool\r | |
14 | */\r | |
15 | public $allow_empty = true;\r | |
16 | \r | |
17 | /**\r | |
18 | * @type string\r | |
19 | */\r | |
20 | public $type = 'optional';\r | |
21 | \r | |
22 | /**\r | |
23 | * @param array $children\r | |
24 | * @param HTMLPurifier_Config $config\r | |
25 | * @param HTMLPurifier_Context $context\r | |
26 | * @return array\r | |
27 | */\r | |
28 | public function validateChildren($children, $config, $context)\r | |
29 | {\r | |
30 | $result = parent::validateChildren($children, $config, $context);\r | |
31 | // we assume that $children is not modified\r | |
32 | if ($result === false) {\r | |
33 | if (empty($children)) {\r | |
34 | return true;\r | |
35 | } elseif ($this->whitespace) {\r | |
36 | return $children;\r | |
37 | } else {\r | |
38 | return array();\r | |
39 | }\r | |
40 | }\r | |
41 | return $result;\r | |
42 | }\r | |
43 | }\r | |
44 | \r | |
45 | // vim: et sw=4 sts=4\r |