4 * Copyright 2005 $ThePhpWikiProgrammingTeam
5 * Copyright 2008-2009 Marc-Etienne Vargenau, Alcatel-Lucent
7 * This file is part of PhpWiki.
9 * PhpWiki is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * PhpWiki is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * Usage: <<WikiAdminSetExternal s||=* >> or called via WikiAdminSelect
26 * @author: Marc-Etienne Vargenau, Alcatel-Lucent
28 require_once 'lib/PageList.php';
29 require_once 'lib/plugin/WikiAdminSelect.php';
31 class WikiPlugin_WikiAdminSetExternal
32 extends WikiPlugin_WikiAdminSelect
36 return _("WikiAdminSetExternal");
39 function getDescription()
41 return _("Mark selected pages as external.");
44 function getDefaultArguments()
48 WikiPlugin_WikiAdminSelect::getDefaultArguments(),
51 /* Columns to include in listing */
52 'info' => 'pagename,external,mtime',
56 function setExternalPages(&$dbi, &$request, $pages)
58 $result = HTML::div();
61 foreach ($pages as $name) {
62 $page = $dbi->getPage($name);
63 $current = $page->getCurrentRevision();
64 $external = $current->get('external');
65 if (!$external) $external = 0;
66 $external = (bool)$external;
68 if (!mayAccessPage('change', $name)) {
69 $result->setAttr('class', 'error');
70 $result->pushContent(HTML::p(fmt("Access denied to change page '%s'.",
73 $version = $current->getVersion();
74 $page->set('external', (bool)1);
75 $ul->pushContent(HTML::li(fmt("change page '%s' to external.", WikiLink($name))));
82 $result->setAttr('class', 'feedback');
84 $result->pushContent(HTML::p(_("One page has been changed:")));
86 $result->pushContent(HTML::p(fmt("%d pages have been changed:", $count)));
88 $result->pushContent($ul);
91 $result->setAttr('class', 'error');
92 $result->pushContent(HTML::p(_("No pages changed.")));
97 function run($dbi, $argstr, &$request, $basepage)
99 if ($request->getArg('action') != 'browse') {
100 if (!$request->getArg('action') == _("PhpWikiAdministration/SetExternal")) {
101 return $this->disabled(_("Plugin not run: not in browse mode"));
105 $args = $this->getArgs($argstr, $request);
106 $this->_args = $args;
107 $this->preSelectS($args, $request);
109 $p = $request->getArg('p');
110 if (!$p) $p = $this->_list;
111 $post_args = $request->getArg('admin_external');
112 if (!$request->isPost() and empty($post_args['external']))
113 $post_args['external'] = $args['external'];
115 if ($p && !$request->isPost())
117 if ($p && $request->isPost() &&
118 !empty($post_args['button']) && empty($post_args['cancel'])
120 // without individual PagePermissions:
121 if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
122 $request->_notAuthorized(WIKIAUTH_ADMIN);
123 $this->disabled("! user->isAdmin");
126 return $this->setExternalPages($dbi, $request, array_keys($p));
128 $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
129 $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args);
130 $pagelist->addPageList($pages);
132 $header = HTML::fieldset();
133 $button_label = _("Set pages to external");
134 $header->pushContent(HTML::legend(_("Select the pages to set as external")));
136 $buttons = HTML::p(Button('submit:admin_external[button]', $button_label, 'wikiadmin'),
137 Button('submit:admin_external[cancel]', _("Cancel"), 'button'));
138 $header->pushContent($buttons);
140 return HTML::form(array('action' => $request->getPostURL(),
143 $pagelist->getContent(),
144 HiddenInputs($request->getArgs(),
146 array('admin_external')),
149 : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
158 // c-hanging-comment-ender-p: nil
159 // indent-tabs-mode: nil