forked from extern/egroupware
beginnings of a working manual app
This commit is contained in:
parent
a5e5dfb7f3
commit
1433ec0b6f
@ -23,18 +23,18 @@
|
||||
/*********************************************/
|
||||
|
||||
class menutree {
|
||||
function showtree($treefile, $num_menus = 50, $invisible_menus = Null){
|
||||
global $phpgw_info;
|
||||
function showtree($treefile, $expandlevels="", $num_menus = 50, $invisible_menus = Null){
|
||||
global $phpgw_info, $phpgw;
|
||||
|
||||
$script = $SCRIPT_NAME;
|
||||
|
||||
$img_expand = "images/tree_expand.gif";
|
||||
$img_collapse = "images/tree_collapse.gif";
|
||||
$img_line = "images/tree_vertline.gif";
|
||||
$img_split = "images/tree_split.gif";
|
||||
$img_end = "images/tree_end.gif";
|
||||
$img_leaf = "images/tree_leaf.gif";
|
||||
$img_spc = "images/tree_space.gif";
|
||||
$img_expand = "templates/default/images/tree_expand.gif";
|
||||
$img_collapse = "templates/default/images/tree_collapse.gif";
|
||||
$img_line = "templates/default/images/tree_vertline.gif";
|
||||
$img_split = "templates/default/images/tree_split.gif";
|
||||
$img_end = "templates/default/images/tree_end.gif";
|
||||
$img_leaf = "templates/default/images/tree_leaf.gif";
|
||||
$img_spc = "templates/default/images/tree_space.gif";
|
||||
|
||||
/*********************************************/
|
||||
/* Read text file with tree structure */
|
||||
@ -54,8 +54,7 @@ class menutree {
|
||||
|
||||
$fd = fopen($treefile, "r");
|
||||
if ($fd==0) die("menutree.inc : Unable to open file ".$treefile);
|
||||
while ($buffer = fgets($fd, 4096))
|
||||
{
|
||||
while ($buffer = fgets($fd, 4096)) {
|
||||
$tree[$cnt][0]=strspn($buffer,".");
|
||||
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
|
||||
$node=explode("|",$tmp);
|
||||
@ -78,11 +77,10 @@ class menutree {
|
||||
/* Get Node numbers to expand */
|
||||
/*********************************************/
|
||||
|
||||
if ($p!="") $explevels = explode("|",$p);
|
||||
if ($expandlevels!="") $explevels = explode("|",$expandlevels);
|
||||
|
||||
$i=0;
|
||||
while($i<count($explevels))
|
||||
{
|
||||
while($i<count($explevels)) {
|
||||
$expand[$explevels[$i]]=1;
|
||||
$i++;
|
||||
}
|
||||
@ -92,21 +90,16 @@ class menutree {
|
||||
/*********************************************/
|
||||
|
||||
$lastlevel=$maxlevel;
|
||||
for ($i=count($tree)-1; $i>=0; $i--)
|
||||
{
|
||||
if ( $tree[$i][0] < $lastlevel )
|
||||
{
|
||||
for ($j=$tree[$i][0]+1; $j <= $maxlevel; $j++)
|
||||
{
|
||||
for ($i=count($tree)-1; $i>=0; $i--) {
|
||||
if ( $tree[$i][0] < $lastlevel ) {
|
||||
for ($j=$tree[$i][0]+1; $j <= $maxlevel; $j++) {
|
||||
$levels[$j]=0;
|
||||
}
|
||||
}
|
||||
if ( $levels[$tree[$i][0]]==0 )
|
||||
{
|
||||
if ( $levels[$tree[$i][0]]==0 ) {
|
||||
$levels[$tree[$i][0]]=1;
|
||||
$tree[$i][4]=1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
$tree[$i][4]=0;
|
||||
$lastlevel=$tree[$i][0];
|
||||
}
|
||||
@ -149,14 +142,11 @@ class menutree {
|
||||
$visible[28]=0; // root is always visible
|
||||
|
||||
|
||||
for ($i=0; $i<count($explevels); $i++)
|
||||
{
|
||||
for ($i=0; $i<count($explevels); $i++) {
|
||||
$n=$explevels[$i];
|
||||
if ( ($visible[$n]==1) && ($expand[$n]==1) )
|
||||
{
|
||||
if ( ($visible[$n]==1) && ($expand[$n]==1) ) {
|
||||
$j=$n+1;
|
||||
while ( $tree[$j][0] > $tree[$n][0] )
|
||||
{
|
||||
while ( $tree[$j][0] > $tree[$n][0] ) {
|
||||
if ($tree[$j][0]==$tree[$n][0]+1) $visible[$j]=1;
|
||||
$j++;
|
||||
}
|
||||
@ -164,15 +154,12 @@ class menutree {
|
||||
}
|
||||
|
||||
|
||||
for ($i=0; $i<count($explevels); $i++)
|
||||
{
|
||||
for ($i=0; $i<count($explevels); $i++) {
|
||||
$n=$explevels[$i];
|
||||
if ( ($visible[$n]==1) && ($expand[$n]==1) )
|
||||
{
|
||||
if ( ($visible[$n]==1) && ($expand[$n]==1) ) {
|
||||
$j=$n+1;
|
||||
while ( $tree[$j][0] > $tree[$n][0] )
|
||||
{
|
||||
if ($tree[$j][0]==$tree[$n][0]+1) $visible[$j]=1;
|
||||
while ( $tree[$j][0] == $tree[$n][0] + 1 ) {
|
||||
$visible[$j]=1;
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
@ -187,99 +174,96 @@ class menutree {
|
||||
|
||||
$maxlevel++;
|
||||
|
||||
echo "<table cellspacing=0 cellpadding=0 border=0 cols=".($maxlevel+3)." width=".($maxlevel*16+100).">\n";
|
||||
echo"<a href=\"index.php\" target=_parent><img src=images/docs.gif border=\"0\"></a>\n";
|
||||
echo "<tr>";
|
||||
for ($i=0; $i<$maxlevel; $i++) echo "<td width=16></td>";
|
||||
echo "<td width=100></td></tr>\n";
|
||||
$cnt=0;
|
||||
while ($cnt<count($tree))
|
||||
{
|
||||
if ($visible[$cnt])
|
||||
{
|
||||
while ($cnt<count($tree)) {
|
||||
if ($visible[$cnt]) {
|
||||
/****************************************/
|
||||
/* Create expand/collapse parameters */
|
||||
/****************************************/
|
||||
$i=1; $params="p=";
|
||||
while($i<count($expand)) {
|
||||
if ( ($expand[$i]==1) && ($cnt!=$i) || ($expand[$i]==0 && $cnt==$i)) {
|
||||
$params=$params.$i;
|
||||
$params=$params."|";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/* Always display the extreme top level */
|
||||
/****************************************/
|
||||
if($cnt==0) {
|
||||
$str = "<table cellspacing=0 cellpadding=0 border=0 cols=".($maxlevel+3)." width=".($maxlevel*16+100).">\n";
|
||||
$str .= "<a href=\"".$phpgw->link("index.php",$params)."\" target=_parent><img src=\"templates/default/images/docs.gif\" border=\"0\"></a>\n";
|
||||
$str .= "<tr>";
|
||||
for ($i=0; $i<$maxlevel; $i++) $str .= "<td width=16></td>";
|
||||
$str .= "<td width=100></td></tr>\n";
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/* start new row */
|
||||
/****************************************/
|
||||
echo "<tr>";
|
||||
$str .= "<tr>";
|
||||
|
||||
/****************************************/
|
||||
/* vertical lines from higher levels */
|
||||
/****************************************/
|
||||
$i=0;
|
||||
while ($i<$tree[$cnt][0]-1)
|
||||
{
|
||||
while ($i<$tree[$cnt][0]-1) {
|
||||
if ($levels[$i]==1)
|
||||
echo "<td><img src=\"".$img_line."\"></td>";
|
||||
$str .= "<td><img src=\"".$img_line."\"></td>";
|
||||
else
|
||||
echo "<td><img src=\"".$img_spc."\"></td>";
|
||||
$str .= "<td><img src=\"".$img_spc."\"></td>";
|
||||
$i++;
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/* corner at end of subtree or t-split */
|
||||
/****************************************/
|
||||
if ($tree[$cnt][4]==1)
|
||||
{
|
||||
echo "<td><img src=\"".$img_end."\"></td>";
|
||||
if ($tree[$cnt][4]==1) {
|
||||
$str .= "<td><img src=\"".$img_end."\"></td>";
|
||||
$levels[$tree[$cnt][0]-1]=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<td><img src=\"".$img_split."\"></td>";
|
||||
} else {
|
||||
$str .= "<td><img src=\"".$img_split."\"></td>";
|
||||
$levels[$tree[$cnt][0]-1]=1;
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
/* Node (with subtree) or Leaf (no subtree) */
|
||||
/********************************************/
|
||||
if ($tree[$cnt+1][0]>$tree[$cnt][0])
|
||||
{
|
||||
if ($tree[$cnt+1][0]>$tree[$cnt][0]) {
|
||||
|
||||
/****************************************/
|
||||
/* Create expand/collapse parameters */
|
||||
/****************************************/
|
||||
$i=0; $params="?p=";
|
||||
while($i<count($expand))
|
||||
{
|
||||
if ( ($expand[$i]==1) && ($cnt!=$i) || ($expand[$i]==0 && $cnt==$i))
|
||||
{
|
||||
$params=$params.$i;
|
||||
$params=$params."|";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($expand[$cnt]==0)
|
||||
echo "<td><a href=\"".$script.$params."\"><img src=\"".$img_expand."\" border=no></a></td>";
|
||||
$str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_expand."\" border=no></a></td>";
|
||||
else
|
||||
echo "<td><a href=\"".$script.$params."\"><img src=\"".$img_collapse."\" border=no></a></td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_collapse."\" border=no></a></td>";
|
||||
} else {
|
||||
/*************************/
|
||||
/* Tree Leaf */
|
||||
/*************************/
|
||||
|
||||
echo "<td><img src=\"".$img_leaf."\"></td>";
|
||||
$str .= "<td><img src=\"".$img_leaf."\"></td>";
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/* output item text */
|
||||
/****************************************/
|
||||
if ($tree[$cnt][2]=="")
|
||||
echo "<td colspan=".($maxlevel-$tree[$cnt][0]).">".$tree[$cnt][1]."<font face\=\"Arial, Helvetica, san-serif\" size=\"2\"></td>";
|
||||
$str .= "<td colspan=".($maxlevel-$tree[$cnt][0]).">".$tree[$cnt][1]."<font face\=\"Arial, Helvetica, san-serif\" size=\"2\"></td>";
|
||||
else
|
||||
echo "<td colspan=".($maxlevel-$tree[$cnt][0])."><font face\=\"Arial, Helvetica, san-serif\" size=\"2\"><a href=\"".$tree[$cnt][2]."\" target=\"".$tree[$cnt][3]."\">".$tree[$cnt][1]."</a></td>";
|
||||
$str .= "<td colspan=".($maxlevel-$tree[$cnt][0])."><font face\=\"Arial, Helvetica, san-serif\" size=\"2\"><a href=\"".$phpgw->link($tree[$cnt][2],$params)."\" target=\"".$tree[$cnt][3]."\">".$tree[$cnt][1]."</a></td>";
|
||||
|
||||
/****************************************/
|
||||
/* end row */
|
||||
/****************************************/
|
||||
|
||||
echo "</tr>\n";
|
||||
$str .= "</tr>\n";
|
||||
}
|
||||
$cnt++;
|
||||
}
|
||||
echo "</table>\n";
|
||||
$str .= "</table>\n";
|
||||
|
||||
return $str;
|
||||
|
||||
/***************************************************/
|
||||
/* Tree file format */
|
||||
|
Loading…
Reference in New Issue
Block a user