]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/removepage.php
Force redirect. (The code for generating the text below the redirect
[SourceForge/phpwiki.git] / lib / removepage.php
1 <?php
2 rcs_id('$Id: removepage.php,v 1.16 2003-03-07 02:50:48 dairiki Exp $');
3 require_once('lib/Template.php');
4
5 function RemovePage (&$request) {
6     global $Theme;
7
8     $page = $request->getPage();
9     $pagelink = WikiLink($page);
10
11     if ($request->getArg('cancel')) {
12         $request->redirect(WikiURL($page)); // noreturn
13     }
14
15     $current = $page->getCurrentRevision();
16     $version = $current->getVersion();
17
18     if (!$request->isPost() || !$request->getArg('verify')) {
19
20         // FIXME: button should be class wikiadmin
21         $removeB = Button('submit:verify', _("Remove the page now"), 'wikiadmin');
22         $cancelB = Button('submit:cancel', _("Cancel"), 'button'); // use generic wiki button look
23
24         $html = HTML(HTML::h2(fmt("You are about to remove '%s' permanently!", $pagelink)),
25                      HTML::form(array('method' => 'post',
26                                       'action' => $request->getPostURL()),
27                                 HiddenInputs(array('currentversion' => $version,
28                                                    'pagename' => $page->getName(),
29                                                    'action' => 'remove')),
30                                 
31                                 HTML::div(array('class' => 'toolbar'),
32                                           $removeB,
33                                           $Theme->getButtonSeparator(),
34                                           $cancelB)));
35     }
36     elseif ($request->getArg('currentversion') != $version) {
37         $html = HTML(HTML::h2(_("Someone has edited the page!")),
38                      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)));
39     }
40     else {
41         // Real delete.
42         $pagename = $page->getName();
43         $dbi = $request->getDbh();
44         $dbi->deletePage($pagename);
45         $dbi->touch();
46         $html = HTML(HTML::h2(fmt("Removed page '%s' succesfully.", $pagename)));
47     }
48
49     GeneratePage($html, _("Remove page"));
50 }
51
52
53 // For emacs users
54 // Local Variables:
55 // mode: php
56 // tab-width: 8
57 // c-basic-offset: 4
58 // c-hanging-comment-ender-p: nil
59 // indent-tabs-mode: nil
60 // End:
61 ?>