]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/removepage.php
Fix for SF bug #630700
[SourceForge/phpwiki.git] / lib / removepage.php
1 <?php
2 rcs_id('$Id: removepage.php,v 1.15 2003-02-22 21:15:54 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), false);
13         // The user probably doesn't see the rest of this.
14         $html = HTML(HTML::h2(_("Request Cancelled!")),
15                      HTML::p(fmt("Return to %s.", $pagelink)));
16     }
17
18     $current = $page->getCurrentRevision();
19     $version = $current->getVersion();
20
21     if (!$request->isPost() || !$request->getArg('verify')) {
22
23         // FIXME: button should be class wikiadmin
24         $removeB = Button('submit:verify', _("Remove the page now"), 'wikiadmin');
25         $cancelB = Button('submit:cancel', _("Cancel"), 'button'); // use generic wiki button look
26
27         $html = HTML(HTML::h2(fmt("You are about to remove '%s' permanently!", $pagelink)),
28                      HTML::form(array('method' => 'post',
29                                       'action' => $request->getPostURL()),
30                                 HiddenInputs(array('currentversion' => $version,
31                                                    'pagename' => $page->getName(),
32                                                    'action' => 'remove')),
33                                 
34                                 HTML::div(array('class' => 'toolbar'),
35                                           $removeB,
36                                           $Theme->getButtonSeparator(),
37                                           $cancelB)));
38     }
39     elseif ($request->getArg('currentversion') != $version) {
40         $html = HTML(HTML::h2(_("Someone has edited the page!")),
41                      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)));
42     }
43     else {
44         // Real delete.
45         $pagename = $page->getName();
46         $dbi = $request->getDbh();
47         $dbi->deletePage($pagename);
48         $dbi->touch();
49         $html = HTML(HTML::h2(fmt("Removed page '%s' succesfully.", $pagename)));
50     }
51
52     GeneratePage($html, _("Remove page"));
53 }
54
55
56 // For emacs users
57 // Local Variables:
58 // mode: php
59 // tab-width: 8
60 // c-basic-offset: 4
61 // c-hanging-comment-ender-p: nil
62 // indent-tabs-mode: nil
63 // End:
64 ?>