Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Deprecations: Changes we can make with 5.3 for the actionlog component (Backend) #44261

Open
wants to merge 18 commits into
base: 5.3-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 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
Expand Up @@ -14,13 +14,13 @@
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Event\ActionLog\AfterLogExportEvent;
use Joomla\CMS\Input\Input;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Router\Route;
use Joomla\Component\Actionlogs\Administrator\Helper\ActionlogsHelper;
use Joomla\Component\Actionlogs\Administrator\Model\ActionlogsModel;
use Joomla\Input\Input;
use Joomla\Utilities\ArrayHelper;

// phpcs:disable PSR1.Files.SideEffects
Expand All @@ -38,8 +38,8 @@ class ActionlogsController extends AdminController
* Constructor.
*
* @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).
* Recognized key values include 'name', 'default_task', 'model_path', and
* 'view_path' (this list is not meant to be comprehensive).
* @param ?MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The Application for the dispatcher
* @param Input $input Input
Expand Down Expand Up @@ -102,7 +102,8 @@ public function exportLogs()

$csvDelimiter = ComponentHelper::getComponent('com_actionlogs')->getParams()->get('csv_delimiter', ',');

$this->app->setHeader('Content-Type', 'application/csv', true)
$this->app
->setHeader('Content-Type', 'application/csv', true)
->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '.csv"', true)
->setHeader('Cache-Control', 'must-revalidate', true)
->sendHeaders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct($form = null)
parent::__construct($form);

// Load the required language
$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$lang->load('com_actionlogs', JPATH_ADMINISTRATOR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Router\Route;
use Joomla\Database\DatabaseInterface;
use Joomla\Filesystem\Path;
use Joomla\String\StringHelper;

Expand Down Expand Up @@ -100,7 +101,7 @@ public static function loadTranslationFiles($extension)
return;
}

$lang = Factory::getLanguage();
$lang = Factory::getApplication()->getLanguage();
$source = '';

switch (substr($extension, 0, 3)) {
Expand Down Expand Up @@ -248,6 +249,13 @@ public static function getContentTypeLink($component, $contentType, $id, $urlVar
$prefix = ucfirst(str_replace('com_', '', $component));
$cName = $prefix . 'Helper';

/*
* @todo: 6.0
* We want to have all classes as namespaces! We need to know the component namespace so we could
* check if NAMESPACE/getContentTypeLink is callable. Maybe we need to boot the component????
*
* Change can be made with 6.0?? Maybe we need a fallback.
*/
\JLoader::register($cName, $file);

if (class_exists($cName) && \is_callable([$cName, 'getContentTypeLink'])) {
Expand Down Expand Up @@ -280,8 +288,8 @@ public static function loadActionLogPluginsLanguage()
}
$loaded = true;

$lang = Factory::getLanguage();
$db = Factory::getDbo();
$lang = Factory::getApplication()->getLanguage();
$db = Factory::getContainer()->get(DatabaseInterface::class);

// Get all (both enabled and disabled) actionlog plugins
$query = $db->getQuery(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ public function delete(&$pks)
try {
$db->execute();
} catch (\RuntimeException $e) {
// @todo: 6.0
rdeutz marked this conversation as resolved.
Show resolved Hide resolved
$this->setError($e->getMessage());

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HtmlView extends BaseHtmlView
/**
* The model state
*
* @var array
* @var object
* @since 3.9.0
*/
protected $state;
Expand Down Expand Up @@ -111,6 +111,7 @@ public function display($tpl = null)
$this->showIpColumn = (bool) $params->get('ip_logging', 0);
$this->dateRelative = (bool) $params->get('date_relative', 1);

// @todo: 6.0
rdeutz marked this conversation as resolved.
Show resolved Hide resolved
if (\count($errors = $model->getErrors())) {
throw new GenericDataException(implode("\n", $errors), 500);
}
Expand All @@ -135,18 +136,22 @@ protected function addToolbar()
ToolbarHelper::title(Text::_('COM_ACTIONLOGS_MANAGER_USERLOGS'), 'icon-list-2');
$toolbar = $this->getDocument()->getToolbar();

$toolbar->standardButton('download', 'COM_ACTIONLOGS_EXPORT_CSV', 'actionlogs.exportSelectedLogs')
$toolbar
->standardButton('download', 'COM_ACTIONLOGS_EXPORT_CSV', 'actionlogs.exportSelectedLogs')
->icon('icon-download')
->listCheck(true);

$toolbar->standardButton('download', 'COM_ACTIONLOGS_EXPORT_ALL_CSV', 'actionlogs.exportLogs')
$toolbar
->standardButton('download', 'COM_ACTIONLOGS_EXPORT_ALL_CSV', 'actionlogs.exportLogs')
->icon('icon-download')
->listCheck(false);

$toolbar->delete('actionlogs.delete')
$toolbar
->delete('actionlogs.delete')
->message('JGLOBAL_CONFIRM_DELETE');

$toolbar->confirmButton('delete', 'COM_ACTIONLOGS_TOOLBAR_PURGE', 'actionlogs.purge')
$toolbar
->confirmButton('delete', 'COM_ACTIONLOGS_TOOLBAR_PURGE', 'actionlogs.purge')
->message('COM_ACTIONLOGS_PURGE_CONFIRM')
->listCheck(false);

Expand Down