]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/WikiForm.php
Activated Revision substitution for Subversion
[SourceForge/phpwiki.git] / lib / plugin / WikiForm.php
1 <?php // -*-php-*-
2 rcs_id('$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
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  * Just a few old actions are supported, which where previously 
26  * encoded with the phpwiki: syntax.
27  *
28  * See WikiFormMore for the more generic version.
29  */
30 class WikiPlugin_WikiForm
31 extends WikiPlugin
32 {
33     function getName () {
34         return _("WikiForm");
35     }
36
37     function getVersion() {
38         return preg_replace("/[Revision: $]/", '',
39                             "\$Revision$");
40     }
41
42     function getDefaultArguments() {
43         return array('action' => 'upload', // 'upload', 'loadfile', or
44                                            // 'dumpserial'
45                      'default' => false,
46                      'buttontext' => false,
47                      'overwrite' => false,
48                      'size' => 50);
49     }
50
51
52     function run($dbi, $argstr, &$request, $basepage) {
53         extract($this->getArgs($argstr, $request));
54         $form = HTML::form(array('action' => $request->getPostURL(),
55                                  'method' => 'post',
56                                  'class'  => 'wikiadmin',
57                                  'accept-charset' => $GLOBALS['charset']),
58                            HiddenInputs(array('action' => $action,
59                                               'pagename' => $basepage)));
60         $input = array('type' => 'text',
61                        'value' => $default,
62                        'size' => $size);
63
64         switch ($action) {
65         case 'loadfile':
66             $input['name'] = 'source';
67             if (!$default)
68                 $input['value'] = DEFAULT_DUMP_DIR;
69             if (!$buttontext)
70                 $buttontext = _("Load File");
71             $class = false;
72             break;
73         case 'login':
74             $input['name'] = 'source';
75             if (!$buttontext)
76                 $buttontext = _("Login");
77             $class = 'wikiadmin';
78             break;
79         case 'dumpserial':
80             $input['name'] = 'directory';
81             if (!$default)
82                 $input['value'] = DEFAULT_DUMP_DIR;
83             if (!$buttontext)
84                 $buttontext = _("Dump Pages");
85             $class = 'wikiadmin';
86             break;
87         case 'dumphtml':
88             $input['name'] = 'directory';
89             if (!$default)
90                 $input['value'] = HTML_DUMP_DIR;
91             if (!$buttontext)
92                 $buttontext = _("Dump Pages as XHTML");
93             $class = 'wikiadmin';
94             break;
95         case 'upload':
96             $form->setAttr('enctype', 'multipart/form-data');
97             $form->pushContent(HTML::input(array('name' => 'MAX_FILE_SIZE',
98                                                  'value' =>  MAX_UPLOAD_SIZE,
99                                                  'type'  => 'hidden')));
100             $input['name'] = 'file';
101             $input['type'] = 'file';
102             if (!$buttontext)
103                 $buttontext = _("Upload");
104             $class = false; // local OS function, so use native OS button
105             break;
106         default:
107             return HTML::p(fmt("WikiForm: %s: unknown action", $action));
108         }
109
110
111         $input = HTML::input($input);
112         $input->addTooltip($buttontext);
113         $button = Button('submit:', $buttontext, $class);
114         if ($request->getArg('start_debug'))
115             $form->pushContent(HTML::input(array('name' => 'start_debug',
116                                                  'value' =>  $request->getArg('start_debug'),
117                                                  'type'  => 'hidden')));
118         $form->pushContent(HTML::span(array('class' => $class),
119                                       $input, $button));
120
121         return $form;
122     }
123 };
124
125 // $Log: not supported by cvs2svn $
126 // Revision 1.15  2004/06/22 07:12:49  rurban
127 // removed USE_TAGLINES constant
128 //
129 // Revision 1.14  2004/06/21 17:06:38  rurban
130 // renamed constant
131 //
132 // Revision 1.13  2004/06/21 16:22:32  rurban
133 // add DEFAULT_DUMP_DIR and HTML_DUMP_DIR constants, for easier cmdline dumps,
134 // fixed dumping buttons locally (images/buttons/),
135 // support pages arg for dumphtml,
136 // optional directory arg for dumpserial + dumphtml,
137 // fix a AllPages warning,
138 // show dump warnings/errors on DEBUG,
139 // don't warn just ignore on wikilens pagelist columns, if not loaded.
140 // RateIt pagelist column is called "rating", not "ratingwidget" (Dan?)
141 //
142 // Revision 1.12  2004/04/18 01:11:52  rurban
143 // more numeric pagename fixes.
144 // fixed action=upload with merge conflict warnings.
145 // charset changed from constant to global (dynamic utf-8 switching)
146 //
147 // Revision 1.11  2004/02/24 15:20:07  rurban
148 // fixed minor warnings: unchecked args, POST => Get urls for sortby e.g.
149 //
150 // Revision 1.10  2004/02/22 23:20:33  rurban
151 // fixed DumpHtmlToDir,
152 // enhanced sortby handling in PageList
153 //   new button_heading th style (enabled),
154 // added sortby and limit support to the db backends and plugins
155 //   for paging support (<<prev, next>> links on long lists)
156 //
157 // Revision 1.9  2003/02/26 01:56:52  dairiki
158 // Tuning/fixing of POST action URLs and hidden inputs.
159 //
160 // Revision 1.8  2003/01/18 22:14:30  carstenklapp
161 // Code cleanup:
162 // Reformatting & tabs to spaces;
163 // Added copyleft, getVersion, getDescription, rcs_id.
164 //
165
166 // For emacs users
167 // Local Variables:
168 // mode: php
169 // tab-width: 8
170 // c-basic-offset: 4
171 // c-hanging-comment-ender-p: nil
172 // indent-tabs-mode: nil
173 // End:
174 ?>