-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.php
89 lines (86 loc) · 2.67 KB
/
header.php
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
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
$PAGES = json_decode(file_get_contents("data/pages.json"), true);
$page = str_replace(array("/", ".php"), array(""), $_SERVER["PHP_SELF"]);
if ($page === "index") {
$page = "";
}
function searchItem($arr) {
global $page;
foreach ($arr as $name => $content) {
if ($content === $page) {
return array(array($name), $name);
} else if (is_array($content)) {
$res = searchItem($content);
if (count($res) === 2) {
array_push($res[0], $name);
return array($res[0], $res[1]);
}
}
}
return array();
}
$result = searchItem($PAGES);
if ($result) {
$actives = $result[0];
$title = $result[1];
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title><?php echo $title?> | Robinson College Students' Association</title>
<link rel="stylesheet" href="/files/lib/css/bootstrap.min.css">
<link rel="stylesheet" href="/files/lib/css/style.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/files/lib/js/jquery.min.js"></script>
<script src="/files/lib/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#nav-collapse">
<span class="sr-only">Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><img width="38" height="45" src="/files/lib/logo.png"> RCSA</a>
</div>
<div id="nav-collapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<?php
function genMenu($arr) {
global $actives;
foreach ($arr as $name => $content) {
if (substr($name, 0, 2) === "//") {
# pass
} else if (is_array($content)) {
if (in_array ($name, $actives)) {
echo "<li class=\"dropdown active\">\n";
} else {
echo "<li class=\"dropdown\">\n";
}
echo "<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">$name<span class=\"caret\"></span></a>\n";
echo "<ul class=\"dropdown-menu\">\n";
genMenu($content);
echo "</ul>\n";
echo "</li>\n";
} else {
if (in_array ($name, $actives)) {
echo "<li class=\"active\">";
} else {
echo "<li>";
}
echo "<a href=\"/$content\">$name</a></li>\n";
}
}
}
genMenu($PAGES);
?>
</ul>
</div>
</div>
</nav>
<div class="container">