"Page list", "version" => "0.6", "author" => "Starbeamrainbowlabs", "description" => "Adds a page that lists all the pages in the index along with their metadata.", "id" => "page-list", "code" => function() { add_action("list", function() { global $pageindex, $settings; $title = "All Pages"; $content = "

$title on $settings->sitename

"; $sorted_pageindex = get_object_vars($pageindex); ksort($sorted_pageindex, SORT_NATURAL); $content .= generate_page_list(array_keys($sorted_pageindex)); exit(page_renderer::render_main("$title - $settings->sitename", $content)); }); add_action("list-tags", function() { global $pageindex, $settings; if(empty($_GET["tag"])) { http_response_code(301); header("location: ?action=list"); } $tag = $_GET["tag"]; $sorted_pageindex = get_object_vars($pageindex); ksort($sorted_pageindex, SORT_NATURAL); $pagelist = []; foreach($pageindex as $pagename => $pagedetails) { if(empty($pagedetails->tags)) continue; if(in_array($tag, $pagedetails->tags)) $pagelist[] = $pagename; } $content = "

$tag

\n"; $content .= generate_page_list($pagelist); exit(page_renderer::render("$tag - Page List - $settings->sitename", $content)); }); } ]); function generate_page_list($pagelist) { global $pageindex; $result = "\n"; foreach($pagelist as $pagename) { $result .= "\t\t\n"; } $result .= "
Page Name Size Last Editor Last Edit Time
$pagename " . human_filesize($pageindex->$pagename->size) . " " . $pageindex->$pagename->lasteditor . " " . human_time_since($pageindex->$pagename->lastmodified) . " (" . date("l jS \of F Y \a\\t h:ia T", $pageindex->$pagename->lastmodified) . ")
"; return $result; } ?>