mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-11-15 17:47:10 +00:00
Reformat to Joomla CS
This commit is contained in:
parent
8ff29492fe
commit
b8170b3993
@ -1,35 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* PatchTester Controller
|
||||
*
|
||||
* @package PatchTester
|
||||
* @since 1.0
|
||||
*/
|
||||
class PatchTesterController extends JControllerLegacy
|
||||
{
|
||||
protected $default_view = 'Pulls';
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
* The default view for the display method.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
|
||||
*
|
||||
* @return JController This object to support chaining.
|
||||
* @since 1.5
|
||||
* @var string
|
||||
* @since 1.0
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = false)
|
||||
{
|
||||
parent::display();
|
||||
|
||||
return $this;
|
||||
}
|
||||
protected $default_view = 'pulls';
|
||||
}
|
||||
|
@ -1,26 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Pull controller class
|
||||
*
|
||||
* @package PatchTester
|
||||
* @since 1.0
|
||||
*/
|
||||
class PatchtesterControllerPull extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* Method to apply a patch
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->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');
|
||||
$type = 'message';
|
||||
@ -34,12 +41,18 @@ class PatchtesterControllerPull extends JControllerLegacy
|
||||
$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');
|
||||
$type = 'message';
|
||||
@ -52,5 +65,4 @@ class PatchtesterControllerPull extends JControllerLegacy
|
||||
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_patchtester&view=pulls', false), $msg, $type);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* User: elkuku
|
||||
* Date: 08.09.12
|
||||
* Time: 19:08
|
||||
* @package PatchTester
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Extended JGithub class allowing additional JGithubObject instances to be used
|
||||
*
|
||||
* @property-read PTGithubRepos $repos GitHub API object for repos.
|
||||
*
|
||||
* @package PatchTester
|
||||
* @since 2.0
|
||||
*/
|
||||
class PTGithub extends JGithub
|
||||
{
|
||||
/**
|
||||
* @var PTGithubRepos
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $repos;
|
||||
|
||||
/**
|
||||
* 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')
|
||||
|
@ -1,58 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* User: elkuku
|
||||
* Date: 08.09.12
|
||||
* Time: 18:54
|
||||
* @package PatchTester
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* A.
|
||||
* GitHub API Repos class.
|
||||
*
|
||||
* @package PatchTester
|
||||
* @since 2.0
|
||||
*/
|
||||
class PTGithubRepos extends JGithubObject
|
||||
{
|
||||
/**
|
||||
* Retrieve information about the specified repository
|
||||
*
|
||||
* @param string $user The username or organization name of the repository owner
|
||||
* @param string $repo The repository to retrieve
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @since 2.0
|
||||
* @throws DomainException
|
||||
*/
|
||||
public function get($user, $repo)
|
||||
{
|
||||
$path = '/repos/'.$user.'/'.$repo;
|
||||
$path = '/repos/' . $user . '/' . $repo;
|
||||
|
||||
// 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);
|
||||
return $this->processResponse($this->client->get($this->fetchUrl($path)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* List public repositories for the specified user.
|
||||
*
|
||||
* @return mixed
|
||||
* @param string $user The username to retrieve repositories for
|
||||
*
|
||||
* @return object
|
||||
*
|
||||
* @since 2.0
|
||||
* @throws DomainException
|
||||
*/
|
||||
public function getPublicRepos($user, $type = 'all', $sort = 'full_name', $direction = 'desc')
|
||||
public function getPublicRepos($user)
|
||||
{
|
||||
$path = '/users/'.$user.'/repos';
|
||||
$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);
|
||||
return $this->processResponse($this->client->get($this->fetchUrl($path)));
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
@ -11,11 +12,13 @@ defined('_JEXEC') or die;
|
||||
* Methods supporting pull requests.
|
||||
*
|
||||
* @package PatchTester
|
||||
* @since 1.0
|
||||
*/
|
||||
class PatchtesterModelPull extends JModelLegacy
|
||||
{
|
||||
/**
|
||||
* @var JHttp
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $transport;
|
||||
|
||||
@ -23,6 +26,7 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
* Github object
|
||||
*
|
||||
* @var PTGithub
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $github;
|
||||
|
||||
@ -30,6 +34,7 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
* Object containing the rate limit data
|
||||
*
|
||||
* @var object
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $rate;
|
||||
|
||||
@ -38,8 +43,7 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
*
|
||||
* @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request).
|
||||
*
|
||||
* @since 12.2
|
||||
* @throws Exception
|
||||
* @since 2.0
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
@ -73,9 +77,10 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
* @note Calling getState() in this method will result in recursion.
|
||||
* @since 1.0
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
@ -88,6 +93,15 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
parent::populateState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to parse a patch and extract the affected files
|
||||
*
|
||||
* @param string $patch Patch file to parse
|
||||
*
|
||||
* @return array Array of files within a patch
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
protected function parsePatch($patch)
|
||||
{
|
||||
$state = 0;
|
||||
@ -104,8 +118,10 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
|
||||
$file = new stdClass;
|
||||
$file->action = 'modified';
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@ -139,12 +155,24 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
$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,6 +247,7 @@ class PatchtesterModelPull extends JModelLegacy
|
||||
{
|
||||
throw new Exception(sprintf('Can not delete the file: %s', JPATH_ROOT . '/' . $file->old));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
jimport('joomla.application.component.modellist');
|
||||
|
||||
/**
|
||||
* Methods supporting a list of pull request.
|
||||
* Methods supporting a list of pull requests.
|
||||
*
|
||||
* @package PatchTester
|
||||
* @since 1.0
|
||||
*/
|
||||
class PatchtesterModelPulls extends JModelList
|
||||
{
|
||||
@ -20,6 +20,7 @@ class PatchtesterModelPulls extends JModelList
|
||||
* Github object
|
||||
*
|
||||
* @var PTGithub
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $github;
|
||||
|
||||
@ -27,6 +28,7 @@ class PatchtesterModelPulls extends JModelList
|
||||
* Object containing the rate limit data
|
||||
*
|
||||
* @var object
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $rate;
|
||||
|
||||
@ -36,7 +38,7 @@ class PatchtesterModelPulls extends JModelList
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
*
|
||||
* @see JController
|
||||
* @since 11.1
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
@ -81,13 +83,16 @@ class PatchtesterModelPulls extends JModelList
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @since 1.6
|
||||
* @return void
|
||||
*
|
||||
* @note Calling getState() in this method will result in recursion.
|
||||
* @since 1.0
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
@ -112,18 +117,44 @@ class PatchtesterModelPulls extends JModelList
|
||||
$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');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$tests = $db->loadObjectList('pull_id');
|
||||
|
||||
$this->_db->setQuery($query);
|
||||
$tests = $this->_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') == '')
|
||||
@ -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,6 +257,13 @@ class PatchtesterModelPulls extends JModelList
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Access check.
|
||||
@ -15,7 +14,7 @@ if (!JFactory::getUser()->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'));
|
||||
|
@ -3,11 +3,11 @@
|
||||
<name>com_patchtester</name>
|
||||
<author>Ian MacLennan</author>
|
||||
<creationDate>October 2011</creationDate>
|
||||
<copyright>(C) 2011 Ian MacLennan. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<copyright>(C) 2011 - 2012 Ian MacLennan, (C) 2013 Open Source Matters, Inc. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later</license>
|
||||
<authorEmail>ianlenmac@gmail.com</authorEmail>
|
||||
<authorUrl>http://github.com/ianmacl</authorUrl>
|
||||
<version>1.5.0.alpha</version>
|
||||
<version>2.0.0.alpha</version>
|
||||
<description>COM_PATCHTESTER_XML_DESCRIPTION</description>
|
||||
<install>
|
||||
<sql>
|
||||
|
@ -1,24 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Tests Table class
|
||||
*
|
||||
* @package PatchTester
|
||||
* @since 1.0
|
||||
*/
|
||||
class PatchtesterTableTests extends JTable
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param JDatabase $db A database connector object
|
||||
* @param JDatabaseDriver &$db JDatabaseDriver object.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct(&$db)
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::_('behavior.tooltip');
|
||||
@ -22,8 +22,7 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
}
|
||||
</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">
|
||||
|
||||
<div>
|
||||
<button type="submit" class="btn"><?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
|
||||
@ -39,14 +38,12 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
<th width="8%">
|
||||
<?php echo JHtml::_('grid.sort', 'COM_PATCHTESTER_PULL_ID', 'number', $listDirn, $listOrder); ?>
|
||||
<br />
|
||||
<input type="text" name="filter_searchid" id="filter_searchid" class="span10"
|
||||
value="<?php echo $this->escape($this->state->get('filter.searchid')); ?>" />
|
||||
<input type="text" name="filter_searchid" id="filter_searchid" class="span10" value="<?php echo $this->escape($this->state->get('filter.searchid')); ?>" />
|
||||
</th>
|
||||
<th class="title">
|
||||
<?php echo JHtml::_('grid.sort', 'JGLOBAL_TITLE', 'title', $listDirn, $listOrder); ?>
|
||||
<br />
|
||||
<input type="text" name="filter_search" id="filter_search"
|
||||
value="<?php echo $this->escape($this->state->get('filter.search')); ?>" />
|
||||
<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" />
|
||||
</th>
|
||||
<th>I</th>
|
||||
<th class="title">
|
||||
@ -74,12 +71,11 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<input type="hidden" name="task" value=""/>
|
||||
<input type="hidden" name="boxchecked" value="0"/>
|
||||
<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'); ?>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -1,37 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
foreach($this->items as $i => $item) :
|
||||
foreach ($this->items as $i => $item) :
|
||||
$status = '';
|
||||
if(isset($this->patches[$item->number])) :
|
||||
|
||||
if (isset($this->patches[$item->number])) :
|
||||
$patch = $this->patches[$item->number];
|
||||
$status = ($patch->applied) ? 'success' : '';
|
||||
else :
|
||||
$patch = false;
|
||||
endif;
|
||||
?>
|
||||
<tr class="<?= $status ?>">
|
||||
?>
|
||||
<tr class="<?php echo $status ?>">
|
||||
<td class="center">
|
||||
<?php echo $item->number; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a class="icon icon16-github hasTip"
|
||||
title="<?php echo JText::_('COM_PATCHTESTER_OPEN_IN_GITHUB'); ?>"
|
||||
href="<?php echo $item->html_url; ?>"
|
||||
target="_blank">
|
||||
<a class="icon icon16-github hasTip" title="<?php echo JText::_('COM_PATCHTESTER_OPEN_IN_GITHUB'); ?>" href="<?php echo $item->html_url; ?>" target="_blank">
|
||||
<?php echo $item->title; ?>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if($item->body) :
|
||||
<?php if ($item->body) :
|
||||
echo JHtml::_('tooltip', htmlspecialchars($item->body), 'Info');
|
||||
else :
|
||||
echo ' ';
|
||||
@ -39,45 +36,35 @@ foreach($this->items as $i => $item) :
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if($item->joomlacode_issue)
|
||||
{
|
||||
$title = ' title="Open link::'.JText::_('COM_PATCHTESTER_OPEN_IN_JOOMLACODE').'"';
|
||||
<?php if ($item->joomlacode_issue) :
|
||||
$title = ' title="Open link::' . JText::_('COM_PATCHTESTER_OPEN_IN_JOOMLACODE') . '"';
|
||||
|
||||
if(is_int($item->joomlacode_issue))
|
||||
{
|
||||
if (is_int($item->joomlacode_issue)) :
|
||||
echo '<a href="http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=';
|
||||
echo $item->joomlacode_issue.'"'.$title.' class="modal hasTip" rel="{handler: \'iframe\', size: {x: 900, y: 500}}">';
|
||||
echo '[#'.$item->joomlacode_issue.']</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a href="'.$item->joomlacode_issue.'"'.$title;
|
||||
echo $item->joomlacode_issue . '"' . $title . ' class="modal hasTip" rel="{handler: \'iframe\', size: {x: 900, y: 500}}">';
|
||||
echo '[#' . $item->joomlacode_issue . ']</a>';
|
||||
else :
|
||||
echo '<a href="' . $item->joomlacode_issue . '"' . $title;
|
||||
echo ' class="modal hasTip" rel="{handler: \'iframe\', size: {x: 900, y: 500}}">';
|
||||
echo '[#joomlacode]</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
endif;
|
||||
endif; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php
|
||||
if($patch && $patch->applied) :
|
||||
<?php if ($patch && $patch->applied) :
|
||||
echo '<div class="patchApplied" style="background-color: #adff2f;">';
|
||||
echo JText::_('COM_PATCHTESTER_APPLIED');
|
||||
echo '</div>';
|
||||
else :
|
||||
echo JText::_('COM_PATCHTESTER_NOT_APPLIED');
|
||||
endif;
|
||||
?>
|
||||
endif; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php
|
||||
if($patch && $patch->applied) :
|
||||
echo '<a href="javascript:submitpatch(\'pull.revert\', '.(int)$patch->id.');">'.JText::_('COM_PATCHTESTER_REVERT_PATCH').'</a>';
|
||||
<?php if ($patch && $patch->applied) :
|
||||
echo '<a href="javascript:submitpatch(\'pull.revert\', ' . (int) $patch->id . ');">' . JText::_('COM_PATCHTESTER_REVERT_PATCH') . '</a>';
|
||||
else :
|
||||
echo '<a href="javascript:submitpatch(\'pull.apply\', '.(int)$item->number.');">'.JText::_('COM_PATCHTESTER_APPLY_PATCH').'</a>';
|
||||
endif;
|
||||
?>
|
||||
echo '<a href="javascript:submitpatch(\'pull.apply\', ' . (int) $item->number . ');">' . JText::_('COM_PATCHTESTER_APPLY_PATCH') . '</a>';
|
||||
endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;
|
||||
|
@ -1,47 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
* @copyright Copyright (C) 2011 Ian MacLennan, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*
|
||||
* @copyright 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
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
jimport('joomla.application.component.view');
|
||||
|
||||
/**
|
||||
* View class for a list of pull requests.
|
||||
*
|
||||
* @package PatchTester
|
||||
* @since 1.0
|
||||
*/
|
||||
class PatchtesterViewPulls extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* Array of open pull requests
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* Object containing data about applied patches
|
||||
*
|
||||
* @var object
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $patches;
|
||||
|
||||
/**
|
||||
* State object
|
||||
*
|
||||
* @var JRegistry
|
||||
* @since 1.0
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Pagination object
|
||||
*
|
||||
* @var JPagination
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return mixed A string if successful, otherwise a Error object.
|
||||
*
|
||||
* @see fetch()
|
||||
* @since 1.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
//@TODO: move the check
|
||||
// TODO: move the check
|
||||
$checkErrs = array();
|
||||
|
||||
if(false == extension_loaded ('openssl'))
|
||||
if (!extension_loaded('openssl'))
|
||||
{
|
||||
$checkErrs[] = 'The OpenSSL extension must be installed and enabled in your php.ini';
|
||||
}
|
||||
|
||||
if(false == in_array('https', stream_get_wrappers()))
|
||||
if (!in_array('https', stream_get_wrappers()))
|
||||
{
|
||||
$checkErrs[] = 'https wrappers must be enabled';
|
||||
}
|
||||
|
||||
if (count($checkErrs))
|
||||
{
|
||||
$application = JFactory::getApplication();
|
||||
|
||||
$application->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)
|
||||
{
|
||||
@ -61,23 +97,26 @@ class PatchtesterViewPulls extends JViewLegacy
|
||||
|
||||
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(
|
||||
|
Loading…
Reference in New Issue
Block a user