This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
menu.inc
76 lines (67 loc) · 2.23 KB
/
menu.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
// Read allmon INI file
$iniFile = 'allmon.ini.php';
if (!file_exists($iniFile)) {
die("Couldn't load ini file: $iniFile");
}
$config = parse_ini_file($iniFile, true);
#print "<pre>"; print_r($config); print "</pre>";
if (count($config) == 0) {
die("Check ini file format");
}
// Make a list of menu items
$systems = array();
foreach($config as $name => $data) {
// Don't show nomenu items
if(isset($data['nomenu']) and $data['nomenu'] == 1) {
continue;
}
// Breaks don't show as a menu item
if(strtolower($name) == 'break') {
continue;
}
// Group menus by system
$sysName = 'MainNavBar';
if (isset($data['system'])) {
$sysName=$data['system'];
}
// URL: Use 'url', 'rtcmnode', 'nodes', or name
if (isset($data['url'])) {
$systems[$sysName][$name]['url'] = $data['url'];
} elseif(isset($data['rtcmnode'])) {
$systems[$sysName][$name]['url'] = "voter.php?node={$data['rtcmnode']}";
} elseif (isset($data['nodes'])) {
$systems[$sysName][$name]['url'] = "link.php?nodes={$data['nodes']}";
} else {
$systems[$sysName][$name]['url'] = "link.php?nodes=$name";
}
}
//print '<pre>'; print_r($systems); print '</pre>';
// Output menu
$outBuf = "<div id=\"menu\">\n";
$outBuf .= "<ul>";
foreach ($systems as $sysName => $items) {
if ($sysName == "MainNavBar") {
// $itemName = key($items);
// $url = $items[$itemName]['url'];
// $outBuf .= "<li><a href=\"$url\">$itemName</a></li>\n";
$outBuf .= "<li>";
foreach($items as $itemName => $itemValue) {
$outBuf .= " <a href=\"" . $itemValue['url'] . "\">$itemName</a>";
}
$outBuf .= "</li>";
} else {
$outBuf .= "<li class=\"dropdown\">\n";
$outBuf .= "<a href=\"#\" class=\"dropbtn\">$sysName</a>\n";
$outBuf .= "<div class=\"dropdown-content\">\n";
foreach($items as $itemName => $itemValue) {
$outBuf .= " <a href=\"" . $itemValue['url'] . "\">$itemName</a>\n";
}
$outBuf .= "</div>\n</li>\n";
}
}
$outBuf .= "</ul>\n</div>\n";
$outBuf .= "<div class=\"clearer\"></div>";
print $outBuf;
//print '<pre>'; print_r($outBuf); print '</pre>';
?>