1: <?php
2:
3: 4: 5:
6: class HTMLPurifier_ChildDef_StrictBlockquote extends HTMLPurifier_ChildDef_Required
7: {
8: protected $real_elements;
9: protected $fake_elements;
10: public $allow_empty = true;
11: public $type = 'strictblockquote';
12: protected $init = false;
13:
14: 15: 16: 17:
18: public function getAllowedElements($config) {
19: $this->init($config);
20: return $this->fake_elements;
21: }
22:
23: public function validateChildren($tokens_of_children, $config, $context) {
24:
25: $this->init($config);
26:
27:
28: $this->elements = $this->fake_elements;
29: $result = parent::validateChildren($tokens_of_children, $config, $context);
30: $this->elements = $this->real_elements;
31:
32: if ($result === false) return array();
33: if ($result === true) $result = $tokens_of_children;
34:
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);
38: $is_inline = false;
39: $depth = 0;
40: $ret = array();
41:
42:
43: foreach ($result as $i => $token) {
44: $token = $result[$i];
45:
46: if (!$is_inline) {
47: if (!$depth) {
48: if (
49: ($token instanceof HTMLPurifier_Token_Text && !$token->is_whitespace) ||
50: (!$token instanceof HTMLPurifier_Token_Text && !isset($this->elements[$token->name]))
51: ) {
52: $is_inline = true;
53: $ret[] = $block_wrap_start;
54: }
55: }
56: } else {
57: if (!$depth) {
58:
59: if ($token instanceof HTMLPurifier_Token_Start || $token instanceof HTMLPurifier_Token_Empty) {
60: if (isset($this->elements[$token->name])) {
61:
62: $ret[] = $block_wrap_end;
63: $is_inline = false;
64: }
65: }
66: }
67: }
68: $ret[] = $token;
69: if ($token instanceof HTMLPurifier_Token_Start) $depth++;
70: if ($token instanceof HTMLPurifier_Token_End) $depth--;
71: }
72: if ($is_inline) $ret[] = $block_wrap_end;
73: return $ret;
74: }
75:
76: private function init($config) {
77: if (!$this->init) {
78: $def = $config->getHTMLDefinition();
79:
80: $this->real_elements = $this->elements;
81: $this->fake_elements = $def->info_content_sets['Flow'];
82: $this->fake_elements['#PCDATA'] = true;
83: $this->init = true;
84: }
85: }
86: }
87:
88:
89: