[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_users/src/View/Login/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_users
   6   *
   7   * @copyright   (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Users\Site\View\Login;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Helper\AuthenticationHelper;
  15  use Joomla\CMS\Language\Text;
  16  use Joomla\CMS\MVC\View\GenericDataException;
  17  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  18  use Joomla\CMS\Object\CMSObject;
  19  use Joomla\CMS\User\User;
  20  
  21  // phpcs:disable PSR1.Files.SideEffects
  22  \defined('_JEXEC') or die;
  23  // phpcs:enable PSR1.Files.SideEffects
  24  
  25  /**
  26   * Login view class for Users.
  27   *
  28   * @since  1.5
  29   */
  30  class HtmlView extends BaseHtmlView
  31  {
  32      /**
  33       * The Form object
  34       *
  35       * @var  \Joomla\CMS\Form\Form
  36       */
  37      protected $form;
  38  
  39      /**
  40       * The page parameters
  41       *
  42       * @var  \Joomla\Registry\Registry|null
  43       */
  44      protected $params;
  45  
  46      /**
  47       * The model state
  48       *
  49       * @var  CMSObject
  50       */
  51      protected $state;
  52  
  53      /**
  54       * The logged in user
  55       *
  56       * @var  User
  57       */
  58      protected $user;
  59  
  60      /**
  61       * The page class suffix
  62       *
  63       * @var    string
  64       * @since  4.0.0
  65       */
  66      protected $pageclass_sfx = '';
  67  
  68      /**
  69       * No longer used
  70       *
  71       * @var    boolean
  72       * @since  4.0.0
  73       * @deprecated 4.2.0 Will be removed in 5.0.
  74       */
  75      protected $tfa = false;
  76  
  77      /**
  78       * Additional buttons to show on the login page
  79       *
  80       * @var    array
  81       * @since  4.0.0
  82       */
  83      protected $extraButtons = [];
  84  
  85      /**
  86       * Method to display the view.
  87       *
  88       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  89       *
  90       * @return  void
  91       *
  92       * @since   1.5
  93       * @throws  \Exception
  94       */
  95      public function display($tpl = null)
  96      {
  97          // Get the view data.
  98          $this->user   = $this->getCurrentUser();
  99          $this->form   = $this->get('Form');
 100          $this->state  = $this->get('State');
 101          $this->params = $this->state->get('params');
 102  
 103          // Check for errors.
 104          if (count($errors = $this->get('Errors'))) {
 105              throw new GenericDataException(implode("\n", $errors), 500);
 106          }
 107  
 108          // Check for layout override
 109          $active = Factory::getApplication()->getMenu()->getActive();
 110  
 111          if (isset($active->query['layout'])) {
 112              $this->setLayout($active->query['layout']);
 113          }
 114  
 115          $this->extraButtons = AuthenticationHelper::getLoginButtons('com-users-login__form');
 116  
 117          // Escape strings for HTML output
 118          $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx', ''), ENT_COMPAT, 'UTF-8');
 119  
 120          $this->prepareDocument();
 121  
 122          parent::display($tpl);
 123      }
 124  
 125      /**
 126       * Prepares the document
 127       *
 128       * @return  void
 129       *
 130       * @since   1.6
 131       * @throws  \Exception
 132       */
 133      protected function prepareDocument()
 134      {
 135          $login = $this->getCurrentUser()->get('guest') ? true : false;
 136  
 137          // Because the application sets a default page title,
 138          // we need to get it from the menu item itself
 139          $menu = Factory::getApplication()->getMenu()->getActive();
 140  
 141          if ($menu) {
 142              $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
 143          } else {
 144              $this->params->def('page_heading', $login ? Text::_('JLOGIN') : Text::_('JLOGOUT'));
 145          }
 146  
 147          $this->setDocumentTitle($this->params->get('page_title', ''));
 148  
 149          if ($this->params->get('menu-meta_description')) {
 150              $this->document->setDescription($this->params->get('menu-meta_description'));
 151          }
 152  
 153          if ($this->params->get('robots')) {
 154              $this->document->setMetaData('robots', $this->params->get('robots'));
 155          }
 156      }
 157  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer