|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
-
-
- class HTMLPurifier_ChildDef_StrictBlockquote extends HTMLPurifier_ChildDef_Required
- {
-
-
- protected $real_elements;
-
-
-
- protected $fake_elements;
-
-
-
- public $allow_empty = true;
-
-
-
- public $type = 'strictblockquote';
-
-
-
- protected $init = false;
-
-
-
- public function getAllowedElements($config)
- {
- $this->init($config);
- return $this->fake_elements;
- }
-
-
-
- public function validateChildren($children, $config, $context)
- {
- $this->init($config);
-
-
- $this->elements = $this->fake_elements;
- $result = parent::validateChildren($children, $config, $context);
- $this->elements = $this->real_elements;
-
- if ($result === false) {
- return array();
- }
- if ($result === true) {
- $result = $children;
- }
-
- $def = $config->getHTMLDefinition();
- $block_wrap_name = $def->info_block_wrapper;
- $block_wrap = false;
- $ret = array();
-
- foreach ($result as $node) {
- if ($block_wrap === false) {
- if (($node instanceof HTMLPurifier_Node_Text && !$node->is_whitespace) ||
- ($node instanceof HTMLPurifier_Node_Element && !isset($this->elements[$node->name]))) {
- $block_wrap = new HTMLPurifier_Node_Element($def->info_block_wrapper);
- $ret[] = $block_wrap;
- }
- } else {
- if ($node instanceof HTMLPurifier_Node_Element && isset($this->elements[$node->name])) {
- $block_wrap = false;
-
- }
- }
- if ($block_wrap) {
- $block_wrap->children[] = $node;
- } else {
- $ret[] = $node;
- }
- }
- return $ret;
- }
-
-
-
- private function init($config)
- {
- if (!$this->init) {
- $def = $config->getHTMLDefinition();
-
- $this->real_elements = $this->elements;
- $this->fake_elements = $def->info_content_sets['Flow'];
- $this->fake_elements['#PCDATA'] = true;
- $this->init = true;
- }
- }
- }
-
-
|