]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/GoTo.php
Add getVersion
[SourceForge/phpwiki.git] / lib / plugin / GoTo.php
1 <?php // -*-php-*-
2 rcs_id('$Id: GoTo.php,v 1.5 2008-08-21 18:32:23 vargenau 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 getVersion() {
26         return preg_replace("/[Revision: $]/", '',
27                             "\$Revision: 1.5 $");
28     }
29
30     function getDefaultArguments() {
31         return array('size' => 32);
32     }
33
34     function run($dbi, $argstr, &$request, $basepage) {
35         $request->setArg('action',false);
36         $args = $this->getArgs($argstr, $request);
37         extract($args);
38
39         if ($goto = $request->getArg('goto')) {
40             // The user has pressed 'Go'; process request
41             $request->setArg('goto', false);
42             $target = $goto['target'];
43             if ($dbi->isWikiPage($target))
44                 $url = WikiURL($target,0,1);
45             else
46                 $url = WikiURL($target, array('action'=>'edit'),1);
47
48             $request->redirect($url);
49             // User should see nothing after redirect
50             return '';
51         } 
52
53         $action = $request->getURLtoSelf();
54         $form = HTML::form(array('action'=>$action,
55                                  'method'=>'post'
56                           ));
57  
58         $form->pushContent(HiddenInputs($request->getArgs()));
59
60         $textfield = HTML::input(array('type' => 'text',
61                                        'size' => $size,
62                                        'name' => 'goto[target]'));
63
64         $button = Button('submit:goto[go]', _("Go"), false);
65
66         $form->pushContent($textfield, $button);
67
68         return $form;
69
70     }
71 };
72
73 // $Log: not supported by cvs2svn $
74 // Revision 1.4  2004/07/08 20:30:07  rurban
75 // plugin->run consistency: request as reference, added basepage.
76 // encountered strange bug in AllPages (and the test) which destroys ->_dbi
77 //
78 // Revision 1.3  2004/04/18 01:11:52  rurban
79 // more numeric pagename fixes.
80 // fixed action=upload with merge conflict warnings.
81 // charset changed from constant to global (dynamic utf-8 switching)
82 //
83 // Revision 1.2  2004/04/12 16:21:01  rurban
84 // fix lib/plugin/RssFeed.php:81: Notice[8]: Undefined variable: th
85 //
86         
87 // Local Variables:
88 // mode: php
89 // tab-width: 8
90 // c-basic-offset: 4
91 // c-hanging-comment-ender-p: nil
92 // indent-tabs-mode: nil
93 // End:   
94 ?>