4 * Takes the contents of blockquote when in strict and reformats for validation.
6 class HTMLPurifier_ChildDef_StrictBlockquote
extends HTMLPurifier_ChildDef_Required
8 protected $real_elements;
9 protected $fake_elements;
10 public $allow_empty = true;
11 public $type = 'strictblockquote';
12 protected $init = false;
15 * @note We don't want MakeWellFormed to auto-close inline elements since
16 * they might be allowed.
18 public function getAllowedElements($config) {
20 return $this->fake_elements
;
23 public function validateChildren($tokens_of_children, $config, $context) {
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 $def = $config->getHTMLDefinition();
36 $block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper
);
37 $block_wrap_end = new HTMLPurifier_Token_End( $def->info_block_wrapper
);
42 // assuming that there are no comment tokens
43 foreach ($result as $i => $token) {
45 // ifs are nested for readability
49 ($token instanceof HTMLPurifier_Token_Text
&& !$token->is_whitespace
) ||
50 (!$token instanceof HTMLPurifier_Token_Text
&& !isset($this->elements
[$token->name
]))
53 $ret[] = $block_wrap_start;
58 // starting tokens have been inline text / empty
59 if ($token instanceof HTMLPurifier_Token_Start ||
$token instanceof HTMLPurifier_Token_Empty
) {
60 if (isset($this->elements
[$token->name
])) {
62 $ret[] = $block_wrap_end;
69 if ($token instanceof HTMLPurifier_Token_Start
) $depth++
;
70 if ($token instanceof HTMLPurifier_Token_End
) $depth--;
72 if ($is_inline) $ret[] = $block_wrap_end;
76 private function init($config) {
78 $def = $config->getHTMLDefinition();
79 // allow all inline elements
80 $this->real_elements
= $this->elements
;
81 $this->fake_elements
= $def->info_content_sets
['Flow'];
82 $this->fake_elements
['#PCDATA'] = true;