]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/removepage.php
updated wording for new delete_page
[SourceForge/phpwiki.git] / lib / removepage.php
1 <?php
2 rcs_id('$Id: removepage.php,v 1.25 2004-12-09 22:10:54 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
17     if (!$current or !($version = $current->getVersion())) {
18         $html = HTML(HTML::h2(_("Already deleted")),
19                      HTML::p(_("Sorry, this page is not in the database.")));
20     }
21     elseif (!$request->isPost() || !$request->getArg('verify')) {
22
23         $removeB = Button('submit:verify', _("Remove Page"), 'wikiadmin');
24         $cancelB = Button('submit:cancel', _("Cancel"), 'button'); // use generic wiki button look
25
26         $html = HTML(HTML::h2(fmt("You are about to remove '%s'!", $pagelink)),
27                      HTML::form(array('method' => 'post',
28                                       'action' => $request->getPostURL()),
29                                 HiddenInputs(array('currentversion' => $version,
30                                                    'pagename' => $page->getName(),
31                                                    'action' => 'remove')),
32                                 
33                                 HTML::div(array('class' => 'toolbar'),
34                                           $removeB,
35                                           $WikiTheme->getButtonSeparator(),
36                                           $cancelB)),
37                      HTML::hr()
38                      );
39         $sample = HTML::div(array('class' => 'transclusion'));
40         // simple and fast preview expanding only newlines
41         foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
42             $sample->pushContent($s, HTML::br());
43         }
44         $html->pushContent(HTML::div(array('class' => 'wikitext'), 
45                                      $sample));
46     }
47     elseif ($request->getArg('currentversion') != $version) {
48         $html = HTML(HTML::h2(_("Someone has edited the page!")),
49                      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)));
50     }
51     else {
52         // Real delete.
53         $pagename = $page->getName();
54         $dbi = $request->getDbh();
55         $dbi->deletePage($pagename);
56         $dbi->touch();
57         $link = HTML::a(array('href' => 'javascript:history.go(-2)'), 
58                         _("Back to the previous page."));
59         $html = HTML(HTML::h2(fmt("Removed page '%s' successfully.", $pagename)),
60                      HTML::div($link), HTML::hr());
61     }
62
63     GeneratePage($html, _("Remove page"));
64 }
65
66
67 // For emacs users
68 // Local Variables:
69 // mode: php
70 // tab-width: 8
71 // c-basic-offset: 4
72 // c-hanging-comment-ender-p: nil
73 // indent-tabs-mode: nil
74 // End:
75 ?>