]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/WikiForm.php
minor fix
[SourceForge/phpwiki.git] / lib / plugin / WikiForm.php
1 <?php // -*-php-*-
2 rcs_id('$Id: WikiForm.php,v 1.7 2002-08-20 08:37:42 rurban Exp $');
3 /**
4  * This is a replacement for MagicPhpWikiURL forms.
5  *
6  *
7  */
8 class WikiPlugin_WikiForm
9 extends WikiPlugin
10 {
11     function getName () {
12         return _("WikiForm");
13     }
14
15     function getDefaultArguments() {
16         return array('action' => 'upload', // 'upload', 'loadfile', or 'dumpserial'
17                      'default' => false,
18                      'buttontext' => false,
19                      'size' => 50);
20     }
21
22
23     function run($dbi, $argstr, $request) {
24         extract($this->getArgs($argstr, $request));
25         $form = HTML::form(array('action' => USE_PATH_INFO ? WikiURL($request->getPage()) : SCRIPT_NAME,
26                                  'method' => 'post',
27                                  'class'  => 'wikiadmin',
28                                  'accept-charset' => CHARSET),
29                            HTML::input(array('type' => 'hidden',
30                                              'name' => 'action',
31                                              'value' => $action)),
32                            USE_PATH_INFO 
33                              ? false
34                              : HTML::input(array('type' => 'hidden',
35                                                  'name' => 'pagename',
36                                                  'value' => $targetpage)));
37         $input = array('type' => 'text',
38                        'value' => $default,
39                        'size' => $size);
40
41         switch ($action) {
42             case 'loadfile':
43                 $input['name'] = 'source';
44             if (!$default)
45                 $input['value'] = '/tmp/wikidump';
46                 if (!$buttontext)
47                     $buttontext = _("Load File");
48                 $class = false;
49                 break;
50             case 'login':
51                 $input['name'] = 'source';
52                 if (!$buttontext)
53                     $buttontext = _("Login");
54                 $class = 'wikiadmin';
55                 break;
56             case 'dumpserial':
57                 $input['name'] = 'directory';
58                 if (!$default)
59                     $input['value'] = '/tmp/wikidump';
60                     if (!$buttontext)
61                         $buttontext = _("Dump Pages");
62                 $class = 'wikiadmin';
63                 break;
64             case 'dumphtml':
65                 $input['name'] = 'directory';
66                 if (!$default)
67                     $input['value'] = '/tmp/wikidumphtml';
68                     if (!$buttontext)
69                         $buttontext = _("Dump Pages as XHTML");
70                 $class = 'wikiadmin';
71                 break;
72             case 'upload':
73                 $form->setAttr('enctype', 'multipart/form-data');
74                 $form->pushContent(HTML::input(array('name' => 'MAX_FILE_SIZE',
75                                                      'value' =>  MAX_UPLOAD_SIZE,
76                                                      'type'  => 'hidden')));
77                 $input['name'] = 'file';
78                 $input['type'] = 'file';
79                 if (!$buttontext)
80                     $buttontext = _("Upload");
81                 $class = false; // local OS function, so use native OS button
82                 break;
83             default:
84                 return HTML::p(fmt("WikiForm: %s: unknown action", $action));
85         }
86
87
88         $input = HTML::input($input);
89         $input->addTooltip($buttontext);
90         $button = Button('submit:', $buttontext, $class);
91
92         $form->pushContent(HTML::span(array('class' => $class),
93                                      $input, $button));
94
95         return $form;
96     }
97 };
98
99 // For emacs users
100 // Local Variables:
101 // mode: php
102 // tab-width: 8
103 // c-basic-offset: 4
104 // c-hanging-comment-ender-p: nil
105 // indent-tabs-mode: nil
106 // End:
107 ?>