From 1f190da2df88cf16caad5fe7f82ea9437c78ff9f Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Sat, 28 Apr 2018 11:06:23 +0100
Subject: [PATCH] Make orphan pages list use page-list statistic type Also add
 count to page-list

---
 build/index.php              | 17 +++--------------
 module_index.json            |  4 ++--
 modules/feature-stats.php    |  1 +
 modules/parser-parsedown.php | 14 +-------------
 4 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/build/index.php b/build/index.php
index e542829..5bd98fc 100644
--- a/build/index.php
+++ b/build/index.php
@@ -387,7 +387,7 @@ if($settings->css === "auto")
 /////////////////////////////////////////////////////////////////////////////
 /** The version of Pepperminty Wiki currently running. */
 $version = "v0.16-dev";
-$commit = "de61612b18b88b9a2e91d1bc7b85438221d88762";
+$commit = "72825f87552618c6a7bd99507d3b588652eea1f6";
 /// Environment ///
 /** Holds information about the current request environment. */
 $env = new stdClass();
@@ -4685,6 +4685,7 @@ register_module([
 							$content .= "<p>$settings->sitename doesn't current have the page listing module installed, so HTML rendering of this statistic is currently unavailable. Try <a href='mailto:" . hide_email($settings->admindetails_email) . "'>contacting $settings->admindetails_name</a>, $settings->sitename's administrator and asking then to install the <code>page-list</code> module.</p>";
 							break;
 						}
+						$content .= "<p><strong>Count:</strong> " . count($stats->{$_GET["stat"]}->value) . "</p>\n";
 						$content .= generate_page_list($stats->{$_GET["stat"]}->value);
 						break;
 					
@@ -8034,7 +8035,7 @@ register_module([
 		statistic_add([
 			"id" => "orphan-pages",
 			"name" => "Orphan Pages",
-			"type" => "page",
+			"type" => "page-list",
 			"update" => function($old_stats) {
 				global $pageindex, $env;
 				
@@ -8066,18 +8067,6 @@ register_module([
 				$result->value = $orphaned_pages;
 				$result->completed = true;
 				return $result;
-			},
-			"render" => function($stats_data) {
-				global $pageindex;
-				$result = "<h2>$stats_data->name</h2>\n";
-				$result .= "<p><strong>Count:</strong> " . count($stats_data->value) . "</p>\n";
-				$result .= "<ul class='orphan-pages'>\n";
-				foreach($stats_data->value as $pagename) {
-					$pagename_display = !empty($pageindex->$pagename->redirect) && $pageindex->$pagename->redirect ? "<em>$pagename</em>" : $pagename;
-					$result .= "\t<li><a href='?page=" . rawurlencode($pagename) . "'>$pagename_display</a></li>\n";
-				}
-				$result .= "</ul>\n";
-				return $result;
 			}
 		]);
 		statistic_add([
diff --git a/module_index.json b/module_index.json
index bbc6a2d..1c7def9 100755
--- a/module_index.json
+++ b/module_index.json
@@ -113,7 +113,7 @@
         "author": "Starbeamrainbowlabs",
         "description": "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.",
         "id": "feature-stats",
-        "lastupdate": 1524781183,
+        "lastupdate": 1524909895,
         "optional": false
     },
     {
@@ -266,7 +266,7 @@
         "author": "Emanuil Rusev & Starbeamrainbowlabs",
         "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
         "id": "parser-parsedown",
-        "lastupdate": 1524909661,
+        "lastupdate": 1524909840,
         "optional": false
     }
 ]
\ No newline at end of file
diff --git a/modules/feature-stats.php b/modules/feature-stats.php
index b834e76..ecfffe9 100644
--- a/modules/feature-stats.php
+++ b/modules/feature-stats.php
@@ -61,6 +61,7 @@ register_module([
 							$content .= "<p>$settings->sitename doesn't current have the page listing module installed, so HTML rendering of this statistic is currently unavailable. Try <a href='mailto:" . hide_email($settings->admindetails_email) . "'>contacting $settings->admindetails_name</a>, $settings->sitename's administrator and asking then to install the <code>page-list</code> module.</p>";
 							break;
 						}
+						$content .= "<p><strong>Count:</strong> " . count($stats->{$_GET["stat"]}->value) . "</p>\n";
 						$content .= generate_page_list($stats->{$_GET["stat"]}->value);
 						break;
 					
diff --git a/modules/parser-parsedown.php b/modules/parser-parsedown.php
index a954ec1..43a82b8 100644
--- a/modules/parser-parsedown.php
+++ b/modules/parser-parsedown.php
@@ -74,7 +74,7 @@ register_module([
 		statistic_add([
 			"id" => "orphan-pages",
 			"name" => "Orphan Pages",
-			"type" => "page",
+			"type" => "page-list",
 			"update" => function($old_stats) {
 				global $pageindex, $env;
 				
@@ -106,18 +106,6 @@ register_module([
 				$result->value = $orphaned_pages;
 				$result->completed = true;
 				return $result;
-			},
-			"render" => function($stats_data) {
-				global $pageindex;
-				$result = "<h2>$stats_data->name</h2>\n";
-				$result .= "<p><strong>Count:</strong> " . count($stats_data->value) . "</p>\n";
-				$result .= "<ul class='orphan-pages'>\n";
-				foreach($stats_data->value as $pagename) {
-					$pagename_display = !empty($pageindex->$pagename->redirect) && $pageindex->$pagename->redirect ? "<em>$pagename</em>" : $pagename;
-					$result .= "\t<li><a href='?page=" . rawurlencode($pagename) . "'>$pagename_display</a></li>\n";
-				}
-				$result .= "</ul>\n";
-				return $result;
 			}
 		]);
 		statistic_add([
