예제 #1
0
function showSubMenu($objprof, $prof_id, $parent)
{
    $sub = $objprof->getMenuByProf($prof_id, $parent);
    if (count($sub) > 0) {
        echo "<ul>";
        foreach ($sub as $k => $v) {
            echo "<li><a href='" . site_url($v->MENU_LINK) . "'>" . $v->MENU_NAME . "</a>";
            echo showSubMenu($objprof, $prof_id, $v->MENU_ID);
            echo "</li>";
        }
        echo "</ul>";
    }
}
예제 #2
0
function nestPages($id, $ancestors)
{
    $menuHTML = "";
    $qry = "SELECT DISTINCT A.*, B.* FROM {$_SESSION['DB_PREFIX']}pagenavigation A " . "INNER JOIN {$_SESSION['DB_PREFIX']}pages B " . "ON A.childpageid = B.pageid " . "INNER JOIN {$_SESSION['DB_PREFIX']}pageroles C " . "ON C.pageid = B.pageid " . "WHERE A.pageid = " . $id . " " . "AND A.pagetype = 'P' " . "AND C.roleid IN (" . ArrayToInClause($_SESSION['ROLES']) . ") " . "ORDER BY A.sequence";
    $result = mysql_query($qry);
    //Check whether the query was successful or not
    if ($result) {
        if (mysql_num_rows($result) == 0) {
            if (isAuthenticated()) {
                $ancestors = findParentMenu($id, $ancestors);
                $menuHTML = $menuHTML . nestPages($ancestors[count($ancestors) - 1], $ancestors);
            }
        } else {
            $result = mysql_query($qry);
            $highestPage = 0;
            while ($member = mysql_fetch_assoc($result)) {
                for ($index = 0; $index < count($ancestors); $index++) {
                    if ($ancestors[$index] == $member['pageid']) {
                        if ($highestPage < $member['pageid']) {
                            $highestPage = $member['pageid'];
                        }
                    }
                }
            }
            $result = mysql_query($qry);
            $first = true;
            $counter = 0;
            $menuHTML = $menuHTML . "<div class='red'><ul class='mega-menu'>\n";
            /* Show children. */
            while ($member = mysql_fetch_assoc($result)) {
                $anchorClass = "";
                $menuHTML = $menuHTML . "<li class='";
                $counter++;
                if ($counter == 6) {
                    $anchorClass = "last ";
                }
                if ($first) {
                    $first = false;
                    $anchorClass = $anchorClass . "first ";
                }
                if ($highestPage == $member['pageid']) {
                    $menuHTML = $menuHTML . "current ";
                }
                $menuHTML = $menuHTML . "' onclick='window.location.href = \"" . $member['pagename'] . "\"'>";
                $target = "";
                if ($member['target'] != null) {
                    $target = " target='" . $member['target'] . "' ";
                }
                $menuHTML = $menuHTML . "<a {$target} class='{$anchorClass}' href='" . $member['pagename'] . "'><em><b>" . $member['label'] . "</b></em></a>\n";
                $menuHTML = $menuHTML . showSubMenu($member['childpageid']);
                $menuHTML = $menuHTML . "</li>\n";
                if ($member['divider'] == 1) {
                    $menuHTML = $menuHTML . "<div class='divider'>&nbsp;</div>\n";
                }
            }
            $menuHTML = $menuHTML . "</ul></div>\n";
        }
    }
    return $menuHTML;
}