[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_privacy/src/View/Confirm/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_privacy
   6   *
   7   * @copyright   (C) 2018 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\Privacy\Site\View\Confirm;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Form\Form;
  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\Registry\Registry;
  20  
  21  // phpcs:disable PSR1.Files.SideEffects
  22  \defined('_JEXEC') or die;
  23  // phpcs:enable PSR1.Files.SideEffects
  24  
  25  /**
  26   * Request confirmation view class
  27   *
  28   * @since  3.9.0
  29   */
  30  class HtmlView extends BaseHtmlView
  31  {
  32      /**
  33       * The form object
  34       *
  35       * @var    Form
  36       * @since  3.9.0
  37       */
  38      protected $form;
  39  
  40      /**
  41       * The CSS class suffix to append to the view container
  42       *
  43       * @var    string
  44       * @since  3.9.0
  45       */
  46      protected $pageclass_sfx;
  47  
  48      /**
  49       * The view parameters
  50       *
  51       * @var    Registry
  52       * @since  3.9.0
  53       */
  54      protected $params;
  55  
  56      /**
  57       * The state information
  58       *
  59       * @var    CMSObject
  60       * @since  3.9.0
  61       */
  62      protected $state;
  63  
  64      /**
  65       * Execute and display a template script.
  66       *
  67       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  68       *
  69       * @return  void
  70       *
  71       * @see     BaseHtmlView::loadTemplate()
  72       * @since   3.9.0
  73       * @throws  \Exception
  74       */
  75      public function display($tpl = null)
  76      {
  77          // Initialise variables.
  78          $this->form   = $this->get('Form');
  79          $this->state  = $this->get('State');
  80          $this->params = $this->state->params;
  81  
  82          // Check for errors.
  83          if (count($errors = $this->get('Errors'))) {
  84              throw new GenericDataException(implode("\n", $errors), 500);
  85          }
  86  
  87          // Escape strings for HTML output
  88          $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx', ''), ENT_COMPAT, 'UTF-8');
  89  
  90          $this->prepareDocument();
  91  
  92          parent::display($tpl);
  93      }
  94  
  95      /**
  96       * Prepares the document.
  97       *
  98       * @return  void
  99       *
 100       * @since   3.9.0
 101       */
 102      protected function prepareDocument()
 103      {
 104          // Because the application sets a default page title,
 105          // we need to get it from the menu item itself
 106          $menu = Factory::getApplication()->getMenu()->getActive();
 107  
 108          if ($menu) {
 109              $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
 110          } else {
 111              $this->params->def('page_heading', Text::_('COM_PRIVACY_VIEW_CONFIRM_PAGE_TITLE'));
 112          }
 113  
 114          $this->setDocumentTitle($this->params->get('page_title', ''));
 115  
 116          if ($this->params->get('menu-meta_description')) {
 117              $this->document->setDescription($this->params->get('menu-meta_description'));
 118          }
 119  
 120          if ($this->params->get('robots')) {
 121              $this->document->setMetaData('robots', $this->params->get('robots'));
 122          }
 123      }
 124  }


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