Added filters above the admin list views to resolve gh-378
This commit is contained in:
@ -22,23 +22,6 @@ if ($this->saveOrder)
|
||||
JHtml::_('sortablelist.sortable', 'help_documentList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
Joomla.orderTable = function()
|
||||
{
|
||||
table = document.getElementById("sortTable");
|
||||
direction = document.getElementById("directionTable");
|
||||
order = table.options[table.selectedIndex].value;
|
||||
if (order != '<?php echo $this->listOrder; ?>')
|
||||
{
|
||||
dirn = 'asc';
|
||||
}
|
||||
else
|
||||
{
|
||||
dirn = direction.options[direction.selectedIndex].value;
|
||||
}
|
||||
Joomla.tableOrdering(order, dirn, '');
|
||||
}
|
||||
</script>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_componentbuilder&view=help_documents'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if(!empty( $this->sidebar)): ?>
|
||||
<div id="j-sidebar-container" class="span2">
|
||||
@ -48,13 +31,15 @@ if ($this->saveOrder)
|
||||
<?php else : ?>
|
||||
<div id="j-main-container">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
// Add the searchtools
|
||||
echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this));
|
||||
?>
|
||||
<?php if (empty($this->items)): ?>
|
||||
<?php echo $this->loadTemplate('toolbar');?>
|
||||
<div class="alert alert-no-items">
|
||||
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<?php echo $this->loadTemplate('toolbar');?>
|
||||
<table class="table table-striped" id="help_documentList">
|
||||
<thead><?php echo $this->loadTemplate('head');?></thead>
|
||||
<tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
|
||||
@ -72,8 +57,6 @@ if ($this->saveOrder)
|
||||
$this->loadTemplate('batch_body')
|
||||
); ?>
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="filter_order" value="<?php echo $this->listOrder; ?>" />
|
||||
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->listDirn; ?>" />
|
||||
<input type="hidden" name="boxchecked" value="0" />
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -16,7 +16,7 @@ defined('_JEXEC') or die('Restricted access');
|
||||
<tr>
|
||||
<?php if ($this->canEdit&& $this->canState): ?>
|
||||
<th width="1%" class="nowrap center hidden-phone">
|
||||
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'a.ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', '', 'a.ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
|
||||
</th>
|
||||
<th width="20" class="nowrap center">
|
||||
<?php echo JHtml::_('grid.checkall'); ?>
|
||||
@ -30,26 +30,26 @@ defined('_JEXEC') or die('Restricted access');
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th class="nowrap" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_TITLE_LABEL', 'a.title', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_TITLE_LABEL', 'a.title', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL', 'a.type', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL', 'a.type', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_GROUPS_LABEL'); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL', 'a.location', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL', 'a.location', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL', 'g.', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL', 'g.', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL', 'h.', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL', 'h.', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<?php if ($this->canState): ?>
|
||||
<th width="10" class="nowrap center" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<?php else: ?>
|
||||
<th width="10" class="nowrap center" >
|
||||
@ -57,6 +57,6 @@ defined('_JEXEC') or die('Restricted access');
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th width="5" class="nowrap center hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_ID', 'a.id', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_HELP_DOCUMENT_ID', 'a.id', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
@ -34,6 +34,10 @@ class ComponentbuilderViewHelp_documents extends JViewLegacy
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->state = $this->get('State');
|
||||
$this->user = JFactory::getUser();
|
||||
// Load the filter form from xml.
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
// Load the active filters.
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
// Add the list ordering clause.
|
||||
$this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id'));
|
||||
$this->listDirn = $this->escape($this->state->get('list.direction', 'DESC'));
|
||||
@ -154,96 +158,6 @@ class ComponentbuilderViewHelp_documents extends JViewLegacy
|
||||
JToolBarHelper::preferences('com_componentbuilder');
|
||||
}
|
||||
|
||||
// Only load publish filter if state change is allowed
|
||||
if ($this->canState)
|
||||
{
|
||||
JHtmlSidebar::addFilter(
|
||||
JText::_('JOPTION_SELECT_PUBLISHED'),
|
||||
'filter_published',
|
||||
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)
|
||||
);
|
||||
}
|
||||
|
||||
// Set Type Selection
|
||||
$this->typeOptions = $this->getTheTypeSelections();
|
||||
// We do some sanitation for Type filter
|
||||
if (ComponentbuilderHelper::checkArray($this->typeOptions) &&
|
||||
isset($this->typeOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->typeOptions[0]->value))
|
||||
{
|
||||
unset($this->typeOptions[0]);
|
||||
}
|
||||
// Only load Type filter if it has values
|
||||
if (ComponentbuilderHelper::checkArray($this->typeOptions))
|
||||
{
|
||||
// Type Filter
|
||||
JHtmlSidebar::addFilter(
|
||||
'- Select '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL').' -',
|
||||
'filter_type',
|
||||
JHtml::_('select.options', $this->typeOptions, 'value', 'text', $this->state->get('filter.type'))
|
||||
);
|
||||
}
|
||||
|
||||
// Set Location Selection
|
||||
$this->locationOptions = $this->getTheLocationSelections();
|
||||
// We do some sanitation for Location filter
|
||||
if (ComponentbuilderHelper::checkArray($this->locationOptions) &&
|
||||
isset($this->locationOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->locationOptions[0]->value))
|
||||
{
|
||||
unset($this->locationOptions[0]);
|
||||
}
|
||||
// Only load Location filter if it has values
|
||||
if (ComponentbuilderHelper::checkArray($this->locationOptions))
|
||||
{
|
||||
// Location Filter
|
||||
JHtmlSidebar::addFilter(
|
||||
'- Select '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL').' -',
|
||||
'filter_location',
|
||||
JHtml::_('select.options', $this->locationOptions, 'value', 'text', $this->state->get('filter.location'))
|
||||
);
|
||||
}
|
||||
|
||||
// Set Admin View Selection
|
||||
$this->admin_viewOptions = JFormHelper::loadFieldType('Adminviewfolderlist')->options;
|
||||
// We do some sanitation for Admin View filter
|
||||
if (ComponentbuilderHelper::checkArray($this->admin_viewOptions) &&
|
||||
isset($this->admin_viewOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->admin_viewOptions[0]->value))
|
||||
{
|
||||
unset($this->admin_viewOptions[0]);
|
||||
}
|
||||
// Only load Admin View filter if it has values
|
||||
if (ComponentbuilderHelper::checkArray($this->admin_viewOptions))
|
||||
{
|
||||
// Admin View Filter
|
||||
JHtmlSidebar::addFilter(
|
||||
'- Select ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL') . ' -',
|
||||
'filter_admin_view',
|
||||
JHtml::_('select.options', $this->admin_viewOptions, 'value', 'text', $this->state->get('filter.admin_view'))
|
||||
);
|
||||
}
|
||||
|
||||
// Set Site View Selection
|
||||
$this->site_viewOptions = JFormHelper::loadFieldType('Siteviewfolderlist')->options;
|
||||
// We do some sanitation for Site View filter
|
||||
if (ComponentbuilderHelper::checkArray($this->site_viewOptions) &&
|
||||
isset($this->site_viewOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->site_viewOptions[0]->value))
|
||||
{
|
||||
unset($this->site_viewOptions[0]);
|
||||
}
|
||||
// Only load Site View filter if it has values
|
||||
if (ComponentbuilderHelper::checkArray($this->site_viewOptions))
|
||||
{
|
||||
// Site View Filter
|
||||
JHtmlSidebar::addFilter(
|
||||
'- Select ' . JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL') . ' -',
|
||||
'filter_site_view',
|
||||
JHtml::_('select.options', $this->site_viewOptions, 'value', 'text', $this->state->get('filter.site_view'))
|
||||
);
|
||||
}
|
||||
|
||||
// Only load published batch if state and batch is allowed
|
||||
if ($this->canState && $this->canBatch)
|
||||
{
|
||||
@ -257,6 +171,15 @@ class ComponentbuilderViewHelp_documents extends JViewLegacy
|
||||
// Only load Type batch if create, edit, and batch is allowed
|
||||
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||
{
|
||||
// Set Type Selection
|
||||
$this->typeOptions = JFormHelper::loadFieldType('helpdocumentsfiltertype')->options;
|
||||
// We do some sanitation for Type filter
|
||||
if (ComponentbuilderHelper::checkArray($this->typeOptions) &&
|
||||
isset($this->typeOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->typeOptions[0]->value))
|
||||
{
|
||||
unset($this->typeOptions[0]);
|
||||
}
|
||||
// Type Batch Selection
|
||||
JHtmlBatch_::addListSelection(
|
||||
'- Keep Original '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL').' -',
|
||||
@ -268,6 +191,15 @@ class ComponentbuilderViewHelp_documents extends JViewLegacy
|
||||
// Only load Location batch if create, edit, and batch is allowed
|
||||
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||
{
|
||||
// Set Location Selection
|
||||
$this->locationOptions = JFormHelper::loadFieldType('helpdocumentsfilterlocation')->options;
|
||||
// We do some sanitation for Location filter
|
||||
if (ComponentbuilderHelper::checkArray($this->locationOptions) &&
|
||||
isset($this->locationOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->locationOptions[0]->value))
|
||||
{
|
||||
unset($this->locationOptions[0]);
|
||||
}
|
||||
// Location Batch Selection
|
||||
JHtmlBatch_::addListSelection(
|
||||
'- Keep Original '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL').' -',
|
||||
@ -279,6 +211,15 @@ class ComponentbuilderViewHelp_documents extends JViewLegacy
|
||||
// Only load Admin View batch if create, edit, and batch is allowed
|
||||
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||
{
|
||||
// Set Admin View Selection
|
||||
$this->admin_viewOptions = JFormHelper::loadFieldType('Adminviewfolderlist')->options;
|
||||
// We do some sanitation for Admin View filter
|
||||
if (ComponentbuilderHelper::checkArray($this->admin_viewOptions) &&
|
||||
isset($this->admin_viewOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->admin_viewOptions[0]->value))
|
||||
{
|
||||
unset($this->admin_viewOptions[0]);
|
||||
}
|
||||
// Admin View Batch Selection
|
||||
JHtmlBatch_::addListSelection(
|
||||
'- Keep Original '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL').' -',
|
||||
@ -290,6 +231,15 @@ class ComponentbuilderViewHelp_documents extends JViewLegacy
|
||||
// Only load Site View batch if create, edit, and batch is allowed
|
||||
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||
{
|
||||
// Set Site View Selection
|
||||
$this->site_viewOptions = JFormHelper::loadFieldType('Siteviewfolderlist')->options;
|
||||
// We do some sanitation for Site View filter
|
||||
if (ComponentbuilderHelper::checkArray($this->site_viewOptions) &&
|
||||
isset($this->site_viewOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->site_viewOptions[0]->value))
|
||||
{
|
||||
unset($this->site_viewOptions[0]);
|
||||
}
|
||||
// Site View Batch Selection
|
||||
JHtmlBatch_::addListSelection(
|
||||
'- Keep Original '.JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL').' -',
|
||||
@ -349,77 +299,5 @@ class ComponentbuilderViewHelp_documents extends JViewLegacy
|
||||
'h.' => JText::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL'),
|
||||
'a.id' => JText::_('JGRID_HEADING_ID')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getTheTypeSelections()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('type'));
|
||||
$query->from($db->quoteName('#__componentbuilder_help_document'));
|
||||
$query->order($db->quoteName('type') . ' ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
|
||||
$results = $db->loadColumn();
|
||||
|
||||
if ($results)
|
||||
{
|
||||
// get model
|
||||
$model = $this->getModel();
|
||||
$results = array_unique($results);
|
||||
$_filter = array();
|
||||
foreach ($results as $type)
|
||||
{
|
||||
// Translate the type selection
|
||||
$text = $model->selectionTranslation($type,'type');
|
||||
// Now add the type and its text to the options array
|
||||
$_filter[] = JHtml::_('select.option', $type, JText::_($text));
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getTheLocationSelections()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('location'));
|
||||
$query->from($db->quoteName('#__componentbuilder_help_document'));
|
||||
$query->order($db->quoteName('location') . ' ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
|
||||
$results = $db->loadColumn();
|
||||
|
||||
if ($results)
|
||||
{
|
||||
// get model
|
||||
$model = $this->getModel();
|
||||
$results = array_unique($results);
|
||||
$_filter = array();
|
||||
foreach ($results as $location)
|
||||
{
|
||||
// Translate the location selection
|
||||
$text = $model->selectionTranslation($location,'location');
|
||||
// Now add the location and its text to the options array
|
||||
$_filter[] = JHtml::_('select.option', $location, JText::_($text));
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user