Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
27 changes: 0 additions & 27 deletions administrator/modules/mod_latestactions/mod_latestactions.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<description>MOD_LATESTACTIONS_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Module\LatestActions</namespace>
<files>
<filename module="mod_latestactions">mod_latestactions.php</filename>
<folder module="mod_latestactions">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
Expand Down
41 changes: 41 additions & 0 deletions administrator/modules/mod_latestactions/services/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

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

\defined('_JEXEC') or die;

use Joomla\CMS\Extension\Service\Provider\HelperFactory;
use Joomla\CMS\Extension\Service\Provider\Module;
use Joomla\CMS\Extension\Service\Provider\ModuleDispatcherFactory;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;

/**
* The latest actions module service provider.
*
* @since __DEPLOY_VERSION__
*/
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function register(Container $container)
{
$container->registerServiceProvider(new ModuleDispatcherFactory('\\Joomla\\Module\\LatestActions'));
$container->registerServiceProvider(new HelperFactory('\\Joomla\\Module\\LatestActions\\Administrator\\Helper'));

$container->registerServiceProvider(new Module());
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

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

namespace Joomla\Module\LatestActions\Administrator\Dispatcher;

use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;
use Joomla\CMS\Helper\HelperFactoryAwareInterface;
use Joomla\CMS\Helper\HelperFactoryAwareTrait;

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

/**
* Dispatcher class for mod_latestactions
*
* @since __DEPLOY_VERSION__
*/
class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface
{
use HelperFactoryAwareTrait;

/**
* Runs the dispatcher.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function dispatch()
{
if (!$this->getApplication()->getIdentity()->authorise('core.admin')) {
return;
}

parent::dispatch();
}

/**
* Returns the layout data.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();

$data['list'] = $this->getHelperFactory()->getHelper('LatestActionsHelper')->getActions($data['params']);

if ($data['params']->get('automatic_title', 0)) {
$this->module->title = $this->getHelperFactory()->getHelper('LatestActionsHelper')->getModuleTitle($data['params']);
}

return $data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @since 3.9.0
*/
abstract class LatestActionsHelper
class LatestActionsHelper
{
/**
* Get a list of logged actions.
Expand All @@ -33,11 +33,11 @@ abstract class LatestActionsHelper
*
* @return mixed An array of action logs, or false on error.
*
* @since 3.9.1
* @since __DEPLOY_VERSION__
*
* @throws \Exception
*/
public static function getList(&$params)
public function getActions(&$params)
{
/** @var \Joomla\Component\Actionlogs\Administrator\Model\ActionlogsModel $model */
$model = Factory::getApplication()->bootComponent('com_actionlogs')->getMVCFactory()
Expand All @@ -61,6 +61,20 @@ public static function getList(&$params)
return $rows;
}

/**
* Get the alternate title for the module
*
* @param Registry $params The module parameters.
*
* @return string The alternate title for the module.
*
* @since __DEPLOY_VERSION__
*/
public function getModuleTitle($params)
{
return Text::plural('MOD_LATESTACTIONS_TITLE', $params->get('count', 5));
}

/**
* Get the alternate title for the module
*
Expand All @@ -69,9 +83,37 @@ public static function getList(&$params)
* @return string The alternate title for the module.
*
* @since 3.9.1
*
* @deprecated __DEPLOY_VERSION__ will be removed in 6.0
* Use the non-static method getModuleTitle
* Example: Factory::getApplication()->bootModule('mod_latestactions', 'administrator')
* ->getHelper('LatestActionsHelper')
* ->getModuleTitle($params)
*/
public static function getTitle($params)
{
return Text::plural('MOD_LATESTACTIONS_TITLE', $params->get('count', 5));
return (new self())->getModuleTitle($params);
}

/**
* Get a list of logged actions.
*
* @param Registry &$params The module parameters.
*
* @return mixed An array of action logs, or false on error.
*
* @since 3.9.1
*
* @throws \Exception
*
* @deprecated __DEPLOY_VERSION__ will be removed in 6.0
* Use the non-static method getActions
* Example: Factory::getApplication()->bootModule('mod_latestactions', 'administrator')
* ->getHelper('LatestActionsHelper')
* ->getActions($params)
*/
public static function getList(&$params)
{
return (new self())->getActions($params);
}
}