00001 <?php
00002
00006 class HTMLPurifier_ChildDef_StrictBlockquote extends HTMLPurifier_ChildDef_Required
00007 {
00008 protected $real_elements;
00009 protected $fake_elements;
00010 public $allow_empty = true;
00011 public $type = 'strictblockquote';
00012 protected $init = false;
00013 public function validateChildren($tokens_of_children, $config, $context) {
00014
00015 $def = $config->getHTMLDefinition();
00016 if (!$this->init) {
00017
00018 $this->real_elements = $this->elements;
00019 $this->fake_elements = $def->info_content_sets['Flow'];
00020 $this->fake_elements['#PCDATA'] = true;
00021 $this->init = true;
00022 }
00023
00024
00025 $this->elements = $this->fake_elements;
00026 $result = parent::validateChildren($tokens_of_children, $config, $context);
00027 $this->elements = $this->real_elements;
00028
00029 if ($result === false) return array();
00030 if ($result === true) $result = $tokens_of_children;
00031
00032 $block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper);
00033 $block_wrap_end = new HTMLPurifier_Token_End( $def->info_block_wrapper);
00034 $is_inline = false;
00035 $depth = 0;
00036 $ret = array();
00037
00038
00039 foreach ($result as $i => $token) {
00040 $token = $result[$i];
00041
00042 if (!$is_inline) {
00043 if (!$depth) {
00044 if (
00045 ($token instanceof HTMLPurifier_Token_Text && !$token->is_whitespace) ||
00046 (!$token instanceof HTMLPurifier_Token_Text && !isset($this->elements[$token->name]))
00047 ) {
00048 $is_inline = true;
00049 $ret[] = $block_wrap_start;
00050 }
00051 }
00052 } else {
00053 if (!$depth) {
00054
00055 if ($token instanceof HTMLPurifier_Token_Start || $token instanceof HTMLPurifier_Token_Empty) {
00056 if (isset($this->elements[$token->name])) {
00057
00058 $ret[] = $block_wrap_end;
00059 $is_inline = false;
00060 }
00061 }
00062 }
00063 }
00064 $ret[] = $token;
00065 if ($token instanceof HTMLPurifier_Token_Start) $depth++;
00066 if ($token instanceof HTMLPurifier_Token_End) $depth--;
00067 }
00068 if ($is_inline) $ret[] = $block_wrap_end;
00069 return $ret;
00070 }
00071 }
00072