Added filters above the admin list views to resolve gh-378

This commit is contained in:
2020-12-03 07:24:20 +02:00
parent 83e4562d62
commit 06c97afa05
277 changed files with 8176 additions and 4301 deletions

View File

@ -65,8 +65,15 @@ class ComponentbuilderModelAdmin_views extends JModelList
$this->context .= '.' . $layout;
}
// Check if the form was submitted
$formSubmited = $app->input->post->get('form_submited');
$access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
$this->setState('filter.access', $access);
if ($formSubmited)
{
$access = $app->input->post->get('access');
$this->setState('filter.access', $access);
}
$published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);
@ -84,28 +91,60 @@ class ComponentbuilderModelAdmin_views extends JModelList
$this->setState('filter.search', $search);
$add_fadein = $this->getUserStateFromRequest($this->context . '.filter.add_fadein', 'filter_add_fadein');
$this->setState('filter.add_fadein', $add_fadein);
if ($formSubmited)
{
$add_fadein = $app->input->post->get('add_fadein');
$this->setState('filter.add_fadein', $add_fadein);
}
$type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type');
$this->setState('filter.type', $type);
if ($formSubmited)
{
$type = $app->input->post->get('type');
$this->setState('filter.type', $type);
}
$add_custom_button = $this->getUserStateFromRequest($this->context . '.filter.add_custom_button', 'filter_add_custom_button');
$this->setState('filter.add_custom_button', $add_custom_button);
if ($formSubmited)
{
$add_custom_button = $app->input->post->get('add_custom_button');
$this->setState('filter.add_custom_button', $add_custom_button);
}
$add_php_ajax = $this->getUserStateFromRequest($this->context . '.filter.add_php_ajax', 'filter_add_php_ajax');
$this->setState('filter.add_php_ajax', $add_php_ajax);
if ($formSubmited)
{
$add_php_ajax = $app->input->post->get('add_php_ajax');
$this->setState('filter.add_php_ajax', $add_php_ajax);
}
$add_custom_import = $this->getUserStateFromRequest($this->context . '.filter.add_custom_import', 'filter_add_custom_import');
$this->setState('filter.add_custom_import', $add_custom_import);
if ($formSubmited)
{
$add_custom_import = $app->input->post->get('add_custom_import');
$this->setState('filter.add_custom_import', $add_custom_import);
}
$system_name = $this->getUserStateFromRequest($this->context . '.filter.system_name', 'filter_system_name');
$this->setState('filter.system_name', $system_name);
if ($formSubmited)
{
$system_name = $app->input->post->get('system_name');
$this->setState('filter.system_name', $system_name);
}
$name_single = $this->getUserStateFromRequest($this->context . '.filter.name_single', 'filter_name_single');
$this->setState('filter.name_single', $name_single);
if ($formSubmited)
{
$name_single = $app->input->post->get('name_single');
$this->setState('filter.name_single', $name_single);
}
$short_description = $this->getUserStateFromRequest($this->context . '.filter.short_description', 'filter_short_description');
$this->setState('filter.short_description', $short_description);
if ($formSubmited)
{
$short_description = $app->input->post->get('short_description');
$this->setState('filter.short_description', $short_description);
}
// List state information.
parent::populateState($ordering, $direction);
@ -344,6 +383,29 @@ class ComponentbuilderModelAdmin_views extends JModelList
{
$query->where('a.type = ' . $db->quote($db->escape($_type)));
}
elseif (ComponentbuilderHelper::checkArray($_type))
{
// Secure the array for the query
$_type = array_map( function ($val) use(&$db) {
if (is_numeric($val))
{
if (is_float($val))
{
return (float) $val;
}
else
{
return (int) $val;
}
}
elseif (ComponentbuilderHelper::checkString($val))
{
return $db->quote($db->escape($val));
}
}, $_type);
// Filter by the Type Array.
$query->where('a.type IN (' . implode(',', $_type) . ')');
}
// Filter by Add_custom_button.
$_add_custom_button = $this->getState('filter.add_custom_button');
if (is_numeric($_add_custom_button))