diff options
author | Satoshi Sahara <sahara.satoshi@gmail.com> | 2020-08-13 12:34:10 +0900 |
---|---|---|
committer | Satoshi Sahara <sahara.satoshi@gmail.com> | 2020-08-13 12:34:10 +0900 |
commit | 2c210ad72adfec6edcda2464d0f4e194d7aa8b3c (patch) | |
tree | 5fcf29cd7ddb196c6f31efa1676f544fef6c68ce | |
parent | 23a8b8f814821853bb3075cb411a68db2ae97e3f (diff) | |
download | dokuwiki-2c210ad72adfec6edcda2464d0f4e194d7aa8b3c.tar.gz dokuwiki-2c210ad72adfec6edcda2464d0f4e194d7aa8b3c.zip |
split out two form creation methods of ResendPwd
we can use prefillInput feature of InputElement class, no need to refer $INPUT in formResendPassword()
-rw-r--r-- | inc/Ui/UserResendPwd.php | 91 |
1 files changed, 58 insertions, 33 deletions
diff --git a/inc/Ui/UserResendPwd.php b/inc/Ui/UserResendPwd.php index ee9b99415..1a7296074 100644 --- a/inc/Ui/UserResendPwd.php +++ b/inc/Ui/UserResendPwd.php @@ -23,7 +23,6 @@ class UserResendPwd extends Ui */ public function show() { - global $lang; global $conf; global $INPUT; @@ -31,47 +30,73 @@ class UserResendPwd extends Ui // print intro print p_locale_xhtml('resetpwd'); - print '<div class="centeralign">'.DOKU_LF; + print '<div class="centeralign">'; if (!$conf['autopasswd'] && $token) { - // create the form - $form = new Form(['id' => 'dw__resendpwd']); - $form->addTagOpen('div')->addClass('no'); - $form->addFieldsetOpen($lang['btn_resendpwd']); - $form->setHiddenField('token', $token); - $form->setHiddenField('do', 'resendpwd'); - $input = $form->addPasswordInput('pass', $lang['pass'])->attr('size', '50')->addClass('edit'); - $input->getLabel()->attr('class', 'block'); - $form->addHTML("<br>\n"); - $input = $form->addPasswordInput('passchk', $lang['passchk'])->attr('size', '50')->addClass('edit'); - $input->getLabel()->attr('class', 'block'); - $form->addHTML("<br>\n"); - $form->addButton('', $lang['btn_resendpwd'])->attrs(['type' => 'submit']); - $form->addFieldsetClose(); - $form->addTagClose('div'); + $form = $this->formSetNewPassword($token); } else { - // create the form - $form = new Form(['id' => 'dw__resendpwd']); - $form->addTagOpen('div')->addClass('no'); - $form->addFieldsetOpen($lang['btn_resendpwd']); - $form->setHiddenField('do', 'resendpwd'); - $form->setHiddenField('save', '1'); - $form->addHTML("<br>\n"); - $input = $form->addTextInput('login', $lang['user'])->addClass('edit') - ->val($INPUT->str('login')); - $input->getLabel()->attr('class', 'block'); - $form->addHTML("<br>\n"); - $form->addHTML("<br>\n"); - $form->addButton('', $lang['btn_resendpwd'])->attrs(['type' => 'submit']); - $form->addFieldsetClose(); - $form->addTagClose('div'); + $form = $this->formResendPassword(); } // emit HTML_RESENDPWDFORM_OUTPUT event Event::createAndTrigger('HTML_RESENDPWDFORM_OUTPUT', $form, null, false); print $form->toHTML(); - print '</div>'.DOKU_LF; + print '</div>'; + } + + /** + * create a form ui to set new password + * + * @params string $token cleaned pwauth request variable + * @return Form + */ + protected function formSetNewPassword($token) + { + global $lang; + + // create the form + $form = new Form(['id' => 'dw__resendpwd']); + $form->addTagOpen('div')->addClass('no'); + $form->addFieldsetOpen($lang['btn_resendpwd']); + $form->setHiddenField('token', $token); + $form->setHiddenField('do', 'resendpwd'); + $input = $form->addPasswordInput('pass', $lang['pass'])->attr('size', '50')->addClass('edit'); + $input->getLabel()->attr('class', 'block'); + $form->addHTML("<br>\n"); + $input = $form->addPasswordInput('passchk', $lang['passchk'])->attr('size', '50')->addClass('edit'); + $input->getLabel()->attr('class', 'block'); + $form->addHTML("<br>\n"); + $form->addButton('', $lang['btn_resendpwd'])->attr('type', 'submit'); + $form->addFieldsetClose(); + $form->addTagClose('div'); + return $form; + } + + /** + * create a form ui to request new password + * + * @return Form + */ + protected function formResendPassword() + { + global $lang; + + // create the form + $form = new Form(['id' => 'dw__resendpwd']); + $form->addTagOpen('div')->addClass('no'); + $form->addFieldsetOpen($lang['btn_resendpwd']); + $form->setHiddenField('do', 'resendpwd'); + $form->setHiddenField('save', '1'); + $form->addHTML("<br>\n"); + $input = $form->addTextInput('login', $lang['user'])->addClass('edit'); + $input->getLabel()->attr('class', 'block'); + $form->addHTML("<br>\n"); + $form->addHTML("<br>\n"); + $form->addButton('', $lang['btn_resendpwd'])->attr('type', 'submit'); + $form->addFieldsetClose(); + $form->addTagClose('div'); + return $form; } } |