Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Modules\Administrator\Extension;

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use Joomla\Component\Modules\Administrator\Service\HTML\Modules;
use Psr\Container\ContainerInterface;

/**
* Component class for com_modules
*
* @since 4.0.0
*/
class ModulesComponent extends MVCComponent implements BootableExtensionInterface
{
use HTMLRegistryAwareTrait;

/**
* Booting the extension. This is the function to set up the environment of the extension like
* registering new class loaders, etc.
*
* If required, some initial set up can be done from services of the container, eg.
* registering HTML services.
*
* @param ContainerInterface $container The container
*
* @return void
*
* @since 4.0.0
*/
public function boot(ContainerInterface $container)
{
$this->getRegistry()->register('modules', new Modules);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Modules\Administrator\Service\HTML;

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Component\Templates\Administrator\Helper\TemplatesHelper;
use Joomla\Utilities\ArrayHelper;
use Joomla\Component\Modules\Administrator\Helper\ModulesHelper;

/**
* JHtml module helper class.
* HTMLHelper module helper class.
*
* @since 1.6
*/
abstract class JHtmlModules
class Modules
{
/**
* Builds an array of template options
Expand All @@ -27,14 +33,14 @@ abstract class JHtmlModules
*
* @return array
*/
public static function templates($clientId = 0, $state = '')
public function templates($clientId = 0, $state = '')
{
$options = array();
$templates = ModulesHelper::getTemplates($clientId, $state);

foreach ($templates as $template)
{
$options[] = JHtml::_('select.option', $template->element, $template->name);
$options[] = HTMLHelper::_('select.option', $template->element, $template->name);
}

return $options;
Expand All @@ -45,11 +51,11 @@ public static function templates($clientId = 0, $state = '')
*
* @return array
*/
public static function types()
public function types()
{
$options = array();
$options[] = JHtml::_('select.option', 'user', 'COM_MODULES_OPTION_POSITION_USER_DEFINED');
$options[] = JHtml::_('select.option', 'template', 'COM_MODULES_OPTION_POSITION_TEMPLATE_DEFINED');
$options[] = HTMLHelper::_('select.option', 'user', 'COM_MODULES_OPTION_POSITION_USER_DEFINED');
$options[] = HTMLHelper::_('select.option', 'template', 'COM_MODULES_OPTION_POSITION_TEMPLATE_DEFINED');

return $options;
}
Expand All @@ -59,11 +65,11 @@ public static function types()
*
* @return array
*/
public static function templateStates()
public function templateStates()
{
$options = array();
$options[] = JHtml::_('select.option', '1', 'JENABLED');
$options[] = JHtml::_('select.option', '0', 'JDISABLED');
$options[] = HTMLHelper::_('select.option', '1', 'JENABLED');
$options[] = HTMLHelper::_('select.option', '0', 'JDISABLED');

return $options;
}
Expand All @@ -78,10 +84,10 @@ public static function templateStates()
*
* @return string The Html code
*
* @see JHtmlJGrid::state
* @see HTMLHelperJGrid::state
* @since 1.7.1
*/
public static function state($value, $i, $enabled = true, $checkbox = 'cb')
public function state($value, $i, $enabled = true, $checkbox = 'cb')
{
$states = array(
1 => array(
Expand Down Expand Up @@ -122,7 +128,7 @@ public static function state($value, $i, $enabled = true, $checkbox = 'cb')
),
);

return JHtml::_('jgrid.state', $states, $value, $i, 'modules.', $enabled, true, $checkbox);
return HTMLHelper::_('jgrid.state', $states, $value, $i, 'modules.', $enabled, true, $checkbox);
}

/**
Expand All @@ -136,9 +142,9 @@ public static function state($value, $i, $enabled = true, $checkbox = 'cb')
*
* @since 2.5
*/
public static function positions($clientId, $state = 1, $selectedPosition = '')
public function positions($clientId, $state = 1, $selectedPosition = '')
{
JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php');
\JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php');

$templates = array_keys(ModulesHelper::getTemplates($clientId, $state));
$templateGroups = array();
Expand Down Expand Up @@ -176,7 +182,7 @@ public static function positions($clientId, $state = 1, $selectedPosition = '')
}

// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');
$customGroupText = Text::_('COM_MODULES_CUSTOM_POSITION');

$editPositions = true;
$customPositions = ModulesHelper::getPositions($clientId, $editPositions);
Expand All @@ -190,15 +196,15 @@ public static function positions($clientId, $state = 1, $selectedPosition = '')
*
* @return void
*/
public static function batchOptions()
public function batchOptions()
{
// Create the copy/move options.
$options = array(
JHtml::_('select.option', 'c', JText::_('JLIB_HTML_BATCH_COPY')),
JHtml::_('select.option', 'm', JText::_('JLIB_HTML_BATCH_MOVE'))
HTMLHelper::_('select.option', 'c', Text::_('JLIB_HTML_BATCH_COPY')),
HTMLHelper::_('select.option', 'm', Text::_('JLIB_HTML_BATCH_MOVE'))
);

echo JHtml::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm');
echo HTMLHelper::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm');
}

/**
Expand All @@ -210,9 +216,9 @@ public static function batchOptions()
*
* @since 2.5
*/
public static function positionList($clientId = 0)
public function positionList($clientId = 0)
{
$db = JFactory::getDbo();
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(position) as value')
->select('position as text')
Expand All @@ -227,9 +233,9 @@ public static function positionList($clientId = 0)
{
$options = $db->loadObjectList();
}
catch (RuntimeException $e)
catch (\RuntimeException $e)
{
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}

// Pop the first item off the array if it's blank
Expand Down
20 changes: 0 additions & 20 deletions administrator/components/com_modules/helpers/modules.php

This file was deleted.

5 changes: 4 additions & 1 deletion administrator/components/com_modules/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Extension\Service\Provider\DispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactoryFactory;
use Joomla\CMS\HTML\Registry;
use Joomla\CMS\MVC\Factory\MVCFactoryFactoryInterface;
use Joomla\Component\Modules\Administrator\Extension\ModulesComponent;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;

Expand Down Expand Up @@ -43,9 +45,10 @@ public function register(Container $container)
ComponentInterface::class,
function (Container $container)
{
$component = new MVCComponent($container->get(DispatcherFactoryInterface::class));
$component = new ModulesComponent($container->get(DispatcherFactoryInterface::class));

$component->setMvcFactoryFactory($container->get(MVCFactoryFactoryInterface::class));
$component->setRegistry($container->get(Registry::class));

return $component;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
<?php
/**
* @package Joomla.Administrator
* @package Joomla.Site
* @subpackage com_modules
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Modules\Site\Dispatcher;

defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\Dispatcher;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\MVC\Controller\BaseController;

/**
* Dispatcher class for com_content
* Dispatcher class for com_modules
*
* @since 4.0.0
*/
class ModulesDispatcher extends Dispatcher
class Dispatcher extends \Joomla\CMS\Dispatcher\Dispatcher
{
/**
* The extension namespace
*
* @var string
*
* @since 4.0.0
*/
protected $namespace = 'Joomla\\Component\\Modules';

/**
* Load the language
*
Expand All @@ -50,14 +43,11 @@ protected function loadLanguage()
*/
public function dispatch()
{
if ($this->input->get('view') === 'modules' && $this->input->get('layout') === 'modal')
if ($this->input->get('view') === 'modules'
&& $this->input->get('layout') === 'modal'
&& !$this->app->getIdentity()->authorise('core.create', 'com_modules'))
{
if (!$this->app->getIdentity()->authorise('core.create', 'com_modules'))
{
$this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');

return;
}
throw new NotAllowed;
}

parent::dispatch();
Expand Down
1 change: 1 addition & 0 deletions libraries/extensions.classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
JLoader::registerAlias('FieldsListPlugin', '\\Joomla\\Component\\Fields\\Administrator\\Plugin\\FieldsListPlugin', '4.0');

JLoader::registerAlias('TagsTableTag', '\\Joomla\\Component\\Tags\\Administrator\\Table\\TagTable', '4.0');
JLoader::registerAlias('ModulesHelper', '\\Joomla\\Component\\Modules\\Administrator\\Helper\\ModulesHelper', '5.0');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here as the templates helpers. For now can we leave the empty files in place and deal with them in another PR