-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.php
121 lines (111 loc) · 4.46 KB
/
page.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<?php
function output_menu($start, $start_url, $expand, $level) {
if (isset($start['menu'])) {
echo '<ul';
if ($expand) {
echo ' class="expand' . $level . '"';
}
echo '>';
$number = 1;
foreach ($start['menu'] as $chapter) {
$url = $start_url . '/' . get_shortname($chapter);
$base_url = $url;
$has_children = isset($chapter['menu']) || isset($chapter['ref']) || isset($chapter['type']) || isset($chapter['link']);
$type = 'page';
if (isset($chapter['type'])) {
$type = $chapter['type'];
$url .= '.' . $type;
echo '<li class="' . $type . '">';
}
else if ($has_children && !$expand) {
echo '<li class="menu">';
}
else if ($level>0) {
echo '<li class="submenu">';
}
else {
echo '<li>';
}
if (isset($chapter['link']))
$url = $chapter['link'];
else if (!$has_children || $expand)
$url = null;
// Alternative types with extra link. Hardcoded to specific type(s) for now.
if ($type=='deck') {
$alttype = 'print';
if (isset($chapter['altname']))
$altname = $chapter['altname'];
else
$altname = $alttype;
echo '<a href="' . $base_url . '.' . $alttype . '" class="alttype ' . $alttype . '">' . $altname . '</a>';
$alttype = 'reveal';
$altname = 'alt';
echo '<a href="' . $base_url . '.' . $alttype . '" class="alttype ' . $alttype . '">' . $altname . '</a>';
}
else if ($type=='app') {
$alttype = 'source';
if (isset($chapter['altname']))
$altname = $chapter['altname'];
else
$altname = $alttype;
echo '<a href="' . $base_url . '.' . $alttype . '" class="alttype ' . $alttype . '">' . $altname . '</a>';
}
if ($url!=null)
echo '<a href="'.$url.'">';
// Output the main text of this item
$title = $chapter['title'];
if ($level>1) {
echo get_html_for_text($title);
}
else {
echo '<h2>'. $title .'</h2>';
}
// Output optional image
if (isset($chapter['image'])) {
$imagePath = '/images/' . $chapter['image'];
echo '<a href="' . $imagePath . '" target="_blank">';
echo '<img src="/images/' . $chapter['image'] . '"';
if (isset($chapter['imagewidth'])) {
echo ' width="' . $chapter['imagewidth'] . '"';
}
echo '></a>';
}
if (isset($chapter['description']))
echo '<p>' . get_html_for_text($chapter['description']) . '</p>';
if ($url!=null)
echo '</a>';
if ($expand)
output_menu($chapter, $start_url, $expand, $level+1);
echo '</li>';
}
echo '</ul>';
}
}
?>
<html>
<head>
<title><?= $page_heading ?></title>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" type="text/css" href="/site.css" />
</head>
<body>
<h1><?= $page_heading ?></h1>
<?php if (isset($page['description'])) echo "<p>${page['description']}</p>"; ?>
<?php if (isset($page['description2'])) echo "<p>${page['description2']}</p>"; ?>
<?php output_menu($page, $page_url, isset($page['expand']), 0); ?>
<footer></footer>
<?php if (isset($_SERVER['GOOGLE_ANALYTICS'])) { ?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?php echo $_SERVER['GOOGLE_ANALYTICS'] ?>']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php } ?>
</body>
</html>