]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/WikiForm.php
don't cache this at all
[SourceForge/phpwiki.git] / lib / plugin / WikiForm.php
1 <?php // -*-php-*-
2 rcs_id('$Id: WikiForm.php,v 1.11 2004-02-24 15:20:07 rurban Exp $');
3 /**
4  Copyright 1999, 2000, 2001, 2002 $ThePhpWikiProgrammingTeam
5
6  This file is part of PhpWiki.
7
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.
12
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.
17
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
21  */
22
23 /**
24  * This is a replacement for MagicPhpWikiURL forms.
25  *
26  *
27  */
28 class WikiPlugin_WikiForm
29 extends WikiPlugin
30 {
31     function getName () {
32         return _("WikiForm");
33     }
34
35     function getVersion() {
36         return preg_replace("/[Revision: $]/", '',
37                             "\$Revision: 1.11 $");
38     }
39
40     function getDefaultArguments() {
41         return array('action' => 'upload', // 'upload', 'loadfile', or
42                                            // 'dumpserial'
43                      'default' => false,
44                      'buttontext' => false,
45                      'size' => 50);
46     }
47
48
49     function run($dbi, $argstr, &$request, $basepage) {
50         extract($this->getArgs($argstr, $request));
51         $form = HTML::form(array('action' => $request->getPostURL(),
52                                  'method' => 'post',
53                                  'class'  => 'wikiadmin',
54                                  'accept-charset' => CHARSET),
55                            HiddenInputs(array('action' => $action,
56                                               'pagename' => $basepage)));
57         $input = array('type' => 'text',
58                        'value' => $default,
59                        'size' => $size);
60
61         switch ($action) {
62         case 'loadfile':
63             $input['name'] = 'source';
64             if (!$default)
65                 $input['value'] = '/tmp/wikidump';
66             if (!$buttontext)
67                 $buttontext = _("Load File");
68             $class = false;
69             break;
70         case 'login':
71             $input['name'] = 'source';
72             if (!$buttontext)
73                 $buttontext = _("Login");
74             $class = 'wikiadmin';
75             break;
76         case 'dumpserial':
77             $input['name'] = 'directory';
78             if (!$default)
79                 $input['value'] = '/tmp/wikidump';
80             if (!$buttontext)
81                 $buttontext = _("Dump Pages");
82             $class = 'wikiadmin';
83             break;
84         case 'dumphtml':
85             $input['name'] = 'directory';
86             if (!$default)
87                 $input['value'] = '/tmp/wikidumphtml';
88             if (!$buttontext)
89                 $buttontext = _("Dump Pages as XHTML");
90             $class = 'wikiadmin';
91             break;
92         case 'upload':
93             $form->setAttr('enctype', 'multipart/form-data');
94             $form->pushContent(HTML::input(array('name' => 'MAX_FILE_SIZE',
95                                                  'value' =>  MAX_UPLOAD_SIZE,
96                                                  'type'  => 'hidden')));
97             $input['name'] = 'file';
98             $input['type'] = 'file';
99             if (!$buttontext)
100                 $buttontext = _("Upload");
101             $class = false; // local OS function, so use native OS button
102             break;
103         default:
104             return HTML::p(fmt("WikiForm: %s: unknown action", $action));
105         }
106
107
108         $input = HTML::input($input);
109         $input->addTooltip($buttontext);
110         $button = Button('submit:', $buttontext, $class);
111         if ($request->getArg('start_debug'))
112             $form->pushContent(HTML::input(array('name' => 'start_debug',
113                                                  'value' =>  $request->getArg('start_debug'),
114                                                  'type'  => 'hidden')));
115         $form->pushContent(HTML::span(array('class' => $class),
116                                       $input, $button));
117
118         return $form;
119     }
120 };
121
122 // $Log: not supported by cvs2svn $
123 // Revision 1.10  2004/02/22 23:20:33  rurban
124 // fixed DumpHtmlToDir,
125 // enhanced sortby handling in PageList
126 //   new button_heading th style (enabled),
127 // added sortby and limit support to the db backends and plugins
128 //   for paging support (<<prev, next>> links on long lists)
129 //
130 // Revision 1.9  2003/02/26 01:56:52  dairiki
131 // Tuning/fixing of POST action URLs and hidden inputs.
132 //
133 // Revision 1.8  2003/01/18 22:14:30  carstenklapp
134 // Code cleanup:
135 // Reformatting & tabs to spaces;
136 // Added copyleft, getVersion, getDescription, rcs_id.
137 //
138
139 // For emacs users
140 // Local Variables:
141 // mode: php
142 // tab-width: 8
143 // c-basic-offset: 4
144 // c-hanging-comment-ender-p: nil
145 // indent-tabs-mode: nil
146 // End:
147 ?>