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
35 return _("WikiAdminSetExternal");
38 function getDescription() {
39 return _("Mark selected pages as external.");
42 function getDefaultArguments() {
45 WikiPlugin_WikiAdminSelect::getDefaultArguments(),
48 /* Columns to include in listing */
49 'info' => 'pagename,external,mtime',
53 function setExternalPages(&$dbi, &$request, $pages) {
54 $result = HTML::div();
57 foreach ($pages as $name) {
58 $page = $dbi->getPage($name);
59 $current = $page->getCurrentRevision();
60 $external = $current->get('external');
61 if (!$external) $external = 0;
62 $external = (bool)$external;
64 if (!mayAccessPage('change', $name)) {
65 $result->setAttr('class', 'error');
66 $result->pushContent(HTML::p(fmt("Access denied to change page '%s'.",
69 $version = $current->getVersion();
70 $page->set('external', (bool)1);
71 $ul->pushContent(HTML::li(fmt("change page '%s' to external.", WikiLink($name))));
78 $result->setAttr('class', 'feedback');
80 $result->pushContent(HTML::p(_("One page has been changed:")));
82 $result->pushContent(HTML::p(fmt("%d pages have been changed:", $count)));
84 $result->pushContent($ul);
87 $result->setAttr('class', 'error');
88 $result->pushContent(HTML::p(_("No pages changed.")));
93 function run($dbi, $argstr, &$request, $basepage) {
94 if ($request->getArg('action') != 'browse') {
95 if (!$request->getArg('action') == _("PhpWikiAdministration/SetExternal")) {
96 return $this->disabled(_("Plugin not run: not in browse mode"));
100 $args = $this->getArgs($argstr, $request);
101 $this->_args = $args;
102 $this->preSelectS($args, $request);
104 $p = $request->getArg('p');
105 if (!$p) $p = $this->_list;
106 $post_args = $request->getArg('admin_external');
107 if (!$request->isPost() and empty($post_args['external']))
108 $post_args['external'] = $args['external'];
110 if ($p && !$request->isPost())
112 if ($p && $request->isPost() &&
113 !empty($post_args['button']) && empty($post_args['cancel'])) {
114 // without individual PagePermissions:
115 if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
116 $request->_notAuthorized(WIKIAUTH_ADMIN);
117 $this->disabled("! user->isAdmin");
120 return $this->setExternalPages($dbi, $request, array_keys($p));
122 $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
123 $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args);
124 $pagelist->addPageList($pages);
126 $header = HTML::fieldset();
127 $button_label = _("Set pages to external");
128 $header->pushContent(HTML::legend(_("Select the pages to set as external")));
130 $buttons = HTML::p(Button('submit:admin_external[button]', $button_label, 'wikiadmin'),
131 Button('submit:admin_external[cancel]', _("Cancel"), 'button'));
132 $header->pushContent($buttons);
134 return HTML::form(array('action' => $request->getPostURL(),
137 $pagelist->getContent(),
138 HiddenInputs($request->getArgs(),
140 array('admin_external')),
143 : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
152 // c-hanging-comment-ender-p: nil
153 // indent-tabs-mode: nil