2 rcs_id('$Id: WikiAdminRemove.php,v 1.2 2002-08-22 23:32:33 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 // maybe display more attributes with this class...
24 //require_once('lib/PageList.php');
26 class WikiPlugin_WikiAdminRemove
30 return _("WikiAdminRemove");
33 function getDescription() {
34 return _("Permanently remove all selected pages.");
37 function getDefaultArguments() {
38 return array('only' => '',
43 function collectPages(&$list, &$dbi) {
44 $allPages = $dbi->getAllPages();
45 while ($pagehandle = $allPages->next()) {
46 $pagename = $pagehandle->getName();
47 if (empty($list[$pagename])) $list[$pagename] = 0;
51 function addTableHead(&$table) {
52 $row = HTML::tr(HTML::th(_("Select")),
54 $table->pushContent(HTML::thead($row));
57 function addTableBody(&$list, &$table) {
58 $tbody = HTML::tbody();
59 foreach ($list as $pagename => $selected) {
61 $row = HTML::tr(array('class' => 'oddrow'),
62 HTML::td(HTML::input(array('type' => 'checkbox',
63 'name' => "p[$pagename]",
66 HTML::td(WikiLink($pagename)));
68 $row = HTML::tr(array('class' => 'evenrow'),
69 HTML::td(HTML::input(array('type' => 'checkbox',
70 'name' => "p[$pagename]",
71 'value' => $pagename))),
72 HTML::td(WikiLink($pagename)));
74 $tbody->pushContent($row);
76 $table->pushContent($tbody);
79 function formatTable(&$list, &$dbi) {
80 $table = HTML::table(array('cellpadding' => 2,
83 'class' => 'pagelist'));
84 $table->pushContent(HTML::caption(array('align'=>'top'),
85 _("Permanently remove all selected pages.")));
86 // $this->addTableHead($table);
87 $this->addTableBody($list, $table);
91 function run($dbi, $argstr, $request) {
92 $args = $this->getArgs($argstr, $request);
93 if (!empty($args['only']))
94 $this->only = explode(',',$args['only']);
95 if (!empty($args['exclude']))
96 $this->only = explode(',',$args['exclude']);
97 $this->debug = $args['debug'];
98 $this->_list = array();
99 // array_multisort($this->_list, SORT_NUMERIC, SORT_DESC);
100 $pagename = $request->getArg('pagename');
101 $form = HTML::form(array('action' => $_SERVER['REQUEST_URI'], 'method' => 'POST'));
102 if ($request->isPost() and $request->getArg('verify')) {
103 // List all to be deleted pages again.
104 foreach ($GLOBALS['HTTP_POST_VARS']['p'] as $page => $name) {
105 $this->_list[$name] = 1;
107 } elseif ($request->isPost() and $request->getArg('remove')) {
110 foreach ($GLOBALS['HTTP_POST_VARS']['p'] as $page => $name) {
111 $dbi = $request->getDbh();
112 $dbi->deletePage($name);
113 $ul->pushContent(HTML::li(fmt("Removed page '%s' succesfully.", $name)));
116 // List all pages to select from.
117 $this->collectPages($this->_list, &$dbi);
119 $table = $this->formatTable($this->_list, &$dbi, &$request);
120 $form->pushContent($table);
121 $form->pushContent(HiddenInputs($GLOBALS['HTTP_GET_VARS'])); // debugging params, ...
122 // if (! USE_PATH_INFO ) $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'pagename', 'value' => $pagename)));
123 if (! $request->getArg('verify')) {
124 $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'verify')));
125 $form->pushContent(Button('submit:verify', _("Remove selected pages"), 'wikiadmin'),
126 Button('submit:cancel', _("Cancel"), 'button'));
128 $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'remove')));
129 $form->pushContent(Button('submit:remove', _("Remove selected pages"), 'wikiadmin'),
130 Button('submit:cancel', _("Cancel"), 'button'));
132 if (! $request->getArg('remove')) {
135 return HTML::div($ul,HTML::p(_('All selected pages have been permanently removed.')));
144 // c-hanging-comment-ender-p: nil
145 // indent-tabs-mode: nil