1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-14 01:43:01 +00:00
Pepperminty-Wiki/modules/page-help.php

81 lines
4 KiB
PHP
Raw Normal View History

2015-09-19 09:19:56 +00:00
<?php
register_module([
"name" => "Help page",
2016-04-09 07:14:55 +00:00
"version" => "0.9.2",
2015-09-19 09:19:56 +00:00
"author" => "Starbeamrainbowlabs",
2016-03-19 18:41:22 +00:00
"description" => "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.",
2015-09-19 09:19:56 +00:00
"id" => "page-help",
"code" => function() {
global $settings;
/*
* ██ ██ ███████ ██ ██████
* ██ ██ ██ ██ ██ ██
* ███████ █████ ██ ██████
* ██ ██ ██ ██ ██
* ██ ██ ███████ ███████ ██
*/
2015-09-19 09:19:56 +00:00
add_action("help", function() {
2016-04-09 07:14:55 +00:00
global $paths, $settings, $version, $help_sections, $actions;
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>
2016-03-19 18:41:22 +00:00
<h3>Registered Help Sections</h3>
2015-12-21 14:35:27 +00:00
<p>The following help sections are currently registered:</p>
<table><tr><th>Index</th><th>Title</th><th>Length</th></tr>\n";
$totalSize = 0;
2015-12-21 14:35:27 +00:00
foreach($help_sections as $index => $section)
{
$sectionLength = strlen($section["content"]);
$totalSize += $sectionLength;
$content .= "\t\t\t<tr><td>$index</td><td>" . $section["title"] . "</td><td>" . human_filesize($sectionLength) . "</td></tr>\n";
2015-12-21 14:35:27 +00:00
}
$content .= "\t\t\t<tr><th colspan='2' style='text-align: right;'>Total:</th><td>" . human_filesize($totalSize) . "</td></tr>\n";
2016-03-19 18:41:22 +00:00
$content .= "\t\t</table>\n";
$content .= "<h3>Registered Actions</h3>
<p>The following actions are currently registered:</p>\n";
$content .= "<p>" . implode(", ", array_keys(get_object_vars($actions))) . "</p>";
$content .= "<h3>Environment</h3>\n";
$content .= "<p>$settings->sitename's root directory is " . (!is_writeable(__DIR__) ? "not " : "") . "writeable.</p>";
2016-04-09 07:14:55 +00:00
$content .= "<p>The page index is currently " . human_filesize(filesize($paths->pageindex)) . " in size.</p>";
2015-12-21 14:35:27 +00:00
}
2015-12-21 14:39:56 +00:00
else
{
$title = "Help - $settings->sitename";
$content = " <h1>$settings->sitename Help</h1>
<p>Welcome to $settings->sitename!</p>
<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
2016-04-09 07:14:55 +00:00
// Todo Insert a table of contents here?
2015-12-21 14:39:56 +00:00
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' class='help-section-header'>" . $section["title"] . "</h2>\n";
2015-12-21 14:39:56 +00:00
$content .= $section["content"] . "\n";
}
}
2015-09-19 09:19:56 +00:00
exit(page_renderer::render_main($title, $content));
});
// 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 &quot;More...&quot; menu in the top right that contains some additional links that you may fine useful.</p>
<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
}
]);
?>