xref: /dokuwiki/inc/Ui/UserRegister.php (revision 66e555e237c4348c799bba8c03f1a8a490fcc7d6)
1<?php
2
3namespace dokuwiki\Ui;
4
5use dokuwiki\Form\Form;
6
7/**
8 * DokuWiki User Registration Interface (Register Form)
9 *
10 * @package dokuwiki\Ui
11 */
12class UserRegister extends Ui
13{
14    /**
15     * Display the User Registration Form Panel
16     *
17     * @author   Andreas Gohr <andi@splitbrain.org>
18     *
19     * @triggers HTMLFORM_REGISTER_OUTPUT
20     * @return void
21     */
22    public function show()
23    {
24        global $lang;
25        global $conf;
26        global $INPUT;
27
28        $base_attrs = array('size' => '50', 'required' => 'required');
29        $email_attrs = $base_attrs + array('type' => 'email');
30
31        // print intro
32        print p_locale_xhtml('register');
33        print '<div class="centeralign">';
34
35        // create the login form
36        $form = new Form(['id' => 'dw__register']);
37        $form->addTagOpen('div')->addClass('no');
38        $form->addFieldsetOpen($lang['btn_register']);
39        $form->setHiddenField('do', 'register');
40        $form->setHiddenField('save', '1');
41
42        $input = $form->addTextInput('login', $lang['user'])->attrs($base_attrs)->addClass('edit')
43            ->val($INPUT->post->str('login'));
44        $input->getLabel()->attr('class', 'block');
45        $form->addHTML("<br>\n");
46
47        if (!$conf['autopasswd']) {
48            $input = $form->addPasswordInput('pass', $lang['pass'])->attrs($base_attrs)->addClass('edit');
49            $input->getLabel()->attr('class', 'block');
50            $form->addHTML("<br>\n");
51            $input = $form->addPasswordInput('passchk', $lang['passchk'])->attrs($base_attrs)->addClass('edit');
52            $input->getLabel()->attr('class', 'block');
53            $form->addHTML("<br>\n");
54        }
55
56        $input = $form->addTextInput('fullname', $lang['fullname'])->attrs($base_attrs)->addClass('edit')
57            ->val($INPUT->post->str('fullname'));
58        $input->getLabel()->attr('class', 'block');
59        $form->addHTML("<br>\n");
60
61        $input = $form->addTextInput('email', $lang['email'])->attrs($email_attrs)->addClass('edit')
62            ->val($INPUT->post->str('email'));
63        $input->getLabel()->attr('class', 'block');
64        $form->addHTML("<br>\n");
65
66        $form->addButton('', $lang['btn_register'])->attr('type', 'submit');
67        $form->addFieldsetClose();
68        $form->addTagClose('div');
69
70        // print form that might be modified by HTMLFORM_REGISTER_OUTPUT event handlers
71        print $form->toHTML('register');
72
73        print '</div>';
74    }
75
76}
77