2 rcs_id('$Id: removepage.php,v 1.22 2004-11-16 17:22:45 rurban Exp $');
3 require_once('lib/Template.php');
5 function RemovePage (&$request) {
8 $page = $request->getPage();
9 $pagelink = WikiLink($page);
11 if ($request->getArg('cancel')) {
12 $request->redirect(WikiURL($page)); // noreturn
15 $current = $page->getCurrentRevision();
16 $version = $current->getVersion();
19 $html = HTML(HTML::h2(_("Already deleted")),
20 HTML::p(_("Sorry, this page is not in the database.")));
22 elseif (!$request->isPost() || !$request->getArg('verify')) {
24 $removeB = Button('submit:verify', _("Remove Page"), 'wikiadmin');
25 $cancelB = Button('submit:cancel', _("Cancel"), 'button'); // use generic wiki button look
26 $sample = firstNWordsOfContent(100, $current->getPackedContent());
28 $html = HTML(HTML::h2(fmt("You are about to remove '%s' permanently!", $pagelink)),
29 HTML::form(array('method' => 'post',
30 'action' => $request->getPostURL()),
31 HiddenInputs(array('currentversion' => $version,
32 'pagename' => $page->getName(),
33 'action' => 'remove')),
35 HTML::div(array('class' => 'toolbar'),
37 $WikiTheme->getButtonSeparator(),
40 HTML::div(array('class' => 'transclusion'), $sample)
43 elseif ($request->getArg('currentversion') != $version) {
44 $html = HTML(HTML::h2(_("Someone has edited the page!")),
45 HTML::p(fmt("Since you started the deletion process, someone has saved a new version of %s. Please check to make sure you still want to permanently remove the page from the database.", $pagelink)));
49 $pagename = $page->getName();
50 $dbi = $request->getDbh();
51 $dbi->deletePage($pagename);
53 $link = HTML::a(array('href' => 'javascript:history.go(-2)'),
54 _("Back to the previous page."));
55 $html = HTML(HTML::h2(fmt("Removed page '%s' successfully.", $pagename)),
56 HTML::div($link), HTML::hr());
59 GeneratePage($html, _("Remove page"));
68 // c-hanging-comment-ender-p: nil
69 // indent-tabs-mode: nil