Now the treeview is colapsed by default. Also made a few changes in the opening/closing of the nodes.

This commit is contained in:
skeeter 2001-05-08 17:56:00 +00:00
parent 01563ab16f
commit 09828d79be

View File

@ -30,19 +30,22 @@ var $read_from_file; // You can send the tree info from a string or fil
var $root_level_value; // This is what the top level name or image will be var $root_level_value; // This is what the top level name or image will be
var $last_column_size; var $last_column_size;
function menutree($read_from_file='T') function menutree($read_from_file='text')
{ {
if($read_from_file == 'T') if($read_from_file == 'text')
{ {
settype($read_from_file,'integer'); $this->read_from_file = False;
$read_from_file = 1;
} }
elseif($read_from_file == 'F') elseif($read_from_file == 'file')
{ {
settype($read_from_file,'integer'); $this->read_from_file = True;
$read_from_file = 0;
} }
$this->read_from_file = $read_from_file; $this->set_lcs();
}
function set_lcs($size=300)
{
$this->last_column_size = $size;
} }
function showtree($treefile, $expandlevels='', $num_menus = 50, $invisible_menus = Null) function showtree($treefile, $expandlevels='', $num_menus = 50, $invisible_menus = Null)
@ -83,69 +86,52 @@ var $last_column_size;
{ {
die("menutree.inc : Unable to open file ".$treefile); die("menutree.inc : Unable to open file ".$treefile);
} }
$treefile = array();
while($buffer = fgets($fd, 4096)) while($buffer = fgets($fd, 4096))
{ {
$cnt++; $treefile[] = buffer;
$tree[$cnt][0]=strspn($buffer,'.');
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
$node=explode('|',$tmp);
$tree[$cnt][1]=$node[0];
$tree[$cnt][2]=$node[1];
$tree[$cnt][3]=$node[2];
$tree[$cnt][4]=0;
if(count($node) == 5)
{
$tree[$cnt][5]=$node[4];
}
if($tree[$cnt][0] > $maxlevel)
{
$maxlevel=$tree[$cnt][0];
}
} }
fclose($fd); fclose($fd);
} }
else if(is_array($treefile))
{ {
if(is_array($treefile)) $ta = $treefile;
}
elseif(gettype($treefile) == 'string')
{
$ta = explode("\n",$treefile);
}
while (list($null,$buffer) = each($ta))
{
$cnt++;
$tree[$cnt][0]=strspn($buffer,".");
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
$node=explode('|',$tmp);
$tree[$cnt][1]=chop($node[0]);
$tree[$cnt][2]=chop($node[1]);
$tree[$cnt][3]=chop($node[2]);
$tree[$cnt][4]=0;
if(count($node) == 5)
{ {
$ta = $treefile; $tree[$cnt][5]=$node[4];
} }
elseif(gettype($treefile) == 'string') if($tree[$cnt][0] > $maxlevel)
{ {
$ta = explode("\n",$treefile); $maxlevel=$tree[$cnt][0];
}
while (list($null,$buffer) = each($ta))
{
$cnt++;
$tree[$cnt][0]=strspn($buffer,".");
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
$node=explode('|',$tmp);
$tree[$cnt][1]=chop($node[0]);
$tree[$cnt][2]=chop($node[1]);
$tree[$cnt][3]=chop($node[2]);
$tree[$cnt][4]=0;
if(count($node) == 5)
{
$tree[$cnt][5]=$node[4];
}
if($tree[$cnt][0] > $maxlevel)
{
$maxlevel=$tree[$cnt][0];
}
} }
} }
$c_tree = count($tree); $c_tree = count($tree);
for($i=0; $i<$c_tree; $i++) for($i=0; $i<$c_tree; $i++)
{ {
if($i!=0) // if($i!=0)
{ // {
$expand[$i]=0; $expand[$i]=0;
} // }
else // else
{ // {
$expand[$i]=1; // $expand[$i]=1;
} // }
if($tree[$i][0] <= 2) if($tree[$i][0] == 1)
{ {
$visible[$i]=1; $visible[$i]=1;
} }
@ -179,7 +165,7 @@ var $last_column_size;
/*********************************************/ /*********************************************/
$lastlevel=$maxlevel; $lastlevel=$maxlevel;
for ($i=count($tree)-1; $i>=0; $i -= 1) for ($i=$c_tree - 1; $i>=0; $i -= 1)
{ {
if($tree[$i][0] < $tree[$i+1][0]) if($tree[$i][0] < $tree[$i+1][0])
{ {
@ -273,7 +259,7 @@ var $last_column_size;
/* Create expand/collapse parameters */ /* Create expand/collapse parameters */
/****************************************/ /****************************************/
$params='p='; $params='p=';
for($i=1;$i<=$c_tree;$i++) for($i=0;$i<=$c_tree;$i++)
{ {
if(($expand[$i]==1) && ($cnt!=$i) || ($expand[$i]==0 && $cnt==$i)) if(($expand[$i]==1) && ($cnt!=$i) || ($expand[$i]==0 && $cnt==$i))
{ {