e = get_extension((int)safe_get("id")); if ($this->e == null) { $error = "bad parameters"; return; } $this->page = safe_get("page"); if (isset($_POST["submit"]) || isset($_POST["preview"]) || isset($_POST["diff"])) { $this->content = safe_post("content"); $this->summary = safe_post("summary"); if (isset($_POST["preview"])) $this->mode = modes::preview; else if (isset($_POST["diff"])) $this->mode = modes::diff; } } public function output() { $head = ""; $markup = ""; switch ($this->mode) { case modes::render: { $markup = wiki::markup($this->page); break; } case modes::preview: { $head = wiki::parse($this->content); $markup = $this->content; break; } case modes::diff: { $head = wiki::diff_content($this->page, $this->content); $markup = $this->content; break; } } $title = sprintf( loc("ext_history"), html::a("ext.html?id=" . $this->e->id(), $this->page)); echo " " . html::wrap_div("ext_editing_title", $title) . " $head
" . "" . "
" . loc("ext_edit_summary") . "
summary\" />
"; if ($this->summary != "") { $p = wiki::parse($this->summary); $p = preg_replace('/

(.*)<\/p>/s', "$1", $p); echo "

" . loc("ext_edit_summary_preview") . "
" . $p . "
" ; } echo " " . html::submit("save") . " " . html::submit("preview", "preview") . " " . html::submit("diff", "diff") . "
"; } public function go() { try { wiki::save($this->page, $this->content, $this->summary); return true; } catch(Exception $e) { return false; } } public function id() { return $this->e->id(); } } $e = new editor; if (isset($_POST["submit"])) { if ($e->go()) { header("Location: ext.html?id=" . $e->id()); exit; } } output_head("extensions", "baretorrent - extensions"); ?>
output(); ?>