-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtutorials.php
51 lines (43 loc) · 1.34 KB
/
tutorials.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
<?php
function formatFileName($fileName) {
// File names are structured as follows:
// TUTORIAL_NUMBER NAME_WITH_SPACES.txt
// Example: 1 Getting Started.txt
$withoutNumber = trim(str_replace(range(0,9),'',$fileName));
$fileName = explode(".", $withoutNumber);
return $fileName[0];
}
$fileNames = array();
if ($handle = opendir('tutorials'))
while ($entry = readdir($handle))
if (! in_array($entry, array('..','.')))
$fileNames[] = $entry;
?>
<!DOCTYPE html>
<html lang="en">
<?php include('head.php') ?>
<body>
<?php $tutorials = true ?>
<?php include('navbar.php') ?>
<div class="container">
<h1>Tutorials</h1>
<h3>Contents</h3>
<ul>
<?php foreach ($fileNames as $tutorialNumber => $fileName): ?>
<li>
<a href="#tutorial-<?php echo $tutorialNumber ?>">
<?php echo formatFileName($fileName) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php foreach ($fileNames as $tutorialNumber => $fileName): ?>
<section data-markdown id="tutorial-<?php echo $tutorialNumber ?>">
<?php echo file_get_contents("tutorials/$fileName") ?>
</section>
<?php endforeach; ?>
</div>
<?php include('footer.php') ?>
<?php include('javascript.php') ?>
</body>
</html>