]> git.mxchange.org Git - friendica.git/blob - mod/help.php
make 'PHP "register_argc_argv"' easier to translate, may require fix for po2php
[friendica.git] / mod / help.php
1 <?php
2
3 if(! function_exists('load_doc_file')) {
4 function load_doc_file($s) {
5         global $lang;
6         if(! isset($lang))
7                 $lang = 'en';
8         $b = basename($s);
9         $d = dirname($s);
10         if(file_exists("$d/$lang/$b"))
11                 return file_get_contents("$d/$lang/$b");
12         if(file_exists($s))
13                 return file_get_contents($s);
14         return '';
15 }}
16
17
18
19 function help_content(&$a) {
20         nav_set_selected('help');
21
22         global $lang;
23
24         require_once('library/markdown.php');
25
26         $text = '';
27
28         if($a->argc > 1) {
29                 $text = load_doc_file('doc/' . $a->argv[1] . '.md');
30                 $a->page['title'] = t('Help:') . ' ' . str_replace('-',' ',notags($a->argv[1]));
31         }
32         if(! $text) {
33                 $text = load_doc_file('doc/Home.md');
34                 $a->page['title'] = t('Help');
35         }
36         
37         if(! strlen($text)) {
38                 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
39                 $tpl = get_markup_template("404.tpl");
40                 return replace_macros($tpl, array(
41                         '$message' =>  t('Page not found.' )
42                 ));
43         }
44         
45         return Markdown($text);
46
47 }