Ermögliche submenüs
bernd

bernd commited on 2007-12-08 16:23:58
Zeige 2 geänderte Dateien mit 28 Einfügungen und 8 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@842 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -132,6 +132,10 @@ a.menuitem {
132 132
         color: #000000;
133 133
 }
134 134
 
135
+a.submenuitem {
136
+  margin-left: 2em;
137
+}
138
+
135 139
 a.active {
136 140
         padding: 3px;
137 141
         border: 1px solid #000000;
... ...
@@ -12,8 +12,12 @@ global $prefix;
12 12
 $menuitem = array();
13 13
 $weighted_menuitem = array();
14 14
 
15
+$submenu = array();
16
+
15 17
 foreach ($config['modules'] as $module)
16 18
 {
19
+  $menu = false;
20
+  if (file_exists("modules/{$module}/menu.php"))
17 21
     include("modules/{$module}/menu.php");
18 22
   if ($menu === false)
19 23
   {
... ...
@@ -27,16 +31,27 @@ foreach ($config['modules'] as $module)
27 31
   {
28 32
     $menu[$key]["file"] = $prefix."go/".$module."/".$menu[$key]["file"];
29 33
     $weight = $menu[$key]["weight"];
34
+    if (isset($menu[$key]['submenu']))
35
+    {
36
+      if (isset($submenu[$menu[$key]['submenu']]))
37
+        array_merge($submenu[$menu[$key]['submenu']], array($key => $menu[$key]));
38
+      else
39
+        $submenu[$menu[$key]['submenu']] = array($key => $menu[$key]);
40
+    }
41
+    else
42
+    {
30 43
       if (array_key_exists($weight, $weighted_menuitem))
31 44
         $weighted_menuitem[$weight] = array_merge($weighted_menuitem[$weight], array($key => $menu[$key]));
32 45
       else
33 46
         $weighted_menuitem[$weight] = array($key => $menu[$key]);
34 47
     }
48
+  }
35 49
   $menuitem = array_merge($menuitem, $menu);
36 50
 }
37 51
 
38 52
 ksort($weighted_menuitem);
39
-DEBUG(print_r($weighted_menuitem, true));
53
+DEBUG($weighted_menuitem);
54
+DEBUG($submenu);
40 55
 
41 56
 
42 57
 
... ...
@@ -97,23 +112,24 @@ $role = $_SESSION['role'];
97 112
         foreach ($menuitem as $key => $item)
98 113
         {
99 114
                 if ($key == $section)
100
-                {
101 115
                         echo '<a href="'.$item['file'].'" class="menuitem active">'.$item['label'].'</a>'."\n";
116
+                else
117
+                        echo '<a href="'.$item['file'].'" class="menuitem">'.$item['label'].'</a>'."\n";
118
+                if ($key == $section || (array_key_exists($key, $submenu) && array_key_exists($section, $submenu[$key])))
119
+                {
102 120
                         if (isset($submenu[$key]))
103 121
                         {
104 122
                                 echo "\n";
105
-                                foreach ($submenu[$key] as $item)
123
+                                foreach ($submenu[$key] as $sec => $item)
106 124
                                 {
107
-                                        if (basename($_SERVER['PHP_SELF']) == basename($item['file']))
108
-                                                echo '<a href="'.$item['file'].'" class="submenuitem subactive">'.$item['label'].'</a>'."\n";
125
+                                        if ($sec == $section)
126
+                                                echo '<a href="'.$item['file'].'" class="submenuitem menuitem active">'.$item['label'].'</a>'."\n";
109 127
                                         else
110
-                                                echo '<a href="'.$item['file'].'" class="submenuitem">'.$item['label'].'</a>'."\n";
128
+                                                echo '<a href="'.$item['file'].'" class="submenuitem menuitem">'.$item['label'].'</a>'."\n";
111 129
                                 }
112 130
                                 echo "\n";
113 131
                         }
114 132
 		}
115
-                else
116
-                        echo '<a href="'.$item['file'].'" class="menuitem">'.$item['label'].'</a>'."\n";
117 133
 
118 134
         }
119 135
 
120 136