[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_users/src/View/Reset/ -> 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\Reset;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\MVC\View\GenericDataException;
  16  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  17  use Joomla\CMS\Object\CMSObject;
  18  
  19  // phpcs:disable PSR1.Files.SideEffects
  20  \defined('_JEXEC') or die;
  21  // phpcs:enable PSR1.Files.SideEffects
  22  
  23  /**
  24   * Reset view class for Users.
  25   *
  26   * @since  1.5
  27   */
  28  class HtmlView extends BaseHtmlView
  29  {
  30      /**
  31       * The Form object
  32       *
  33       * @var  \Joomla\CMS\Form\Form
  34       */
  35      protected $form;
  36  
  37      /**
  38       * The page parameters
  39       *
  40       * @var  \Joomla\Registry\Registry|null
  41       */
  42      protected $params;
  43  
  44      /**
  45       * The model state
  46       *
  47       * @var  CMSObject
  48       */
  49      protected $state;
  50  
  51      /**
  52       * The page class suffix
  53       *
  54       * @var    string
  55       * @since  4.0.0
  56       */
  57      protected $pageclass_sfx = '';
  58  
  59      /**
  60       * Method to display the view.
  61       *
  62       * @param   string  $tpl  The template file to include
  63       *
  64       * @return  mixed
  65       *
  66       * @since   1.5
  67       */
  68      public function display($tpl = null)
  69      {
  70          // This name will be used to get the model
  71          $name = $this->getLayout();
  72  
  73          // Check that the name is valid - has an associated model.
  74          if (!in_array($name, array('confirm', 'complete'))) {
  75              $name = 'default';
  76          }
  77  
  78          if ('default' === $name) {
  79              $formname = 'Form';
  80          } else {
  81              $formname = ucfirst($this->_name) . ucfirst($name) . 'Form';
  82          }
  83  
  84          // Get the view data.
  85          $this->form   = $this->get($formname);
  86          $this->state  = $this->get('State');
  87          $this->params = $this->state->params;
  88  
  89          // Check for errors.
  90          if (count($errors = $this->get('Errors'))) {
  91              throw new GenericDataException(implode("\n", $errors), 500);
  92          }
  93  
  94          // Escape strings for HTML output
  95          $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx', ''), ENT_COMPAT, 'UTF-8');
  96  
  97          $this->prepareDocument();
  98  
  99          parent::display($tpl);
 100      }
 101  
 102      /**
 103       * Prepares the document.
 104       *
 105       * @return  void
 106       *
 107       * @since   1.6
 108       * @throws  \Exception
 109       */
 110      protected function prepareDocument()
 111      {
 112          // Because the application sets a default page title,
 113          // we need to get it from the menu item itself
 114          $menu = Factory::getApplication()->getMenu()->getActive();
 115  
 116          if ($menu) {
 117              $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
 118          } else {
 119              $this->params->def('page_heading', Text::_('COM_USERS_RESET'));
 120          }
 121  
 122          $this->setDocumentTitle($this->params->get('page_title', ''));
 123  
 124          if ($this->params->get('menu-meta_description')) {
 125              $this->document->setDescription($this->params->get('menu-meta_description'));
 126          }
 127  
 128          if ($this->params->get('robots')) {
 129              $this->document->setMetaData('robots', $this->params->get('robots'));
 130          }
 131      }
 132  }


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