diff --git a/ext/wiki/main.php b/ext/wiki/main.php index ec375c28..496f1499 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -198,6 +198,9 @@ class Wiki extends Extension } else { $this->theme->display_permission_denied(); } + } elseif ($event->page_matches("wiki_admin/history")) { + $history = $this->get_history($_GET['title']); + $this->theme->display_page_history($page, $_GET['title'], $history); } elseif ($event->page_matches("wiki_admin/delete_revision")) { if ($user->can(Permissions::WIKI_ADMIN)) { send_event(new WikiDeleteRevisionEvent($_POST["title"], (int)$_POST["revision"])); @@ -301,6 +304,20 @@ class Wiki extends Extension return false; } + public static function get_history(string $title): array + { + global $database; + // first try and get the actual page + return $database->get_all( + " + SELECT revision, date + FROM wiki_pages + WHERE LOWER(title) LIKE LOWER(:title) + ORDER BY revision DESC + ", + ["title"=>$title] + ); + } public static function get_page(string $title, int $revision=-1): WikiPage { global $database; diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index c635face..dbef45ed 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -42,6 +42,20 @@ class WikiTheme extends Themelet $page->add_block(new Block($title_html, $this->create_display_html($wiki_page))); } + public function display_page_history(Page $page, string $title, array $history) + { + $html = ""; + foreach ($history as $row) { + $rev = $row['revision']; + $html .= ""; + } + $html .= "
{$rev}{$row['date']}
"; + $page->set_title(html_escape($title)); + $page->set_heading(html_escape($title)); + $page->add_block(new NavBlock()); + $page->add_block(new Block(html_escape($title), $html)); + } + public function display_page_editor(Page $page, WikiPage $wiki_page) { $page->set_title(html_escape($wiki_page->title)); @@ -111,7 +125,7 @@ class WikiTheme extends Themelet $formatted_body