2015-09-19 09:19:56 +00:00
|
|
|
<?php
|
|
|
|
register_module([
|
|
|
|
"name" => "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;
|
|
|
|
|
2015-10-25 15:45:25 +00:00
|
|
|
$title = "All Pages";
|
|
|
|
$content = " <h1>$title on $settings->sitename</h1>";
|
|
|
|
|
2015-09-19 09:19:56 +00:00
|
|
|
$sorted_pageindex = get_object_vars($pageindex);
|
|
|
|
ksort($sorted_pageindex, SORT_NATURAL);
|
2015-10-25 15:45:25 +00:00
|
|
|
|
|
|
|
$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;
|
|
|
|
|
2015-11-09 07:37:38 +00:00
|
|
|
if(!isset($_GET["tag"]))
|
2015-10-25 15:45:25 +00:00
|
|
|
{
|
2015-11-09 07:37:38 +00:00
|
|
|
// 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 = "<h1>All tags</h1>
|
|
|
|
<ul>\n";
|
|
|
|
foreach($all_tags as $tag)
|
|
|
|
{
|
|
|
|
$content .= " <li><a href='?action=list_tags&tag=" . rawurlencode($tag) . "'>$tag</a></li>\n";
|
|
|
|
}
|
|
|
|
$content .= "</ul>";
|
|
|
|
|
|
|
|
exit(page_renderer::render("All tags - $settings->sitename", $content));
|
2015-10-25 15:45:25 +00:00
|
|
|
}
|
|
|
|
$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 = "<h1>$tag</h1>\n";
|
|
|
|
$content .= generate_page_list($pagelist);
|
|
|
|
|
|
|
|
exit(page_renderer::render("$tag - Page List - $settings->sitename", $content));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
function generate_page_list($pagelist)
|
|
|
|
{
|
|
|
|
global $pageindex;
|
|
|
|
|
|
|
|
$result = "<table>
|
2015-09-19 09:19:56 +00:00
|
|
|
<tr>
|
|
|
|
<th>Page Name</th>
|
|
|
|
<th>Size</th>
|
|
|
|
<th>Last Editor</th>
|
|
|
|
<th>Last Edit Time</th>
|
|
|
|
</tr>\n";
|
2015-10-25 15:45:25 +00:00
|
|
|
foreach($pagelist as $pagename)
|
|
|
|
{
|
|
|
|
$result .= "\t\t<tr>
|
2015-09-19 09:19:56 +00:00
|
|
|
<td><a href='index.php?page=$pagename'>$pagename</a></td>
|
2015-10-25 15:45:25 +00:00
|
|
|
<td>" . human_filesize($pageindex->$pagename->size) . "</td>
|
|
|
|
<td>" . $pageindex->$pagename->lasteditor . "</td>
|
|
|
|
<td>" . human_time_since($pageindex->$pagename->lastmodified) . " <small>(" . date("l jS \of F Y \a\\t h:ia T", $pageindex->$pagename->lastmodified) . ")</small></td>
|
|
|
|
|
|
|
|
</tr>\n";
|
2015-09-19 09:19:56 +00:00
|
|
|
}
|
2015-10-25 15:45:25 +00:00
|
|
|
$result .= " </table>";
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
2015-09-19 09:19:56 +00:00
|
|
|
|
|
|
|
?>
|