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); 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("Content", $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 can_edit(User $user, WikiPage $page) {
global $config;
if(!is_null($page) && $page->is_locked() && !$user->is_admin()) return false;
if($config->get_bool("wiki_edit_anon", false) && $user->is_anonymous()) return true;
if($config->get_bool("wiki_edit_user", false) && !$user->is_anonymous()) return true;
if($user->is_admin()) return true;
return false;
}
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 "