Location: PHPKode > scripts > alarisMenu > alarismenu/alarisAdmin/menu.php
<?
/* 
 * Menu display and editing - utilizes the menu class and submenu class - returns objects.
 */

?>

<table width="590" cellpadding="0" cellspacing="1"  border="0">
   <tr>
        <td width="10" class="titlebar">&nbsp;</td> 
  	<td width="30" class="titlebar"><div align="center"><b>Id<b></div></td>
    	<td width="160" class="titlebar">&nbsp;<b>Title</b></td>
        <td width="310" class="titlebar">&nbsp;<b>URL</b></td>
        <td width="40" class="titlebar"><div align="center"><b>Edit</b></div></td>
        <td width="40" class="titlebar"><div align="center"><b>Delete</b></div></td>
   </tr>
</table>
<?
/*
 * Main table with display of database content in tables 'menu' & 'sub_menu'
 */

$bgcolor = "#cccc99";
for($i=0; $i < count($menu);$i++){

if ($bgcolor == "#cccc99") {
$bgcolor = "#ffffcc";
} else {
$bgcolor = "#cccc99";
}
   echo "<table width=\"590\" cellpadding=\"0\" cellspacing=\"1\"  border=\"0\">"      
        ."<tr bgcolor=\"$bgcolor\">";
 if(!empty($submenu[$i])){
   if(isset($expand[$i])) 
      echo "<td width=\"10\"><div align=\"center\"><a class=\"menu\" href=\"alarisAdmin.php?view=menu\">-</a></div></td>";
   else
      echo "<td width=\"10\"><div align=\"center\"><a class=\"menu\" href=\"alarisAdmin.php?view=menu&expand[$i]=true\">+</a></div></td>";
 }else{
   echo "<td width=\"10\">&nbsp;</td>";
 }     
   echo	"<td width=\"30\"><div align=\"center\">".$menu[$i]->PARENT_ID."</div></td>"
    	."<td width=\"160\">&nbsp;".$menu[$i]->TITLE."</td>"
        ."<td width=\"310\">&nbsp;".$menu[$i]->URL."</td>";
        if(isset($expand[$i])){
         echo "<td width=\"40\"><div align=\"center\"><a href=\"alarisAdmin.php?view=menu&expand[$i]=true&edit=".$menu[$i]->PARENT_ID."\"><font color=\"darkred\">Edit</font></a></div></td>";
        }else{
         echo "<td width=\"40\"><div align=\"center\"><a href=\"alarisAdmin.php?view=menu&edit=".$menu[$i]->PARENT_ID."\"><font color=\"darkred\">Edit</font></a></div></td>";
        }
        if(isset($expand[$i])){
         echo "<td width=\"40\"><div align=\"center\"><a onClick=\"return confirmSubmit();\" href=\"mysql_delete_menu.php?view=menu&expand[$i]=true&edit=".$menu[$i]->PARENT_ID."\"><font color=\"darkred\">Delete</font></a></div></td>";
        }else{
         echo "<td width=\"40\"><div align=\"center\"><a onClick=\"return confirmSubmit();\" href=\"mysql_delete_menu.php?view=menu&edit=".$menu[$i]->PARENT_ID."\"><font color=\"darkred\">Delete</font></a></div></td>";
        }
        echo "</tr>";
   /* Display the submenu if expand-link is pressed */
   if(!empty($submenu[$i]) && isset($expand[$i])){
     for($j=0; $j < count($submenu[$i]);$j++){
        echo "<tr bgcolor=\"$bgcolor\">"
             ."<td width=\"10\">&nbsp;</td>"
             ."<td width=\"30\"><div align=\"center\">".$submenu[$i][$j]->SUB_ID."</div></td>"
             ."<td width=\"160\">&nbsp;".$submenu[$i][$j]->TITLE."</td>"
             ."<td width=\"310\">&nbsp;".$submenu[$i][$j]->URL."</td>"
             ."<td width=\"40\"><div align=\"center\"><a href=\"alarisAdmin.php?view=menu&expand[$i]=true&edit_sub=".$submenu[$i][$j]->SUB_ID."\"><font color=\"darkred\">Edit</font></a></div></td>"
             ."<td width=\"40\"><div align=\"center\"><a onClick=\"return confirmSubmit();\" href=\"mysql_delete_menu.php?view=menu&expand[$i]=true&edit_sub=".$submenu[$i][$j]->SUB_ID."\"><font color=\"darkred\">Delete</font></a></div></td>"
             ."</tr>";
     }
   }
}

echo "</table>";



/*
 * This allow for editing the main menus.
 */

if(isset($edit) || $action=="new_main"){
if(isset($edit)){
$display_menu = get_menu($edit);
}
?>

<form action="mysql_menu.php" method="post" class="thin">
<? if(isset($edit)) echo "<input type=\"hidden\" name=\"edit\" value=\"$edit\">"; ?>
<table width="590" cellpadding="0" celspacing="0" border="0">
   <tr>
   	<td>&nbsp;</td>
   </tr>
   <tr>
   	<td>Title</td>
   	<td>URL</td>
   	<td>Width</td>
   	<td>Target</td>
   </tr>
   <tr>
        <!--<td><input type="text" name="menu_parent_id" class="textfield" size="1" value="<? if(isset($edit)) echo $display_menu[parent_id]; ?>" readonly></td>-->
     	<td><input type="text" name="menu_title" class="textfield" size="20" value="<? if(isset($edit)) echo $display_menu[title]; ?>"></td>
     	<td><input type="text" name="menu_url" class="textfield" size="35" value="<? if(isset($edit)) echo $display_menu[url]; ?>"></td>
     	<td><input type="text" name="menu_width" class="textfield" size="4" value="<? if(isset($edit)) echo $display_menu[width]; ?>"></td>
     	<td><input type="text" name="menu_target" class="textfield" size="8" value="<? if(isset($edit)) echo $display_menu[target]; ?>"></td>
   </tr>
   <tr>
   	<td colspan="5"><input type="Submit" class="button" value=<? isset($edit) ? print("Change") : print("Submit");?> >
	                <input type="Reset" class="button" value="Reset">
	                <? if(isset($edit)) print("&nbsp;<input type=\"button\" class=\"button\" value=\"New\" onclick=\"window.location='alarisAdmin.php?view=menu&action=new_main'\">"); ?>
   	</td>
  </tr> 	
</table>
</form>
<?
}



/*
 * This allow for editing the sub menus - include db connect to retrieve data.
 */

if(isset($edit_sub) || $action=="new_sub"){

if(isset($edit_sub)){
$display_sub = get_submenu($edit_sub);
}
?>
<form action="mysql_submenu.php" method="post" class="thin">
<? if(isset($edit_sub)) echo "<input type=\"hidden\" name=\"edit_sub\" value=\"$edit_sub\">"; ?>
<table width="590" cellpadding="0" celspacing="0" border="0">
   <tr>
   	<td>&nbsp;</td>
   </tr>
   <tr>
   	<td>Parent ID</td>
   	<td>Title</td>
   	<td>URL</td>
   	<td>Target</td>
   </tr>
   <tr>
        <td><? echo query_select("sub_parent_id","SELECT alaris_menu.parent_id, alaris_menu.title FROM alaris_menu ORDER BY parent_id","$display_sub[sub_parent_id]"); ?></td>
     	<td><input type="text" name="new_title_sub" class="textfield" size="20" value="<? if(isset($edit_sub)) echo $display_sub[title_sub]; ?>"></td>
     	<td><input type="text" name="new_url_sub" class="textfield" size="35" value="<? if(isset($edit_sub)) echo $display_sub[url_sub]; ?>"></td>
     	<td><input type="text" name="new_target_sub" class="textfield" size="8" value="<? if(isset($edit_sub)) echo $display_sub[target_sub]; ?>"></td>
   </tr>
   <tr>
   	<td colspan="5"><input type="Submit" class="button" value=<? isset($edit_sub) ? print("Change") : print("Submit");?> >
	                <input type="Reset" class="button" value="Reset">
	                <? if(isset($edit_sub)) print("&nbsp;<input type=\"button\" class=\"button\" value=\"New\" onclick=\"window.location='alarisAdmin.php?view=menu&action=new_sub'\">"); ?>
   	</td>
  </tr> 	
</table>
</form>
<?
}
?>

Return current item: alarisMenu