[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Ui/ -> Login.php (source)

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