3 require_once 'HTMLPurifier/ChildDef/Required.php';
6 * Takes the contents of blockquote when in strict and reformats for validation.
8 class HTMLPurifier_ChildDef_StrictBlockquote
9 extends HTMLPurifier_ChildDef_Required
13 var $allow_empty = true;
14 var $type = 'strictblockquote';
16 function validateChildren($tokens_of_children, $config, &$context) {
18 $def = $config->getHTMLDefinition();
20 // allow all inline elements
21 $this->real_elements
= $this->elements
;
22 $this->fake_elements
= $def->info_content_sets
['Flow'];
23 $this->fake_elements
['#PCDATA'] = true;
27 // trick the parent class into thinking it allows more
28 $this->elements
= $this->fake_elements
;
29 $result = parent
::validateChildren($tokens_of_children, $config, $context);
30 $this->elements
= $this->real_elements
;
32 if ($result === false) return array();
33 if ($result === true) $result = $tokens_of_children;
35 $block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper
);
36 $block_wrap_end = new HTMLPurifier_Token_End( $def->info_block_wrapper
);
41 // assuming that there are no comment tokens
42 foreach ($result as $i => $token) {
44 // ifs are nested for readability
48 $token->type
== 'text' ||
49 !isset($this->elements
[$token->name
])
52 $ret[] = $block_wrap_start;
57 // starting tokens have been inline text / empty
58 if ($token->type
== 'start' ||
$token->type
== 'empty') {
59 if (isset($this->elements
[$token->name
])) {
61 $ret[] = $block_wrap_end;
68 if ($token->type
== 'start') $depth++
;
69 if ($token->type
== 'end') $depth--;
71 if ($is_inline) $ret[] = $block_wrap_end;