Skip to content

Commit

Permalink
Quick fix the $node->get() method to handle properly the new
Browse files Browse the repository at this point in the history
"emulated" text nodes. Also removed some Call-pass-time warnings.


git-svn-id: http://svn.php.net/repository/pear/packages/XML_Tree/trunk@82543 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
tvvcox committed May 17, 2002
1 parent dc724c7 commit 3502b18
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions Tree/Node.php
Expand Up @@ -155,7 +155,7 @@ function &insertChild($path,$pos,&$child, $content = '', $attributes = array())
* @deprecated
*/
function &insert_child($path,$pos,&$child, $content = '', $attributes = array()) {
return $this->insertChild($path,$pos,&$child, $content, $attributes);
return $this->insertChild($path,$pos,$child, $content, $attributes);
}

/**
Expand Down Expand Up @@ -185,27 +185,39 @@ function &remove_child($pos) {
function &get()
{
static $deep = -1;
static $do_ident = true;
$deep++;
$ident = str_repeat(' ', $deep);
$out = $ident . '<' . $this->name;

foreach ($this->attributes as $name => $value) {
$out .= ' ' . $name . '="' . $value . '"';
}

$out .= '>' . $this->content;
if ($this->name !== null) {
$ident = str_repeat(' ', $deep);
if ($do_ident) {
$out = $ident . '<' . $this->name;
} else {
$out = '<' . $this->name;
}
foreach ($this->attributes as $name => $value) {
$out .= ' ' . $name . '="' . $value . '"';
}

if (sizeof($this->children) > 0) {
$out .= "\n";
$out .= '>' . $this->content;

foreach ($this->children as $child) {
$out .= $child->get();
if (sizeof($this->children) > 0) {
$out .= "\n";
foreach ($this->children as $child) {
$out .= $child->get();
}
} else {
$ident = '';
}
if ($do_ident) {
$out .= $ident . '</' . $this->name . ">\n";
} else {
$out .= '</' . $this->name . '>';
}
$do_ident = true;
} else {
$ident = '';
$out = $this->content;
$do_ident = false;
}

$out .= $ident . '</' . $this->name . ">\n";
$deep--;
return $out;
}
Expand Down Expand Up @@ -294,7 +306,7 @@ function setContent(&$content)

function set_content(&$content)
{
return $this->setContent(&$content);
return $this->setContent($content);
}

/**
Expand Down

0 comments on commit 3502b18

Please sign in to comment.