]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/WikiForm.php
add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps,
[SourceForge/phpwiki.git] / lib / plugin / WikiForm.php
1 <?php // -*-php-*-
2 rcs_id('$Id: WikiForm.php,v 1.13 2004-06-21 16:22:32 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.13 $");
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' => $GLOBALS['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'] = DEFAULT_DUMP_DIR;
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'] = DUMP_DIR;
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'] = HTML_DUMP_DIR;
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.12  2004/04/18 01:11:52  rurban
124 // more numeric pagename fixes.
125 // fixed action=upload with merge conflict warnings.
126 // charset changed from constant to global (dynamic utf-8 switching)
127 //
128 // Revision 1.11  2004/02/24 15:20:07  rurban
129 // fixed minor warnings: unchecked args, POST => Get urls for sortby e.g.
130 //
131 // Revision 1.10  2004/02/22 23:20:33  rurban
132 // fixed DumpHtmlToDir,
133 // enhanced sortby handling in PageList
134 //   new button_heading th style (enabled),
135 // added sortby and limit support to the db backends and plugins
136 //   for paging support (<<prev, next>> links on long lists)
137 //
138 // Revision 1.9  2003/02/26 01:56:52  dairiki
139 // Tuning/fixing of POST action URLs and hidden inputs.
140 //
141 // Revision 1.8  2003/01/18 22:14:30  carstenklapp
142 // Code cleanup:
143 // Reformatting & tabs to spaces;
144 // Added copyleft, getVersion, getDescription, rcs_id.
145 //
146
147 // For emacs users
148 // Local Variables:
149 // mode: php
150 // tab-width: 8
151 // c-basic-offset: 4
152 // c-hanging-comment-ender-p: nil
153 // indent-tabs-mode: nil
154 // End:
155 ?>