php8
[web.mtrack] / MTrackWeb / Help.php
1 <?php # vim:ts=2:sw=2:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
3
4 require_once 'MTrackWeb.php';
5 class MTrackWeb_Help extends MTrackWeb
6 {
7     var $template = 'help.html';
8     function get($topic)
9     {
10         $helpdir = dirname(__FILE__) . '/../defaults/help';
11         if (strpos($topic, '.') !== false) {
12             throw new Exception("invalid help topic");
13         }
14         $name = $helpdir . '/' . $topic;
15
16         if (empty($topic)) {
17             $this->title = "Help topics";
18             $this->topics = array();
19             foreach (glob("$helpdir/*") as $topic) {
20                 $topic = basename($topic);
21                 $this->topics[] = $topic;
22                 
23             } 
24             return;
25         }
26         if (!file_exists($name)) {
27             $this->title = "no help topic $topic";
28             $this->no_topic = $topic;
29             return;
30         }
31         
32         $this->body = MTrack_Wiki::format_to_html(file_get_contents($name));
33     }
34 }
35