Added new filters to admin, and custom admin, and site list view. gh-651
This commit is contained in:
@ -42,6 +42,51 @@ class ComponentbuilderModelAdmin_views extends JModelList
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filter form - Override the parent method
|
||||
*
|
||||
* @param array $data data
|
||||
* @param boolean $loadData load current data
|
||||
*
|
||||
* @return \JForm|boolean The \JForm object or false on error
|
||||
*
|
||||
* @since JCB 2.12.5
|
||||
*/
|
||||
public function getFilterForm($data = array(), $loadData = true)
|
||||
{
|
||||
// load form from the parent class
|
||||
$form = parent::getFilterForm($data, $loadData);
|
||||
|
||||
// Create the "joomla_component" filter
|
||||
$attributes = array(
|
||||
'name' => 'joomla_component',
|
||||
'type' => 'list',
|
||||
'onchange' => 'this.form.submit();',
|
||||
);
|
||||
$options = array(
|
||||
'' => '- ' . JText::_('COM_COMPONENTBUILDER_NO_COMPONENTS_FOUND') . ' -'
|
||||
);
|
||||
// check if we have joomla components
|
||||
if (($joomla_components = ComponentbuilderHelper::getByTypeTheIdsSystemNames('joomla_component')) !== false)
|
||||
{
|
||||
$options = array(
|
||||
'' => '- ' . JText::_('COM_COMPONENTBUILDER_SELECT_COMPONENT') . ' -'
|
||||
);
|
||||
// make sure we do not lose the key values in normal merge
|
||||
$options = $options + $joomla_components;
|
||||
}
|
||||
|
||||
$form->setField(ComponentbuilderHelper::getFieldXML($attributes, $options),'filter');
|
||||
$form->setValue(
|
||||
'joomla_component',
|
||||
'filter',
|
||||
$this->state->get("filter.joomla_component")
|
||||
);
|
||||
array_push($this->filter_fields, 'joomla_component');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,6 +346,25 @@ class ComponentbuilderModelAdmin_views extends JModelList
|
||||
// From the componentbuilder_item table
|
||||
$query->from($db->quoteName('#__componentbuilder_admin_view', 'a'));
|
||||
|
||||
// do not use these filters in the export method
|
||||
if (!isset($_export) || !$_export)
|
||||
{
|
||||
// Filtering "joomla components"
|
||||
$filter_joomla_component = $this->state->get("filter.joomla_component");
|
||||
if ($filter_joomla_component !== null && !empty($filter_joomla_component))
|
||||
{
|
||||
if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_joomla_component, 'joomla_component_admin_views')) !== false)
|
||||
{
|
||||
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is none
|
||||
$query->where($db->quoteName('a.id') . ' = ' . 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by published state
|
||||
$published = $this->getState('filter.published');
|
||||
if (is_numeric($published))
|
||||
@ -516,6 +580,25 @@ class ComponentbuilderModelAdmin_views extends JModelList
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',',$pks) . ')');
|
||||
}
|
||||
|
||||
// do not use these filters in the export method
|
||||
if (!isset($_export) || !$_export)
|
||||
{
|
||||
// Filtering "joomla components"
|
||||
$filter_joomla_component = $this->state->get("filter.joomla_component");
|
||||
if ($filter_joomla_component !== null && !empty($filter_joomla_component))
|
||||
{
|
||||
if (($ids = ComponentbuilderHelper::getAreaLinkedIDs($filter_joomla_component, 'joomla_component_admin_views')) !== false)
|
||||
{
|
||||
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $ids) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
// there is none
|
||||
$query->where($db->quoteName('a.id') . ' = ' . 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Implement View Level Access
|
||||
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||
{
|
||||
|
Reference in New Issue
Block a user