10 public $elements = array(
'tr' =>
true,
'tbody' =>
true,
'thead' =>
true,
11 'tfoot' =>
true,
'caption' =>
true,
'colgroup' =>
true,
'col' =>
true);
14 if (empty($tokens_of_children))
return false;
19 $tokens_of_children[] =
false;
31 $is_collecting =
false;
33 $collection = array();
37 foreach ($tokens_of_children as $token) {
38 $is_child = ($nesting == 0);
40 if ($token ===
false) {
53 switch ($collection[$tag_index]->name) {
56 $content[] = $collection;
59 if ($caption !==
false)
break;
60 $caption = $collection;
65 $var = $collection[$tag_index]->name;
66 if ($$var ===
false) {
71 $collection[$tag_index]->name =
'tbody';
72 $collection[count($collection)-1]->name =
'tbody';
73 $content[] = $collection;
77 $cols[] = $collection;
80 $collection = array();
81 $is_collecting =
false;
85 $collection[] = $token;
90 if ($token ===
false)
break;
94 if ($token->name ==
'col') {
97 $cols[] = array_merge($collection, array($token));
98 $collection = array();
102 switch($token->name) {
109 $is_collecting =
true;
110 $collection[] = $token;
113 if (!empty($token->is_whitespace)) {
114 $collection[] = $token;
122 if (empty($content))
return false;
125 if ($caption !==
false)
$ret = array_merge(
$ret, $caption);
126 if ($cols !==
false)
foreach ($cols as $token_array)
$ret = array_merge(
$ret, $token_array);
127 if ($thead !==
false)
$ret = array_merge(
$ret, $thead);
128 if ($tfoot !==
false)
$ret = array_merge(
$ret, $tfoot);
129 foreach ($content as $token_array)
$ret = array_merge(
$ret, $token_array);
130 if (!empty($collection) && $is_collecting ==
false){
132 $ret = array_merge(
$ret, $collection);
135 array_pop($tokens_of_children);
137 return (
$ret === $tokens_of_children) ?
true :
$ret;