function displayNavigation($path = "0", $limit = null, $selection = null, $pageName = "main", $moremenuLimit = null, $moremenuCounter = null, $moremenu = null, $stub = FALSE)
{
    //  Handle recursion
    $limitNext = $limit === null ? null : $limit - 1;
    $obj = explode(",", $path);
    $depth = count($obj) - 1;
    $first = $obj[1];
    $final = $obj[$depth];
    $target = null;
    for ($i = 1; $i < count($obj); $i++) {
        if ($i > 1) {
            $target .= ",";
        }
        $target .= $obj[$i];
    }
    if (!$target) {
        $target = $path;
    }
    // Check for selection
    $selected = false;
    $selects = explode(",", $selection);
    for ($i = 0; $i < count($selects); $i++) {
        if ($selection && $selects[$i] == $final) {
            $selected = true;
        }
    }
    //  Pull from current node
    $sql = "\n\t\tSELECT * FROM objects \n\t\tWHERE id = '{$final}' \n\t\tAND active = 1 \n\t\tLIMIT 1\n\t\t";
    $res = MYSQL_QUERY($sql);
    $row = MYSQL_FETCH_ARRAY($res);
    $name = nl2br($row["name1"]);
    $rank = nl2br($row["rank"]);
    $deck = nl2br($row["deck"]);
    $body = nl2br($row["body"]);
    $bodyParts = explode("|", $body);
    //  Check if $obj is a root
    if ($final == 0) {
        $name = "";
    }
    if (substr($name, 0, 1) == "+") {
        $name = "";
    }
    //  Display current node
    if (substr($name, 0, 1) != "." && substr($name, 0, 1) != "_" && ($moremenuCounter <= $moremenuLimit || $moremenu)) {
        $html = "\n<li class='list";
        $html .= $selected || $final == 0 ? "Active" : "Static";
        $html .= "'>";
        $html .= "<a href='";
        // Check if URL and whether full or partial
        $checkURL = substr($row["url"], -1);
        $hasFullURL = FALSE;
        if ($checkURL == '0' || $checkURL == '1' || $checkURL == '2' || $checkURL == '3' || $checkURL == '4' || $checkURL == '5' || $checkURL == '6' || $checkURL == '7' || $checkURL == '8' || $checkURL == '9') {
            $hasFullURL = TRUE;
        }
        // echo $hasFullURL;
        if ($row['url']) {
            if ($hasFullURL) {
                $html .= $row['url'];
            } else {
                $html .= $row['url'] . ".html?id=" . $row["objectsId"];
            }
        } else {
            if ($selected) {
                $html .= "main.html";
            } else {
                $html .= $pageName . ".html?id={$target}";
            }
        }
        $html .= "' style='display: block; padding-left: " . $depth * 50 . "px;'>";
        if ($body) {
            $html .= $rank . "—";
        }
        $html .= $name;
        $html .= "</a></li>";
        echo $html;
        //  Find children of current node
        if (($limit > 0 || $limit === null || $selected) && !$stub) {
            $sql = "\n\t\t\t\tSELECT objects.id AS objectsId FROM wires, objects \n\t\t\t\tWHERE wires.fromid = '{$final}' AND wires.toid = objects.id \n\t\t\t\tAND wires.active = 1 AND objects.active = 1 \n\t\t\t\tORDER BY objects.rank, end DESC, begin DESC, name1, name2, objects.modified DESC, objects.created DESC\n\t\t\t\t";
            $res = MYSQL_QUERY($sql);
            while ($row = MYSQL_FETCH_ARRAY($res)) {
                $moremenuCounter++;
                $tmp = $path . "," . $row["objectsId"];
                $limitTemp = $selected ? $limit : $limitNext;
                displayNavigation($tmp, $limitTemp, $selection, $pageName, $moremenuLimit, $moremenuCounter, $moremenu);
            }
        }
    } else {
        if ($moremenuCounter >= $moremenuLimit && !$moremenu) {
            $html .= "\n\t\t<li class='listActive'><a href='" . $pageName . ".html?id=" . $selection . "&moremenu=1' style='display: block;'>More . . .</a></li>";
            echo $html;
            exit;
        }
    }
}
Esempio n. 2
0
 * relayed trough this file.
 * 
 * Modified by DIRN on 09/06/2015, changelog 12341	
 */
session_start();
// set serverside cookie
require_once "conf/config.conf.php";
// System configuration also contains other require-statements
// set to the user defined error handler, see : lib/general.lib.php
$new_error_handler = set_error_handler("fcErrorHandler");
$db_conn = databaseConnect();
// Connect to DB
// Since every request or POST is routed via this PHP file
// we may need to process a submitted form. Depending on the action argument
// processCurrentAction does that.
//
// Avoid HTML output before this action. See for mapping of commands processing.lib.php
processCurrentAction();
// Functions that generate content to browser, see general.lib.php
displayHeader();
// Generate HTML header as well as the `top' of the page
displayNavigation();
// Generate navigation bar-menu
displaySearch();
//Generate search input
renderCurrentAction();
// Generate main content, basad upon action argument. See for mapping rendering.lib.php
displayFooter();
// Generate footer and HTML footer as well.
databaseDisconnect($db_conn);
// disconnect from DB
Esempio n. 3
0
function displayNavigation($path = "0", $limit = null, $selection = null, $pageName = "main", $stub = FALSE, $breadcrumbsMode = FALSE, $multiColumn = null)
{
    //  Handle recursion
    $limitNext = $limit === null ? null : $limit - 1;
    $obj = explode(",", $path);
    $depth = count($obj) - 1;
    $first = $obj[1];
    $final = $obj[$depth];
    // build target
    $target = null;
    for ($i = 1; $i < count($obj); $i++) {
        if ($i > 1) {
            $target .= ",";
        }
        $target .= $obj[$i];
    }
    if (!$target) {
        $target = $path;
    }
    // Check for selection
    $selected = false;
    $selects = explode(",", $selection);
    for ($i = 0; $i < count($selects); $i++) {
        if ($selection && $selects[$i] == $final) {
            $selected = true;
        }
    }
    //  Pull from current node
    $sql = "SELECT * \n\t\t\tFROM objects \n\t\t\tWHERE \n\t\t\t\tid = '{$final}' \n\t\t\t\tAND active = 1 \n\t\t\tLIMIT 1";
    $res = MYSQL_QUERY($sql);
    $row = MYSQL_FETCH_ARRAY($res);
    $name = nl2br($row["name1"]);
    $rank = nl2br($row["rank"]);
    $deck = nl2br($row["deck"]);
    $body = nl2br($row["body"]);
    $bodyParts = explode("|", $body);
    //  Check if $obj is a root
    if ($final == 0) {
        $name = "";
    }
    if (substr($name, 0, 1) == "+") {
        $name = "";
    }
    //  Display current node
    if (substr($name, 0, 1) != "." && substr($name, 0, 1) != "_") {
        $html = "<div class='menuItemContainer ";
        $html .= $selected || $final == 0 ? "active" : "static";
        $html .= "'>";
        $html .= "<a href='";
        // Check if URL and whether full or partial
        $pattern = "/html/";
        $URL = $row["url"];
        if (preg_match($pattern, $URL)) {
            $fullURL = TRUE;
        }
        $html .= $URL ? $URL : $pageName;
        // normal
        if (!$fullURL) {
            $html .= ".php?id={$target}";
        }
        $html .= "'>";
        $html .= $name;
        $html .= "</a></div>";
        if ($breadcrumbsMode && $depth <= count($selects)) {
            if ($selected) {
                echo $html;
            }
        } else {
            // k.m-specific hack -- don't show top-level deutsch / english
            if ($depth > 0) {
                echo $html;
            }
        }
        //  Find children of current node
        if (($limit > 0 || $limit === null || $selected) && !$stub) {
            $sql = "SELECT objects.id AS objectsId \n\t\t\t\t\tFROM \n\t\t\t\t\t\twires, \n\t\t\t\t\t\tobjects \n\t\t\t\t\tWHERE \n\t\t\t\t\t\twires.fromid = '{$final}' \n\t\t\t\t\t\tAND wires.toid = objects.id \n\t\t\t\t\t\tAND wires.active = 1 \n\t\t\t\t\t\tAND objects.active = 1 \n\t\t\t\t\tORDER BY \n\t\t\t\t\t\tobjects.rank, \n\t\t\t\t\t\tend DESC, \n\t\t\t\t\t\tbegin DESC, \n\t\t\t\t\t\tname1, \n\t\t\t\t\t\tname2, \n\t\t\t\t\t\tobjects.modified DESC, \n\t\t\t\t\t\tobjects.created DESC";
            $res = MYSQL_QUERY($sql);
            //if ($multiColumn && $depth>1)
            if ($multiColumn && $depth != 0) {
                echo "<div style='padding-left:" . $multiColumn . "px;'>";
            }
            // acquiring modernity hack -- not sure if nec for k.m?
            if ($final && $depth > 0) {
                $breadcrumbsMode = TRUE;
            }
            while ($row = MYSQL_FETCH_ARRAY($res)) {
                $tmp = $path . "," . $row["objectsId"];
                $limitTemp = $selected ? $limit : $limitNext;
                displayNavigation($tmp, $limitTemp, $selection, $pageName, $stub, $breadcrumbsMode, $multiColumn);
            }
            //if ($multiColumn && $depth>1)
            if ($multiColumn && $depth != 0) {
                echo "</div>";
            }
        }
    }
}