[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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


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