4 * Copyright (C) 2004 $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
24 * Display a form with text entry box and 'Go' button.
25 * The user enters a page name... if it exists, browse
26 * that page; if not, edit (create) that page.
27 * Note: pagenames are absolute, not relative to the actual subpage.
29 * Usage: <?plugin GoTo ?>
30 * @author: Michael van Dam
40 function getDescription () {
41 return _("Go to or create page.");
44 function getVersion() {
45 return preg_replace("/[Revision: $]/", '',
49 function getDefaultArguments() {
50 return array('size' => 32);
53 function run($dbi, $argstr, &$request, $basepage) {
54 $request->setArg('action',false);
55 $args = $this->getArgs($argstr, $request);
58 if ($goto = $request->getArg('goto')) {
59 // The user has pressed 'Go'; process request
60 $request->setArg('goto', false);
61 $target = $goto['target'];
62 if ($dbi->isWikiPage($target))
63 $url = WikiURL($target,0,1);
65 $url = WikiURL($target, array('action'=>'edit'),1);
67 $request->redirect($url);
68 // User should see nothing after redirect
72 $action = $request->getURLtoSelf();
73 $form = HTML::form(array('action'=>$action,
77 $form->pushContent(HiddenInputs($request->getArgs()));
79 $textfield = HTML::input(array('type' => 'text',
81 'name' => 'goto[target]'));
83 $button = Button('submit:goto[go]', _("Go"), false);
85 $form->pushContent($textfield, $button);
96 // c-hanging-comment-ender-p: nil
97 // indent-tabs-mode: nil