protected function parse_hierarchy($self_close)
{
if ($this->status['closing_tag']) {
$found = false;
for ($count = count($this->hierarchy), $i = $count - 1; $i >= 0; $i--) {
if (strcasecmp($this->hierarchy[$i]['name'], $this->status['tag_name']) === 0) {
for ($ii = $count - $i - 1; $ii >= 0; $ii--) {
$e = array_pop($this->hierarchy);
if ($ii > 0) {
$this->addError('Closing tag "' . $this->status['tag_name'] . '" while "' . $e['name'] . '" is not closed yet');
}
}
$found = true;
break;
}
}
if (!$found) {
$this->addError('Closing tag "' . $this->status['tag_name'] . '" which is not open');
}
} else {
$tag = array('name' => $this->status['tag_name'], 'attrs' => $this->status['attributes'], 'children' => array());
if ($this->hierarchy) {
$current =& $this->hierarchy[count($this->hierarchy) - 1];
$current['children'][] = $tag;
$tag =& $current['children'][count($current['children']) - 1];
unset($current['tagData']);
} else {
$this->root = $tag;
$tag =& $this->root;
$self_close = false;
}
if (!$self_close) {
$this->hierarchy[] =& $tag;
}
}
}