Failed Conditions
Pull Request — master (#3198)
by
unknown
02:57
created

UserResendPwd::show()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 51

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 0
dl 0
loc 51
rs 9.069
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace dokuwiki\Ui;
4
5
use dokuwiki\Extension\Event;
6
use dokuwiki\Form\Form;
7
8
/**
9
 * DokuWiki Resend Password Request Insterface
10
 *
11
 * @package dokuwiki\Ui
12
 */
13
class UserResendPwd extends Ui
14
{
15
    /**
16
     * Display the form to request a new password for an existing account
17
     *
18
     * @author   Benoit Chesneau <[email protected]>
19
     * @author   Andreas Gohr <[email protected]>
20
     *
21
     * @triggers HTML_RESENDPWDFORM_OUTPUT
22
     * @return void
23
     */
24
    public function show()
25
    {
26
        global $lang;
27
        global $conf;
28
        global $INPUT;
29
30
        $token = preg_replace('/[^a-f0-9]+/', '', $INPUT->str('pwauth'));
31
32
        // print intro
33
        print p_locale_xhtml('resetpwd');
34
        print '<div class="centeralign">'.DOKU_LF;
35
36
        if (!$conf['autopasswd'] && $token) {
37
            // create the form
38
            $form = new Form(['id' => 'dw__resendpwd']);
39
            $form->addTagOpen('div')->addClass('no');
40
            $form->addFieldsetOpen($lang['btn_resendpwd']);
41
            $form->setHiddenField('token', $token);
42
            $form->setHiddenField('do', 'resendpwd');
43
            $input = $form->addPasswordInput('pass', $lang['pass'])->attr('size', '50')->addClass('edit');
44
            $input->getLabel()->attr('class', 'block');
45
            $form->addHTML("<br>\n");
46
            $input = $form->addPasswordInput('passchk', $lang['passchk'])->attr('size', '50')->addClass('edit');
47
            $input->getLabel()->attr('class', 'block');
48
            $form->addHTML("<br>\n");
49
            $form->addButton('', $lang['btn_resendpwd'])->attrs(['type' => 'submit']);
50
            $form->addFieldsetClose();
51
            $form->addTagClose('div');
52
        } else {
53
            // create the form
54
            $form = new Form(['id' => 'dw__resendpwd']);
55
            $form->addTagOpen('div')->addClass('no');
56
            $form->addFieldsetOpen($lang['btn_resendpwd']);
57
            $form->setHiddenField('do', 'resendpwd');
58
            $form->setHiddenField('save', '1');
59
            $form->addHTML("<br>\n");
60
            $input = $form->addTextInput('login', $lang['user'])->addClass('edit')
61
                ->val($INPUT->str('login'));
62
            $input->getLabel()->attr('class', 'block');
63
            $form->addHTML("<br>\n");
64
            $form->addHTML("<br>\n");
65
            $form->addButton('', $lang['btn_resendpwd'])->attrs(['type' => 'submit']);
66
            $form->addFieldsetClose();
67
            $form->addTagClose('div');
68
        }
69
70
        // emit HTML_RESENDPWDFORM_OUTPUT event, print the form
71
        Event::createAndTrigger('HTML_RESENDPWDFORM_OUTPUT', $form, 'html_form_output', false);
72
73
        print '</div>'.DOKU_LF;
74
    }
75
76
}
77