CoreFiles by mySites.guru
HtmlView.php108 lines, 2,886 bytes, from Joomla_6.0.4-Stable-Full_Package.zip
Raw History Compare with 6.0.3
md5
a67813f1b528797a05e54b221c07077f
sha1
e4925a8127469c225980026bba90f2f6f688a7f4
sha256
917aacfaba87ea0575c80f8c64b6e86350b9d6d016b538d646fb81e77e5f421a
<?php

/**
 * @package     Joomla.Site
 * @subpackage  com_config
 *
 * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Config\Site\View\Modules;

use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\Component\Config\Site\Model\ModulesModel;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * View to edit a module.
 *
 * @since       3.2
 */
class HtmlView extends BaseHtmlView
{
    /**
     * The module to be rendered
     *
     * @var   array
     *
     * @since 3.2
     */
    public $item;

    /**
     * The form object
     *
     * @var   Form
     *
     * @since 3.2
     */
    public $form;

    /**
     * Execute and display a template script.
     *
     * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
     *
     * @return  void
     *
     * @since   3.2
     */
    public function display($tpl = null)
    {
        $lang = Factory::getApplication()->getLanguage();
        $lang->load('', JPATH_ADMINISTRATOR, $lang->getTag());
        $lang->load('com_modules', JPATH_ADMINISTRATOR, $lang->getTag());

        // @todo Move and clean up
        $module = (new \Joomla\Component\Modules\Administrator\Model\ModuleModel())->getItem(Factory::getApplication()->getInput()->getInt('id'));

        $moduleData = get_object_vars($module);
        unset($moduleData['xml']);

        /** @var \Joomla\Component\Config\Site\Model\ModulesModel $model */
        $model = $this->getModel();

        // Need to add module name to the state of model
        $model->getState()->set('module.name', $moduleData['module']);

        /** @var ModulesModel $model */
        $model           = $this->getModel();
        $this->form      = $model->getForm();
        $this->positions = $model->getPositions();
        $this->item      = $moduleData;

        if ($this->form) {
            $this->form->bind($moduleData);

            // Add form control fields
            $this->form
                ->addControlField('task', '')
                ->addControlField('return', Factory::getApplication()->getInput()->get('return', null, 'base64'))
                ->addControlField('id', $this->item['id']);
        }

        $this->_prepareDocument();

        parent::display($tpl);
    }

    /**
     * Prepares the document.
     *
     * @return  void
     *
     * @since   4.0.0
     */
    protected function _prepareDocument()
    {
        // There is no menu item for this so we have to use the title from the component
        $this->setDocumentTitle(Text::_('COM_CONFIG_MODULES_SETTINGS_TITLE'));
    }
}

The same content is in 18 releases, Joomla 6.0.0-beta1 to 6.1.0-alpha2. See them all, or every version of this file.