mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2025-01-22 22:58:27 +00:00
Add ordering and filter
This commit is contained in:
parent
3babe57078
commit
27c685217e
@ -48,17 +48,19 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
*/
|
*/
|
||||||
protected function populateState($ordering = null, $direction = null)
|
protected function populateState($ordering = null, $direction = null)
|
||||||
{
|
{
|
||||||
// Initialise variables.
|
// Load the filter state.
|
||||||
$app = JFactory::getApplication('administrator');
|
$search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
|
||||||
|
$this->setState('filter.search', $search);
|
||||||
|
|
||||||
// Load the parameters.
|
// Load the parameters.
|
||||||
$params = JComponentHelper::getParams('com_patchtester');
|
$params = JComponentHelper::getParams('com_patchtester');
|
||||||
|
|
||||||
$this->setState('params', $params);
|
$this->setState('params', $params);
|
||||||
$this->setState('github_user', $params->get('org', 'joomla'));
|
$this->setState('github_user', $params->get('org', 'joomla'));
|
||||||
$this->setState('github_repo', $params->get('repo', 'joomla-cms'));
|
$this->setState('github_repo', $params->get('repo', 'joomla-cms'));
|
||||||
|
|
||||||
// List state information.
|
// List state information.
|
||||||
parent::populateState('title', 'asc');
|
parent::populateState('number', 'desc');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,7 +85,7 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
$query->select('*');
|
$query->select('*');
|
||||||
$query->from('#__tests');
|
$query->from('#__tests');
|
||||||
$query->where('applied = 1');
|
$query->where('applied = 1');
|
||||||
|
|
||||||
$this->_db->setQuery($query);
|
$this->_db->setQuery($query);
|
||||||
$tests = $this->_db->loadObjectList('pull_id');
|
$tests = $this->_db->loadObjectList('pull_id');
|
||||||
return $tests;
|
return $tests;
|
||||||
@ -97,12 +99,20 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->ordering = $this->getState('list.ordering', 'title');
|
||||||
|
$this->orderDir = $this->getState('list.direction', 'asc');
|
||||||
|
$search = $this->getState('filter.search');
|
||||||
|
|
||||||
$github = new JGithub();
|
$github = new JGithub();
|
||||||
$pulls = $github->pulls->getAll($this->getState('github_user'), $this->getState('github_repo'));
|
$pulls = $github->pulls->getAll($this->getState('github_user'), $this->getState('github_repo'));
|
||||||
usort($pulls, array($this, 'sortItems'));
|
usort($pulls, array($this, 'sortItems'));
|
||||||
|
|
||||||
foreach ($pulls AS &$pull)
|
foreach ($pulls AS $i => &$pull)
|
||||||
{
|
{
|
||||||
|
if($search && false === strpos($pull->title, $search)) {
|
||||||
|
unset($pulls[$i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$matches = array();
|
$matches = array();
|
||||||
preg_match('#\[\#([0-9]+)\]#', $pull->title, $matches);
|
preg_match('#\[\#([0-9]+)\]#', $pull->title, $matches);
|
||||||
$pull->joomlacode_issue = isset($matches[1]) ? $matches[1] : 0;
|
$pull->joomlacode_issue = isset($matches[1]) ? $matches[1] : 0;
|
||||||
@ -112,6 +122,14 @@ class PatchtesterModelPulls extends JModelList
|
|||||||
|
|
||||||
public function sortItems($a, $b)
|
public function sortItems($a, $b)
|
||||||
{
|
{
|
||||||
return strcasecmp($a->title, $b->title);
|
switch ($this->ordering)
|
||||||
|
{
|
||||||
|
case 'title' :
|
||||||
|
return ($this->orderDir == 'asc') ? strcasecmp($a->title, $b->title) : strcasecmp($b->title, $a->title);
|
||||||
|
|
||||||
|
case 'number' :
|
||||||
|
default :
|
||||||
|
return ($this->orderDir == 'asc') ? $b->number < $a->number : $b->number > $a->number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@ defined('_JEXEC') or die;
|
|||||||
JHtml::_('behavior.tooltip');
|
JHtml::_('behavior.tooltip');
|
||||||
JHtml::_('behavior.modal');
|
JHtml::_('behavior.modal');
|
||||||
|
|
||||||
|
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||||
|
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var submitpatch = function(task, id) {
|
var submitpatch = function(task, id) {
|
||||||
@ -20,6 +23,15 @@ JHtml::_('behavior.modal');
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form action="<?php echo JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm">
|
<form action="<?php echo JRoute::_('index.php?option=com_patchtester&view=pulls'); ?>" method="post" name="adminForm" id="adminForm">
|
||||||
|
<fieldset id="filter-bar">
|
||||||
|
<div class="filter-search fltlft">
|
||||||
|
<label class="filter-search-lbl" for="filter_search"><?php echo JText::_('JSEARCH_FILTER_LABEL'); ?></label>
|
||||||
|
<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" title="<?php echo JText::_('COM_BANNERS_SEARCH_IN_TITLE'); ?>" />
|
||||||
|
<button type="submit"><?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
|
||||||
|
<button type="button" onclick="document.id('filter_search').value='';this.form.submit();"><?php echo JText::_('JSEARCH_FILTER_CLEAR'); ?></button>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<div class="clr"> </div>
|
||||||
|
|
||||||
<table class="adminlist">
|
<table class="adminlist">
|
||||||
<thead>
|
<thead>
|
||||||
@ -27,8 +39,11 @@ JHtml::_('behavior.modal');
|
|||||||
<th width="1%">
|
<th width="1%">
|
||||||
<input type="checkbox" name="checkall-toggle" value="" title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)" />
|
<input type="checkbox" name="checkall-toggle" value="" title="<?php echo JText::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)" />
|
||||||
</th>
|
</th>
|
||||||
|
<th width="5%">
|
||||||
|
<?php echo JHtml::_('grid.sort', 'COM_PATCHTESTER_PULL_ID', 'number', $listDirn, $listOrder); ?>
|
||||||
|
</th>
|
||||||
<th class="title">
|
<th class="title">
|
||||||
<?php echo JText::_('JGLOBAL_TITLE'); ?>
|
<?php echo JHtml::_('grid.sort', 'JGLOBAL_TITLE', 'title', $listDirn, $listOrder); ?>
|
||||||
</th>
|
</th>
|
||||||
<th class="title">
|
<th class="title">
|
||||||
<?php echo JText::_('COM_PATCHTESTER_JOOMLACODE_ISSUE'); ?>
|
<?php echo JText::_('COM_PATCHTESTER_JOOMLACODE_ISSUE'); ?>
|
||||||
@ -59,6 +74,9 @@ JHtml::_('behavior.modal');
|
|||||||
<td class="center">
|
<td class="center">
|
||||||
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
|
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="center">
|
||||||
|
<?php echo $item->number; ?>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?php echo $item->html_url; ?>" title="<?php echo htmlspecialchars($item->body); ?>"><?php echo $item->title; ?></a>
|
<a href="<?php echo $item->html_url; ?>" title="<?php echo htmlspecialchars($item->body); ?>"><?php echo $item->title; ?></a>
|
||||||
</td>
|
</td>
|
||||||
@ -98,6 +116,8 @@ JHtml::_('behavior.modal');
|
|||||||
<input type="hidden" name="task" value="" />
|
<input type="hidden" name="task" value="" />
|
||||||
<input type="hidden" name="boxchecked" value="0" />
|
<input type="hidden" name="boxchecked" value="0" />
|
||||||
<input type="hidden" name="pull_id" id="pull_id" value="" />
|
<input type="hidden" name="pull_id" id="pull_id" value="" />
|
||||||
|
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
|
||||||
|
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
|
||||||
<?php echo JHtml::_('form.token'); ?>
|
<?php echo JHtml::_('form.token'); ?>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user