first commit
This commit is contained in:
51
components/com_modules/src/Controller/DisplayController.php
Normal file
51
components/com_modules/src/Controller/DisplayController.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_modules
|
||||
*
|
||||
* @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\Modules\Site\Controller;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Input\Input;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Modules manager display controller.
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
class DisplayController extends BaseController
|
||||
{
|
||||
/**
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* Recognized key values include 'name', 'default_task', 'model_path', and
|
||||
* 'view_path' (this list is not meant to be comprehensive).
|
||||
* @param MVCFactoryInterface|null $factory The factory.
|
||||
* @param CMSApplication|null $app The Application for the dispatcher
|
||||
* @param Input|null $input The Input object for the request
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
|
||||
{
|
||||
$this->input = Factory::getApplication()->getInput();
|
||||
|
||||
// Modules frontpage Editor Module proxying.
|
||||
if ($this->input->get('view') === 'modules' && $this->input->get('layout') === 'modal') {
|
||||
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
|
||||
}
|
||||
|
||||
parent::__construct($config, $factory, $app, $input);
|
||||
}
|
||||
}
|
||||
80
components/com_modules/src/Dispatcher/Dispatcher.php
Normal file
80
components/com_modules/src/Dispatcher/Dispatcher.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_modules
|
||||
*
|
||||
* @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\Modules\Site\Dispatcher;
|
||||
|
||||
use Joomla\CMS\Access\Exception\NotAllowed;
|
||||
use Joomla\CMS\Dispatcher\ComponentDispatcher;
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* ComponentDispatcher class for com_modules
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class Dispatcher extends ComponentDispatcher
|
||||
{
|
||||
/**
|
||||
* Load the language
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function loadLanguage()
|
||||
{
|
||||
$this->app->getLanguage()->load('com_modules', JPATH_ADMINISTRATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a controller task. Redirecting the user if appropriate.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function checkAccess()
|
||||
{
|
||||
parent::checkAccess();
|
||||
|
||||
if (
|
||||
$this->input->get('view') === 'modules'
|
||||
&& $this->input->get('layout') === 'modal'
|
||||
&& !$this->app->getIdentity()->authorise('core.create', 'com_modules')
|
||||
) {
|
||||
throw new NotAllowed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a controller from the component
|
||||
*
|
||||
* @param string $name Controller name
|
||||
* @param string $client Optional client (like Administrator, Site etc.)
|
||||
* @param array $config Optional controller config
|
||||
*
|
||||
* @return \Joomla\CMS\MVC\Controller\BaseController
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function getController(string $name, string $client = '', array $config = []): BaseController
|
||||
{
|
||||
if ($this->input->get('task') === 'orderPosition') {
|
||||
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
|
||||
$client = 'Administrator';
|
||||
}
|
||||
|
||||
return parent::getController($name, $client, $config);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user