Ejemplo n.º 1
0
function option_parente($pere = '', $excl = '', $niveaux = array(1, 2))
{
    global $db;
    foreach (menu_ordonne($db, NULL, 1) as $lp) {
        $niveau = $lp['niveau'];
        if (in_array($niveau, $niveaux)) {
            $nom = $lp['nom'];
            if (strcmp($nom, $excl)) {
                if (!strcmp($pere, $nom)) {
                    $sel = ' selected="selected"';
                } else {
                    $sel = '';
                }
                echo '<option value="' . urlencode($nom) . '"' . $sel . '>' . str_repeat('#', $niveau - 1) . ' ' . $nom . '</option>' . "\n";
            }
        }
    }
}
Ejemplo n.º 2
0
<?php

/*
 * ### Lister
 * Liste des pages
 */
?>
<h1>Liste des pages</h1>
<p>Liste des pages existantes, classée par numéro d'ordre.</p>
<?php 
echo '<table cellspacing="5" cellpadding="2" style="margin:1ex;">' . "\n";
echo '<tr><th style="text-align:center;">Nom de la page</th><th>Ordre</th></tr>' . "\n";
$liste = menu_ordonne($db, NULL, 1);
foreach ($liste as $l) {
    $decalage = ($l['niveau'] - 1) * 5;
    echo '<tr><td style="padding-left:' . $decalage . 'ex;">';
    echo '<a href="?page=' . protect_url($l['nom']) . '">' . $l['nom'] . '</a></td>';
    echo '<td style="text-align:right;">' . $l['ordre'];
    echo str_repeat('&nbsp;&nbsp;&nbsp;', 3 - $l['niveau']) . "</td></tr>\n";
}
echo "</table>\n";
Ejemplo n.º 3
0
function menu_ordonne($db, $peres, $niveau)
{
    if ((!isset($peres) or empty($peres)) && $niveau == 1) {
        $peres = menu_les_peres($db, array(1));
    }
    $rep = array();
    foreach ($peres as $l) {
        array_push($rep, array('nom' => $l['nom'], 'niveau' => $l['niveau'], 'ordre' => $l['ordre']));
        if ($niveau < 3) {
            foreach (menu_ordonne($db, menu_les_fils($db, $l['nom']), $niveau + 1) as $m) {
                array_push($rep, $m);
            }
        }
    }
    return $rep;
}