]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/WikiForm.php
WikiFormMore does not exist
[SourceForge/phpwiki.git] / lib / plugin / WikiForm.php
1 <?php // -*-php-*-
2 // $Id$
3 /**
4  * Copyright 1999, 2000, 2001, 2002, 2004 $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 along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 /**
24  * This is a replacement for MagicPhpWikiURL forms.
25  * Just a few old actions are supported, which where previously
26  * encoded with the phpwiki: syntax.
27  */
28 class WikiPlugin_WikiForm
29 extends WikiPlugin
30 {
31     function getName () {
32         return _("WikiForm");
33     }
34
35     function getDescription () {
36         return _("Provide generic WikiForm input buttons");
37     }
38
39     function getDefaultArguments() {
40         return array('action' => 'upload', // 'upload', 'loadfile', or
41                                            // 'dumpserial'
42                      'default' => false,
43                      'buttontext' => false,
44                      'overwrite' => false,
45                      'size' => 50);
46     }
47
48     function run($dbi, $argstr, &$request, $basepage) {
49         extract($this->getArgs($argstr, $request));
50         $form = HTML::form(array('action' => $request->getPostURL(),
51                                  'method' => 'post',
52                                  'class'  => 'wikiadmin',
53                                  'accept-charset' => $GLOBALS['charset']),
54                            HiddenInputs(array('action' => $action,
55                                               'pagename' => $basepage)));
56         $input = array('type' => 'text',
57                        'value' => $default,
58                        'size' => $size);
59
60         switch ($action) {
61         case 'loadfile':
62             $input['name'] = 'source';
63             if (!$default)
64                 $input['value'] = DEFAULT_DUMP_DIR;
65             if (!$buttontext)
66                 $buttontext = _("Load File");
67             $class = false;
68             break;
69         case 'login':
70             $input['name'] = 'source';
71             if (!$buttontext)
72                 $buttontext = _("Sign In");
73             $class = 'wikiadmin';
74             break;
75         case 'dumpserial':
76             $input['name'] = 'directory';
77             if (!$default)
78                 $input['value'] = DEFAULT_DUMP_DIR;
79             if (!$buttontext)
80                 $buttontext = _("Dump Pages");
81             $class = 'wikiadmin';
82             break;
83         case 'dumphtml':
84             $input['name'] = 'directory';
85             if (!$default)
86                 $input['value'] = HTML_DUMP_DIR;
87             if (!$buttontext)
88                 $buttontext = _("Dump Pages as XHTML");
89             $class = 'wikiadmin';
90             break;
91         case 'upload':
92             $form->setAttr('enctype', 'multipart/form-data');
93             $form->pushContent(HTML::input(array('name' => 'MAX_FILE_SIZE',
94                                                  'value' =>  MAX_UPLOAD_SIZE,
95                                                  'type'  => 'hidden')));
96             $input['name'] = 'file';
97             $input['type'] = 'file';
98             if (!$buttontext)
99                 $buttontext = _("Upload");
100             $class = false; // local OS function, so use native OS button
101             break;
102         default:
103             return HTML::div(array('class' => "error"), fmt("WikiForm: %s: unknown action", $action));
104         }
105
106         $input = HTML::input($input);
107         $input->addTooltip($buttontext);
108         $button = Button('submit:', $buttontext, $class);
109         if ($request->getArg('start_debug'))
110             $form->pushContent(HTML::input(array('name' => 'start_debug',
111                                                  'value' =>  $request->getArg('start_debug'),
112                                                  'type'  => 'hidden')));
113         $form->pushContent(HTML::span(array('class' => $class),
114                                       $input, $button));
115
116         return $form;
117     }
118 };
119
120 // Local Variables:
121 // mode: php
122 // tab-width: 8
123 // c-basic-offset: 4
124 // c-hanging-comment-ender-p: nil
125 // indent-tabs-mode: nil
126 // End:
127 ?>