diff --git a/core.php b/core.php
index 8c1851a..7d2720b 100644
--- a/core.php
+++ b/core.php
@@ -77,20 +77,19 @@ function get_subpages($pageindex, $pagename)
$result = new stdClass();
$stem = "$pagename/";
- $stem_length = stelen($stem);
- foreach($pagenames as $entry)
+ $stem_length = strlen($stem);
+ foreach($pagenames as $entry => $value)
{
if(substr($entry, 0, $stem_length) == $stem)
{
// We found a subpage
// Extract the subpage's key relative to the page that we are searching for
- $subpage_relative_key = substr($item, $stem_length, -3);
+ $subpage_relative_key = substr($entry, $stem_length, -3);
// Calculate how many times removed the current subpage is from the current page. 0 = direct descendant.
$times_removed = substr_count($subpage_relative_key, "/");
- $subpage_full_key = substr($item, 0, -3);
// Store the name of the subpage we found
- $result->$subpage_full_key = $times_removed;
+ $result->$entry = $times_removed;
}
}
@@ -282,6 +281,7 @@ class page_renderer
public static $main_content_template = "{navigation-bar}
{sitename}
{content}
+
Powered by Pepperminty Wiki, which was built by Starbeamrainbowlabs . Send bugs to 'bugs at starbeamrainbowlabs dot com' or open an issue on github .
Your local friendly administrators are {admins-name-list}.
diff --git a/index.php b/index.php
index 7abd049..e5ea2e9 100644
--- a/index.php
+++ b/index.php
@@ -54,6 +54,13 @@ $settings->defaultpage = "Main Page";
// automatically views the default page (see above).
$settings->defaultaction = "view";
+// Whether to show a list of subpages at the bottom of the page.
+$settings->show_subpages = true;
+
+// The depth to which we should display when listing subpages at the bottom of
+// the page.
+$settings->subpages_display_depth = 3;
+
// An array of usernames and passwords - passwords should be hashed with
// sha256. Put one user / password on each line, remembering the comma at the
// end. The last user in the list doesn't need a comma after their details though.
@@ -232,20 +239,19 @@ function get_subpages($pageindex, $pagename)
$result = new stdClass();
$stem = "$pagename/";
- $stem_length = stelen($stem);
- foreach($pagenames as $entry)
+ $stem_length = strlen($stem);
+ foreach($pagenames as $entry => $value)
{
if(substr($entry, 0, $stem_length) == $stem)
{
// We found a subpage
// Extract the subpage's key relative to the page that we are searching for
- $subpage_relative_key = substr($item, $stem_length, -3);
+ $subpage_relative_key = substr($entry, $stem_length, -3);
// Calculate how many times removed the current subpage is from the current page. 0 = direct descendant.
$times_removed = substr_count($subpage_relative_key, "/");
- $subpage_full_key = substr($item, 0, -3);
// Store the name of the subpage we found
- $result->$subpage_full_key = $times_removed;
+ $result->$entry = $times_removed;
}
}
@@ -437,6 +443,7 @@ class page_renderer
public static $main_content_template = "{navigation-bar}
{sitename}
{content}
+
Powered by Pepperminty Wiki, which was built by Starbeamrainbowlabs . Send bugs to 'bugs at starbeamrainbowlabs dot com' or open an issue on github .
Your local friendly administrators are {admins-name-list}.
@@ -694,7 +701,6 @@ register_module([
add_action("credits", function() {
global $settings, $version, $pageindex, $modules;
-
$credits = [
"Code" => [
"author" => "Starbeamrainbowlabs",
@@ -1269,7 +1275,7 @@ register_module([
register_module([
"name" => "Page viewer",
- "version" => "0.7",
+ "version" => "0.8",
"author" => "Starbeamrainbowlabs",
"description" => "Allows you to view pages. You should include this one.",
"id" => "page-view",
@@ -1284,7 +1290,7 @@ register_module([
if($settings->editing)
{
//editing is enabled, redirect to the editing page
- http_response_code(307); //temporary redirect
+ http_response_code(307); // Temporary redirect
header("location: index.php?action=edit&newpage=yes&page=" . rawurlencode($page));
exit();
}
@@ -1302,6 +1308,26 @@ register_module([
$content .= $parse_page_source(file_get_contents("$page.md"));
+ if($settings->show_subpages)
+ {
+ $subpages = get_object_vars(get_subpages($pageindex, $page));
+
+ if(count($subpages) > 0)
+ {
+ $content .= "
";
+ $content .= "Subpages: ";
+ foreach($subpages as $subpage => $times_removed)
+ {
+ if($times_removed <= $settings->subpages_display_depth)
+ {
+ $content .= "$subpage , ";
+ }
+ }
+ // Remove the last comma from the content
+ $content = substr($content, 0, -2);
+ }
+ }
+
$content .= "\n\t\t\n";
if(isset($_GET["printable"]) and $_GET["printable"] === "yes")
diff --git a/module_index.json b/module_index.json
index 9ddd71e..b9aecbd 100644
--- a/module_index.json
+++ b/module_index.json
@@ -13,7 +13,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds the credits page. You *must* have this module :D",
"id": "page-credits",
- "lastupdate": 1436886691
+ "lastupdate": 1436886734
},
{
"name": "Page deleter",
@@ -81,11 +81,11 @@
},
{
"name": "Page viewer",
- "version": "0.7",
+ "version": "0.8",
"author": "Starbeamrainbowlabs",
"description": "Allows you to view pages. You should include this one.",
"id": "page-view",
- "lastupdate": 1432719098
+ "lastupdate": 1436889549
},
{
"name": "Default Parser",
diff --git a/modules/page-credits.php b/modules/page-credits.php
index 85b809b..07980d8 100644
--- a/modules/page-credits.php
+++ b/modules/page-credits.php
@@ -9,7 +9,6 @@ register_module([
add_action("credits", function() {
global $settings, $version, $pageindex, $modules;
-
$credits = [
"Code" => [
"author" => "Starbeamrainbowlabs",
diff --git a/modules/page-view.php b/modules/page-view.php
index a060bf9..7d11d26 100644
--- a/modules/page-view.php
+++ b/modules/page-view.php
@@ -1,7 +1,7 @@
"Page viewer",
- "version" => "0.7",
+ "version" => "0.8",
"author" => "Starbeamrainbowlabs",
"description" => "Allows you to view pages. You should include this one.",
"id" => "page-view",
@@ -16,7 +16,7 @@ register_module([
if($settings->editing)
{
//editing is enabled, redirect to the editing page
- http_response_code(307); //temporary redirect
+ http_response_code(307); // Temporary redirect
header("location: index.php?action=edit&newpage=yes&page=" . rawurlencode($page));
exit();
}
@@ -34,6 +34,26 @@ register_module([
$content .= $parse_page_source(file_get_contents("$page.md"));
+ if($settings->show_subpages)
+ {
+ $subpages = get_object_vars(get_subpages($pageindex, $page));
+
+ if(count($subpages) > 0)
+ {
+ $content .= " ";
+ $content .= "Subpages: ";
+ foreach($subpages as $subpage => $times_removed)
+ {
+ if($times_removed <= $settings->subpages_display_depth)
+ {
+ $content .= "$subpage , ";
+ }
+ }
+ // Remove the last comma from the content
+ $content = substr($content, 0, -2);
+ }
+ }
+
$content .= "\n\t\t\n";
if(isset($_GET["printable"]) and $_GET["printable"] === "yes")
diff --git a/settings.fragment.php b/settings.fragment.php
index 3c9ce48..ab1fa76 100644
--- a/settings.fragment.php
+++ b/settings.fragment.php
@@ -51,6 +51,13 @@ $settings->defaultpage = "Main Page";
// automatically views the default page (see above).
$settings->defaultaction = "view";
+// Whether to show a list of subpages at the bottom of the page.
+$settings->show_subpages = true;
+
+// The depth to which we should display when listing subpages at the bottom of
+// the page.
+$settings->subpages_display_depth = 3;
+
// An array of usernames and passwords - passwords should be hashed with
// sha256. Put one user / password on each line, remembering the comma at the
// end. The last user in the list doesn't need a comma after their details though.
diff --git a/testcheck.php b/testcheck.php
deleted file mode 100644
index 32727b3..0000000
--- a/testcheck.php
+++ /dev/null
@@ -1,34 +0,0 @@
-filename = $parent_page_filename;
- $newentry->size = 0;
- $newentry->lastmodified = 0;
- $newentry->lasteditor = "none";
-
- }
-
- check_subpage_parents($parent_pagename);
-}
-
-check_subpage_parents("New Test\/New");
\ No newline at end of file