Skip to content

Commit

Permalink
Remove legacy code for filtering state in backend models
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackwar committed Apr 8, 2024
1 parent eb9d704 commit 44ea1cb
Show file tree
Hide file tree
Showing 25 changed files with 0 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ protected function populateState($ordering = 'ordering', $direction = 'asc')
$this->setState('itemtype', $this->getUserStateFromRequest($this->context . '.itemtype', 'itemtype', '', 'string'));
$this->setState('language', $this->getUserStateFromRequest($this->context . '.language', 'language', '', 'string'));

$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'cmd'));
$this->setState('filter.category_id', $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '', 'cmd'));
$this->setState('filter.menutype', $this->getUserStateFromRequest($this->context . '.filter.menutype', 'filter_menutype', '', 'string'));
$this->setState('filter.access', $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', '', 'string'));
$this->setState('filter.level', $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', '', 'cmd'));

// List state information.
parent::populateState($ordering, $direction);

Expand Down
3 changes: 0 additions & 3 deletions administrator/components/com_cache/src/Model/CacheModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ public function __construct($config = [])
*/
protected function populateState($ordering = 'group', $direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));

parent::populateState($ordering, $direction);
}

Expand Down
37 changes: 0 additions & 37 deletions administrator/components/com_content/src/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,43 +140,6 @@ protected function populateState($ordering = 'a.id', $direction = 'desc')
$this->context .= '.' . $forcedLanguage;
}

$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);

$featured = $this->getUserStateFromRequest($this->context . '.filter.featured', 'filter_featured', '');
$this->setState('filter.featured', $featured);

$published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);

$level = $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level');
$this->setState('filter.level', $level);

$language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);

$formSubmitted = $input->post->get('form_submitted');

// Gets the value of a user state variable and sets it in the session
$this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access');
$this->getUserStateFromRequest($this->context . '.filter.author_id', 'filter_author_id');
$this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
$this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', '');

if ($formSubmitted) {
$access = $input->post->get('access');
$this->setState('filter.access', $access);

$authorId = $input->post->get('author_id');
$this->setState('filter.author_id', $authorId);

$categoryId = $input->post->get('category_id');
$this->setState('filter.category_id', $categoryId);

$tag = $input->post->get('tag');
$this->setState('filter.tag', $tag);
}

// List state information.
parent::populateState($ordering, $direction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ protected function getStoreId($id = '')
*/
protected function populateState($ordering = 'a.title', $direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'cmd'));

// Load the parameters.
$params = ComponentHelper::getParams('com_finder');
$this->setState('params', $params);
Expand Down
7 changes: 0 additions & 7 deletions administrator/components/com_finder/src/Model/IndexModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,6 @@ public function purge()
*/
protected function populateState($ordering = 'l.title', $direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'cmd'));
$this->setState('filter.type', $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'cmd'));
$this->setState('filter.content_map', $this->getUserStateFromRequest($this->context . '.filter.content_map', 'filter_content_map', '', 'cmd'));
$this->setState('filter.language', $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', ''));

// Load the parameters.
$params = ComponentHelper::getParams('com_finder');
$this->setState('params', $params);
Expand Down
6 changes: 0 additions & 6 deletions administrator/components/com_finder/src/Model/MapsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,6 @@ public function getTable($type = 'Map', $prefix = 'Administrator', $config = [])
*/
protected function populateState($ordering = 'branch_title, a.lft', $direction = 'ASC')
{
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'cmd'));
$this->setState('filter.branch', $this->getUserStateFromRequest($this->context . '.filter.branch', 'filter_branch', '', 'cmd'));
$this->setState('filter.level', $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', '', 'cmd'));

// Load the parameters.
$params = ComponentHelper::getParams('com_finder');
$this->setState('params', $params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ public function __construct($config = [])
*/
protected function populateState($ordering = 'a.ordering', $direction = 'ASC')
{
$app = Factory::getApplication();
$extension = $app->getUserStateFromRequest($this->context . '.filter.extension', 'extension', null, 'cmd');

$this->setState('filter.extension', $extension);

parent::populateState($ordering, $direction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,6 @@ private function fetchSchemaCache($cid = 0)
*/
protected function populateState($ordering = 'name', $direction = 'asc')
{
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.client_id', $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', null, 'int'));
$this->setState('filter.type', $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string'));
$this->setState('filter.folder', $this->getUserStateFromRequest($this->context . '.filter.folder', 'filter_folder', '', 'string'));

parent::populateState($ordering, $direction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ protected function populateState($ordering = 'name', $direction = 'asc')
{
$app = Factory::getApplication();

// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.client_id', $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', null, 'int'));
$this->setState('filter.type', $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string'));
$this->setState('filter.folder', $this->getUserStateFromRequest($this->context . '.filter.folder', 'filter_folder', '', 'string'));

$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ protected function getStoreId($id = '')
*/
protected function populateState($ordering = 'name', $direction = 'asc')
{
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));

$this->setState('extension_message', Factory::getApplication()->getUserState('com_installer.extension_message'));

parent::populateState($ordering, $direction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@ protected function populateState($ordering = 'name', $direction = 'asc')
{
$app = Factory::getApplication();

// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.client_id', $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', null, 'int'));
$this->setState('filter.package_id', $this->getUserStateFromRequest($this->context . '.filter.package_id', 'filter_package_id', null, 'int'));
$this->setState('filter.status', $this->getUserStateFromRequest($this->context . '.filter.status', 'filter_status', '', 'string'));
$this->setState('filter.type', $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string'));
$this->setState('filter.folder', $this->getUserStateFromRequest($this->context . '.filter.folder', 'filter_folder', '', 'string'));
$this->setState('filter.core', $this->getUserStateFromRequest($this->context . '.filter.core', 'filter_core', '', 'string'));

$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ public function __construct($config = [], MVCFactoryInterface $factory = null)
*/
protected function populateState($ordering = 'u.name', $direction = 'asc')
{
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.client_id', $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', null, 'int'));
$this->setState('filter.type', $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string'));
$this->setState('filter.folder', $this->getUserStateFromRequest($this->context . '.filter.folder', 'filter_folder', '', 'string'));

$app = Factory::getApplication();
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,40 +465,6 @@ static function ($item) {
*/
protected function populateState($ordering = 'name', $direction = 'asc')
{
// Load the filter state.
$stateKeys = [
'search' => 'string',
'client_id' => 'int',
'enabled' => 'string',
'type' => 'string',
'folder' => 'string',
'supported' => 'int',
];

foreach ($stateKeys as $key => $filterType) {
$stateKey = 'filter.' . $key;

switch ($filterType) {
case 'int':
case 'bool':
$default = null;
break;

default:
$default = '';
break;
}

$stateValue = $this->getUserStateFromRequest(
$this->context . '.' . $stateKey,
'filter_' . $key,
$default,
$filterType
);

$this->setState($stateKey, $stateValue);
}

parent::populateState($ordering, $direction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ public function __construct($config = [], MVCFactoryInterface $factory = null)
*/
protected function populateState($ordering = 'name', $direction = 'asc')
{
// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));

// Special case for client id.
$clientId = (int) $this->getUserStateFromRequest($this->context . '.client_id', 'client_id', 0, 'int');
$clientId = (!\in_array($clientId, [0, 1])) ? 0 : $clientId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,7 @@ protected function populateState($ordering = 'key', $direction = 'asc')
$client = substr($language_client, -1);
$language = substr($language_client, 0, -1);

// Sets the search filter.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);

$this->setState('language_client', $language . $client);
$this->setState('filter.client', $client ? 'administrator' : 'site');
$this->setState('filter.language', $language);

// Add the 'language_client' value to the session to display a message if none selected
$app->setUserState('com_languages.overrides.language_client', $language . $client);
Expand Down
15 changes: 0 additions & 15 deletions administrator/components/com_menus/src/Model/ItemsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,6 @@ protected function populateState($ordering = 'a.lft', $direction = 'asc')
$this->context .= '.' . $forcedLanguage;
}

$search = $this->getUserStateFromRequest($this->context . '.search', 'filter_search');
$this->setState('filter.search', $search);

$published = $this->getUserStateFromRequest($this->context . '.published', 'filter_published', '');
$this->setState('filter.published', $published);

$access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access');
$this->setState('filter.access', $access);

$parentId = $this->getUserStateFromRequest($this->context . '.filter.parent_id', 'filter_parent_id');
$this->setState('filter.parent_id', $parentId);

$level = $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level');
$this->setState('filter.level', $level);

// Watch changes in client_id and menutype and keep sync whenever needed.
$currentClientId = $app->getUserState($this->context . '.client_id', 0);
$clientId = $app->getInput()->getInt('client_id', $currentClientId);
Expand Down
3 changes: 0 additions & 3 deletions administrator/components/com_menus/src/Model/MenusModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ protected function getListQuery()
*/
protected function populateState($ordering = 'a.ordering', $direction = 'asc')
{
$search = $this->getUserStateFromRequest($this->context . '.search', 'filter_search');
$this->setState('filter.search', $search);

$clientId = (int) $this->getUserStateFromRequest($this->context . '.client_id', 'client_id', 0, 'int');
$this->setState('client_id', $clientId);

Expand Down
11 changes: 0 additions & 11 deletions administrator/components/com_modules/src/Model/ModulesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,10 @@ protected function populateState($ordering = 'a.position', $direction = 'asc')
// Make context client aware
$this->context .= '.' . $app->getInput()->get->getInt('client_id', 0);

// Load the filter state.
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
$this->setState('filter.position', $this->getUserStateFromRequest($this->context . '.filter.position', 'filter_position', '', 'string'));
$this->setState('filter.module', $this->getUserStateFromRequest($this->context . '.filter.module', 'filter_module', '', 'string'));
$this->setState('filter.menuitem', $this->getUserStateFromRequest($this->context . '.filter.menuitem', 'filter_menuitem', '', 'cmd'));
$this->setState('filter.access', $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', '', 'cmd'));

// If in modal layout on the frontend, state and language are always forced.
if ($app->isClient('site') && $layout === 'modal') {
$this->setState('filter.language', 'current');
$this->setState('filter.state', 1);
} else {
// If in backend (modal or not) we get the same fields from the user request.
$this->setState('filter.language', $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '', 'string'));
$this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string'));
}

// Special case for the client id.
Expand Down
13 changes: 0 additions & 13 deletions administrator/components/com_modules/src/Model/PositionsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ public function __construct($config = [])
*/
protected function populateState($ordering = 'ordering', $direction = 'asc')
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);

$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $state);

$template = $this->getUserStateFromRequest($this->context . '.filter.template', 'filter_template', '', 'string');
$this->setState('filter.template', $template);

$type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string');
$this->setState('filter.type', $type);

// Special case for the client id.
$clientId = (int) $this->getUserStateFromRequest($this->context . '.client_id', 'client_id', 0, 'int');
$clientId = (!\in_array((int) $clientId, [0, 1])) ? 0 : (int) $clientId;
Expand Down
16 changes: 0 additions & 16 deletions administrator/components/com_privacy/src/Model/ConsentsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,6 @@ protected function getStoreId($id = '')
*/
protected function populateState($ordering = 'a.id', $direction = 'desc')
{
// Load the filter state.
$this->setState(
'filter.search',
$this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search')
);

$this->setState(
'filter.subject',
$this->getUserStateFromRequest($this->context . '.filter.subject', 'filter_subject')
);

$this->setState(
'filter.state',
$this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state')
);

// Load the parameters.
$this->setState('params', ComponentHelper::getParams('com_privacy'));

Expand Down
16 changes: 0 additions & 16 deletions administrator/components/com_privacy/src/Model/RequestsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,6 @@ protected function getStoreId($id = '')
*/
protected function populateState($ordering = 'a.id', $direction = 'desc')
{
// Load the filter state.
$this->setState(
'filter.search',
$this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search')
);

$this->setState(
'filter.status',
$this->getUserStateFromRequest($this->context . '.filter.status', 'filter_status', '', 'int')
);

$this->setState(
'filter.request_type',
$this->getUserStateFromRequest($this->context . '.filter.request_type', 'filter_request_type', '', 'string')
);

// Load the parameters.
$this->setState('params', ComponentHelper::getParams('com_privacy'));

Expand Down
Loading

0 comments on commit 44ea1cb

Please sign in to comment.