title and ->body * $nav_page A wiki page object with navigation, has ->body */ public function display_page(Page $page, WikiPage $wiki_page, ?WikiPage $nav_page = null): void { global $user; if (is_null($nav_page)) { $nav_page = new WikiPage(); $nav_page->body = ""; } $tfe = send_event(new TextFormattingEvent($nav_page->body)); // only the admin can edit the sidebar if ($user->can(Permissions::WIKI_ADMIN)) { $tfe->formatted .= "
(Edit)";
}
// see if title is a category'd tag
$title_html = html_escape($wiki_page->title);
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
$tagcategories = new TagCategories();
$tag_category_dict = $tagcategories->getKeyedDict();
$title_html = $tagcategories->getTagHtml($title_html, $tag_category_dict);
}
if (!$wiki_page->exists) {
$page->set_code(404);
}
$page->set_title(html_escape($wiki_page->title));
$page->set_heading(html_escape($wiki_page->title));
$page->add_block(new NavBlock());
$page->add_block(new Block("Wiki Index", $tfe->formatted, "left", 20));
$page->add_block(new Block($title_html, $this->create_display_html($wiki_page)));
}
/**
* @param array";
foreach ($history as $row) {
$rev = $row['revision'];
$html .= "
";
$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): void
{
$page->set_title(html_escape($wiki_page->title));
$page->set_heading(html_escape($wiki_page->title));
$page->add_block(new NavBlock());
$page->add_block(new Block("Editor", $this->create_edit_html($wiki_page)));
}
protected function create_edit_html(WikiPage $page): string
{
$h_title = html_escape($page->title);
$i_revision = $page->revision + 1;
global $user;
if ($user->can(Permissions::WIKI_ADMIN)) {
$val = $page->is_locked() ? " checked" : "";
$lock = " ";
}
$html .= "{$rev} {$row['date']}
Lock page: ";
} else {
$lock = "";
}
return "
".make_form(make_link("wiki_admin/save"))."
$lock
";
}
protected function create_display_html(WikiPage $page): string
{
global $user;
$owner = $page->get_owner();
$formatted_body = Wiki::format_tag_wiki_page($page);
$edit = "
";
return "
";
$edit .= Wiki::can_edit($user, $page) ?
"
".make_form(make_link("wiki_admin/edit"))."
" :
"";
if ($user->can(Permissions::WIKI_ADMIN)) {
$edit .= "
".make_form(make_link("wiki_admin/delete_revision"))."
".make_form(make_link("wiki_admin/delete_all"))."
";
}
$edit .= "