title and ->body * $nav_page = a wiki page object with navigation, has ->body */ public function display_page(Page $page, WikiPage $wiki_page, $nav_page) { // $nav_page = WikiPage or null if(is_null($nav_page)) { $nav_page = new WikiPage(); $nav_page->body = ""; } $tfe = new TextFormattingEvent($nav_page->body); send_event($tfe); // only the admin can edit the sidebar global $user; if($user->is_admin()) { $tfe->formatted .= "
(Edit)";
}
$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(html_escape($wiki_page->title), $this->create_display_html($wiki_page)));
}
public function display_page_editor(Page $page, WikiPage $wiki_page) {
$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) {
$h_title = html_escape($page->title);
$u_title = url_escape($page->title);
$i_revision = int_escape($page->revision) + 1;
global $user;
if($user->is_admin()) {
$val = $page->is_locked() ? " checked" : "";
$lock = "
Lock page: ";
}
else {
$lock = "";
}
return "
".make_form(make_link("wiki_admin/save"))."
$lock
";
}
protected function create_display_html(WikiPage $page) {
$owner = $page->get_owner();
$tfe = new TextFormattingEvent($page->body);
send_event($tfe);
global $user;
$edit = "
".make_form(make_link("wiki_admin/edit"))." | " : ""; if($user->is_admin()) { $edit .= "".make_form(make_link("wiki_admin/delete_revision"))." | ".make_form(make_link("wiki_admin/delete_all"))." | "; } $edit .= "