Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
edab7e0
Prevent exception if $error is no array
bembelimen Aug 30, 2024
0059699
Update ListView to reflect current status of the toolbar
bembelimen Aug 30, 2024
cd2642b
Convert contacts list view to ListView class
bembelimen Aug 30, 2024
e5ac559
Convert modules list view to ListView class
bembelimen Sep 8, 2024
dcdae85
Update to Joomla! 5.3
bembelimen Nov 13, 2024
79dabdc
Convert Actionlogs list view to LiewView class
bembelimen Nov 14, 2024
7cfceb6
Convert banners list view to ListView class
bembelimen Nov 14, 2024
e2ef1b4
Use normal models
bembelimen Nov 14, 2024
71da7f3
Merge remote-tracking branch 'Joomla/6.0-dev' into 6.0/toolbar-buttons
bembelimen Mar 12, 2025
1e0bbae
Merge remote-tracking branch 'Joomla/6.0-dev' into 6.0/toolbar-buttons
bembelimen Apr 23, 2025
0d551fe
Merge branch '6.0-dev' into 6.0/toolbar-buttons
bembelimen May 23, 2025
7ac0700
Apply suggestions from code review
Bodge-IT Jun 4, 2025
c6fe198
Merge remote-tracking branch 'Joomla/6.0-dev' into 6.0/toolbar-buttons
bembelimen Aug 11, 2025
cadbda7
Fix namespace usage
bembelimen Aug 11, 2025
377778c
Fix code style
bembelimen Aug 11, 2025
5092343
Codestyle
bembelimen Aug 11, 2025
9883be5
Remove unused usages
bembelimen Aug 11, 2025
fffa39e
Remove phpstan occurences
bembelimen Aug 11, 2025
cbf9eaf
Merge branch '6.0-dev' into 6.0/toolbar-buttons
softforge Aug 12, 2025
d1e6031
Merge branch '6.0-dev' into 6.0/toolbar-buttons
bembelimen Aug 14, 2025
9673cb8
Merge branch '6.0-dev' into 6.0/toolbar-buttons
bembelimen Aug 15, 2025
a9a296c
Merge branch '6.0-dev' into 6.0/toolbar-buttons
softforge Aug 16, 2025
c443453
Merge branch '6.0-dev' into 6.0/toolbar-buttons
softforge Aug 16, 2025
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 @@ -11,14 +11,10 @@
namespace Joomla\Component\Actionlogs\Administrator\View\Actionlogs;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\MVC\View\ListView;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Component\Actionlogs\Administrator\Helper\ActionlogsHelper;
use Joomla\Component\Actionlogs\Administrator\Model\ActionlogsModel;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -29,48 +25,8 @@
*
* @since 3.9.0
*/
class HtmlView extends BaseHtmlView
class HtmlView extends ListView
{
/**
* An array of items.
*
* @var array
* @since 3.9.0
*/
protected $items;

/**
* The model state
*
* @var array
* @since 3.9.0
*/
protected $state;

/**
* The pagination object
*
* @var Pagination
* @since 3.9.0
*/
protected $pagination;

/**
* Form object for search filters
*
* @var Form
* @since 3.9.0
*/
public $filterForm;

/**
* The active search filters
*
* @var array
* @since 3.9.0
*/
public $activeFilters;

/**
* Setting if the IP column should be shown
*
Expand All @@ -88,44 +44,46 @@ class HtmlView extends BaseHtmlView
protected $dateRelative = false;

/**
* Method to display the view.
* Constructor
*
* @param string $tpl A template file to load. [optional]
* @param array $config An optional associative array of configuration settings.
*
* @return void
* @since __DEPLOY_VERSION__
*/
public function __construct(array $config)
{
if (empty($config['option'])) {
$config['option'] = 'com_actionlogs';
}

$config['toolbar_title'] = 'COM_ACTIONLOGS_MANAGER_USERLOGS';
$config['toolbar_icon'] = 'list-2 actionlog';

parent::__construct($config);
}

/**
* Prepare view data
*
* @since 3.9.0
* @return void
*
* @throws \Exception
* @since __DEPLOY_VERSION__
*/
public function display($tpl = null)
protected function initializeView()
{
/** @var ActionlogsModel $model */
$model = $this->getModel();
$this->items = $model->getItems();
$this->state = $model->getState();
$this->pagination = $model->getPagination();
$this->filterForm = $model->getFilterForm();
$this->activeFilters = $model->getActiveFilters();
parent::initializeView();

$params = ComponentHelper::getParams('com_actionlogs');
$this->showIpColumn = (bool) $params->get('ip_logging', 0);
$this->dateRelative = (bool) $params->get('date_relative', 1);

if (\count($errors = $model->getErrors())) {
throw new GenericDataException(implode("\n", $errors), 500);
}

$this->addToolbar();

// Load all actionlog plugins language files
ActionlogsHelper::loadActionLogPluginsLanguage();

// Add form control fields
$this->filterForm
->addControlField('task', '')
->addControlField('boxchecked', '0');

parent::display($tpl);
}

/**
Expand All @@ -138,6 +96,7 @@ public function display($tpl = null)
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')
Expand Down
177 changes: 26 additions & 151 deletions administrator/components/com_banners/src/View/Banners/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@

namespace Joomla\Component\Banners\Administrator\View\Banners;

use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\Toolbar\Button\DropdownButton;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\MVC\View\ListView;
use Joomla\Component\Banners\Administrator\Model\BannersModel;
use Joomla\Registry\Registry;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -31,24 +24,8 @@
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
class HtmlView extends ListView
{
/**
* The search tools form
*
* @var Form
* @since 1.6
*/
public $filterForm;

/**
* The active search filters
*
* @var array
* @since 1.6
*/
public $activeFilters = [];

/**
* Category data
*
Expand All @@ -58,68 +35,48 @@ class HtmlView extends BaseHtmlView
protected $categories = [];

/**
* An array of items
* The help link for the view
*
* @var array
* @since 1.6
* @var string
*/
protected $items = [];
protected $helpLink = 'Banners';

/**
* The pagination object
* Constructor
*
* @var Pagination
* @since 1.6
*/
protected $pagination;

/**
* The model state
* @param array $config An optional associative array of configuration settings.
*
* @var Registry
* @since 1.6
* @since __DEPLOY_VERSION__
*/
protected $state;
public function __construct(array $config)
{
if (empty($config['option'])) {
$config['option'] = 'com_banners';
}

/**
* Is this view an Empty State
*
* @var boolean
* @since 4.0.0
*/
private $isEmptyState = false;
$config['toolbar_icon'] = 'bookmark banners';
$config['supports_batch'] = true;
$config['category'] = 'com_banners';

parent::__construct($config);
}

/**
* Method to display the view.
*
* @param string $tpl A template file to load. [optional]
* Prepare view data
*
* @return void
*
* @since 1.6
* @throws \Exception
* @since __DEPLOY_VERSION__
*/
public function display($tpl = null): void
protected function initializeView()
{
parent::initializeView();

/** @var BannersModel $model */
$model = $this->getModel();
$this->categories = $model->getCategoryOrders();
$this->items = $model->getItems();
$this->pagination = $model->getPagination();
$this->state = $model->getState();
$this->filterForm = $model->getFilterForm();
$this->activeFilters = $model->getActiveFilters();

if (!\count($this->items) && $this->isEmptyState = $model->getIsEmptyState()) {
$this->setLayout('emptystate');
}

// Check for errors.
if (\count($errors = $model->getErrors())) {
throw new GenericDataException(implode("\n", $errors), 500);
}

$this->addToolbar();
$this->categories = $model->getCategoryOrders();
$this->canDo = ContentHelper::getActions('com_banners', 'category', $this->state->get('filter.category_id'));

// We do not need to filter by language when multilingual is disabled
if (!Multilanguage::isEnabled()) {
Expand All @@ -131,87 +88,5 @@ public function display($tpl = null): void
$this->filterForm
->addControlField('task', '')
->addControlField('boxchecked', '0');

parent::display($tpl);
}

/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar(): void
{
$canDo = ContentHelper::getActions('com_banners', 'category', $this->state->get('filter.category_id'));
$user = $this->getCurrentUser();
$toolbar = $this->getDocument()->getToolbar();

ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_BANNERS'), 'bookmark banners');

if ($canDo->get('core.create') || \count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0) {
$toolbar->addNew('banner.add');
}

if (!$this->isEmptyState && ($canDo->get('core.edit.state') || ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')))) {
/** @var DropdownButton $dropdown */
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
->icon('icon-ellipsis-h')
->buttonClass('btn btn-action')
->listCheck(true);

$childBar = $dropdown->getChildToolbar();

if ($canDo->get('core.edit.state')) {
if ($this->state->get('filter.published') != 2) {
$childBar->publish('banners.publish')->listCheck(true);

$childBar->unpublish('banners.unpublish')->listCheck(true);
}

if ($this->state->get('filter.published') != -1) {
if ($this->state->get('filter.published') != 2) {
$childBar->archive('banners.archive')->listCheck(true);
} elseif ($this->state->get('filter.published') == 2) {
$childBar->publish('publish')->task('banners.publish')->listCheck(true);
}
}

$childBar->checkin('banners.checkin');

if ($this->state->get('filter.published') != -2) {
$childBar->trash('banners.trash')->listCheck(true);
}
}

if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
$toolbar->delete('banners.delete', 'JTOOLBAR_DELETE_FROM_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}

// Add a batch button
if (
$user->authorise('core.create', 'com_banners')
&& $user->authorise('core.edit', 'com_banners')
&& $user->authorise('core.edit.state', 'com_banners')
) {
$childBar->popupButton('batch', 'JTOOLBAR_BATCH')
->popupType('inline')
->textHeader(Text::_('COM_BANNERS_BATCH_OPTIONS'))
->url('#joomla-dialog-batch')
->modalWidth('800px')
->modalHeight('fit-content')
->listCheck(true);
}
}

if ($user->authorise('core.admin', 'com_banners') || $user->authorise('core.options', 'com_banners')) {
$toolbar->preferences('com_banners');
}

$toolbar->help('Banners');
}
}
Loading
Loading