diff --git a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini index 6550d0e..e9d6270 100644 --- a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini +++ b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.ini @@ -12,3 +12,4 @@ COM_PATCHTESTER_FIELD_ORG_DESC="Name of account on Github of which to monitor pu COM_PATCHTESTER_FIELD_REPO_LABEL="Github Repository" COM_PATCHTESTER_FIELD_REPO_DESC="Name of repository on Github of which to monitor pull requests" COM_PATCHTESTER_JOOMLACODE_ISSUE="Joomlacode Issue" +COM_PATCHTESTER_PULL_ID="Pull ID" diff --git a/administrator/components/com_patchtester/models/pulls.php b/administrator/components/com_patchtester/models/pulls.php index 49e1b1f..9f9f843 100644 --- a/administrator/components/com_patchtester/models/pulls.php +++ b/administrator/components/com_patchtester/models/pulls.php @@ -48,17 +48,19 @@ class PatchtesterModelPulls extends JModelList */ protected function populateState($ordering = null, $direction = null) { - // Initialise variables. - $app = JFactory::getApplication('administrator'); - + // Load the filter state. + $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + // Load the parameters. $params = JComponentHelper::getParams('com_patchtester'); - + $this->setState('params', $params); $this->setState('github_user', $params->get('org', 'joomla')); $this->setState('github_repo', $params->get('repo', 'joomla-cms')); + // List state information. - parent::populateState('title', 'asc'); + parent::populateState('number', 'desc'); } /** @@ -83,7 +85,7 @@ class PatchtesterModelPulls extends JModelList $query->select('*'); $query->from('#__tests'); $query->where('applied = 1'); - + $this->_db->setQuery($query); $tests = $this->_db->loadObjectList('pull_id'); return $tests; @@ -97,12 +99,20 @@ class PatchtesterModelPulls extends JModelList return array(); } + $this->ordering = $this->getState('list.ordering', 'title'); + $this->orderDir = $this->getState('list.direction', 'asc'); + $search = $this->getState('filter.search'); + $github = new JGithub(); $pulls = $github->pulls->getAll($this->getState('github_user'), $this->getState('github_repo')); 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(); preg_match('#\[\#([0-9]+)\]#', $pull->title, $matches); $pull->joomlacode_issue = isset($matches[1]) ? $matches[1] : 0; @@ -112,6 +122,14 @@ class PatchtesterModelPulls extends JModelList 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; + } } } diff --git a/administrator/components/com_patchtester/views/pulls/tmpl/default.php b/administrator/components/com_patchtester/views/pulls/tmpl/default.php index a449399..2f72c79 100644 --- a/administrator/components/com_patchtester/views/pulls/tmpl/default.php +++ b/administrator/components/com_patchtester/views/pulls/tmpl/default.php @@ -11,6 +11,9 @@ defined('_JEXEC') or die; JHtml::_('behavior.tooltip'); JHtml::_('behavior.modal'); +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); + ?>
+
+ +
+
@@ -27,8 +39,11 @@ JHtml::_('behavior.modal'); + + @@ -98,6 +116,8 @@ JHtml::_('behavior.modal'); + +
+ + - + @@ -59,6 +74,9 @@ JHtml::_('behavior.modal'); id); ?> + number; ?> + title; ?>