Exemple #1
0
function matchSectionLI($matches)
{
    global $html;
    global $currentDirectory;
    global $nestLevel;
    global $processedSections;
    global $count;
    $li = $matches[0];
    $href = $matches[1];
    $page = $matches[2];
    $title = $matches[3];
    $special = "";
    $filePath = $_SERVER["DOCUMENT_ROOT"] . $href . "_nav.inc";
    $processSubnav = true;
    //check if file exists and contains no lis
    if (file_exists($filePath)) {
        $file = file_get_contents($filePath);
        $regex = '/(<li[^>]*?>[\\s]*?<a[^>]*?>[\\s\\S]*?<\\/a>[\\s]*?<\\/li>)/';
        if (!preg_match($regex, $file)) {
            $processSubnav = false;
        }
    } else {
        $processSubnav = false;
    }
    //no _nav in section
    //check if this is the current sections index page link
    if (!strcmp($href, $currentDirectory)) {
        $processSubnav = false;
    }
    //check if class=ou-no-subnav within the li's node
    if (strpos($li, "class=\"ou-no-subnav\"") !== false) {
        $processSubnav = false;
    }
    //process a section only once to avoid infinite recursion when cross/links are added
    if (in_array($href, $processedSections)) {
        $processSubnav = false;
    }
    //used to be 3 and change to 1
    if ($processSubnav && $nestLevel < 1) {
        if ($href != '') {
            array_push($processedSections, $href);
        }
        $html .= "<li><a href=\"{$href}{$page}\">{$title}</a>\n\t\t\t\t\t\t<ul class=\"flat-list list-group\">";
        $currentDirectory = $href;
        processNavFile($filePath);
        $html .= "</ul></li>";
        $count++;
    } else {
        $html .= $li;
    }
    //just copy the li
}
Exemple #2
0
<?php 
include_once 'nav_functions.php';
parse_str($_SERVER['QUERY_STRING']);
$leftnav = isset($leftnav) ? $leftnav : "/_nav.inc";
$serverFilePath = $_SERVER["DOCUMENT_ROOT"] . $leftnav;
$currentDirectory = str_replace("_nav.inc", "", $leftnav);
$nestLevel = 1;
$count = 1;
$processedSections = array();
$html = "";
processNavFile($serverFilePath);
echo $html;