<?php
// erstmal herausfinden, auf welchem Menupunkt wir uns gerade befinden:
$current = isset($_GET['menu_id']) ? $_GET['menu_id'] : NULL;
if( is_null($current) )
{
$current = isset($_COOKIE['menu_id']) ? $_COOKIE['menu_id'] : NULL;
}
setcookie('menu_id', $current);
/* Array für Menü-Elemente:
Aufbau:
array {
'unixname' => array(parent, caption, location, eventhandler, template),
'unixname' => ...
unixname: ein eindeutig identifizierbarer Name
parent: Entweder NULL oder unixname eines gewünschten Elternteils
caption: das was man im Endeffekt sieht, der klickbare text
eventhandler: ON_LOAD oder ON_KLICK (einfach bisschen rumprobieren)
template: unixname eines templates, das geparst werden soll
*/
$a_menu = array(
'main' => array(NULL, 'Startseite', 'test.php', ON_LOAD, 'item'),
'tools' => array(NULL, 'Tools', 'test.php', ON_LOAD, 'item'),
'search' => array(NULL, 'Suchen', 'test.php', ON_LOAD, 'item'),
'misc' => array(NULL, 'Misc', 'test.php', ON_LOAD, 'item'),
'exchange' => array(NULL, 'Exchange', 'test.php', ON_LOAD, 'item'),
'admin' => array(NULL, 'Administration', 'test.php', ON_LOAD, 'item'),
'sub1' => array('main', 'Sub 1', 'test.php', ON_KLICK, 'subitem'),
'sub2' => array('main', 'Sub 2', 'test.php', ON_KLICK, 'subitem'),
'sub3' => array('cat2', 'Sub 3', 'test.php', ON_KLICK, 'subitem'),
'sub4' => array('cat2', 'Sub 4', 'test.php', ON_KLICK, 'subitem'),
'sub5' => array('cat1', 'Sub 5', 'test.php', ON_LOAD, 'subitem'),
'top' => array('misc', '<img src="images/toplist.gif"> Toplist', 'test.php', ON_KLICK, 'subitem'),
'list' => array('misc', '<img src="images/list.gif"> Verzeichnis', 'test.php', ON_KLICK, 'subitem'),
'playlist' => array('misc', '<img src="images/playlist.gif"> Playlist', 'test.php', ON_KLICK, 'subitem'),
'export' => array('exchange', '<img src="images/export.gif"> Export', 'test.php', ON_KLICK, 'subitem'),
'import' => array('exchange', '<img src="images/import.gif"> Import', 'test.php', ON_KLICK, 'subitem'),
'edit' => array('admin', '<img src="images/edit.gif"> Verwalten', 'test.php', ON_KLICK, 'subitem'),
'settings' => array('admin', '<img src="images/settings.gif"> Einstellungen', 'test.php', ON_KLICK, 'subitem'),
);
/* Array für Menütemplates
Aufbau:
array {
'unixname' => 'template',
}
unixname: templates eindeutig identifizierbarer name
template: html-template informationen mit folgenden gültigen werten:
{unixname} - unixname also
{location} - href="{location}"
{caption} - <a href="...">{caption}</a>
{parent} - weiß der geier vielleicht, ich nicht mehr, wozu das ist =)
{active} - <a class="{active}"></a> wird später erklärt
{assembly_line} - <a class="{assembly_line}"></a> wird später erklärt
{level} - einrücklevel
*/
$a_templates = array(
'item' => '<li id="{unixname}"><a href="{location}">{caption}</a></li>',
'subitem' => '<li id="{unixname}"><a href="{location}">{caption}</a></li>',
);
/* Fehlt noch der Menüaufruf:
Parameterliste:
new menu( array items, array template, mixed current, string [activelink]);
items: array der items
template: array der templates
current: unixname des aktuellen links
activelink: erklärung unten
*/
$menu = new menu($a_item, $a_template, $current, 'menulink_active');
$parsed = $menu->parse();
echo '<pre>';
var_dump($parsed);
// sorry bin mir gerade ned sicher, was da rauskommt.
?>
|