diff options
Diffstat (limited to 'mod/help.php')
-rw-r--r-- | mod/help.php | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/mod/help.php b/mod/help.php index af05bd47c..81ecd6ba9 100644 --- a/mod/help.php +++ b/mod/help.php @@ -1,8 +1,19 @@ <?php +/** + * You can create local site resources in doc/Site.md and either link to doc/Home.md for the standard resources + * or use our include mechanism to include it on your local page. + * + * #include doc/Home.md; + * + * The syntax is somewhat strict. + * + */ + + if(! function_exists('load_doc_file')) { function load_doc_file($s) { - global $lang; + $lang = get_app()->language; if(! isset($lang)) $lang = 'en'; $b = basename($s); @@ -21,16 +32,36 @@ function help_content(&$a) { global $lang; + $doctype = 'markdown'; + require_once('library/markdown.php'); $text = ''; - if($a->argc > 1) { + if(argc() > 1) { $text = load_doc_file('doc/' . $a->argv[1] . '.md'); - $a->page['title'] = t('Help:') . ' ' . str_replace('-',' ',notags($a->argv[1])); + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags(argv(1)))); + } + if(! $text) { + $text = load_doc_file('doc/' . $a->argv[1] . '.bb'); + if($text) + $doctype = 'bbcode'; + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('_',' ',notags(argv(1)))); + } + if(! $text) { + $text = load_doc_file('doc/' . $a->argv[1] . '.html'); + if($text) + $doctype = 'html'; + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags(argv(1)))); + } + + if(! $text) { + $text = load_doc_file('doc/Site.md'); + $a->page['title'] = t('Help'); } if(! $text) { - $text = load_doc_file('doc/Home.md'); + $doctype = 'bbcode'; + $text = load_doc_file('doc/main.bb'); $a->page['title'] = t('Help'); } @@ -41,7 +72,29 @@ function help_content(&$a) { '$message' => t('Page not found.' ) )); } - - return Markdown($text); + + $text = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $text); + + if($doctype === 'html') + $content = $text; + if($doctype === 'markdown') + $content = Markdown($text); + if($doctype === 'bbcode') { + require_once('include/bbcode.php'); + $content = bbcode($text); + } + + return replace_macros(get_markup_template("help.tpl"), array( + '$content' => $content + )); } + + +function preg_callback_help_include($matches) { + + if($matches[1]) + return str_replace($matches[0],load_doc_file($matches[1]),$matches[0]); + +} + |