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

Simplify params model state for com_contact, com_newsfeeds #34894

Merged
20 changes: 4 additions & 16 deletions components/com_contact/src/Model/CategoryModel.php
Expand Up @@ -12,7 +12,6 @@

use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Categories\CategoryNode;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\Language\Multilanguage;
Expand Down Expand Up @@ -263,17 +262,9 @@ protected function getListQuery()
protected function populateState($ordering = null, $direction = null)
{
$app = Factory::getApplication();
$params = ComponentHelper::getParams('com_contact');

// Get list ordering default from the parameters
if ($menu = $app->getMenu()->getActive()) {
$menuParams = $menu->getParams();
} else {
$menuParams = new Registry();
}

$mergedParams = clone $params;
$mergedParams->merge($menuParams);
$params = $app->getParams();
$this->setState('params', $params);

// List state information
$format = $app->input->getWord('format');
Expand All @@ -284,7 +275,7 @@ protected function populateState($ordering = null, $direction = null)
$limit = $app->getUserStateFromRequest(
'com_contact.category.list.limit',
'limit',
$mergedParams->get('contacts_display_num', $app->get('list_limit')),
$params->get('contacts_display_num', $app->get('list_limit')),
'uint'
);
}
Expand All @@ -299,7 +290,7 @@ protected function populateState($ordering = null, $direction = null)
$search = $app->getUserStateFromRequest('com_contact.category.list.' . $itemid . '.filter-search', 'filter-search', '', 'string');
$this->setState('list.filter', $search);

$orderCol = $app->input->get('filter_order', $mergedParams->get('initial_sort', 'ordering'));
$orderCol = $app->input->get('filter_order', $params->get('initial_sort', 'ordering'));

if (!in_array($orderCol, $this->filter_fields)) {
$orderCol = 'ordering';
Expand Down Expand Up @@ -329,9 +320,6 @@ protected function populateState($ordering = null, $direction = null)
}

$this->setState('filter.language', Multilanguage::isEnabled());

// Load the parameters.
$this->setState('params', $params);
}

/**
Expand Down
8 changes: 3 additions & 5 deletions components/com_newsfeeds/src/Model/CategoryModel.php
Expand Up @@ -12,7 +12,6 @@

use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Categories\CategoryNode;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\Language\Multilanguage;
Expand Down Expand Up @@ -244,7 +243,9 @@ protected function getListQuery()
protected function populateState($ordering = null, $direction = null)
{
$app = Factory::getApplication();
$params = ComponentHelper::getParams('com_newsfeeds');

$params = $app->getParams();
$this->setState('params', $params);

// List state information
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'uint');
Expand Down Expand Up @@ -286,9 +287,6 @@ protected function populateState($ordering = null, $direction = null)
}

$this->setState('filter.language', Multilanguage::isEnabled());

// Load the parameters.
$this->setState('params', $params);
}

/**
Expand Down