2 rcs_id('$Id: WikiAdminRemove.php,v 1.1 2002-08-20 20:34:20 rurban Exp $');
4 Copyright 2002 $ThePhpWikiProgrammingTeam
6 This file is part of PhpWiki.
8 PhpWiki is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 PhpWiki is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with PhpWiki; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //require_once('lib/PageList.php');
25 class WikiPlugin_WikiAdminRemove
29 return _("WikiAdminRemove");
32 function getDescription() {
33 return _("Permanently remove all selected pages.");
36 function getDefaultArguments() {
37 return array('only' => '',
42 function collectPages(&$list, &$dbi) {
43 $allPages = $dbi->getAllPages();
44 while ($pagehandle = $allPages->next()) {
45 $pagename = $pagehandle->getName();
46 if (empty($list[$pagename])) $list[$pagename] = 0;
50 function sortCollectedPages(&$list) {
54 function addTableHead(&$table) {
55 $row = HTML::tr(HTML::th(_("Select")),
57 $table->pushContent(HTML::thead($row));
60 function addTableBody(&$list, &$table) {
61 $tbody = HTML::tbody();
62 foreach ($list as $pagename => $selected) {
64 $row = HTML::tr(array('class' => 'oddrow'),
65 HTML::td(HTML::input(array('type' => 'checkbox',
66 'name' => "p[$pagename]",
69 HTML::td(WikiLink($pagename)));
71 $row = HTML::tr(array('class' => 'evenrow'),
72 HTML::td(HTML::input(array('type' => 'checkbox',
73 'name' => "p[$pagename]",
74 'value' => $pagename))),
75 HTML::td(WikiLink($pagename)));
77 $tbody->pushContent($row);
79 $table->pushContent($tbody);
82 function formatTable(&$list, &$dbi) {
83 $table = HTML::table(array('cellpadding' => 2,
86 'class' => 'pagelist'));
87 $table->pushContent(HTML::caption(array('align'=>'top'),
88 _("Permanently remove all selected pages.")));
89 // $this->addTableHead($table);
90 $this->addTableBody($list, $table);
94 function run($dbi, $argstr, $request) {
95 $args = $this->getArgs($argstr, $request);
96 if (!empty($args['only']))
97 $this->only = explode(',',$args['only']);
98 if (!empty($args['exclude']))
99 $this->only = explode(',',$args['exclude']);
100 $this->debug = $args['debug'];
101 $this->_list = array();
102 // array_multisort($this->_list, SORT_NUMERIC, SORT_DESC);
103 $pagename = $request->getArg('pagename');
104 $form = HTML::form(array('action' => WikiURL($pagename),'method' => 'POST'));
105 if ($request->isPost() and $request->getArg('verify')) {
106 // List all to be deleted pages again.
107 foreach ($GLOBALS['HTTP_POST_VARS']['p'] as $page => $name) { // requires php-4.2.0
108 $this->_list[$name] = 1;
110 } elseif ($request->isPost() and $request->getArg('remove')) {
113 foreach ($GLOBALS['HTTP_POST_VARS']['p'] as $page => $name) { // requires php-4.2.0
114 $dbi = $request->getDbh();
115 $dbi->deletePage($name);
116 $ul->pushContent(HTML::li(fmt("Removed page '%s' succesfully.", $name)));
119 // List all pages to select from.
120 $this->collectPages($this->_list, &$dbi);
122 $table = $this->formatTable($this->_list, &$dbi, &$request);
123 $form->pushContent($table);
124 $form->pushContent(HiddenInputs($GLOBALS['HTTP_GET_VARS'])); // debugging params, ...
125 // if (! USE_PATH_INFO ) $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'pagename', 'value' => $pagename)));
126 if (! $request->getArg('verify')) {
127 $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'verify')));
128 $form->pushContent(Button('submit:verify', _("Remove selected pages"), 'wikiadmin'),
129 Button('submit:cancel', _("Cancel"), 'button'));
131 $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'remove')));
132 $form->pushContent(Button('submit:remove', _("Remove selected pages"), 'wikiadmin'),
133 Button('submit:cancel', _("Cancel"), 'button'));
135 if (! $request->getArg('remove')) {
138 return HTML::div($ul,HTML::p(_('All selected pages have been permanently removed.')));
147 // c-hanging-comment-ender-p: nil
148 // indent-tabs-mode: nil