beginnings of a working manual app

This commit is contained in:
skeeter 2000-12-30 04:07:14 +00:00
parent a5e5dfb7f3
commit 1433ec0b6f

View File

@ -23,18 +23,18 @@
/*********************************************/ /*********************************************/
class menutree { class menutree {
function showtree($treefile, $num_menus = 50, $invisible_menus = Null){ function showtree($treefile, $expandlevels="", $num_menus = 50, $invisible_menus = Null){
global $phpgw_info; global $phpgw_info, $phpgw;
$script = $SCRIPT_NAME; $script = $SCRIPT_NAME;
$img_expand = "images/tree_expand.gif"; $img_expand = "templates/default/images/tree_expand.gif";
$img_collapse = "images/tree_collapse.gif"; $img_collapse = "templates/default/images/tree_collapse.gif";
$img_line = "images/tree_vertline.gif"; $img_line = "templates/default/images/tree_vertline.gif";
$img_split = "images/tree_split.gif"; $img_split = "templates/default/images/tree_split.gif";
$img_end = "images/tree_end.gif"; $img_end = "templates/default/images/tree_end.gif";
$img_leaf = "images/tree_leaf.gif"; $img_leaf = "templates/default/images/tree_leaf.gif";
$img_spc = "images/tree_space.gif"; $img_spc = "templates/default/images/tree_space.gif";
/*********************************************/ /*********************************************/
/* Read text file with tree structure */ /* Read text file with tree structure */
@ -54,8 +54,7 @@ class menutree {
$fd = fopen($treefile, "r"); $fd = fopen($treefile, "r");
if ($fd==0) die("menutree.inc : Unable to open file ".$treefile); 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,"."); $tree[$cnt][0]=strspn($buffer,".");
$tmp=rtrim(substr($buffer,$tree[$cnt][0])); $tmp=rtrim(substr($buffer,$tree[$cnt][0]));
$node=explode("|",$tmp); $node=explode("|",$tmp);
@ -78,11 +77,10 @@ class menutree {
/* Get Node numbers to expand */ /* Get Node numbers to expand */
/*********************************************/ /*********************************************/
if ($p!="") $explevels = explode("|",$p); if ($expandlevels!="") $explevels = explode("|",$expandlevels);
$i=0; $i=0;
while($i<count($explevels)) while($i<count($explevels)) {
{
$expand[$explevels[$i]]=1; $expand[$explevels[$i]]=1;
$i++; $i++;
} }
@ -92,21 +90,16 @@ class menutree {
/*********************************************/ /*********************************************/
$lastlevel=$maxlevel; $lastlevel=$maxlevel;
for ($i=count($tree)-1; $i>=0; $i--) for ($i=count($tree)-1; $i>=0; $i--) {
{ if ( $tree[$i][0] < $lastlevel ) {
if ( $tree[$i][0] < $lastlevel ) for ($j=$tree[$i][0]+1; $j <= $maxlevel; $j++) {
{
for ($j=$tree[$i][0]+1; $j <= $maxlevel; $j++)
{
$levels[$j]=0; $levels[$j]=0;
} }
} }
if ( $levels[$tree[$i][0]]==0 ) if ( $levels[$tree[$i][0]]==0 ) {
{
$levels[$tree[$i][0]]=1; $levels[$tree[$i][0]]=1;
$tree[$i][4]=1; $tree[$i][4]=1;
} } else
else
$tree[$i][4]=0; $tree[$i][4]=0;
$lastlevel=$tree[$i][0]; $lastlevel=$tree[$i][0];
} }
@ -149,14 +142,11 @@ class menutree {
$visible[28]=0; // root is always visible $visible[28]=0; // root is always visible
for ($i=0; $i<count($explevels); $i++) for ($i=0; $i<count($explevels); $i++) {
{
$n=$explevels[$i]; $n=$explevels[$i];
if ( ($visible[$n]==1) && ($expand[$n]==1) ) if ( ($visible[$n]==1) && ($expand[$n]==1) ) {
{
$j=$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; if ($tree[$j][0]==$tree[$n][0]+1) $visible[$j]=1;
$j++; $j++;
} }
@ -164,15 +154,12 @@ class menutree {
} }
for ($i=0; $i<count($explevels); $i++) for ($i=0; $i<count($explevels); $i++) {
{
$n=$explevels[$i]; $n=$explevels[$i];
if ( ($visible[$n]==1) && ($expand[$n]==1) ) if ( ($visible[$n]==1) && ($expand[$n]==1) ) {
{
$j=$n+1; $j=$n+1;
while ( $tree[$j][0] > $tree[$n][0] ) while ( $tree[$j][0] == $tree[$n][0] + 1 ) {
{ $visible[$j]=1;
if ($tree[$j][0]==$tree[$n][0]+1) $visible[$j]=1;
$j++; $j++;
} }
} }
@ -187,99 +174,96 @@ class menutree {
$maxlevel++; $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; $cnt=0;
while ($cnt<count($tree)) while ($cnt<count($tree)) {
{ if ($visible[$cnt]) {
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 */ /* start new row */
/****************************************/ /****************************************/
echo "<tr>"; $str .= "<tr>";
/****************************************/ /****************************************/
/* vertical lines from higher levels */ /* vertical lines from higher levels */
/****************************************/ /****************************************/
$i=0; $i=0;
while ($i<$tree[$cnt][0]-1) while ($i<$tree[$cnt][0]-1) {
{
if ($levels[$i]==1) if ($levels[$i]==1)
echo "<td><img src=\"".$img_line."\"></td>"; $str .= "<td><img src=\"".$img_line."\"></td>";
else else
echo "<td><img src=\"".$img_spc."\"></td>"; $str .= "<td><img src=\"".$img_spc."\"></td>";
$i++; $i++;
} }
/****************************************/ /****************************************/
/* corner at end of subtree or t-split */ /* corner at end of subtree or t-split */
/****************************************/ /****************************************/
if ($tree[$cnt][4]==1) if ($tree[$cnt][4]==1) {
{ $str .= "<td><img src=\"".$img_end."\"></td>";
echo "<td><img src=\"".$img_end."\"></td>";
$levels[$tree[$cnt][0]-1]=0; $levels[$tree[$cnt][0]-1]=0;
} } else {
else $str .= "<td><img src=\"".$img_split."\"></td>";
{
echo "<td><img src=\"".$img_split."\"></td>";
$levels[$tree[$cnt][0]-1]=1; $levels[$tree[$cnt][0]-1]=1;
} }
/********************************************/ /********************************************/
/* Node (with subtree) or Leaf (no subtree) */ /* 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) 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 else
echo "<td><a href=\"".$script.$params."\"><img src=\"".$img_collapse."\" border=no></a></td>"; $str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_collapse."\" border=no></a></td>";
} } else {
else
{
/*************************/ /*************************/
/* Tree Leaf */ /* Tree Leaf */
/*************************/ /*************************/
echo "<td><img src=\"".$img_leaf."\"></td>"; $str .= "<td><img src=\"".$img_leaf."\"></td>";
} }
/****************************************/ /****************************************/
/* output item text */ /* output item text */
/****************************************/ /****************************************/
if ($tree[$cnt][2]=="") 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 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 */ /* end row */
/****************************************/ /****************************************/
echo "</tr>\n"; $str .= "</tr>\n";
} }
$cnt++; $cnt++;
} }
echo "</table>\n"; $str .= "</table>\n";
return $str;
/***************************************************/ /***************************************************/
/* Tree file format */ /* Tree file format */