2015-09-19 09:19:56 +00:00
< ? php
register_module ([
" name " => " Help page " ,
2016-03-19 18:28:27 +00:00
" version " => " 0.7.1 " ,
2015-09-19 09:19:56 +00:00
" author " => " Starbeamrainbowlabs " ,
" description " => " Adds the help action. You really want this one. " ,
" id " => " page-help " ,
" code " => function () {
2015-12-21 08:45:38 +00:00
global $settings ;
2015-12-26 12:55:19 +00:00
/*
* ██ ██ ███████ ██ ██████
* ██ ██ ██ ██ ██ ██
* ███████ █████ ██ ██████
* ██ ██ ██ ██ ██
* ██ ██ ███████ ███████ ██
*/
2015-09-19 09:19:56 +00:00
add_action ( " help " , function () {
2015-12-21 08:45:38 +00:00
global $settings , $version , $help_sections ;
2015-09-19 09:19:56 +00:00
2015-12-21 14:39:56 +00:00
// Sort the help sections by key
ksort ( $help_sections , SORT_NATURAL );
2015-12-21 14:35:27 +00:00
if ( isset ( $_GET [ " dev " ]) and $_GET [ " dev " ] == " yes " )
{
$title = " Developers Help - $settings->sitename " ;
$content = " <p> $settings->sitename runs on Pepperminty Wiki, an entire wiki packed into a single file. This page contains some information that developers may find useful.</p>
< p > A full guide to developing a Pepperminty Wiki module can be found < a href = '//github.com/sbrl/Pepperminty-Wiki/blob/master/Module_API_Docs.md#module-api-documentation' > on GitHub </ a >.</ p >
< p > The following help sections are currently registered :</ p >
< table >< tr >< th > Index </ th >< th > Title </ th >< th > Length </ th ></ tr > \n " ;
foreach ( $help_sections as $index => $section )
{
2015-12-21 14:39:56 +00:00
$content .= " \t \t \t <tr><td> $index </td><td> " . $section [ " title " ] . " </td><td> " . human_filesize ( strlen ( $section [ " content " ])) . " </td></tr> \n " ;
2015-12-21 14:35:27 +00:00
}
$content .= " \t \t </table> " ;
}
2015-12-21 14:39:56 +00:00
else
{
$title = " Help - $settings->sitename " ;
$content = " <h1> $settings->sitename Help</h1>
2015-12-21 08:45:38 +00:00
< p > Welcome to $settings -> sitename !</ p >
2016-03-19 18:28:27 +00:00
< p > $settings -> sitename is powered by Pepperminty Wiki , a complete wiki in a box you can drop into your server and expect it to just < em > work </ em >.</ p > " ;
2015-12-21 14:39:56 +00:00
// todo Insert a table of contents here?
foreach ( $help_sections as $index => $section )
{
// Todo add a button that you can click to get a permanent link
// to this section.
$content .= " <h2 id=' $index '> " . $section [ " title " ] . " </h2> \n " ;
$content .= $section [ " content " ] . " \n " ;
}
2015-12-21 08:45:38 +00:00
}
2015-09-19 09:19:56 +00:00
exit ( page_renderer :: render_main ( $title , $content ));
});
2015-12-21 08:45:38 +00:00
// Register a help section on general navigation
2015-12-21 14:35:27 +00:00
add_help_section ( " 5-navigation " , " Navigating " , " <p>All the navigation links can be found on the top bar, along with a search box (if your site administrator has enabled it). There is also a "More..." menu in the top right that contains some additional links that you may fine useful.</p>
2015-12-21 08:45:38 +00:00
< p > This page , along with the credits page , can be found on the bar at the bottom of every page .</ p > " );
2015-12-21 14:35:27 +00:00
add_help_section ( " 999-extra " , " Extra Information " , " <p>You can find out whch version of Pepperminty Wiki $settings->sitename is using by visiting the <a href='?action=credits'>credits</a> page.</p>
< p > Information for developers can be found on < a href = '?action=help&dev=yes' > this page </ a >.</ p > " );
2015-09-19 09:19:56 +00:00
}
]);
?>