Esempio n. 1
0
/**
 * makeMenu
 * Creates a ul li list with the specified array
 *
 * $items:
 *      Array to convert as menu
 * 
 * $level = 0:
 *      Indentation level (4 tabs per level) to write
 * 
 * $parent = "":
 *      When generating the href, will use parent appended with the current key name. 
 * 
 * $first = false:
 *      Will print a class on the first ul generated only. 
 *
 */
function makeMenu($items, $level = 0, $parent = "", $first = false)
{
    /* Returning if empty */
    if (empty($items)) {
        return;
    }
    $ret = "";
    $firstUl = $first ? 'class="main-navigation__list  js-main-navigation__list"' : '';
    $indent = str_repeat(" ", $level * 4);
    $ret .= sprintf("%s<ul {$firstUl}>\n", $indent);
    $indent = str_repeat(" ", ++$level * 4);
    foreach ($items as $item => $subitems) {
        $hasChild = !empty($subitems) ? "has_children" : "";
        if (!is_numeric($item)) {
            $ret .= sprintf("%s<li class=\"{$hasChild}\"><a href='{$parent}/{$item}'>%s</a>", $indent, $item);
        }
        if (is_array($subitems)) {
            $ret .= "\n";
            $ret .= MakeMenu($subitems, $level + 1, $parent . "/" . $item);
            $ret .= $indent;
        } else {
            if (strcmp($item, $subitems)) {
                $ret .= sprintf("%s<li class=\"{$hasChild}\"><a href='{$parent}/{$subitems}'>%s</a>", $indent, $subitems);
            }
        }
        $ret .= sprintf("</li>\n", $indent);
    }
    $indent = str_repeat(" ", --$level * 4);
    $ret .= sprintf("%s</ul>\n", $indent);
    return $ret;
}
Esempio n. 2
0
                $OK = SaveConfig($config);
                if ($OK) {
                    Redirect('config.php?section=' . $_REQUEST['section'] . '#' . $_REQUEST['add'] . $_REQUEST['id']);
                }
            }
        }
    }
}
if ($OK) {
    ?>

<table width="100%">
<tr>
<td valign="top" width="270">
<?php 
    MakeMenu();
    ?>

<div class="block">
<center>
<a class="commandlink" href="index.php">back to main page</a>
</center>
</div>

</td>

<td valign="top">
<?php 
    echo '<form action="config.php" method=' . $FormMethod . '">';
    echo '<input type="hidden" name="save" value="1">';
    echo '<input type="hidden" name="section" value="' . $reqsection . '">';