4 * Takes the contents of blockquote when in strict and reformats for validation.
6 class HTMLPurifier_ChildDef_StrictBlockquote
extends HTMLPurifier_ChildDef_Required
11 protected $real_elements;
16 protected $fake_elements;
21 public $allow_empty = true;
26 public $type = 'strictblockquote';
31 protected $init = false;
34 * @param HTMLPurifier_Config $config
36 * @note We don't want MakeWellFormed to auto-close inline elements since
37 * they might be allowed.
39 public function getAllowedElements($config)
42 return $this->fake_elements
;
46 * @param array $tokens_of_children
47 * @param HTMLPurifier_Config $config
48 * @param HTMLPurifier_Context $context
51 public function validateChildren($tokens_of_children, $config, $context)
55 // trick the parent class into thinking it allows more
56 $this->elements
= $this->fake_elements
;
57 $result = parent
::validateChildren($tokens_of_children, $config, $context);
58 $this->elements
= $this->real_elements
;
60 if ($result === false) {
63 if ($result === true) {
64 $result = $tokens_of_children;
67 $def = $config->getHTMLDefinition();
68 $block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper
);
69 $block_wrap_end = new HTMLPurifier_Token_End($def->info_block_wrapper
);
74 // assuming that there are no comment tokens
75 foreach ($result as $i => $token) {
77 // ifs are nested for readability
80 if (($token instanceof HTMLPurifier_Token_Text
&& !$token->is_whitespace
) ||
81 (!$token instanceof HTMLPurifier_Token_Text
&& !isset($this->elements
[$token->name
]))) {
83 $ret[] = $block_wrap_start;
88 // starting tokens have been inline text / empty
89 if ($token instanceof HTMLPurifier_Token_Start ||
$token instanceof HTMLPurifier_Token_Empty
) {
90 if (isset($this->elements
[$token->name
])) {
92 $ret[] = $block_wrap_end;
99 if ($token instanceof HTMLPurifier_Token_Start
) {
102 if ($token instanceof HTMLPurifier_Token_End
) {
107 $ret[] = $block_wrap_end;
113 * @param HTMLPurifier_Config $config
115 private function init($config)
118 $def = $config->getHTMLDefinition();
119 // allow all inline elements
120 $this->real_elements
= $this->elements
;
121 $this->fake_elements
= $def->info_content_sets
['Flow'];
122 $this->fake_elements
['#PCDATA'] = true;
128 // vim: et sw=4 sts=4