]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/WikiForm.php
New dumphtml action.
[SourceForge/phpwiki.git] / lib / plugin / WikiForm.php
1 <?php // -*-php-*-
2 rcs_id('$Id: WikiForm.php,v 1.4 2002-02-20 00:16:11 carstenklapp 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     }
20
21
22     function run($dbi, $argstr, $request) {
23         extract($this->getArgs($argstr, $request));
24
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
33         $input = array('type' => 'text',
34                        'value' => $default,
35                        'size' => 50);
36
37         switch ($action) {
38             case 'loadfile':
39                 $input['name'] = 'source';
40             if (!$default)
41                 $input['value'] = '/tmp/wikidump';
42                 if (!$buttontext)
43                     $buttontext = _("Load File");
44                 $class = 'wikiadmin';
45                 break;
46             case 'dumpserial':
47                 $input['name'] = 'directory';
48                 if (!$default)
49                     $input['value'] = '/tmp/wikidump';
50                     if (!$buttontext)
51                         $buttontext = _("Dump Pages");
52                 $class = 'wikiadmin';
53                 break;
54             case 'dumphtml':
55                 $input['name'] = 'directory';
56                 if (!$default)
57                     $input['value'] = '/tmp/wikidumphtml';
58                     if (!$buttontext)
59                         $buttontext = _("Dump Pages as XHTML");
60                 $class = 'wikiadmin';
61                 break;
62             case 'upload':
63                 $form->setAttr('enctype', 'multipart/form-data');
64                 $form->pushContent(HTML::input(array('name' => 'MAX_FILE_SIZE',
65                                                      'value' =>  MAX_UPLOAD_SIZE,
66                                                      'type'  => 'hidden')));
67                 $input['name'] = 'file';
68                 $input['type'] = 'file';
69                 if (!$buttontext)
70                     $buttontext = _("Upload");
71                 $class = false; // local OS function, so use natve OS button
72                 break;
73             default:
74                 return HTML::p(fmt("WikiForm: %s: unknown action", $action));
75         }
76
77
78         $input = HTML::input($input);
79         $input->addTooltip($buttontext);
80         $button = Button('submit:', $buttontext, $class);
81
82         $form->pushContent(HTML::div(array('class' => $class),
83                                      $input, $button));
84
85         return $form;
86     }
87 };
88
89 // For emacs users
90 // Local Variables:
91 // mode: php
92 // tab-width: 8
93 // c-basic-offset: 4
94 // c-hanging-comment-ender-p: nil
95 // indent-tabs-mode: nil
96 // End:
97 ?>