예제 #1
0
function Arbo_print($object)
{
    $What_isn_visible = array();
    $remain_query = "";
    // Supprimer les doublons de la query string (PHP_SESSION_ID)
    // Peu efficace mais ceci limite les dégats.
    $own_query = implode("&", array_unique(explode("&", $GLOBALS["QUERY_STRING"])));
    // Détecter la présence de paramètre dans la requête
    if (strchr($object->url, "?")) {
        $is_there_QS = TRUE;
        $object->url = substr($object->url, strpos($object->url, "?") + 1, strlen($object->url));
        print "<H2>" . $object->url . "</H2>";
    }
    if (isset($GLOBALS["MENU"]) && $GLOBALS["MENU"]) {
        $What_isn_visible = explode(",", $GLOBALS["MENU"]);
    }
    if (ereg("MENU=[^&]*(.*)", $own_query, $regs)) {
        $remain_query = $regs[1];
    } else {
        if ($own_query) {
            $remain_query = "&" . $own_query;
        }
    }
    print "<TR valign=\"top\"><TD nowrap>";
    for ($count = 0; $count < $object->level; $count++) {
        if ($count + 1 == $object->level) {
            if ($object->line[$count] == 1) {
                if ($object->havechild) {
                    if ($object->visible) {
                        printf(TAG_HREF, $GLOBALS["PHP_SELF"], implode(",", $What_isn_visible), 'P' . $object->ident, $remain_query);
                        printf(TAG_IMG, PATH_IMG, TEE_MINUS_IMG);
                        print "</A>\n";
                    } else {
                        printf(TAG_HREF, $GLOBALS["PHP_SELF"], implode(",", $What_isn_visible), 'M' . $object->ident, $remain_query);
                        printf(TAG_IMG, PATH_IMG, TEE_PLUS_IMG);
                        print "</A >\n";
                    }
                } else {
                    printf(TAG_IMG, PATH_IMG, TEE_IMG);
                }
            } else {
                if ($object->havechild) {
                    if ($object->visible) {
                        printf(TAG_HREF, $GLOBALS["PHP_SELF"], implode(",", $What_isn_visible), 'P' . $object->ident, $remain_query);
                        printf(TAG_IMG, PATH_IMG, CORNER_BL_MINUS_IMG);
                        print "</A >\n";
                    } else {
                        printf(TAG_HREF, $GLOBALS["PHP_SELF"], implode(",", $What_isn_visible), 'M' . $object->ident, $remain_query);
                        printf(TAG_IMG, PATH_IMG, CORNER_BL_PLUS_IMG);
                        print "</A >\n";
                    }
                } else {
                    printf(TAG_IMG, PATH_IMG, CORNER_BL_IMG);
                }
            }
        } else {
            if ($object->line[$count] == 1) {
                printf(TAG_IMG, PATH_IMG, VERTICAL_IMG);
            } else {
                printf(TAG_IMG, PATH_IMG, EMPTY_IMG);
            }
        }
    }
    print "<font size=\"2\">\n";
    if ($object->havechild || $object->ident == -1) {
        printf(TAG_IMG, PATH_IMG, FOLDER_DEF_IMG);
        print TAG_SIMPLE_HREF . $object->url . ($is_there_QS ? '&' : '?') . $own_query . "\">{$object->name}</A>\n";
    } else {
        printf(TAG_IMG, PATH_IMG, trim($object->identchild[0]));
        print TAG_SIMPLE_HREF . $object->url . ($is_there_QS ? '&' : '?') . $own_query . "\">{$object->name}</A>\n";
    }
    print "</font>\n";
    print "</TD></TR>";
    if (isset($object) && $object->visible) {
        foreach ($object->what as $key => $value) {
            Arbo_print($object->what[$key]);
        }
    }
    return $object;
}
예제 #2
0
<HR><BR>

<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">

<?php 
// Ouvrez une section "TABLE" (ajoutez un style CSS c'est plus agréable)
// Ici -> implémentation de votre menu : d'abord la classe ...
require_once "menu.php";
// ensuite la description du menu (une simple chaîne)
require_once "t_string.php";
// String_to_Arbo crée l'instance menu (avec un titre)
$menu = String_to_Arbo($t_string, "Eléments");
// do_visibility met a jour les "extends" et les "collapses"
$menu->do_visibility();
// Arbo_print affiche les cellules de la table contenant le menu
Arbo_print($menu);
// On ferme la table. Le travail est fait
?>
</TABLE>

<?php 
echo "<HR/>Contenu de \$t_string (chaîne de configuration)<HR/>";
echo str_replace(array("\r\n", "\r", "\n", "\t"), array("<BR/>", "<BR/>", "<BR/>", "&nbsp;&nbsp;&nbsp;"), $t_string);
?>
<br>Explications des param&egrave;tres du noeud :
<br>
<table BORDER COLS=2 WIDTH="100%" >
<tr>
<td>( 1,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

<td><font color="#006600">// 1 = noeud ouvert , 0 = noeud ferm&eacute;</font></td>