File manager - Edit - /home/ferretapmx/public_html/Dispatcher.zip
Back
PK z�\J���~ ~ AbstractModuleDispatcher.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Dispatcher; use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\CMS\Helper\ModuleHelper; use Joomla\Input\Input; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Base class for a Joomla Module Dispatcher. * * @since 4.0.0 */ abstract class AbstractModuleDispatcher extends Dispatcher { /** * The module instance * * @var \stdClass * @since 4.0.0 */ protected $module; /** * Constructor for Dispatcher * * @param \stdClass $module The module * @param CMSApplicationInterface $app The application instance * @param Input $input The input instance * * @since 4.0.0 */ public function __construct(\stdClass $module, CMSApplicationInterface $app, Input $input) { parent::__construct($app, $input); $this->module = $module; } /** * Runs the dispatcher. * * @return void * * @since 4.0.0 */ public function dispatch() { $this->loadLanguage(); $displayData = $this->getLayoutData(); // Stop when display data is false if ($displayData === false) { return; } // Execute the layout without the module context $loader = static function (array $displayData) { // If $displayData doesn't exist in extracted data, unset the variable. if (!\array_key_exists('displayData', $displayData)) { extract($displayData); unset($displayData); } else { extract($displayData); } /** * Extracted variables * ----------------- * @var \stdClass $module * @var Registry $params */ require ModuleHelper::getLayoutPath($module->module, $params->get('layout', 'default')); }; $loader($displayData); } /** * Returns the layout data. This function can be overridden by subclasses to add more * attributes for the layout. * * If false is returned, then it means that the dispatch process should be stopped. * * @return array|false * * @since 4.0.0 */ protected function getLayoutData() { return [ 'module' => $this->module, 'app' => $this->app, 'input' => $this->input, 'params' => new Registry($this->module->params), 'template' => $this->app->getTemplate(), ]; } /** * Load the language. * * @return void * * @since 4.0.0 */ protected function loadLanguage() { $language = $this->app->getLanguage(); $coreLanguageDirectory = JPATH_BASE; $extensionLanguageDirectory = JPATH_BASE . '/modules/' . $this->module->module; $langPaths = $language->getPaths(); // Only load the module's language file if it hasn't been already if (!$langPaths || (!isset($langPaths[$coreLanguageDirectory]) && !isset($langPaths[$extensionLanguageDirectory]))) { // 1.5 or Core then 1.6 3PD $language->load($this->module->module, $coreLanguageDirectory) || $language->load($this->module->module, $extensionLanguageDirectory); } } } PK z�\�q�p p ComponentDispatcher.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Dispatcher; use Joomla\CMS\Access\Exception\NotAllowed; use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\BaseController; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\Input\Input; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Base class for a Joomla Component Dispatcher * * Dispatchers are responsible for checking ACL of a component if appropriate and * choosing an appropriate controller (and if necessary, a task) and executing it. * * @since 4.0.0 */ class ComponentDispatcher extends Dispatcher { /** * The URL option for the component. * * @var string * @since 4.0.0 */ protected $option; /** * The MVC factory * * @var MVCFactoryInterface * * @since 4.0.0 */ protected $mvcFactory; /** * Constructor for ComponentDispatcher * * @param CMSApplicationInterface $app The application instance * @param Input $input The input instance * @param MVCFactoryInterface $mvcFactory The MVC factory instance * * @since 4.0.0 */ public function __construct(CMSApplicationInterface $app, Input $input, MVCFactoryInterface $mvcFactory) { parent::__construct($app, $input); $this->mvcFactory = $mvcFactory; // If option is not provided, detect it from dispatcher class name, ie ContentDispatcher if (empty($this->option)) { $this->option = ComponentHelper::getComponentName( $this, str_replace('com_', '', $input->get('option')) ); } $this->loadLanguage(); } /** * Load the language * * @return void * * @since 4.0.0 */ protected function loadLanguage() { // Load common and local language files. $this->app->getLanguage()->load($this->option, JPATH_BASE) || $this->app->getLanguage()->load($this->option, JPATH_BASE . '/components/' . $this->option); } /** * Method to check component access permission * * @return void * * @since 4.0.0 */ protected function checkAccess() { // Check the user has permission to access this component if in the backend if ($this->app->isClient('administrator') && !$this->app->getIdentity()->authorise('core.manage', $this->option)) { throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403); } } /** * Dispatch a controller task. Redirecting the user if appropriate. * * @return void * * @since 4.0.0 */ public function dispatch() { // Check component access permission $this->checkAccess(); $command = $this->input->getCmd('task', 'display'); // Check for a controller.task command. if (str_contains($command, '.')) { // Explode the controller.task command. [$controller, $task] = explode('.', $command); $this->input->set('controller', $controller); $this->input->set('task', $task); } else { // Do we have a controller? $controller = $this->input->get('controller', 'display'); $task = $command; } // Build controller config data $config = ['option' => $this->option]; // Set name of controller if it is passed in the request if ($this->input->exists('controller')) { $config['name'] = strtolower($this->input->get('controller')); } // Execute the task for this component $controller = $this->getController($controller, ucfirst($this->app->getName()), $config); $controller->execute($task); $controller->redirect(); } /** * 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 BaseController * * @since 4.0.0 */ public function getController(string $name, string $client = '', array $config = []): BaseController { // Set up the client $client = $client ?: ucfirst($this->app->getName()); // Get the controller instance $controller = $this->mvcFactory->createController( $name, $client, $config, $this->app, $this->input ); // Check if the controller could be created if (!$controller) { throw new \InvalidArgumentException(Text::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS', $name), 404); } return $controller; } } PK z�\K�? ? LegacyComponentDispatcher.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Dispatcher; use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Language\Text; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Base class for a legacy Joomla Dispatcher * * Executes the single entry file of a legacy component. * * @since 4.0.0 */ class LegacyComponentDispatcher implements DispatcherInterface { /** * The application instance * * @var CMSApplication * @since 4.0.0 */ private $app; /** * Constructor for Dispatcher * * @param CMSApplication $app The application instance * * @since 4.0.0 */ public function __construct(CMSApplication $app) { $this->app = $app; } /** * Dispatch a controller task. Redirecting the user if appropriate. * * @return void * * @since 4.0.0 */ public function dispatch() { $path = JPATH_BASE . '/components/' . $this->app->scope . '/' . substr($this->app->scope, 4) . '.php'; // If component file doesn't exist throw error if (!is_file($path)) { throw new \Exception(Text::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404); } $lang = $this->app->getLanguage(); // Load common and local language files. $lang->load($this->app->scope, JPATH_BASE) || $lang->load($this->app->scope, JPATH_BASE . '/components/' . $this->app->scope); // Execute the component $loader = static function ($path) { require_once $path; }; $loader($path); } } PK z�\��[q q ModuleDispatcher.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Dispatcher; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Base class for a Joomla Module Dispatcher * * Executes the single entry file of a module. * * @since 4.0.0 */ class ModuleDispatcher extends AbstractModuleDispatcher { /** * Dispatches the dispatcher. * * @return void * * @since 4.0.0 */ public function dispatch() { $path = JPATH_BASE . '/modules/' . $this->module->module . '/' . $this->module->module . '.php'; if (!is_file($path)) { return; } $this->loadLanguage(); // Execute the layout without the module context $loader = static function ($path, array $displayData) { // If $displayData doesn't exist in extracted data, unset the variable. if (!\array_key_exists('displayData', $displayData)) { extract($displayData); unset($displayData); } else { extract($displayData); } include $path; }; $loader($path, $this->getLayoutData()); } } PK z�\� r r Dispatcher.phpnu �[��� <?php /** * @package Joomla.Site * @subpackage mod_finder * * @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Module\Finder\Site\Dispatcher; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Dispatcher\AbstractModuleDispatcher; use Joomla\CMS\Helper\HelperFactoryAwareInterface; use Joomla\CMS\Helper\HelperFactoryAwareTrait; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; use Joomla\CMS\Uri\Uri; use Joomla\Component\Finder\Administrator\Helper\LanguageHelper; use Joomla\Component\Finder\Site\Helper\RouteHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Dispatcher class for mod_finder * * @since 5.4.0 */ class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface { use HelperFactoryAwareTrait; /** * Returns the layout data. * * @return array * * @since 5.4.0 */ protected function getLayoutData() { $data = parent::getLayoutData(); $cparams = ComponentHelper::getParams('com_finder'); // Check for OpenSearch if ($data['params']->get('opensearch', $cparams->get('opensearch', 1))) { $defaultTitle = Text::_('MOD_FINDER_OPENSEARCH_NAME') . ' ' . $data['app']->get('sitename'); $ostitle = $data['params']->get('opensearch_name', $cparams->get('opensearch_name', $defaultTitle)); $data['app']->getDocument()->addHeadLink( Uri::getInstance()->toString(['scheme', 'host', 'port']) . Route::_('index.php?option=com_finder&view=search&format=opensearch'), 'search', 'rel', ['title' => $ostitle, 'type' => 'application/opensearchdescription+xml'] ); } // Get the route. $data['route'] = RouteHelper::getSearchRoute($data['params']->get('searchfilter', null)); if ($data['params']->get('set_itemid')) { $uri = Uri::getInstance($data['route']); $uri->setVar('Itemid', $data['params']->get('set_itemid')); $data['route'] = $uri->toString(['path', 'query']); } // Load component language file. LanguageHelper::loadComponentLanguage(); // Load plugin language files. LanguageHelper::loadPluginLanguage(); // Get Smart Search query object. $data['query'] = $this->getHelperFactory()->getHelper('FinderHelper')->getSearchQuery($data['params'], $data['app']); return $data; } } PK z�\8S��� � ComponentDispatcherFactory.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Dispatcher; use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\Input\Input; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Namespace based implementation of the ComponentDispatcherFactoryInterface * * @since 4.0.0 */ class ComponentDispatcherFactory implements ComponentDispatcherFactoryInterface { /** * The extension namespace * * @var string * * @since 4.0.0 */ protected $namespace; /** * The MVC factory * * @var MVCFactoryInterface * * @since 4.0.0 */ private $mvcFactory; /** * ComponentDispatcherFactory constructor. * * @param string $namespace The namespace * @param MVCFactoryInterface $mvcFactory The MVC factory * * @since 4.0.0 */ public function __construct(string $namespace, MVCFactoryInterface $mvcFactory) { $this->namespace = $namespace; $this->mvcFactory = $mvcFactory; } /** * Creates a dispatcher. * * @param CMSApplicationInterface $application The application * @param ?Input $input The input object, defaults to the one in the application * * @return DispatcherInterface * * @since 4.0.0 */ public function createDispatcher(CMSApplicationInterface $application, ?Input $input = null): DispatcherInterface { $name = ucfirst($application->getName()); $className = '\\' . trim($this->namespace, '\\') . '\\' . $name . '\\Dispatcher\\Dispatcher'; if (!class_exists($className)) { if ($application->isClient('api')) { $className = ApiDispatcher::class; } else { $className = ComponentDispatcher::class; } } return new $className($application, $input ?: $application->getInput(), $this->mvcFactory); } } PK z�\J+��K K ApiDispatcher.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Dispatcher; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * API Implementation for our dispatcher. It loads a component's administrator language files, and calls the API * Controller so that components that haven't implemented web services can add their own handling. * * @since 4.0.0 */ final class ApiDispatcher extends ComponentDispatcher { /** * Load the component's administrator language * * @since 4.0.0 * * @return void */ protected function loadLanguage() { // Load common and local language files. $this->app->getLanguage()->load($this->option, JPATH_BASE) || $this->app->getLanguage()->load($this->option, JPATH_ADMINISTRATOR) || $this->app->getLanguage()->load($this->option, JPATH_ADMINISTRATOR . '/components/' . $this->option); } /** * Dispatch a controller task. API Overrides to ensure there is no redirects. * * @return void * * @since 4.0.0 */ public function dispatch() { $task = $this->input->getCmd('task', 'display'); // Build controller config data $config = ['option' => $this->option]; // Set name of controller if it is passed in the request if ($this->input->exists('controller')) { $config['name'] = strtolower($this->input->get('controller')); } $controller = $this->input->get('controller'); $controller = $this->getController($controller, ucfirst($this->app->getName()), $config); $controller->execute($task); } } PK z�\���G� � ModuleDispatcherFactory.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Dispatcher; use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\Input\Input; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Namespace based implementation of the ModuleDispatcherFactoryInterface * * @since 4.0.0 */ class ModuleDispatcherFactory implements ModuleDispatcherFactoryInterface { /** * The extension namespace * * @var string * * @since 4.0.0 */ private $namespace; /** * ModuleDispatcherFactory constructor. * * @param string $namespace The namespace * * @since 4.0.0 */ public function __construct(string $namespace) { $this->namespace = $namespace; } /** * Creates a dispatcher. * * @param \stdClass $module The module * @param CMSApplicationInterface $application The application * @param ?Input $input The input object, defaults to the one in the application * * @return DispatcherInterface * * @since 4.0.0 */ public function createDispatcher(\stdClass $module, CMSApplicationInterface $application, ?Input $input = null): DispatcherInterface { $name = 'Site'; if ($application->isClient('administrator')) { $name = 'Administrator'; } $className = '\\' . trim($this->namespace, '\\') . '\\' . $name . '\\Dispatcher\\Dispatcher'; if (!class_exists($className)) { $className = ModuleDispatcher::class; } return new $className($module, $application, $input ?: $application->getInput()); } } PK z�\�#R�O O DispatcherInterface.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Dispatcher; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla Platform CMS Dispatcher Interface * * @since 4.0.0 */ interface DispatcherInterface { /** * Runs the dispatcher. * * @return void * * @since 4.0.0 */ public function dispatch(); } PK z�\���� � '