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 $children
47 * @param HTMLPurifier_Config $config
48 * @param HTMLPurifier_Context $context
51 public function validateChildren($children, $config, $context)
55 // trick the parent class into thinking it allows more
56 $this->elements = $this->fake_elements;
57 $result = parent::validateChildren($children, $config, $context);
58 $this->elements = $this->real_elements;
60 if ($result === false) {
63 if ($result === true) {
67 $def = $config->getHTMLDefinition();
68 $block_wrap_name = $def->info_block_wrapper;
72 foreach ($result as $node) {
73 if ($block_wrap === false) {
74 if (($node instanceof HTMLPurifier_Node_Text && !$node->is_whitespace) ||
75 ($node instanceof HTMLPurifier_Node_Element && !isset($this->elements[$node->name]))) {
76 $block_wrap = new HTMLPurifier_Node_Element($def->info_block_wrapper);
80 if ($node instanceof HTMLPurifier_Node_Element && isset($this->elements[$node->name])) {
86 $block_wrap->children[] = $node;
95 * @param HTMLPurifier_Config $config
97 private function init($config)
100 $def = $config->getHTMLDefinition();
101 // allow all inline elements
102 $this->real_elements = $this->elements;
103 $this->fake_elements = $def->info_content_sets['Flow'];
104 $this->fake_elements['#PCDATA'] = true;
110 // vim: et sw=4 sts=4