Added filters above the admin list views to resolve gh-378
This commit is contained in:
@ -15,6 +15,7 @@ defined('_JEXEC') or die('Restricted access');
|
||||
JHtml::_('behavior.tooltip');
|
||||
JHtml::_('behavior.multiselect');
|
||||
JHtml::_('dropdown.init');
|
||||
JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_COMPONENTBUILDER_FILTER_SELECT_ACCESS') . ' -'));
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
if ($this->saveOrder)
|
||||
{
|
||||
@ -22,23 +23,6 @@ if ($this->saveOrder)
|
||||
JHtml::_('sortablelist.sortable', 'serverList', '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=servers'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<?php if(!empty( $this->sidebar)): ?>
|
||||
<div id="j-sidebar-container" class="span2">
|
||||
@ -48,13 +32,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="serverList">
|
||||
<thead><?php echo $this->loadTemplate('head');?></thead>
|
||||
<tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
|
||||
@ -72,8 +58,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,14 +30,14 @@ defined('_JEXEC') or die('Restricted access');
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th class="nowrap" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SERVER_NAME_LABEL', 'a.name', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_SERVER_NAME_LABEL', 'a.name', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL', 'a.protocol', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL', 'a.protocol', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<?php if ($this->canState): ?>
|
||||
<th width="10" class="nowrap center" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SERVER_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_SERVER_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<?php else: ?>
|
||||
<th width="10" class="nowrap center" >
|
||||
@ -45,6 +45,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_SERVER_ID', 'a.id', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('searchtools.sort', 'COM_COMPONENTBUILDER_SERVER_ID', 'a.id', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
</tr>
|
@ -34,6 +34,10 @@ class ComponentbuilderViewServers 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,62 +158,6 @@ class ComponentbuilderViewServers 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)
|
||||
);
|
||||
}
|
||||
|
||||
JHtmlSidebar::addFilter(
|
||||
JText::_('JOPTION_SELECT_ACCESS'),
|
||||
'filter_access',
|
||||
JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))
|
||||
);
|
||||
|
||||
// Set Name Selection
|
||||
$this->nameOptions = $this->getTheNameSelections();
|
||||
// We do some sanitation for Name filter
|
||||
if (ComponentbuilderHelper::checkArray($this->nameOptions) &&
|
||||
isset($this->nameOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->nameOptions[0]->value))
|
||||
{
|
||||
unset($this->nameOptions[0]);
|
||||
}
|
||||
// Only load Name filter if it has values
|
||||
if (ComponentbuilderHelper::checkArray($this->nameOptions))
|
||||
{
|
||||
// Name Filter
|
||||
JHtmlSidebar::addFilter(
|
||||
'- Select '.JText::_('COM_COMPONENTBUILDER_SERVER_NAME_LABEL').' -',
|
||||
'filter_name',
|
||||
JHtml::_('select.options', $this->nameOptions, 'value', 'text', $this->state->get('filter.name'))
|
||||
);
|
||||
}
|
||||
|
||||
// Set Protocol Selection
|
||||
$this->protocolOptions = $this->getTheProtocolSelections();
|
||||
// We do some sanitation for Protocol filter
|
||||
if (ComponentbuilderHelper::checkArray($this->protocolOptions) &&
|
||||
isset($this->protocolOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->protocolOptions[0]->value))
|
||||
{
|
||||
unset($this->protocolOptions[0]);
|
||||
}
|
||||
// Only load Protocol filter if it has values
|
||||
if (ComponentbuilderHelper::checkArray($this->protocolOptions))
|
||||
{
|
||||
// Protocol Filter
|
||||
JHtmlSidebar::addFilter(
|
||||
'- Select '.JText::_('COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL').' -',
|
||||
'filter_protocol',
|
||||
JHtml::_('select.options', $this->protocolOptions, 'value', 'text', $this->state->get('filter.protocol'))
|
||||
);
|
||||
}
|
||||
|
||||
// Only load published batch if state and batch is allowed
|
||||
if ($this->canState && $this->canBatch)
|
||||
{
|
||||
@ -233,6 +181,15 @@ class ComponentbuilderViewServers extends JViewLegacy
|
||||
// Only load Name batch if create, edit, and batch is allowed
|
||||
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||
{
|
||||
// Set Name Selection
|
||||
$this->nameOptions = JFormHelper::loadFieldType('serversfiltername')->options;
|
||||
// We do some sanitation for Name filter
|
||||
if (ComponentbuilderHelper::checkArray($this->nameOptions) &&
|
||||
isset($this->nameOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->nameOptions[0]->value))
|
||||
{
|
||||
unset($this->nameOptions[0]);
|
||||
}
|
||||
// Name Batch Selection
|
||||
JHtmlBatch_::addListSelection(
|
||||
'- Keep Original '.JText::_('COM_COMPONENTBUILDER_SERVER_NAME_LABEL').' -',
|
||||
@ -244,6 +201,15 @@ class ComponentbuilderViewServers extends JViewLegacy
|
||||
// Only load Protocol batch if create, edit, and batch is allowed
|
||||
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||
{
|
||||
// Set Protocol Selection
|
||||
$this->protocolOptions = JFormHelper::loadFieldType('serversfilterprotocol')->options;
|
||||
// We do some sanitation for Protocol filter
|
||||
if (ComponentbuilderHelper::checkArray($this->protocolOptions) &&
|
||||
isset($this->protocolOptions[0]->value) &&
|
||||
!ComponentbuilderHelper::checkString($this->protocolOptions[0]->value))
|
||||
{
|
||||
unset($this->protocolOptions[0]);
|
||||
}
|
||||
// Protocol Batch Selection
|
||||
JHtmlBatch_::addListSelection(
|
||||
'- Keep Original '.JText::_('COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL').' -',
|
||||
@ -300,73 +266,5 @@ class ComponentbuilderViewServers extends JViewLegacy
|
||||
'a.protocol' => JText::_('COM_COMPONENTBUILDER_SERVER_PROTOCOL_LABEL'),
|
||||
'a.id' => JText::_('JGRID_HEADING_ID')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getTheNameSelections()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('name'));
|
||||
$query->from($db->quoteName('#__componentbuilder_server'));
|
||||
$query->order($db->quoteName('name') . ' ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
|
||||
$results = $db->loadColumn();
|
||||
|
||||
if ($results)
|
||||
{
|
||||
$results = array_unique($results);
|
||||
$_filter = array();
|
||||
foreach ($results as $name)
|
||||
{
|
||||
// Now add the name and its text to the options array
|
||||
$_filter[] = JHtml::_('select.option', $name, $name);
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getTheProtocolSelections()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('protocol'));
|
||||
$query->from($db->quoteName('#__componentbuilder_server'));
|
||||
$query->order($db->quoteName('protocol') . ' 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 $protocol)
|
||||
{
|
||||
// Translate the protocol selection
|
||||
$text = $model->selectionTranslation($protocol,'protocol');
|
||||
// Now add the protocol and its text to the options array
|
||||
$_filter[] = JHtml::_('select.option', $protocol, JText::_($text));
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user