2 require_once('library/markdown.php');
4 if (!function_exists('load_doc_file')) {
6 function load_doc_file($s) {
12 if (file_exists("$d/$lang/$b"))
13 return file_get_contents("$d/$lang/$b");
15 return file_get_contents($s);
21 if(! function_exists('help_content')) {
22 function help_content(&$a) {
24 nav_set_selected('help');
32 // looping through the argv keys bigger than 0 to build
33 // a path relative to /help
34 for($x = 1; $x < argc(); $x ++) {
39 $title = basename($path);
41 $text = load_doc_file('doc/' . $path . '.md');
42 $a->page['title'] = t('Help:') . ' ' . str_replace('-', ' ', notags($title));
44 $home = load_doc_file('doc/Home.md');
48 $a->page['title'] = t('Help');
50 $a->page['aside'] = Markdown($home);
54 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
55 $tpl = get_markup_template("404.tpl");
56 return replace_macros($tpl, array(
57 '$message' => t('Page not found.')
61 $html = Markdown($text);
63 if ($filename !== "Home") {
64 // create TOC but not for home
65 $lines = explode("\n", $html);
66 $toc="<style>aside ul {padding-left: 1em;}</style><h2>TOC</h2><ul id='toc'>";
68 $idnum = array(0,0,0,0,0,0,0);
69 foreach($lines as &$line){
70 if (substr($line,0,2)=="<h") {
71 $level = substr($line,2,1);
73 $level = intval($level);
74 if ($level<$lastlevel) {
75 for($k=$level;$k<$lastlevel; $k++) $toc.="</ul>";
76 for($k=$level+1;$k<count($idnum);$k++) $idnum[$k]=0;
78 if ($level>$lastlevel) $toc.="<ul>";
80 $id = implode("_", array_slice($idnum,1,$level));
81 $href = $a->get_baseurl()."/help/{$filename}#{$id}";
82 $toc .= "<li><a href='{$href}'>".strip_tags($line)."</a></li>";
83 $line = "<a name='{$id}'></a>".$line;
88 for($k=1;$k<$lastlevel; $k++) $toc.="</ul>";
89 $html = implode("\n",$lines);
91 $a->page['aside'] = $toc.$a->page['aside'];
97 padding: 1em; border: #ff0000 solid 2px;
98 background-color: #f9a3a3; color: #ffffff;