[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_config/src/View/Modules/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_config
   6   *
   7   * @copyright   (C) 2017 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\Config\Site\View\Modules;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Form\Form;
  15  use Joomla\CMS\Language\Text;
  16  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * View to edit a module.
  24   *
  25   * @since       3.2
  26   */
  27  class HtmlView extends BaseHtmlView
  28  {
  29      /**
  30       * The module to be rendered
  31       *
  32       * @var   array
  33       *
  34       * @since 3.2
  35       */
  36      public $item;
  37  
  38      /**
  39       * The form object
  40       *
  41       * @var   Form
  42       *
  43       * @since 3.2
  44       */
  45      public $form;
  46  
  47      /**
  48       * Execute and display a template script.
  49       *
  50       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  51       *
  52       * @return  void
  53       *
  54       * @since   3.2
  55       */
  56      public function display($tpl = null)
  57      {
  58          $lang = Factory::getApplication()->getLanguage();
  59          $lang->load('', JPATH_ADMINISTRATOR, $lang->getTag());
  60          $lang->load('com_modules', JPATH_ADMINISTRATOR, $lang->getTag());
  61  
  62          // @todo Move and clean up
  63          $module = (new \Joomla\Component\Modules\Administrator\Model\ModuleModel())->getItem(Factory::getApplication()->input->getInt('id'));
  64  
  65          $moduleData = $module->getProperties();
  66          unset($moduleData['xml']);
  67  
  68          /** @var \Joomla\Component\Config\Site\Model\ModulesModel $model */
  69          $model = $this->getModel();
  70  
  71          // Need to add module name to the state of model
  72          $model->getState()->set('module.name', $moduleData['module']);
  73  
  74          /** @var Form form */
  75          $this->form      = $this->get('form');
  76          $this->positions = $this->get('positions');
  77          $this->item      = $moduleData;
  78  
  79          if ($this->form) {
  80              $this->form->bind($moduleData);
  81          }
  82  
  83          $this->_prepareDocument();
  84  
  85          parent::display($tpl);
  86      }
  87  
  88      /**
  89       * Prepares the document.
  90       *
  91       * @return  void
  92       *
  93       * @since   4.0.0
  94       */
  95      protected function _prepareDocument()
  96      {
  97          // There is no menu item for this so we have to use the title from the component
  98          $this->setDocumentTitle(Text::_('COM_CONFIG_MODULES_SETTINGS_TITLE'));
  99      }
 100  }


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