AtomParser::end_element()
最后更新于:2021-11-25 19:07:30
AtomParser::end_element($parser, $name)源文件
文件: gc-includes/atomlib.php
function end_element($parser, $name) {
$name_parts = explode(":", $name);
$tag = array_pop($name_parts);
$ccount = count($this->in_content);
# if we are *in* content, then let's proceed to serialize it
if(!empty($this->in_content)) {
# if we are ending the original content element
# then let's finalize the content
if($this->in_content[0][0] == $tag &&
$this->in_content[0][1] == $this->depth) {
$origtype = $this->in_content[0][2];
array_shift($this->in_content);
$newcontent = array();
foreach($this->in_content as $c) {
if(count($c) == 3) {
array_push($newcontent, $c[2]);
} else {
if($this->is_xhtml || $this->is_text) {
array_push($newcontent, $this->xml_escape($c));
} else {
array_push($newcontent, $c);
}
}
}
if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) {
$this->current->$tag = array($origtype, join('',$newcontent));
} else {
$this->current->$tag = join('',$newcontent);
}
$this->in_content = array();
} else if($this->in_content[$ccount-1][0] == $tag &&
$this->in_content[$ccount-1][1] == $this->depth) {
$this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>";
} else {
# else, just finalize the current element's content
$endtag = $this->ns_to_prefix($name);
array_push($this->in_content, array($tag, $this->depth, "</$endtag[1]>"));
}
}
array_shift($this->ns_contexts);
$this->depth--;
if($name == ($this->NS . ':entry')) {
array_push($this->feed->entries, $this->current);
$this->current = null;
}
$this->_p("end_element('$name')");
}