Login.php 2.3 KB

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