<?php
if (! defined("TOP_INCLUDED"))
{
define("TOP_INCLUDED", true);
require_once("inc/error.php");
global $prefix, $section;
$menuitem = array();
$weighted_menuitem = array();
$submenu = array();
foreach (config('modules') as $module)
{
$menu = false;
if (file_exists("modules/{$module}/menu.php"))
include("modules/{$module}/menu.php");
if ($menu === false)
{
DEBUG("Modul {$module} hat keine Menüeinträge");
continue;
}
DEBUG("<h4>$module</h4>");
DEBUG($menu);
// $menu["foo"]["file"] enthält den Link
foreach (array_keys($menu) as $key)
{
$menu[$key]["file"] = $prefix."go/".$module."/".$menu[$key]["file"];
$weight = $menu[$key]["weight"];
if (isset($menu[$key]['submenu']))
{
if (isset($submenu[$menu[$key]['submenu']][$weight]))
$submenu[$menu[$key]['submenu']][$weight] = array_merge($submenu[$menu[$key]['submenu']][$weight], array($key => $menu[$key]));
else
$submenu[$menu[$key]['submenu']][$weight] = array($key => $menu[$key]);
}
else
{
if (array_key_exists($weight, $weighted_menuitem))
$weighted_menuitem[$weight] = array_merge($weighted_menuitem[$weight], array($key => $menu[$key]));
else
$weighted_menuitem[$weight] = array($key => $menu[$key]);
}
}
$menuitem = array_merge($menuitem, $menu);
}
ksort($weighted_menuitem);