forked from clagnut/webtypography
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoc.php
74 lines (63 loc) · 2.08 KB
/
toc.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
<?php
// Turn on PHP Error Reporting
#ini_set("display_errors","2");
#ERROR_REPORTING(E_ALL);
$dr = str_replace($_SERVER['SCRIPT_NAME'], '/includes/', $_SERVER['SCRIPT_FILENAME']);
$data = require_once($dr . "data.inc.php");
$chapters = $data['chapters'];
$sections = $data['sections'];
$items = $data['items'];
?>
<!DOCTYPE html>
<html lang="en-gb">
<head>
<title>Table of Contents | The Elements of Typographic Style Applied to the Web</title>
<?php include($dr . "headlinks.inc.php") ?>
<style type="text/css">
OL {list-style:none}
</style>
</head>
<body class="bits">
<?php include($dr . "header.inc.php") ?>
<div id="main">
<h1>Table of Contents</h1>
<ol id='toc'>
<li><a href="/">Front cover</a></li>
<li style="margin-bottom:1.5em"><a href="/intro/">Introduction</a></li>
<?php
// Inefficient looping through the ToC data arrays, but heh it works doesn't it?
foreach($chapters as $chapter_num => $chapter) {
echo "<li id='$chapter_num'><span>$chapter_num </span><h3>".htmlentities($chapter)."</h3>\n<ol>\n";
foreach($sections as $section_num => $section) {
$section_chapter_ar = explode("." , $section_num);
$section_chapter = $section_chapter_ar[0];
if($section_chapter == $chapter_num) {
echo "<li id='$section_num'><span>$section_num </span><h4>".htmlentities($section)."</h4>\n<ol>\n";
foreach($items as $item_num => $item) {
$item_ar = explode("." , $item_num);
$item_section = $item_ar[0] . "." . $item_ar[1];
if($item_section == $section_num) {
echo "<li id='$item_num'><span>$item_num </span><a href='/$item_num'>".preventOrphans($item)."</a></li>\n";
}
}
echo "</ol>\n</li>\n";
}
}
echo "</ol>\n</li>\n";
}
?>
<li><h3>Reference</h3>
<ol id="reference">
<li><a href="/bibliography/">Bibliography</a></li>
</ol>
</li>
</ol>
</div> <!-- /main -->
<div id="supp">
<h3>Note</h3>
<p>This is a work in progress. The entire site is now open source, so please feel free to contribute by <a href="https://github.com/clagnut/webtypography">forking it on GitHub</a>.</p>
</p>
</div> <!-- /supp -->
<?php include($dr . "footer.inc.php") ?>
</body>
</html>