]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/GoTo.php
plugin->run consistency: request as reference, added basepage.
[SourceForge/phpwiki.git] / lib / plugin / GoTo.php
1 <?php // -*-php-*-
2 rcs_id('$Id: GoTo.php,v 1.4 2004-07-08 20:30:07 rurban Exp $');
3
4 /**
5  *  Display a form with text entry box and 'Go' button.
6  *  The user enters a page name... if it exists, browse
7  *  that page; if not, edit (create) that page.
8  *  Note: pagenames are absolute, not relative to the actual subpage.
9  *
10  *  Usage: <?plugin GoTo ?>
11  *  @author: Michael van Dam
12  */
13
14 class WikiPlugin_GoTo
15 extends WikiPlugin
16 {
17     function getName () {
18         return _("GoTo");
19     }
20
21     function getDescription () {
22         return _("Go to or create page.");
23     }
24     
25     function getDefaultArguments() {
26         return array('size' => 32);
27     }
28
29     function run($dbi, $argstr, &$request, $basepage) {
30         $request->setArg('action',false);
31         $args = $this->getArgs($argstr, $request);
32         extract($args);
33
34         if ($goto = $request->getArg('goto')) {
35             // The user has pressed 'Go'; process request
36             $request->setArg('goto', false);
37             $target = $goto['target'];
38             if ($dbi->isWikiPage($target))
39                 $url = WikiURL($target,0,1);
40             else
41                 $url = WikiURL($target, array('action'=>'edit'),1);
42
43             $request->redirect($url);
44             // User should see nothing after redirect
45             return '';
46         } 
47
48         $action = $request->getURLtoSelf();
49         $form = HTML::form(array('action'=>$action,
50                                  'method'=>'post'
51                           ));
52  
53         $form->pushContent(HiddenInputs($request->getArgs()));
54
55         $textfield = HTML::input(array('type' => 'text',
56                                        'size' => $size,
57                                        'name' => 'goto[target]'));
58
59         $button = Button('submit:goto[go]', _("Go"), false);
60
61         $form->pushContent($textfield, $button);
62
63         return $form;
64
65     }
66 };
67
68 // $Log: not supported by cvs2svn $
69 // Revision 1.3  2004/04/18 01:11:52  rurban
70 // more numeric pagename fixes.
71 // fixed action=upload with merge conflict warnings.
72 // charset changed from constant to global (dynamic utf-8 switching)
73 //
74 // Revision 1.2  2004/04/12 16:21:01  rurban
75 // fix lib/plugin/RssFeed.php:81: Notice[8]: Undefined variable: th
76 //
77         
78 // Local Variables:
79 // mode: php
80 // tab-width: 8
81 // c-basic-offset: 4
82 // c-hanging-comment-ender-p: nil
83 // indent-tabs-mode: nil
84 // End:   
85 ?>