Skip to content

Commit

Permalink
Merge tag 'psr12final' into psr12/merge/28508
Browse files Browse the repository at this point in the history
  • Loading branch information
joomla-bot committed Jun 27, 2022
2 parents 56eadab + 09d14c6 commit bc33ec0
Show file tree
Hide file tree
Showing 2,577 changed files with 332,652 additions and 354,673 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Expand Up @@ -19,7 +19,7 @@ steps:
depends_on: [ composer ]
commands:
- echo $(date)
- ./libraries/vendor/bin/phpcs --extensions=php -p --standard=libraries/vendor/joomla/cms-coding-standards/lib/Joomla-CMS .
- ./libraries/vendor/bin/phpcs --extensions=php -p --standard=ruleset.xml .
- echo $(date)

- name: npm
Expand Down Expand Up @@ -475,6 +475,6 @@ trigger:

---
kind: signature
hmac: d5db8148323f0205a8c0cd165da3934f5a77b25f73862d09ead95d3c42f1df01
hmac: 783273e5140ae315f2403b13eb12f4773b77995a3d44a38551b55c89b9d40350

...
6 changes: 3 additions & 3 deletions .editorconfig
Expand Up @@ -3,14 +3,14 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
# Unix-style end of lines and a blank line at the end of the file
[*]
indent_style = tab
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{js,json,scss,css,vue}]
indent_style = space
indent_size = 2
46 changes: 23 additions & 23 deletions administrator/components/com_actionlogs/services/provider.php
@@ -1,4 +1,5 @@
<?php

/**
* @package Joomla.Administrator
* @subpackage com_actionlogs
Expand All @@ -25,30 +26,29 @@
*/
return new class implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0.0
*/
public function register(Container $container)
{
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Actionlogs'));
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Actionlogs'));
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0.0
*/
public function register(Container $container)
{
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Actionlogs'));
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Actionlogs'));

$container->set(
ComponentInterface::class,
function (Container $container)
{
$component = new MVCComponent($container->get(ComponentDispatcherFactoryInterface::class));
$container->set(
ComponentInterface::class,
function (Container $container) {
$component = new MVCComponent($container->get(ComponentDispatcherFactoryInterface::class));

$component->setMVCFactory($container->get(MVCFactoryInterface::class));
$component->setMVCFactory($container->get(MVCFactoryInterface::class));

return $component;
}
);
}
return $component;
}
);
}
};
@@ -1,4 +1,5 @@
<?php

/**
* @package Joomla.Administrator
* @subpackage com_actionlogs
Expand All @@ -9,8 +10,6 @@

namespace Joomla\Component\Actionlogs\Administrator\Controller;

\defined('_JEXEC') or die;

use DateTimeZone;
use Exception;
use InvalidArgumentException;
Expand All @@ -33,142 +32,131 @@
*/
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).
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The Application for the dispatcher
* @param Input $input Input
*
* @since 3.9.0
*
* @throws Exception
*/
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config, $factory, $app, $input);

$this->registerTask('exportSelectedLogs', 'exportLogs');
}

/**
* Method to export logs
*
* @return void
*
* @since 3.9.0
*
* @throws Exception
*/
public function exportLogs()
{
// Check for request forgeries.
$this->checkToken();

$task = $this->getTask();

$pks = array();

if ($task == 'exportSelectedLogs')
{
// Get selected logs
$pks = ArrayHelper::toInteger(explode(',', $this->input->post->getString('cids')));
}

/** @var ActionlogsModel $model */
$model = $this->getModel();

// Get the logs data
$data = $model->getLogDataAsIterator($pks);

if (\count($data))
{
try
{
$rows = ActionlogsHelper::getCsvData($data);
}
catch (InvalidArgumentException $exception)
{
$this->setMessage(Text::_('COM_ACTIONLOGS_ERROR_COULD_NOT_EXPORT_DATA'), 'error');
$this->setRedirect(Route::_('index.php?option=com_actionlogs&view=actionlogs', false));

return;
}

// Destroy the iterator now
unset($data);

$date = new Date('now', new DateTimeZone('UTC'));
$filename = 'logs_' . $date->format('Y-m-d_His_T');

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

$this->app->setHeader('Content-Type', 'application/csv', true)
->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '.csv"', true)
->setHeader('Cache-Control', 'must-revalidate', true)
->sendHeaders();

$output = fopen("php://output", "w");

foreach ($rows as $row)
{
fputcsv($output, $row, $csvDelimiter);
}

fclose($output);
$this->app->triggerEvent('onAfterLogExport', array());
$this->app->close();
}
else
{
$this->setMessage(Text::_('COM_ACTIONLOGS_NO_LOGS_TO_EXPORT'));
$this->setRedirect(Route::_('index.php?option=com_actionlogs&view=actionlogs', false));
}
}

/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 3.9.0
*/
public function getModel($name = 'Actionlogs', $prefix = 'Administrator', $config = ['ignore_request' => true])
{
// Return the model
return parent::getModel($name, $prefix, $config);
}

/**
* Clean out the logs
*
* @return void
*
* @since 3.9.0
*/
public function purge()
{
// Check for request forgeries.
$this->checkToken();

$model = $this->getModel();

if ($model->purge())
{
$message = Text::_('COM_ACTIONLOGS_PURGE_SUCCESS');
}
else
{
$message = Text::_('COM_ACTIONLOGS_PURGE_FAIL');
}

$this->setRedirect(Route::_('index.php?option=com_actionlogs&view=actionlogs', false), $message);
}
/**
* 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).
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The Application for the dispatcher
* @param Input $input Input
*
* @since 3.9.0
*
* @throws Exception
*/
public function __construct($config = [], MVCFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config, $factory, $app, $input);

$this->registerTask('exportSelectedLogs', 'exportLogs');
}

/**
* Method to export logs
*
* @return void
*
* @since 3.9.0
*
* @throws Exception
*/
public function exportLogs()
{
// Check for request forgeries.
$this->checkToken();

$task = $this->getTask();

$pks = array();

if ($task == 'exportSelectedLogs') {
// Get selected logs
$pks = ArrayHelper::toInteger(explode(',', $this->input->post->getString('cids')));
}

/** @var ActionlogsModel $model */
$model = $this->getModel();

// Get the logs data
$data = $model->getLogDataAsIterator($pks);

if (\count($data)) {
try {
$rows = ActionlogsHelper::getCsvData($data);
} catch (InvalidArgumentException $exception) {
$this->setMessage(Text::_('COM_ACTIONLOGS_ERROR_COULD_NOT_EXPORT_DATA'), 'error');
$this->setRedirect(Route::_('index.php?option=com_actionlogs&view=actionlogs', false));

return;
}

// Destroy the iterator now
unset($data);

$date = new Date('now', new DateTimeZone('UTC'));
$filename = 'logs_' . $date->format('Y-m-d_His_T');

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

$this->app->setHeader('Content-Type', 'application/csv', true)
->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '.csv"', true)
->setHeader('Cache-Control', 'must-revalidate', true)
->sendHeaders();

$output = fopen("php://output", "w");

foreach ($rows as $row) {
fputcsv($output, $row, $csvDelimiter);
}

fclose($output);
$this->app->triggerEvent('onAfterLogExport', array());
$this->app->close();
} else {
$this->setMessage(Text::_('COM_ACTIONLOGS_NO_LOGS_TO_EXPORT'));
$this->setRedirect(Route::_('index.php?option=com_actionlogs&view=actionlogs', false));
}
}

/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 3.9.0
*/
public function getModel($name = 'Actionlogs', $prefix = 'Administrator', $config = ['ignore_request' => true])
{
// Return the model
return parent::getModel($name, $prefix, $config);
}

/**
* Clean out the logs
*
* @return void
*
* @since 3.9.0
*/
public function purge()
{
// Check for request forgeries.
$this->checkToken();

$model = $this->getModel();

if ($model->purge()) {
$message = Text::_('COM_ACTIONLOGS_PURGE_SUCCESS');
} else {
$message = Text::_('COM_ACTIONLOGS_PURGE_FAIL');
}

$this->setRedirect(Route::_('index.php?option=com_actionlogs&view=actionlogs', false), $message);
}
}

0 comments on commit bc33ec0

Please sign in to comment.