"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(!isset($_GET["tag"]))
{
// Render a list of all tags
$all_tags = [];
foreach($pageindex as $entry)
{
if(!isset($entry->tags)) continue;
foreach($entry->tags as $tag)
{
if(!in_array($tag, $all_tags)) $all_tags[] = $tag;
}
}
$content = "
\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)
{
// Construct a list of tags that are attached to this page ready for display
$tags = "";
// Make sure that this page does actually have some tags first
if(isset($pageindex->$pagename->tags))
{
foreach($pageindex->$pagename->tags as $tag)
{
$tags .= "$tag, ";
}
$tags = substr($tags, 0, -2); // Remove the last ", " from the tag list
}
$result .= "