[Phplib-commit] CVS: php-lib-stable/php tree.inc,1.1.1.1,1.2
Brought to you by:
nhruby,
richardarcher
From: Richard A. <ric...@us...> - 2001-08-16 05:39:10
|
Update of /cvsroot/phplib/php-lib-stable/php In directory usw-pr-cvs1:/tmp/cvs-serv4461 Modified Files: tree.inc Log Message: A few enhancements to tree.inc: resolve bug ID #450713 - check that the $k var contains something Add minimal session-awareness to make the example in the docs work fix a few undefined variable warnings fix typos, whitespace, escaping '\' chars It works fine for me in PHP3 and PHP4, but may still have a few issues. Index: tree.inc =================================================================== RCS file: /cvsroot/phplib/php-lib-stable/php/tree.inc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** tree.inc 2000/04/17 16:40:14 1.1.1.1 --- tree.inc 2001/08/16 05:39:07 1.2 *************** *** 42,50 **** var $prfx=array(); var $sufx=array(); ! var $outp; var $flags; function build_tree () { ! ## Dis function must be overriden by user! ## Result should fill $this->tree ## Perhaps it is easier to use this function in a recursive manner --- 42,50 ---- var $prfx=array(); var $sufx=array(); ! var $outp=""; var $flags; function build_tree () { ! ## This function must be overridden by user! ## Result should fill $this->tree ## Perhaps it is easier to use this function in a recursive manner *************** *** 74,78 **** eval($evalnext); ## First element $i=1; ! while ($k || "0"==$k) { $eval2= $eval . "[\"". ereg_Replace("\"","\\\"",$k) ."\"]"; eval("\$t=gettype($eval2); \$v=$eval2;"); --- 74,78 ---- eval($evalnext); ## First element $i=1; ! while (strlen($k)) { $eval2= $eval . "[\"". ereg_Replace("\"","\\\"",$k) ."\"]"; eval("\$t=gettype($eval2); \$v=$eval2;"); *************** *** 122,125 **** --- 122,127 ---- $index=implode("\"][\"",explode($this->delimiter,$path)); $index = "[\"${index}\"]"; + } else { + $index=""; } return($index); *************** *** 149,153 **** ## Same as path_to_index and path_to_child but only ## working on path ! ## function path_add ($path,$key) { --- 151,155 ---- ## Same as path_to_index and path_to_child but only ## working on path ! ## function path_add ($path,$key) { *************** *** 183,186 **** --- 185,193 ---- # I have made a little example, of how to make a simple # explorer like output + # + # These functions attempt to be session-aware. They + # look for a global variable called $sess and if it + # is set they generate relative URLs containing the + # session ID. function starttree () { *************** *** 192,195 **** --- 199,203 ---- function growtree ($key,$value,$path,$depth,$count,$pcount) { + global $sess; #DEB echo ">>> GROWTREE<BR>"; $this->outp.= "<TT>" . join($this->prfx,""); *************** *** 197,207 **** $this->outp.="^----"; } elseif ($count==$pcount) { ! $this->outp.=" \---"; } else { $this->outp.="O----"; } ! $this->outp.= sprintf("</TT> %s->'<A HREF=\"?val=%s\">%s</A>'". " : '%s' (%s) [%s/%s]<BR>\n", ! $key,URLEncode($value),$value,$path,$depth,$pcount,$count); if ($count > $pcount) { $this->prfx[$depth]="|    "; --- 205,222 ---- $this->outp.="^----"; } elseif ($count==$pcount) { ! $this->outp.=" \\---"; } else { $this->outp.="O----"; } ! if (isset($sess)) { ! $query_string = $sess->url($GLOBALS["PHP_SELF"]); ! $query_string .= $sess->mode == "get" ? "&" : "?"; ! $query_string .= "val=" . urlencode($value); ! } else { ! $query_string = $GLOBALS["PHP_SELF"] . "?val=" . urlencode($value); ! } ! $this->outp.= sprintf("</TT> %s->'<A HREF=\"%s\">%s</A>'". " : '%s' (%s) [%s/%s]<BR>\n", ! $key,$query_string,$value,$path,$depth,$pcount,$count); if ($count > $pcount) { $this->prfx[$depth]="|    "; *************** *** 213,216 **** --- 228,232 ---- function leaftree ($key,$value,$path,$depth,$count,$pcount) { + global $sess; #DEB echo "--- LEAFTREE<BR>"; $this->outp.= "<TT>" . join($this->prfx,""); *************** *** 218,228 **** $this->outp.="*----"; } elseif ($count==$pcount) { ! $this->outp.=" \---"; } else { $this->outp.="+----"; } ! $this->outp.= sprintf("</TT> %s->'<A HREF=\"?val=%s\">%s</A>'". " : '%s' (%s) [%s/%s]<BR>\n", ! $key,URLEncode($value),$value,$path,$depth,$pcount,$count); $this->flag=false; } --- 234,251 ---- $this->outp.="*----"; } elseif ($count==$pcount) { ! $this->outp.=" \\---"; } else { $this->outp.="+----"; } ! if (isset($sess)) { ! $query_string = $sess->url($GLOBALS["PHP_SELF"]); ! $query_string .= $sess->mode == "get" ? "&" : "?"; ! $query_string .= "val=" . urlencode($value); ! } else { ! $query_string = $GLOBALS["PHP_SELF"] . "?val=" . urlencode($value); ! } ! $this->outp.= sprintf("</TT> %s->'<A HREF=\"%s\">%s</A>'". " : '%s' (%s) [%s/%s]<BR>\n", ! $key,$query_string,$value,$path,$depth,$pcount,$count); $this->flag=false; } |