cvs: pear /XML_Tree/Tree Node.php

From: Date: Fri, 17 May 2002 12:17:18 +0000
Subject: cvs: pear /XML_Tree/Tree Node.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-3891@lists.php.net to get a copy of this message
cox Fri May 17 08:17:18 2002 EDT Modified files: /pear/XML_Tree/Tree Node.php Log: Quick fix the $node->get() method to handle properly the new "emulated" text nodes. Also removed some Call-pass-time warnings. Index: pear/XML_Tree/Tree/Node.php diff -u pear/XML_Tree/Tree/Node.php:1.7 pear/XML_Tree/Tree/Node.php:1.8 --- pear/XML_Tree/Tree/Node.php:1.7 Thu May 16 10:43:27 2002 +++ pear/XML_Tree/Tree/Node.php Fri May 17 08:17:18 2002 @@ -18,7 +18,7 @@ // | Christian Kühn <ck@chkuehn.de> (escape xml entities) | // +----------------------------------------------------------------------+ // -// $Id: Node.php,v 1.7 2002/05/16 14:43:27 cox Exp $ +// $Id: Node.php,v 1.8 2002/05/17 12:17:18 cox Exp $ // /** @@ -155,7 +155,7 @@ * @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); } /** @@ -185,27 +185,39 @@ 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; } @@ -294,7 +306,7 @@ function set_content(&$content) { - return $this->setContent(&$content); + return $this->setContent($content); } /**

« previous php.pear.cvs (#3891) next »