]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/removepage.php
link back 3 pages before. already deleted check
[SourceForge/phpwiki.git] / lib / removepage.php
1 <?php
2 rcs_id('$Id: removepage.php,v 1.21 2004-09-23 18:50:55 rurban Exp $');
3 require_once('lib/Template.php');
4
5 function RemovePage (&$request) {
6     global $WikiTheme;
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 (!$version) {
19         $html = HTML(HTML::h2(_("Already deleted")),
20                      HTML::p(_("Sorry, this page is not in the database.")));
21     }
22     elseif (!$request->isPost() || !$request->getArg('verify')) {
23
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());
27
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')),
34                                 
35                                 HTML::div(array('class' => 'toolbar'),
36                                           $removeB,
37                                           $WikiTheme->getButtonSeparator(),
38                                           $cancelB)),
39                      HTML::hr(),
40                      HTML::div(array('class' => 'transclusion'), $sample)
41                      );
42     }
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)));
46     }
47     else {
48         // Real delete.
49         $pagename = $page->getName();
50         $dbi = $request->getDbh();
51         $dbi->deletePage($pagename);
52         $dbi->touch();
53         $link = HTML::a(array('href' => 'javascript:history.go(-3)'), 
54                         _("Back to the previous page."));
55         $html = HTML(HTML::h2(fmt("Removed page '%s' successfully.", $pagename)),
56                      HTML::div($link), HTML::hr());
57     }
58
59     GeneratePage($html, _("Remove page"));
60 }
61
62
63 // For emacs users
64 // Local Variables:
65 // mode: php
66 // tab-width: 8
67 // c-basic-offset: 4
68 // c-hanging-comment-ender-p: nil
69 // indent-tabs-mode: nil
70 // End:
71 ?>