CoreFiles by mySites.guru
HtmlView.php110 lines, 2,934 bytes, from Joomla_6.3.0-alpha1-Alpha-Full_Package.zip
Raw History Compare with 6.2.0-alpha3
md5
71dbc228748ea1cae55f1c677528bcab
sha1
28c0e716f06561bcd92a8bf425f169fa4ea50fd3
sha256
db84c3a46f6a2917965a2efa484c91081883d935522e2d987269ad7d2c427672
<?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') . ': ' . $this->item['title']
        );
    }
}

No other release has this exact content. See every version of this file.