1<?php 2 3namespace dokuwiki\Ui; 4 5use dokuwiki\Extension\Event; 6use dokuwiki\Form\Form; 7 8/** 9 * DokuWiki User Login Insterface (Login Form) 10 * 11 * @package dokuwiki\Ui 12 */ 13class Login extends Ui 14{ 15 /** 16 * Display the Login Form Panel 17 * 18 * @author Andreas Gohr <andi@splitbrain.org> 19 * 20 * @triggers HTML_LOGINFORM_OUTPUT 21 * @param bool $svg Whether to show svg icons in the register and resendpwd links or not 22 * @return void 23 */ 24 public function show($svg = false) 25 { 26 global $lang; 27 global $conf; 28 global $ID; 29 global $INPUT; 30 31 // print intro 32 print p_locale_xhtml('login'); 33 print '<div class="centeralign">'.NL; 34 35 // create the login form 36 $form = new Form(['id' => 'dw__login', 'action' => wl($ID)]); 37 $form->addTagOpen('div')->addClass('no'); 38 $form->addFieldsetOpen($lang['btn_login']); 39 $form->setHiddenField('id', $ID); 40 $form->setHiddenField('do', 'login'); 41 42 $input = $form->addTextInput('u', $lang['user'])->id('focus__this')->addClass('edit') 43 ->val((!$INPUT->bool('http_credentials')) ? $INPUT->str('u') : ''); 44 $input->getLabel()->attr('class', 'block'); 45 $form->addHTML("<br>\n"); 46 47 $input = $form->addPasswordInput('p', $lang['pass'])->addClass('block edit'); 48 $input->getLabel()->attr('class', 'block'); 49 $form->addHTML("<br>\n"); 50 51 if ($conf['rememberme']) { 52 $form->addCheckbox('r', $lang['remember'])->id('remember__me')->val('1'); 53 } 54 $form->addButton('', $lang['btn_login'])->attr('type', 'submit'); 55 $form->addFieldsetClose(); 56 $form->addTagClose('div'); 57 58 if(actionOK('register')){ 59 $registerLink = (new \dokuwiki\Menu\Item\Register())->asHtmlLink('', $svg); 60 $form->addHTML('<p>'.$lang['reghere'].': '. $registerLink .'</p>'); 61 } 62 63 if (actionOK('resendpwd')) { 64 $resendPwLink = (new \dokuwiki\Menu\Item\Resendpwd())->asHtmlLink('', $svg); 65 $form->addHTML('<p>'.$lang['pwdforget'].': '. $resendPwLink .'</p>'); 66 } 67 68 // emit HTML_LOGINFORM_OUTPUT event, print the form 69 Event::createAndTrigger('HTML_LOGINFORM_OUTPUT', $form, 'html_form_output', false); 70 71 print '</div>'.DOKU_LF; 72 } 73 74} 75