import
[web.mtrack] / web / help.php
1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
3
4 include '../inc/common.php';
5
6 $topic = mtrack_get_pathinfo();
7 $helpdir = dirname(__FILE__) . '/../defaults/help';
8 if (strpos($topic, '.') !== false) {
9   throw new Exception("invalid help topic");
10 }
11 $name = $helpdir . '/' . $topic;
12
13 if (!strlen($topic)) {
14   mtrack_head("Help topics");
15
16   echo "<h1>Help topics</h1>";
17   echo "<ul>\n";
18   foreach (glob("$helpdir/*") as $topic) {
19     $topic = basename($topic);
20     echo "<li><a href='{$ABSWEB}help.php/$topic'>$topic</a></li>\n";
21   }
22   echo "</ul>\n";
23
24 } elseif (!file_exists($name)) {
25   mtrack_head("no help topic $topic");
26
27   echo "<h1>No Help topic ", htmlentities($topic), "</h1>";
28 } else {
29   mtrack_head("Help: $topic");
30   echo MTrackWiki::format_to_html(file_get_contents($name));
31 }
32
33 mtrack_foot();