Fix bugs in the menu manager. Fix the links, hide the order number for sub-menus because they are meant to displayed in order by the menu title.

This commit is contained in:
Mark Crane 2012-09-06 21:42:37 +00:00
parent ba8c205e20
commit 04dfeac49a
3 changed files with 29 additions and 23 deletions

View File

@ -120,18 +120,20 @@ else {
if ($_POST["persistformvar"] != "true") {
//add a menu item
if ($action == "add" && permission_exists('menu_add')) {
$sql = "SELECT menu_item_order FROM v_menu_items ";
$sql .= "where menu_uuid = '$menu_uuid' ";
$sql .= "and menu_item_parent_uuid = '$menu_item_parent_uuid' ";
$sql .= "order by menu_item_order desc ";
$sql .= "limit 1 ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$highest_menu_item_order = $row[menu_item_order];
if (strlen($menu_item_parent_uuid) == 0) {
$sql = "SELECT menu_item_order FROM v_menu_items ";
$sql .= "where menu_uuid = '$menu_uuid' ";
$sql .= "and menu_item_parent_uuid = '$menu_item_parent_uuid' ";
$sql .= "order by menu_item_order desc ";
$sql .= "limit 1 ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$highest_menu_item_order = $row['menu_item_order'];
}
unset($prep_statement);
}
unset($prep_statement);
$menu_item_uuid = uuid();
$sql = "insert into v_menu_items ";
@ -144,7 +146,9 @@ else {
$sql .= "menu_item_protected, ";
$sql .= "menu_item_uuid, ";
$sql .= "menu_item_parent_uuid, ";
$sql .= "menu_item_order, ";
if (strlen($menu_item_parent_uuid) == 0) {
$sql .= "menu_item_order, ";
}
$sql .= "menu_item_add_user, ";
$sql .= "menu_item_add_date ";
$sql .= ")";
@ -159,11 +163,11 @@ else {
$sql .= "'".$menu_item_uuid."', ";
if (strlen($menu_item_parent_uuid) == 0) {
$sql .= "null, ";
$sql .= "'".($highest_menu_item_order+1)."', ";
}
else {
$sql .= "'$menu_item_parent_uuid', ";
}
$sql .= "'".($highest_menu_item_order+1)."', ";
$sql .= "'".$_SESSION["username"]."', ";
$sql .= "now() ";
$sql .= ")";
@ -181,11 +185,11 @@ else {
$sql .= "menu_item_protected = '$menu_item_protected', ";
if (strlen($menu_item_parent_uuid) == 0) {
$sql .= "menu_item_parent_uuid = null, ";
$sql .= "menu_item_order = '$menu_item_order', ";
}
else {
$sql .= "menu_item_parent_uuid = '$menu_item_parent_uuid', ";
}
$sql .= "menu_item_order = '$menu_item_order', ";
$sql .= "menu_item_mod_user = '".$_SESSION["username"]."', ";
$sql .= "menu_item_mod_date = now() ";
$sql .= "where menu_uuid = '$menu_uuid' ";
@ -396,10 +400,12 @@ else {
echo "</tr>\n";
if ($action == "update") {
echo " <tr>";
echo " <td class='vncell'>Menu Order:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='menu_item_order' value='$menu_item_order'></td>";
echo " </tr>";
if ($menu_item_parent_uuid == "") {
echo " <tr>";
echo " <td class='vncell'>Menu Order:</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='menu_item_order' value='$menu_item_order'></td>";
echo " </tr>";
}
//echo " <tr>";
//echo " <td class='vncell'>Added By:</td>";
//echo " <td class='vtable'>$menu_item_add_user &nbsp;</td>";

View File

@ -44,7 +44,7 @@ function build_db_child_menu_list ($db, $menu_item_level, $menu_item_uuid, $c) {
$sql = "select * from v_menu_items ";
$sql .= "where menu_uuid = '".$menu_uuid."' ";
$sql .= "and menu_item_parent_uuid = '".$menu_item_uuid."' ";
$sql .= "order by menu_item_order, menu_item_title asc ";
$sql .= "order by menu_item_title, menu_item_order asc ";
$prep_statement_2 = $db->prepare($sql);
$prep_statement_2->execute();
$result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
@ -87,10 +87,10 @@ function build_db_child_menu_list ($db, $menu_item_level, $menu_item_uuid, $c) {
//display the main body of the list
switch ($menu_item_category) {
case "internal":
$menu_item_title = "<a href='".PROJECT_PATH."/$menu_item_link'>$menu_item_title</a>";
$menu_item_title = "<a href='".PROJECT_PATH . $menu_item_link."'>$menu_item_title</a>";
break;
case "external":
if (substr($menu_item_link, 0,1) == "/") {
if (substr($menu_item_link,0,1) == "/") {
$menu_item_link = PROJECT_PATH . $menu_item_link;
}
$menu_item_title = "<a href='$menu_item_link' target='_blank'>$menu_item_title</a>";
@ -266,7 +266,7 @@ $order = $_GET["order"];
//add the type link based on the typd of the menu
switch ($menu_item_category) {
case "internal":
$menu_item_title = "<a href='".PROJECT_PATH."/$menu_item_link'>$menu_item_title</a>";
$menu_item_title = "<a href='".PROJECT_PATH . $menu_item_link."'>$menu_item_title</a>";
break;
case "external":
if (substr($menu_item_link, 0,1) == "/") {

View File

@ -283,7 +283,7 @@
}
$sql .= ") ";
$sql .= ") ";
$sql .= "order by menu_item_order, menu_item_title asc ";
$sql .= "order by menu_item_title, menu_item_order asc ";
$prep_statement_2 = $db->prepare($sql);
$prep_statement_2->execute();
$result_2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);