]> git.mxchange.org Git - friendica.git/blob - mod/help.php
Merge pull request #2094 from annando/1511-api
[friendica.git] / mod / help.php
1 <?php
2 require_once('library/markdown.php');
3
4 if (!function_exists('load_doc_file')) {
5
6         function load_doc_file($s) {
7                 global $lang;
8                 if (!isset($lang))
9                         $lang = 'en';
10                 $b = basename($s);
11                 $d = dirname($s);
12                 if (file_exists("$d/$lang/$b"))
13                         return file_get_contents("$d/$lang/$b");
14                 if (file_exists($s))
15                         return file_get_contents($s);
16                 return '';
17         }
18
19 }
20
21 function help_content(&$a) {
22
23         nav_set_selected('help');
24
25         global $lang;
26
27         $text = '';
28
29         if ($a->argc > 1) {
30                 $text = load_doc_file('doc/' . $a->argv[1] . '.md');
31                 $a->page['title'] = t('Help:') . ' ' . str_replace('-', ' ', notags($a->argv[1]));
32         }
33         $home = load_doc_file('doc/Home.md');
34         if (!$text) {
35                 $text = $home;
36                 $a->page['title'] = t('Help');
37         } else {
38                 $a->page['aside'] = Markdown($home);
39         }
40
41         if (!strlen($text)) {
42                 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
43                 $tpl = get_markup_template("404.tpl");
44                 return replace_macros($tpl, array(
45                                         '$message' => t('Page not found.')
46                                 ));
47         }
48
49         $html = Markdown($text);
50         $html = "<style>.md_warning { padding: 1em; border: #ff0000 solid 2px; background-color: #f9a3a3; color: #ffffff;</style>".$html;
51         return $html;
52
53 }