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     * @return void
18     * @author   Andreas Gohr <andi@splitbrain.org>
19     *
20     */
21    public function show()
22    {
23        global $lang;
24        global $conf;
25        global $INPUT;
26
27        $base_attrs = ['size' => '50', 'required' => 'required'];
28        $email_attrs = $base_attrs + ['type' => 'email'];
29
30        // print intro
31        echo p_locale_xhtml('register');
32        echo '<div class="centeralign">';
33
34        // create the login form
35        $form = new Form(['id' => 'dw__register']);
36        $form->addTagOpen('div')->addClass('no');
37        $form->addFieldsetOpen($lang['btn_register']);
38        $form->setHiddenField('do', 'register');
39        $form->setHiddenField('save', '1');
40
41        $input = $form->addTextInput('login', $lang['user'])->attrs($base_attrs)->addClass('edit')
42            ->val($INPUT->post->str('login'));
43        $input->getLabel()->attr('class', 'block');
44        $form->addHTML("<br>\n");
45
46        if (!$conf['autopasswd']) {
47            $input = $form->addPasswordInput('pass', $lang['pass'])->attrs($base_attrs)->addClass('edit');
48            $input->getLabel()->attr('class', 'block');
49            $form->addHTML("<br>\n");
50            $input = $form->addPasswordInput('passchk', $lang['passchk'])->attrs($base_attrs)->addClass('edit');
51            $input->getLabel()->attr('class', 'block');
52            $form->addHTML("<br>\n");
53        }
54
55        $input = $form->addTextInput('fullname', $lang['fullname'])->attrs($base_attrs)->addClass('edit')
56            ->val($INPUT->post->str('fullname'));
57        $input->getLabel()->attr('class', 'block');
58        $form->addHTML("<br>\n");
59
60        $input = $form->addTextInput('email', $lang['email'])->attrs($email_attrs)->addClass('edit')
61            ->val($INPUT->post->str('email'));
62        $input->getLabel()->attr('class', 'block');
63        $form->addHTML("<br>\n");
64
65        $form->addButton('', $lang['btn_register'])->attr('type', 'submit');
66        $form->addFieldsetClose();
67        $form->addTagClose('div');
68
69        echo $form->toHTML('Register');
70
71        echo '</div>';
72    }
73}
74