"Page list", "version" => "0.10.4", "author" => "Starbeamrainbowlabs", "description" => "Adds a page that lists all the pages in the index along with their metadata.", "id" => "page-list", "code" => function() { global $settings; /** * @api {get} ?action=list List all pages * @apiDescription Gets a list of all the pages currently stored on the wiki. * @apiName ListPages * @apiGroup Page * @apiPermission Anonymous */ /* * ██ ██ ███████ ████████ * ██ ██ ██ ██ * ██ ██ ███████ ██ * ██ ██ ██ ██ * ███████ ██ ███████ ██ */ add_action("list", function() { global $pageindex, $settings; $title = "All Pages"; $content = "
(All tags)
\n"; exit(page_renderer::render("$tag - Tag List - $settings->sitename", $content)); }); statistic_add([ "id" => "tag-count", "name" => "Number of Tags", "type" => "scalar", "update" => function($old_data) { global $pageindex; $all_tags = []; foreach($pageindex as $page_entry) { if(empty($page_entry->tags)) continue; foreach($page_entry->tags as $tag) { if(!in_array($tag, $all_tags)) $all_tags[] = $tag; } } $result = new stdClass(); // value, state, completed $result->value = count($all_tags); $result->completed = true; return $result; } ]); statistic_add([ "id" => "tags-per-page", "name" => "Average Number of Tags per Page", "type" => "scalar", "update" => function($old_data) { global $pageindex; $tag_counts = []; foreach($pageindex as $page_entry) $tag_counts[] = count($page_entry->tags ?? []); $result = new stdClass(); // value, state, completed $result->value = round(array_sum($tag_counts) / count($tag_counts), 3); $result->completed = true; return $result; } ]); statistic_add([ "id" => "most-tags", "name" => "Most tags on a single page", "type" => "scalar", "update" => function($old_data) { global $pageindex; $highest_tag_count = 0; $highest_tag_page = ""; foreach($pageindex as $pagename => $page_entry) { if(count($page_entry->tags ?? []) > $highest_tag_count) { $highest_tag_count = count($page_entry->tags ?? []); $highest_tag_page = $pagename; } } $result = new stdClass(); // value, state, completed $result->value = "$highest_tag_count (" . htmlentities($highest_tag_page) . ")"; $result->completed = true; return $result; } ]); statistic_add([ "id" => "untagged-pages", "name" => "Untagged Pages", "type" => "page-list", "update" => function($old_data) { global $pageindex; $untagged_pages = []; foreach($pageindex as $pagename => $page_entry) { if(empty($page_entry->tags) || count($page_entry->tags ?? []) == 0) $untagged_pages[] = $pagename; } sort($untagged_pages, SORT_STRING | SORT_FLAG_CASE); $result = new stdClass(); // value, state, completed $result->value = $untagged_pages; $result->completed = true; return $result; } ]); add_help_section("30-all-pages-tags", "Listing pages and tags", "All the pages and tags on $settings->sitename are listed on a pair of pages to aid navigation. The list of all pages on $settings->sitename can be found by clicking "All Pages" on the top bar. The list of all the tags currently in use can be found by clicking "All Tags" in the "More..." menu in the top right.
Each tag on either page can be clicked, and leads to a list of all pages that possess that particular tag.
Redirect pages are shown in italics. A page's last known editor is also shown next to each entry on a list of pages, along with the last known size (which should correct, unless it was changed outside of $settings->sitename) and the time since the last modification (hovering over this will show the exact time that the last modification was made in a tooltip).
"); } ]); /** * Renders a list of pages as HTML. * @package page-list * @param string[] $pagelist A list of page names to include in the list. * @return string The specified list of pages as HTML. */ function generate_page_list($pagelist) { global $pageindex; // ✎ ✎ 🕒 🕒 $result = "