From b8170b39932cc2a76c8435d7cb05690160c740da Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Fri, 12 Jul 2013 21:26:21 -0500 Subject: [PATCH] Reformat to Joomla CS --- .../components/com_patchtester/controller.php | 27 ++-- .../com_patchtester/controllers/pull.php | 40 ++++-- .../com_patchtester/helpers/github/github.php | 58 +++++--- .../com_patchtester/helpers/github/repos.php | 87 ++++++----- .../language/en-GB/en-GB.com_patchtester.ini | 52 +++---- .../en-GB/en-GB.com_patchtester.sys.ini | 7 +- .../com_patchtester/models/pull.php | 114 ++++++++++----- .../com_patchtester/models/pulls.php | 136 ++++++++++++------ .../com_patchtester/patchtester.php | 11 +- .../com_patchtester/patchtester.xml | 6 +- .../com_patchtester/tables/tests.php | 15 +- .../views/pulls/tmpl/default.php | 74 +++++----- .../views/pulls/tmpl/default_items.php | 135 ++++++++--------- .../com_patchtester/views/pulls/view.html.php | 93 ++++++++---- 14 files changed, 494 insertions(+), 361 deletions(-) diff --git a/administrator/components/com_patchtester/controller.php b/administrator/components/com_patchtester/controller.php index da4cf8d..441d499 100644 --- a/administrator/components/com_patchtester/controller.php +++ b/administrator/components/com_patchtester/controller.php @@ -1,35 +1,26 @@ getModel('pull') - ->apply(JFactory::getApplication()->input->getInt('pull_id')); + $this->getModel('pull')->apply(JFactory::getApplication()->input->getInt('pull_id')); - $msg = JText::_('COM_PATCHTESTER_APPLY_OK'); + $msg = JText::_('COM_PATCHTESTER_APPLY_OK'); $type = 'message'; } catch (Exception $e) { - $msg = $e->getMessage(); + $msg = $e->getMessage(); $type = 'error'; } $this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type); } + /** + * Method to revert a patch + * + * @return void + * + * @since 1.0 + */ public function revert() { try { - $this->getModel('pull') - ->revert(JFactory::getApplication()->input->getInt('pull_id')); + $this->getModel('pull')->revert(JFactory::getApplication()->input->getInt('pull_id')); - $msg = JText::_('COM_PATCHTESTER_REVERT_OK'); + $msg = JText::_('COM_PATCHTESTER_REVERT_OK'); $type = 'message'; } catch (Exception $e) { - $msg = $e->getMessage(); + $msg = $e->getMessage(); $type = 'error'; } $this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type); } - } diff --git a/administrator/components/com_patchtester/helpers/github/github.php b/administrator/components/com_patchtester/helpers/github/github.php index 92b86a4..2caa477 100644 --- a/administrator/components/com_patchtester/helpers/github/github.php +++ b/administrator/components/com_patchtester/helpers/github/github.php @@ -1,30 +1,50 @@ repos == null) - { - $this->repos = new PTGithubRepos($this->options, $this->client); - } + /** + * Magic method to lazily create API objects + * + * @param string $name Name of property to retrieve + * + * @return JGithubObject GitHub API object (gists, issues, pulls, etc). + * + * @since 2.0 + */ + public function __get($name) + { + if ($name == 'repos') + { + if ($this->repos == null) + { + $this->repos = new PTGithubRepos($this->options, $this->client); + } - return $this->repos; - } + return $this->repos; + } - return parent::__get($name); - } + return parent::__get($name); + } } diff --git a/administrator/components/com_patchtester/helpers/github/repos.php b/administrator/components/com_patchtester/helpers/github/repos.php index 5e9c1c9..179aac5 100644 --- a/administrator/components/com_patchtester/helpers/github/repos.php +++ b/administrator/components/com_patchtester/helpers/github/repos.php @@ -1,58 +1,53 @@ client->get($this->fetchUrl($path)); + // Send the request. + return $this->processResponse($this->client->get($this->fetchUrl($path))); + } - // Validate the response code. - if($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); + /** + * List public repositories for the specified user. + * + * @param string $user The username to retrieve repositories for + * + * @return object + * + * @since 2.0 + * @throws DomainException + */ + public function getPublicRepos($user) + { + $path = '/users/' . $user . '/repos'; - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } - - /** - * @param string $user - * @param string $type all, owner, public, private, member. Default: all. - * @param string $sort created, updated, pushed, full_name, default: full_name. - * @param string $direction asc or desc, default: when using full_name: asc, otherwise desc. - * - * @return mixed - * @throws DomainException - */ - public function getPublicRepos($user, $type = 'all', $sort = 'full_name', $direction = 'desc') - { - $path = '/users/'.$user.'/repos'; - - // Send the request. - $response = $this->client->get($this->fetchUrl($path)); - - // Validate the response code. - if($response->code != 200) - { - // Decode the error response and throw an exception. - $error = json_decode($response->body); - throw new DomainException($error->message, $response->code); - } - - return json_decode($response->body); - } + // Send the request. + return $this->processResponse($this->client->get($this->fetchUrl($path))); + } } 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 68ff8fa..bcf4d47 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 @@ -1,36 +1,38 @@ -COM_PATCHTESTER="Patch Tester" -COM_PATCHTESTER_CONFIGURATION="Patch Tester Settings" -COM_PATCHTESTER_NOT_APPLIED="Not Applied" +; Joomla! Project +; Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 Open Source Matters, Inc. All rights reserved. +; License GNU General Public License version 2 or later +; Note : All ini files need to be saved as UTF-8 + +COM_PATCHTESTER="Joomla! Patch Tester" +COM_PATCHTESTER_API_LIMIT_ACTION="The GitHub API rate limit has been reached for this resource, could not connect to GitHub to perform the requested action. The rate limit will reset at %s" +COM_PATCHTESTER_API_LIMIT_LIST="The GitHub API rate limit has been reached for this resource, could not connect to GitHub for updated data. The rate limit will reset at %s" COM_PATCHTESTER_APPLIED="Applied" -COM_PATCHTESTER_REVERT_PATCH="Revert Patch" +COM_PATCHTESTER_APPLY_OK="Patch successfully applied" COM_PATCHTESTER_APPLY_PATCH="Apply Patch" -COM_PATCHTESTER_TEST_THIS_PATCH="Test This Patch" -COM_PATCHTESTER_COMPONENT_LABEL="Patch Tester" -COM_PATCHTESTER_COMPONENT_DESC="Patch Tester Configuration Values" +COM_PATCHTESTER_COMPONENT_DESC="Joomla! Patch Tester Configuration Values" +COM_PATCHTESTER_COMPONENT_LABEL="Joomla! Patch Tester" +COM_PATCHTESTER_CONFIGURATION="Joomla! Patch Tester Settings" +COM_PATCHTESTER_CONFLICT_S="The patch could not be applied because it conflicts with a previously applied patch: %s" +COM_PATCHTESTER_FIELD_GH_PASSWORD_LABEL="GitHub Account Password" +COM_PATCHTESTER_FIELD_GH_PASSWORD_DESC="Password for the account entered in the "_QQ_"GitHub Account"_QQ_" field" +COM_PATCHTESTER_FIELD_GH_USER_LABEL="GitHub Account" +COM_PATCHTESTER_FIELD_GH_USER_DESC="Name of account on GitHub of which to authenticate to the API with" COM_PATCHTESTER_FIELD_ORG_LABEL="GitHub Username" COM_PATCHTESTER_FIELD_ORG_DESC="Name of account on GitHub of which to monitor pull requests" 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_FIELD_GH_USER_LABEL="GitHub Account" -COM_PATCHTESTER_FIELD_GH_USER_DESC="Name of account on GitHub of which to authenticate to the API with" -COM_PATCHTESTER_FIELD_GH_PASSWORD_LABEL="GitHub Account Password" -COM_PATCHTESTER_FIELD_GH_PASSWORD_DESC="Password for the account entered in the "_QQ_"GitHub Account"_QQ_" field" +COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S="The file marked for deletion does not exist: %s" +COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S="The file marked for modification does not exist: %s" COM_PATCHTESTER_JOOMLACODE_ISSUE="Joomlacode Issue" COM_PATCHTESTER_PULL_ID="Pull ID" +COM_PATCHTESTER_NO_CREDENTIALS="No user credentials are saved, this will allow only 60 requests to the GitHub API per hour. Saving user credentials will allow 5,000 requests per hour." +COM_PATCHTESTER_NOT_APPLIED="Not Applied" +COM_PATCHTESTER_OPEN_IN_GITHUB="Open in GitHub" +COM_PATCHTESTER_OPEN_IN_JOOMLACODE="Open in JoomlaCode" +COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the repository is missing" +COM_PATCHTESTER_REVERT_OK="Patch successfully reverted" +COM_PATCHTESTER_REVERT_PATCH="Revert Patch" COM_PATCHTESTER_SEARCH_IN_PULL_ID="Pull ID" COM_PATCHTESTER_SEARCH_IN_TITLE="Pull title" COM_PATCHTESTER_SORT="Sort:" - -;messages -COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the repository is missing" -COM_PATCHTESTER_CONFLICT_S="The patch could not be applied because it conflicts with a previously applied patch: %s" -COM_PATCHTESTER_FILE_DELETED_DOES_NOT_EXIST_S="The file marked for deletion does not exist: %s" -COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S="The file marked for modification does not exist: %s" -COM_PATCHTESTER_API_LIMIT_ACTION="The GitHub API rate limit has been reached for this resource, could not connect to GitHub to perform the requested action. The rate limit will reset at %s" -COM_PATCHTESTER_API_LIMIT_LIST="The GitHub API rate limit has been reached for this resource, could not connect to GitHub for updated data. The rate limit will reset at %s" -COM_PATCHTESTER_NO_CREDENTIALS="No user credentials are saved, this will allow only 60 requests to the GitHub API per hour. Saving user credentials will allow 5,000 requests per hour." - -COM_PATCHTESTER_OPEN_IN_GITHUB="Open in GitHub" -COM_PATCHTESTER_OPEN_IN_JOOMLACODE="Open in JoomlaCode" -COM_PATCHTESTER_APPLY_OK="Patch successfully applied" -COM_PATCHTESTER_REVERT_OK="Patch successfully reverted" +COM_PATCHTESTER_TEST_THIS_PATCH="Test This Patch" diff --git a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.sys.ini b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.sys.ini index d7f8009..d78dadf 100644 --- a/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.sys.ini +++ b/administrator/components/com_patchtester/language/en-GB/en-GB.com_patchtester.sys.ini @@ -1,3 +1,8 @@ -COM_PATCHTESTER="Patch Tester" +; Joomla! Project +; Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 Open Source Matters, Inc. All rights reserved. +; License GNU General Public License version 2 or later +; Note : All ini files need to be saved as UTF-8 + +COM_PATCHTESTER="Joomla! Patch Tester" COM_PATCHTESTER_XML_DESCRIPTION="Component for pull request management testing" diff --git a/administrator/components/com_patchtester/models/pull.php b/administrator/components/com_patchtester/models/pull.php index c6d4e72..199bfa1 100644 --- a/administrator/components/com_patchtester/models/pull.php +++ b/administrator/components/com_patchtester/models/pull.php @@ -1,8 +1,9 @@ action = 'modified'; + break; case 1: @@ -136,15 +152,27 @@ class PatchtesterModelPull extends JModelLegacy if (strpos($line, '@@') === 0) { - $state = 0; + $state = 0; $files[] = $file; } + break; } } + return $files; } + /** + * Patches the code with the supplied pull request + * + * @param integer $id ID of the pull request to apply + * + * @return boolean + * + * @since 1.0 + * @throws Exception + */ public function apply($id) { // Only act if there are API hits remaining @@ -181,8 +209,7 @@ class PatchtesterModelPull extends JModelLegacy throw new Exception(sprintf(JText::_('COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S'), $file->old)); } - $url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' . - $pull->head->ref . '/' . $file->new; + $url = 'https://raw.github.com/' . $pull->head->user->login . '/' . $pull->head->repo->name . '/' . $pull->head->ref . '/' . $file->new; $file->body = $this->transport->get($url)->body; } @@ -198,8 +225,9 @@ class PatchtesterModelPull extends JModelLegacy { if (!JFile::copy(JPath::clean(JPATH_ROOT . '/' . $file->old), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt')) { - throw new Exception(sprintf('Can not copy file %s to %s' - , JPATH_ROOT . '/' . $file->old, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt')); + throw new Exception( + sprintf('Can not copy file %s to %s', JPATH_ROOT . '/' . $file->old, JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt') + ); } } @@ -211,6 +239,7 @@ class PatchtesterModelPull extends JModelLegacy { throw new Exception(sprintf('Can not write the file: %s', JPATH_ROOT . '/' . $file->new)); } + break; case 'deleted': @@ -218,15 +247,16 @@ class PatchtesterModelPull extends JModelLegacy { throw new Exception(sprintf('Can not delete the file: %s', JPATH_ROOT . '/' . $file->old)); } + break; } } - $table = JTable::getInstance('tests', 'PatchTesterTable'); - $table->pull_id = $pull->number; - $table->data = json_encode($files); - $table->patched_by = JFactory::getUser()->id; - $table->applied = 1; + $table = JTable::getInstance('tests', 'PatchTesterTable'); + $table->pull_id = $pull->number; + $table->data = json_encode($files); + $table->patched_by = JFactory::getUser()->id; + $table->applied = 1; $table->applied_version = JVERSION; if (!$table->store()) @@ -242,6 +272,16 @@ class PatchtesterModelPull extends JModelLegacy return true; } + /** + * Reverts the specified pull request + * + * @param integer $id ID of the pull request to Reverts + * + * @return boolean + * + * @since 1.0 + * @throws Exception + */ public function revert($id) { $table = JTable::getInstance('tests', 'PatchTesterTable'); @@ -259,8 +299,7 @@ class PatchtesterModelPull extends JModelLegacy if (!$files) { - throw new Exception(sprintf(JText::_('%s - Error retrieving table data (%s)') - , __METHOD__, htmlentities($table->data))); + throw new Exception(sprintf(JText::_('%s - Error retrieving table data (%s)'), __METHOD__, htmlentities($table->data))); } jimport('joomla.filesystem.file'); @@ -271,32 +310,30 @@ class PatchtesterModelPull extends JModelLegacy { case 'deleted': case 'modified': - if (!JFile::copy( - JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt' - , JPATH_ROOT . '/' . $file->old) - ) + if (!JFile::copy(JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt', JPATH_ROOT . '/' . $file->old)) { - throw new Exception(sprintf( - JText::_('Can not copy file %s to %s') - , JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt' - , JPATH_ROOT . '/' . $file->old)); + throw new Exception( + sprintf( + JText::_('Can not copy file %s to %s'), + JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt', + JPATH_ROOT . '/' . $file->old + ) + ); } if (!JFile::delete(JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt')) { - throw new Exception(sprintf( - JText::_('Can not delete the file: %s') - , JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt')); + throw new Exception(sprintf(JText::_('Can not delete the file: %s'), JPATH_COMPONENT . '/backups/' . md5($file->old) . '.txt')); } + break; case 'added': if (!JFile::delete(JPath::clean(JPATH_ROOT . '/' . $file->new))) { - throw new Exception(sprintf( - JText::_('Can not delete the file: %s') - , JPATH_ROOT . '/' . $file->new)); + throw new Exception(sprintf(JText::_('Can not delete the file: %s'), JPATH_ROOT . '/' . $file->new)); } + break; } } @@ -305,5 +342,4 @@ class PatchtesterModelPull extends JModelLegacy return true; } - } diff --git a/administrator/components/com_patchtester/models/pulls.php b/administrator/components/com_patchtester/models/pulls.php index 2951193..52c56d6 100644 --- a/administrator/components/com_patchtester/models/pulls.php +++ b/administrator/components/com_patchtester/models/pulls.php @@ -1,32 +1,34 @@ getUserStateFromRequest($this->context . '.filter.searchid', 'filter_searchid'); $this->setState('filter.searchid', $searchId); - // Load the parameters. - $params = JComponentHelper::getParams('com_patchtester'); + // 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')); + $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('number', 'desc'); + // List state information. + parent::populateState('number', 'desc'); - // GitHub's default list limit is 30 - $this->setState('list.limit', 30); + // GitHub's default list limit is 30 + $this->setState('list.limit', 30); } + /** + * Retrieves a list of applied patches + * + * @return mixed + * + * @since 1.0 + */ public function getAppliedPatches() { - $query = $this->_db->getQuery(true); - $query->select('*'); - $query->from('#__patchtester_tests'); - $query->where('applied = 1'); + $db = $this->getDbo(); + $query = $db->getQuery(true) + ->select('*') + ->from('#__patchtester_tests') + ->where('applied = 1'); - $this->_db->setQuery($query); - $tests = $this->_db->loadObjectList('pull_id'); - return $tests; + $db->setQuery($query); + + try + { + $tests = $db->loadObjectList('pull_id'); + + return $tests; + } + catch (RuntimeException $e) + { + $this->setError($e->getMessage()); + + return false; + } } + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + * + * @since 1.0 + */ public function getItems() { if ($this->getState('github_user') == '' || $this->getState('github_repo') == '') @@ -133,10 +164,10 @@ class PatchtesterModelPulls extends JModelList $this->ordering = $this->getState('list.ordering', 'title'); $this->orderDir = $this->getState('list.direction', 'asc'); - $search = $this->getState('filter.search'); - $searchId = $this->getState('filter.searchid'); + $search = $this->getState('filter.search'); + $searchId = $this->getState('filter.searchid'); - $page = $this->getPagination()->pagesCurrent; + $page = $this->getPagination()->pagesCurrent; try { @@ -161,7 +192,7 @@ class PatchtesterModelPulls extends JModelList continue; } - // Try to find a joomlacode issue number + // Try to find a Joomlacode issue number $pulls[$i]->joomlacode_issue = 0; $matches = array(); @@ -203,6 +234,16 @@ class PatchtesterModelPulls extends JModelList } } + /** + * Method to sort the items array + * + * @param object $a First sort object + * @param object $b Second sort object + * + * @return mixed + * + * @since 1.0 + */ public function sortItems($a, $b) { switch ($this->ordering) @@ -216,15 +257,22 @@ class PatchtesterModelPulls extends JModelList } } - public function getTotal() - { - if ($this->rate->remaining > 0) - { - return $this->github->repos->get('joomla', 'joomla-cms')->open_issues_count; - } - else - { - return 0; - } - } + /** + * Method to get the total number of items for the data set. + * + * @return integer The total number of items available in the data set. + * + * @since 2.0 + */ + public function getTotal() + { + if ($this->rate->remaining > 0) + { + return $this->github->repos->get('joomla', 'joomla-cms')->open_issues_count; + } + else + { + return 0; + } + } } diff --git a/administrator/components/com_patchtester/patchtester.php b/administrator/components/com_patchtester/patchtester.php index a680084..0961722 100644 --- a/administrator/components/com_patchtester/patchtester.php +++ b/administrator/components/com_patchtester/patchtester.php @@ -1,12 +1,11 @@ authorise('core.manage', 'com_patchtester')) return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } -JLoader::registerPrefix('PT', __DIR__.'/helpers'); +JLoader::registerPrefix('PT', __DIR__ . '/helpers'); $controller = JControllerLegacy::getInstance('PatchTester'); $controller->execute(JFactory::getApplication()->input->getCmd('task')); diff --git a/administrator/components/com_patchtester/patchtester.xml b/administrator/components/com_patchtester/patchtester.xml index d733f89..1506258 100644 --- a/administrator/components/com_patchtester/patchtester.xml +++ b/administrator/components/com_patchtester/patchtester.xml @@ -3,11 +3,11 @@ com_patchtester Ian MacLennan October 2011 - (C) 2011 Ian MacLennan. All rights reserved. - GNU General Public License version 2 or later; see LICENSE.txt + (C) 2011 - 2012 Ian MacLennan, (C) 2013 Open Source Matters, Inc. All rights reserved. + GNU General Public License version 2 or later ianlenmac@gmail.com http://github.com/ianmacl - 1.5.0.alpha + 2.0.0.alpha COM_PATCHTESTER_XML_DESCRIPTION diff --git a/administrator/components/com_patchtester/tables/tests.php b/administrator/components/com_patchtester/tables/tests.php index f9cc080..be99283 100644 --- a/administrator/components/com_patchtester/tables/tests.php +++ b/administrator/components/com_patchtester/tables/tests.php @@ -1,24 +1,27 @@ escape($this->state->get('list.ordering')); -$listDirn = $this->escape($this->state->get('list.direction')); +$listDirn = $this->escape($this->state->get('list.direction')); ?> -
+ -
- - -
+
+ + +
- +
+ +
+ + + +
+ + - - - + + + loadTemplate('items'); ?>
- -
- -
- -
- -
I @@ -61,25 +58,24 @@ $listDirn = $this->escape($this->state->get('list.direction'));
-
+
-
+
- pagination->getListFooter(); ?> -
-
- - - - - - + pagination->getListFooter(); ?>
+ + + + + + + diff --git a/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php b/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php index d54af3b..b3ce9c6 100644 --- a/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php +++ b/administrator/components/com_patchtester/views/pulls/tmpl/default_items.php @@ -1,83 +1,70 @@ items as $i => $item) : - $status = ''; - if(isset($this->patches[$item->number])) : - $patch = $this->patches[$item->number]; - $status = ($patch->applied) ? 'success' : ''; - else : - $patch = false; - endif; - ?> - - - number; ?> - - - - title; ?> - - - - body) : - echo JHtml::_('tooltip', htmlspecialchars($item->body), 'Info'); - else : - echo ' '; - endif; - ?> - - - joomlacode_issue) - { - $title = ' title="Open link::'.JText::_('COM_PATCHTESTER_OPEN_IN_JOOMLACODE').'"'; +foreach ($this->items as $i => $item) : + $status = ''; - if(is_int($item->joomlacode_issue)) - { - echo ''; - echo '[#'.$item->joomlacode_issue.']'; - } - else - { - echo ''; - echo '[#joomlacode]'; - } - } - ?> - - - applied) : - echo '
'; - echo JText::_('COM_PATCHTESTER_APPLIED'); - echo '
'; - else : - echo JText::_('COM_PATCHTESTER_NOT_APPLIED'); - endif; - ?> - - - applied) : - echo ''.JText::_('COM_PATCHTESTER_REVERT_PATCH').''; - else : - echo ''.JText::_('COM_PATCHTESTER_APPLY_PATCH').''; - endif; - ?> - + if (isset($this->patches[$item->number])) : + $patch = $this->patches[$item->number]; + $status = ($patch->applied) ? 'success' : ''; + else : + $patch = false; + endif; +?> + + + number; ?> + + + + title; ?> + + + + body) : + echo JHtml::_('tooltip', htmlspecialchars($item->body), 'Info'); + else : + echo ' '; + endif; + ?> + + + joomlacode_issue) : + $title = ' title="Open link::' . JText::_('COM_PATCHTESTER_OPEN_IN_JOOMLACODE') . '"'; + + if (is_int($item->joomlacode_issue)) : + echo ''; + echo '[#' . $item->joomlacode_issue . ']'; + else : + echo ''; + echo '[#joomlacode]'; + endif; + endif; ?> + + + applied) : + echo '
'; + echo JText::_('COM_PATCHTESTER_APPLIED'); + echo '
'; + else : + echo JText::_('COM_PATCHTESTER_NOT_APPLIED'); + endif; ?> + + + applied) : + echo '' . JText::_('COM_PATCHTESTER_REVERT_PATCH') . ''; + else : + echo '' . JText::_('COM_PATCHTESTER_APPLY_PATCH') . ''; + endif; ?> + enqueueMessage( - 'Your system does not meet the requirements to run the PullTester extension:' - , 'error'); + $application->enqueueMessage('Your system does not meet the requirements to run the PullTester extension:', 'error'); foreach ($checkErrs as $error) { @@ -51,33 +87,36 @@ class PatchtesterViewPulls extends JViewLegacy return $this; } - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->patches = $this->get('AppliedPatches'); - $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->items = $this->get('Items'); + $this->patches = $this->get('AppliedPatches'); + $this->pagination = $this->get('Pagination'); // Check for errors. - $errors = $this->get('Errors'); + $errors = $this->get('Errors'); if (count($errors)) { - var_dump($errors); - var_dump($this->pagination); -// JError::raiseError(500, implode("\n", $errors)); -// return false; + JError::raiseError(500, implode("\n", $errors)); + + return false; } $this->addToolbar(); - parent::display($tpl); + return parent::display($tpl); } /** * Add the page title and toolbar. + * + * @return void + * + * @since 1.0 */ protected function addToolbar() { - JToolBarHelper::title('Joomla! Patch Tester', 'patchtester'); + JToolBarHelper::title(JText::_('COM_PATCHTESTER'), 'patchtester'); JToolBarHelper::preferences('com_patchtester'); JFactory::getDocument()->addStyleDeclaration(