31
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-06-04 22:50:46 +00:00

Bump to 3.8 minimum, use namespaced classes

This commit is contained in:
Michael Babker 2017-08-17 18:22:01 -05:00
parent e9c99d9a1c
commit 4d5475bc18
18 changed files with 119 additions and 89 deletions

View File

@ -9,6 +9,8 @@
namespace PatchTester\Controller; namespace PatchTester\Controller;
use Joomla\Application\AbstractApplication; use Joomla\Application\AbstractApplication;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
/** /**
@ -16,7 +18,7 @@ use Joomla\Registry\Registry;
* *
* @since 2.0 * @since 2.0
* *
* @method \JApplicationCms getApplication() getApplication() Get the application object. * @method CMSApplication getApplication() getApplication() Get the application object.
*/ */
abstract class AbstractController extends \JControllerBase abstract class AbstractController extends \JControllerBase
{ {
@ -66,7 +68,7 @@ abstract class AbstractController extends \JControllerBase
$state = new Registry; $state = new Registry;
// Load the parameters. // Load the parameters.
$params = \JComponentHelper::getParams('com_patchtester'); $params = ComponentHelper::getParams('com_patchtester');
$state->set('github_user', $params->get('org', 'joomla')); $state->set('github_user', $params->get('org', 'joomla'));
$state->set('github_repo', $params->get('repo', 'joomla-cms')); $state->set('github_repo', $params->get('repo', 'joomla-cms'));

View File

@ -8,6 +8,7 @@
namespace PatchTester\Controller; namespace PatchTester\Controller;
use Joomla\CMS\Factory;
use PatchTester\Model\PullModel; use PatchTester\Model\PullModel;
/** /**
@ -28,7 +29,7 @@ class ApplyController extends AbstractController
{ {
try try
{ {
$model = new PullModel(null, \JFactory::getDbo()); $model = new PullModel(null, Factory::getDbo());
// Initialize the state for the model // Initialize the state for the model
$model->setState($this->initializeState($model)); $model->setState($this->initializeState($model));

View File

@ -8,6 +8,7 @@
namespace PatchTester\Controller; namespace PatchTester\Controller;
use Joomla\CMS\Factory;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
/** /**
@ -68,17 +69,17 @@ class DisplayController extends AbstractController
if (!class_exists($viewClass)) if (!class_exists($viewClass))
{ {
throw new \RuntimeException(JText::sprintf('COM_PATCHTESTER_ERROR_VIEW_NOT_FOUND', $view, $format), 500); throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_ERROR_VIEW_NOT_FOUND', $view, $format), 500);
} }
} }
if (!class_exists($modelClass)) if (!class_exists($modelClass))
{ {
throw new \RuntimeException(JText::sprintf('COM_PATCHTESTER_ERROR_MODEL_NOT_FOUND', $modelClass), 500); throw new \RuntimeException(\JText::sprintf('COM_PATCHTESTER_ERROR_MODEL_NOT_FOUND', $modelClass), 500);
} }
// Initialize the model class now; need to do it before setting the state to get required data from it // Initialize the model class now; need to do it before setting the state to get required data from it
$model = new $modelClass($this->context, null, \JFactory::getDbo()); $model = new $modelClass($this->context, null, Factory::getDbo());
// Initialize the state for the model // Initialize the state for the model
$model->setState($this->initializeState($model)); $model->setState($this->initializeState($model));

View File

@ -8,6 +8,8 @@
namespace PatchTester\Controller; namespace PatchTester\Controller;
use Joomla\CMS\Factory;
use Joomla\CMS\Response\JsonResponse;
use PatchTester\Model\PullsModel; use PatchTester\Model\PullsModel;
/** /**
@ -33,14 +35,14 @@ class FetchController extends AbstractController
$this->getApplication()->setHeader('Pragma', 'no-cache'); $this->getApplication()->setHeader('Pragma', 'no-cache');
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet); $this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
$session = \JFactory::getSession(); $session = Factory::getSession();
try try
{ {
// Fetch our page from the session // Fetch our page from the session
$page = $session->get('com_patchtester_fetcher_page', 1); $page = $session->get('com_patchtester_fetcher_page', 1);
$model = new PullsModel('com_patchtester.fetch', null, \JFactory::getDbo()); $model = new PullsModel('com_patchtester.fetch', null, Factory::getDbo());
// Initialize the state for the model // Initialize the state for the model
$model->setState($this->initializeState($model)); $model->setState($this->initializeState($model));
@ -49,7 +51,7 @@ class FetchController extends AbstractController
} }
catch (\Exception $e) catch (\Exception $e)
{ {
$response = new \JResponseJson($e); $response = new JsonResponse($e);
$this->getApplication()->sendHeaders(); $this->getApplication()->sendHeaders();
echo json_encode($response); echo json_encode($response);
@ -87,7 +89,7 @@ class FetchController extends AbstractController
} }
} }
$response = new \JResponseJson($status, $message, false, true); $response = new JsonResponse($status, $message, false, true);
$this->getApplication()->sendHeaders(); $this->getApplication()->sendHeaders();
echo json_encode($response); echo json_encode($response);

View File

@ -8,6 +8,7 @@
namespace PatchTester\Controller; namespace PatchTester\Controller;
use Joomla\CMS\Factory;
use PatchTester\Model\PullModel; use PatchTester\Model\PullModel;
use PatchTester\Model\PullsModel; use PatchTester\Model\PullsModel;
use PatchTester\Model\TestsModel; use PatchTester\Model\TestsModel;
@ -32,9 +33,9 @@ class ResetController extends AbstractController
{ {
$hasErrors = false; $hasErrors = false;
$pullModel = new PullModel(null, \JFactory::getDbo()); $pullModel = new PullModel(null, Factory::getDbo());
$pullsModel = new PullsModel($this->context, null, \JFactory::getDbo()); $pullsModel = new PullsModel($this->context, null, Factory::getDbo());
$testsModel = new TestsModel(null, \JFactory::getDbo()); $testsModel = new TestsModel(null, Factory::getDbo());
// Check the applied patches in the database first // Check the applied patches in the database first
$appliedPatches = $testsModel->getAppliedPatches(); $appliedPatches = $testsModel->getAppliedPatches();
@ -113,7 +114,7 @@ class ResetController extends AbstractController
if ($hasErrors) if ($hasErrors)
{ {
$msg = \JText::sprintf( $msg = \JText::sprintf(
'COM_PATCHTESTER_RESET_HAS_ERRORS', JPATH_COMPONENT . '/backups', \JFactory::getDbo()->replacePrefix('#__patchtester_tests') 'COM_PATCHTESTER_RESET_HAS_ERRORS', JPATH_COMPONENT . '/backups', Factory::getDbo()->replacePrefix('#__patchtester_tests')
); );
$type = 'warning'; $type = 'warning';
} }

View File

@ -8,6 +8,7 @@
namespace PatchTester\Controller; namespace PatchTester\Controller;
use Joomla\CMS\Factory;
use PatchTester\Model\PullModel; use PatchTester\Model\PullModel;
/** /**
@ -28,7 +29,7 @@ class RevertController extends AbstractController
{ {
try try
{ {
$model = new PullModel(null, \JFactory::getDbo()); $model = new PullModel(null, Factory::getDbo());
// Initialize the state for the model // Initialize the state for the model
$model->setState($this->initializeState($model)); $model->setState($this->initializeState($model));

View File

@ -8,9 +8,10 @@
namespace PatchTester\Controller; namespace PatchTester\Controller;
use PatchTester\GitHub\Exception\UnexpectedResponse; use Joomla\CMS\Factory;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Session\Session;
use PatchTester\Helper; use PatchTester\Helper;
use PatchTester\Model\PullsModel;
use PatchTester\Model\TestsModel; use PatchTester\Model\TestsModel;
/** /**
@ -37,9 +38,9 @@ class StartfetchController extends AbstractController
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet); $this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
// Check for a valid token. If invalid, send a 403 with the error message. // Check for a valid token. If invalid, send a 403 with the error message.
if (!\JSession::checkToken('request')) if (!Session::checkToken('request'))
{ {
$response = new \JResponseJson(new \Exception(\JText::_('JINVALID_TOKEN'), 403)); $response = new JsonResponse(new \Exception(\JText::_('JINVALID_TOKEN'), 403));
$this->getApplication()->sendHeaders(); $this->getApplication()->sendHeaders();
echo json_encode($response); echo json_encode($response);
@ -55,7 +56,7 @@ class StartfetchController extends AbstractController
} }
catch (\Exception $e) catch (\Exception $e)
{ {
$response = new \JResponseJson( $response = new JsonResponse(
new \Exception( new \Exception(
\JText::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage()), \JText::sprintf('COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB', $e->getMessage()),
$e->getCode(), $e->getCode(),
@ -72,9 +73,9 @@ class StartfetchController extends AbstractController
// If over the API limit, we can't build this list // If over the API limit, we can't build this list
if ($rate->resources->core->remaining < 10) if ($rate->resources->core->remaining < 10)
{ {
$response = new \JResponseJson( $response = new JsonResponse(
new \Exception( new \Exception(
\JText::sprintf('COM_PATCHTESTER_API_LIMIT_LIST', \JFactory::getDate($rate->resources->core->reset)), \JText::sprintf('COM_PATCHTESTER_API_LIMIT_LIST', Factory::getDate($rate->resources->core->reset)),
429 429
) )
); );
@ -85,14 +86,14 @@ class StartfetchController extends AbstractController
$this->getApplication()->close(1); $this->getApplication()->close(1);
} }
$testsModel = new TestsModel(null, \JFactory::getDbo()); $testsModel = new TestsModel(null, Factory::getDbo());
try try
{ {
// Sanity check, ensure there aren't any applied patches // Sanity check, ensure there aren't any applied patches
if (count($testsModel->getAppliedPatches()) >= 1) if (count($testsModel->getAppliedPatches()) >= 1)
{ {
$response = new \JResponseJson(new \Exception(\JText::_('COM_PATCHTESTER_ERROR_APPLIED_PATCHES'), 500)); $response = new JsonResponse(new \Exception(\JText::_('COM_PATCHTESTER_ERROR_APPLIED_PATCHES'), 500));
$this->getApplication()->sendHeaders(); $this->getApplication()->sendHeaders();
echo json_encode($response); echo json_encode($response);
@ -102,7 +103,7 @@ class StartfetchController extends AbstractController
} }
catch (\Exception $e) catch (\Exception $e)
{ {
$response = new \JResponseJson($e); $response = new JsonResponse($e);
$this->getApplication()->sendHeaders(); $this->getApplication()->sendHeaders();
echo json_encode($response); echo json_encode($response);
@ -111,9 +112,9 @@ class StartfetchController extends AbstractController
} }
// We're able to successfully pull data, prepare our environment // We're able to successfully pull data, prepare our environment
\JFactory::getSession()->set('com_patchtester_fetcher_page', 1); Factory::getSession()->set('com_patchtester_fetcher_page', 1);
$response = new \JResponseJson( $response = new JsonResponse(
array('complete' => false, 'header' => \JText::_('COM_PATCHTESTER_FETCH_PROCESSING', true)), array('complete' => false, 'header' => \JText::_('COM_PATCHTESTER_FETCH_PROCESSING', true)),
\JText::sprintf('COM_PATCHTESTER_FETCH_PAGE_NUMBER', 1), \JText::sprintf('COM_PATCHTESTER_FETCH_PAGE_NUMBER', 1),
false, false,

View File

@ -8,6 +8,8 @@
namespace PatchTester\GitHub\Exception; namespace PatchTester\GitHub\Exception;
use Joomla\CMS\Http\Response;
/** /**
* Exception representing an unexpected response * Exception representing an unexpected response
* *
@ -18,7 +20,7 @@ class UnexpectedResponse extends \DomainException
/** /**
* The Response object. * The Response object.
* *
* @var \JHttpResponse * @var Response
* @since 3.0.0 * @since 3.0.0
*/ */
private $response; private $response;
@ -26,14 +28,14 @@ class UnexpectedResponse extends \DomainException
/** /**
* Constructor * Constructor
* *
* @param \JHttpResponse $response The Response object. * @param Response $response The Response object.
* @param string $message The Exception message to throw. * @param string $message The Exception message to throw.
* @param integer $code The Exception code. * @param integer $code The Exception code.
* @param \Exception $previous The previous exception used for the exception chaining. * @param \Exception $previous The previous exception used for the exception chaining.
* *
* @since 3.0.0 * @since 3.0.0
*/ */
public function __construct(\JHttpResponse $response, $message = '', $code = 0, \Exception $previous = null) public function __construct(Response $response, $message = '', $code = 0, \Exception $previous = null)
{ {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
@ -43,9 +45,9 @@ class UnexpectedResponse extends \DomainException
/** /**
* Get the Response object. * Get the Response object.
* *
* @return \JHttpResponse * @return Response
* *
* @since 3.0.0 * @since 3.0.0
*/ */
public function getResponse() public function getResponse()
{ {

View File

@ -8,6 +8,10 @@
namespace PatchTester\GitHub; namespace PatchTester\GitHub;
use Joomla\CMS\Http\Http;
use Joomla\CMS\Http\HttpFactory;
use Joomla\CMS\Http\Response;
use Joomla\CMS\Uri\Uri;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
/** /**
@ -28,7 +32,7 @@ class GitHub
/** /**
* The HTTP client object to use in sending HTTP requests. * The HTTP client object to use in sending HTTP requests.
* *
* @var \JHttp * @var Http
* @since 3.0.0 * @since 3.0.0
*/ */
protected $client; protected $client;
@ -37,14 +41,14 @@ class GitHub
* Constructor. * Constructor.
* *
* @param Registry $options Connector options. * @param Registry $options Connector options.
* @param \JHttp $client The HTTP client object. * @param Http $client The HTTP client object.
* *
* @since 3.0.0 * @since 3.0.0
*/ */
public function __construct(Registry $options = null, \JHttp $client = null) public function __construct(Registry $options = null, Http $client = null)
{ {
$this->options = $options ?: new Registry; $this->options = $options ?: new Registry;
$this->client = $client ?: \JHttpFactory::getHttp($options); $this->client = $client ?: HttpFactory::getHttp($options);
} }
/** /**
@ -63,8 +67,8 @@ class GitHub
*/ */
protected function fetchUrl($path, $page = 0, $limit = 0) protected function fetchUrl($path, $page = 0, $limit = 0)
{ {
// Get a new JUri object fousing the api url and given path. // Get a new Uri object using the API URL and given path.
$uri = new \JUri($this->options->get('api.url') . $path); $uri = new Uri($this->options->get('api.url') . $path);
// Only apply basic authentication if an access token is not set // Only apply basic authentication if an access token is not set
if ($this->options->get('gh.token', false) === false) if ($this->options->get('gh.token', false) === false)
@ -103,7 +107,7 @@ class GitHub
/** /**
* Get the HTTP client for this connector. * Get the HTTP client for this connector.
* *
* @return \JHttp * @return Http
* *
* @since 3.0.0 * @since 3.0.0
*/ */
@ -119,7 +123,7 @@ class GitHub
* @param string $repo The name of the GitHub repository. * @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number. * @param integer $pullId The pull request number.
* *
* @return \JHttpResponse * @return Response
* *
* @since 3.0.0 * @since 3.0.0
*/ */
@ -144,7 +148,7 @@ class GitHub
* @param string $path The content path. * @param string $path The content path.
* @param string $ref The name of the commit/branch/tag. Default: the repositorys default branch (usually master) * @param string $ref The name of the commit/branch/tag. Default: the repositorys default branch (usually master)
* *
* @return \JHttpResponse * @return Response
* *
* @since 3.0.0 * @since 3.0.0
*/ */
@ -156,7 +160,7 @@ class GitHub
if ($ref) if ($ref)
{ {
$url = new \JUri($prepared['url']); $url = new Uri($prepared['url']);
$url->setVar('ref', $ref); $url->setVar('ref', $ref);
$prepared['url'] = (string) $url; $prepared['url'] = (string) $url;
@ -172,7 +176,7 @@ class GitHub
* @param string $repo The name of the GitHub repository. * @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number. * @param integer $pullId The pull request number.
* *
* @return \JHttpResponse * @return Response
* *
* @since 3.0.0 * @since 3.0.0
*/ */
@ -194,7 +198,7 @@ class GitHub
* @param integer $page The page number from which to get items. * @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page. * @param integer $limit The number of items on a page.
* *
* @return \JHttpResponse * @return Response
* *
* @since 3.0.0 * @since 3.0.0
*/ */
@ -227,7 +231,7 @@ class GitHub
* @param string $repo The name of the GitHub repository. * @param string $repo The name of the GitHub repository.
* @param integer $pullId The pull request number. * @param integer $pullId The pull request number.
* *
* @return \JHttpResponse * @return Response
* *
* @since 3.0.0 * @since 3.0.0
*/ */
@ -244,7 +248,7 @@ class GitHub
/** /**
* Get the rate limit for the authenticated user. * Get the rate limit for the authenticated user.
* *
* @return \JHttpResponse * @return Response
* *
* @since 3.0.0 * @since 3.0.0
*/ */
@ -258,15 +262,15 @@ class GitHub
/** /**
* Process the response and return it. * Process the response and return it.
* *
* @param \JHttpResponse $response The response. * @param Response $response The response.
* @param integer $expectedCode The expected response code. * @param integer $expectedCode The expected response code.
* *
* @return \JHttpResponse * @return Response
* *
* @since 3.0.0 * @since 3.0.0
* @throws Exception\UnexpectedResponse * @throws Exception\UnexpectedResponse
*/ */
protected function processResponse(\JHttpResponse $response, $expectedCode = 200) protected function processResponse(Response $response, $expectedCode = 200)
{ {
// Validate the response code. // Validate the response code.
if ($response->code != $expectedCode) if ($response->code != $expectedCode)

View File

@ -8,6 +8,8 @@
namespace PatchTester; namespace PatchTester;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
use PatchTester\GitHub\GitHub; use PatchTester\GitHub\GitHub;
@ -27,7 +29,7 @@ abstract class Helper
*/ */
public static function initializeGithub() public static function initializeGithub()
{ {
$params = \JComponentHelper::getParams('com_patchtester'); $params = ComponentHelper::getParams('com_patchtester');
$options = new Registry; $options = new Registry;
@ -54,7 +56,7 @@ abstract class Helper
// Display a message about the lowered API limit without credentials // Display a message about the lowered API limit without credentials
else else
{ {
\JFactory::getApplication()->enqueueMessage(\JText::_('COM_PATCHTESTER_NO_CREDENTIALS'), 'notice'); Factory::getApplication()->enqueueMessage(\JText::_('COM_PATCHTESTER_NO_CREDENTIALS'), 'notice');
} }
return new GitHub($options); return new GitHub($options);

View File

@ -8,6 +8,8 @@
namespace PatchTester\Model; namespace PatchTester\Model;
use Joomla\CMS\Factory;
use Joomla\CMS\Version;
use PatchTester\GitHub\Exception\UnexpectedResponse; use PatchTester\GitHub\Exception\UnexpectedResponse;
use PatchTester\Helper; use PatchTester\Helper;
@ -158,7 +160,7 @@ class PullModel extends \JModelDatabase
if ($rate->resources->core->remaining == 0) if ($rate->resources->core->remaining == 0)
{ {
throw new \RuntimeException( throw new \RuntimeException(
\JText::sprintf('COM_PATCHTESTER_API_LIMIT_LIST', \JFactory::getDate($rate->resources->core->reset)) \JText::sprintf('COM_PATCHTESTER_API_LIMIT_LIST', Factory::getDate($rate->resources->core->reset))
); );
} }
@ -309,7 +311,7 @@ class PullModel extends \JModelDatabase
$record = (object) array( $record = (object) array(
'pull_id' => $pull->number, 'pull_id' => $pull->number,
'data' => json_encode($parsedFiles), 'data' => json_encode($parsedFiles),
'patched_by' => \JFactory::getUser()->id, 'patched_by' => Factory::getUser()->id,
'applied' => 1, 'applied' => 1,
'applied_version' => JVERSION, 'applied_version' => JVERSION,
); );
@ -327,7 +329,7 @@ class PullModel extends \JModelDatabase
)->execute(); )->execute();
// Change the media version // Change the media version
$version = new \JVersion; $version = new Version;
$version->refreshMediaVersion(); $version->refreshMediaVersion();
return true; return true;
@ -445,7 +447,7 @@ class PullModel extends \JModelDatabase
} }
// Change the media version // Change the media version
$version = new \JVersion; $version = new Version;
$version->refreshMediaVersion(); $version->refreshMediaVersion();
return $this->removeTest($testRecord); return $this->removeTest($testRecord);

View File

@ -8,8 +8,8 @@
namespace PatchTester\Model; namespace PatchTester\Model;
use Joomla\CMS\Pagination\Pagination;
use Joomla\Registry\Registry; use Joomla\Registry\Registry;
use PatchTester\GitHub\Exception\UnexpectedResponse; use PatchTester\GitHub\Exception\UnexpectedResponse;
use PatchTester\Helper; use PatchTester\Helper;
@ -187,9 +187,9 @@ class PullsModel extends \JModelDatabase
} }
/** /**
* Method to get a JPagination object for the data set. * Method to get a Pagination object for the data set.
* *
* @return \JPagination A JPagination object for the data set. * @return Pagination A Pagination object for the data set.
* *
* @since 2.0 * @since 2.0
*/ */
@ -205,7 +205,7 @@ class PullsModel extends \JModelDatabase
} }
// Create the pagination object and add the object to the internal cache. // Create the pagination object and add the object to the internal cache.
$this->cache[$store] = new \JPagination($this->getTotal(), $this->getStart(), (int) $this->getState()->get('list.limit', 20)); $this->cache[$store] = new Pagination($this->getTotal(), $this->getStart(), (int) $this->getState()->get('list.limit', 20));
return $this->cache[$store]; return $this->cache[$store];
} }

View File

@ -8,10 +8,6 @@
namespace PatchTester\Model; namespace PatchTester\Model;
use Joomla\Registry\Registry;
use PatchTester\Helper;
/** /**
* Methods supporting applied pull requests. * Methods supporting applied pull requests.
* *

View File

@ -6,6 +6,8 @@
* @license GNU General Public License version 2 or later * @license GNU General Public License version 2 or later
*/ */
use Joomla\CMS\Factory;
/** @var \PatchTester\View\DefaultHtmlView $this */ /** @var \PatchTester\View\DefaultHtmlView $this */
\JHtml::_('jquery.framework'); \JHtml::_('jquery.framework');
@ -20,5 +22,5 @@
<div id="progress" class="progress progress-striped active"> <div id="progress" class="progress progress-striped active">
<div id="progress-bar" class="bar bar-success" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div> <div id="progress-bar" class="bar bar-success" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div> </div>
<input id="patchtester-token" type="hidden" name="<?php echo \JFactory::getSession()->getFormToken(); ?>" value="1" /> <input id="patchtester-token" type="hidden" name="<?php echo Factory::getSession()->getFormToken(); ?>" value="1" />
</div> </div>

View File

@ -8,6 +8,10 @@
namespace PatchTester\View\Pulls; namespace PatchTester\View\Pulls;
use Joomla\CMS\Factory;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\Registry\Registry;
use PatchTester\TrackerHelper; use PatchTester\TrackerHelper;
use PatchTester\View\DefaultHtmlView; use PatchTester\View\DefaultHtmlView;
@ -47,7 +51,7 @@ class PullsHtmlView extends DefaultHtmlView
/** /**
* Pagination object * Pagination object
* *
* @var \JPagination * @var Pagination
* @since 2.0 * @since 2.0
*/ */
protected $pagination; protected $pagination;
@ -55,7 +59,7 @@ class PullsHtmlView extends DefaultHtmlView
/** /**
* The model state * The model state
* *
* @var \Joomla\Registry\Registry * @var Registry
* @since 2.0 * @since 2.0
*/ */
protected $state; protected $state;
@ -111,7 +115,7 @@ class PullsHtmlView extends DefaultHtmlView
// Set a warning on 4.0 branch // Set a warning on 4.0 branch
if (version_compare(JVERSION, '4.0', 'ge')) if (version_compare(JVERSION, '4.0', 'ge'))
{ {
\JFactory::getApplication()->enqueueMessage(\JText::_('COM_PATCHTESTER_40_WARNING'), 'warning'); Factory::getApplication()->enqueueMessage(\JText::_('COM_PATCHTESTER_40_WARNING'), 'warning');
} }
return parent::render(); return parent::render();
@ -130,7 +134,7 @@ class PullsHtmlView extends DefaultHtmlView
if (!count($this->envErrors)) if (!count($this->envErrors))
{ {
$toolbar = \JToolbar::getInstance('toolbar'); $toolbar = Toolbar::getInstance('toolbar');
$toolbar->appendButton( $toolbar->appendButton(
'Popup', 'Popup',

View File

@ -8,14 +8,16 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\Factory;
// Access check. // Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_patchtester')) if (!Factory::getUser()->authorise('core.manage', 'com_patchtester'))
{ {
throw new RuntimeException(JText::_('JERROR_ALERTNOAUTHOR'), 403); throw new RuntimeException(JText::_('JERROR_ALERTNOAUTHOR'), 403);
} }
// Application reference // Application reference
$app = JFactory::getApplication(); $app = Factory::getApplication();
// Import our Composer autoloader to load the component classes // Import our Composer autoloader to load the component classes
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/vendor/autoload.php';

View File

@ -6,12 +6,16 @@
* @license GNU General Public License version 2 or later * @license GNU General Public License version 2 or later
*/ */
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\Adapter\ComponentAdapter;
use Joomla\CMS\Installer\InstallerScript;
/** /**
* Installation class to perform additional changes during install/uninstall/update * Installation class to perform additional changes during install/uninstall/update
* *
* @since 2.0 * @since 2.0
*/ */
class Com_PatchtesterInstallerScript extends JInstallerScript class Com_PatchtesterInstallerScript extends InstallerScript
{ {
/** /**
* Array of templates with supported overrides * Array of templates with supported overrides
@ -28,7 +32,7 @@ class Com_PatchtesterInstallerScript extends JInstallerScript
*/ */
public function __construct() public function __construct()
{ {
$this->minimumJoomla = '3.7'; $this->minimumJoomla = '3.8';
$this->minimumPhp = JOOMLA_MINIMUM_PHP; $this->minimumPhp = JOOMLA_MINIMUM_PHP;
$this->deleteFiles = array( $this->deleteFiles = array(
@ -44,7 +48,7 @@ class Com_PatchtesterInstallerScript extends JInstallerScript
/** /**
* Function to perform changes during install * Function to perform changes during install
* *
* @param JInstallerAdapterComponent $parent The class calling this method * @param ComponentAdapter $parent The class calling this method
* *
* @return void * @return void
* *
@ -58,7 +62,7 @@ class Com_PatchtesterInstallerScript extends JInstallerScript
/** /**
* Function to perform changes during update * Function to perform changes during update
* *
* @param JInstallerAdapterComponent $parent The class calling this method * @param ComponentAdapter $parent The class calling this method
* *
* @return void * @return void
* *
@ -72,7 +76,7 @@ class Com_PatchtesterInstallerScript extends JInstallerScript
/** /**
* Function to perform changes during uninstall * Function to perform changes during uninstall
* *
* @param JInstallerAdapterComponent $parent The class calling this method * @param ComponentAdapter $parent The class calling this method
* *
* @return void * @return void
* *
@ -106,15 +110,15 @@ class Com_PatchtesterInstallerScript extends JInstallerScript
// If we couldn't remove any overrides, notify the user // If we couldn't remove any overrides, notify the user
if (count($errorTemplates) > 0) if (count($errorTemplates) > 0)
{ {
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_PATCHTESTER_COULD_NOT_REMOVE_OVERRIDES', implode(', ', $errorTemplates))); Factory::getApplication()->enqueueMessage(JText::sprintf('COM_PATCHTESTER_COULD_NOT_REMOVE_OVERRIDES', implode(', ', $errorTemplates)));
} }
} }
/** /**
* Function to perform changes during postflight * Function to perform changes during postflight
* *
* @param string $type The action being performed * @param string $type The action being performed
* @param JInstallerAdapterComponent $parent The class calling this method * @param ComponentAdapter $parent The class calling this method
* *
* @return void * @return void
* *
@ -168,7 +172,7 @@ class Com_PatchtesterInstallerScript extends JInstallerScript
// If we couldn't remove any overrides, notify the user // If we couldn't remove any overrides, notify the user
if (count($errorTemplates) > 0) if (count($errorTemplates) > 0)
{ {
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_PATCHTESTER_COULD_NOT_INSTALL_OVERRIDES', implode(', ', $errorTemplates))); Factory::getApplication()->enqueueMessage(JText::sprintf('COM_PATCHTESTER_COULD_NOT_INSTALL_OVERRIDES', implode(', ', $errorTemplates)));
} }
} }
} }

View File

@ -6,6 +6,9 @@
* @license GNU General Public License version 2 or later * @license GNU General Public License version 2 or later
*/ */
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;
/** @var \PatchTester\View\Pulls\PullsHtmlView $this */ /** @var \PatchTester\View\Pulls\PullsHtmlView $this */
\JHtml::_('behavior.core'); \JHtml::_('behavior.core');
@ -20,7 +23,7 @@ $filterBranch = $this->escape($this->state->get('filter.branch'));
$filterRtc = $this->escape($this->state->get('filter.rtc')); $filterRtc = $this->escape($this->state->get('filter.rtc'));
$colSpan = $this->trackerAlias !== false ? 8 : 7; $colSpan = $this->trackerAlias !== false ? 8 : 7;
\JFactory::getDocument()->addStyleDeclaration( Factory::getDocument()->addStyleDeclaration(
' '
.icon-48-patchtester { background-image:url("/media/com_patchtester/images/icon-48-patchtester.png"); } .icon-48-patchtester { background-image:url("/media/com_patchtester/images/icon-48-patchtester.png"); }
' '
@ -29,7 +32,7 @@ echo \JHtml::_(
'bootstrap.renderModal', 'bootstrap.renderModal',
'modal-refresh', 'modal-refresh',
array( array(
'url' => \JUri::root() . 'administrator/index.php?option=com_patchtester&view=fetch&tmpl=component', 'url' => Uri::root() . 'administrator/index.php?option=com_patchtester&view=fetch&tmpl=component',
'title' => \JText::_('COM_PATCHTESTER_TOOLBAR_FETCH_DATA'), 'title' => \JText::_('COM_PATCHTESTER_TOOLBAR_FETCH_DATA'),
'width' => '800px', 'width' => '800px',
'height' => '300px' 'height' => '300px'
@ -41,25 +44,25 @@ echo \JHtml::_(
<fieldset id="filter-bar"> <fieldset id="filter-bar">
<legend class="element-invisible"><?php echo \JText::_('JSEARCH_FILTER_LABEL'); ?></legend> <legend class="element-invisible"><?php echo \JText::_('JSEARCH_FILTER_LABEL'); ?></legend>
<div class="filter-search"> <div class="filter-search">
<label class="filter-search-lbl" for="filter_search"><?php echo JText::_('JSEARCH_FILTER_LABEL'); ?></label> <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_PATCHTESTER_FILTER_SEARCH_DESCRIPTION'); ?>" /> <input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" title="<?php echo \JText::_('COM_PATCHTESTER_FILTER_SEARCH_DESCRIPTION'); ?>" />
<button type="submit" class="btn"><?php echo \JText::_('JSEARCH_FILTER_SUBMIT'); ?></button> <button type="submit" class="btn"><?php echo \JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
<button type="button" onclick="document.getElementById('filter_search').value='';this.form.submit();"><?php echo \JText::_('JSEARCH_FILTER_CLEAR'); ?></button> <button type="button" onclick="document.getElementById('filter_search').value='';this.form.submit();"><?php echo \JText::_('JSEARCH_FILTER_CLEAR'); ?></button>
</div> </div>
<div class="filter-select"> <div class="filter-select">
<label class="selectlabel" for="filter_applied"><?php echo JText::_('COM_PATCHTESTER_FILTER_APPLIED_PATCHES'); ?></label> <label class="selectlabel" for="filter_applied"><?php echo \JText::_('COM_PATCHTESTER_FILTER_APPLIED_PATCHES'); ?></label>
<select name="filter_applied" id="filter_applied"> <select name="filter_applied" id="filter_applied">
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_APPLIED_PATCHES'); ?></option> <option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_APPLIED_PATCHES'); ?></option>
<option value="yes"<?php if ($filterApplied == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_APPLIED'); ?></option> <option value="yes"<?php if ($filterApplied == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_APPLIED'); ?></option>
<option value="no"<?php if ($filterApplied == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_APPLIED'); ?></option> <option value="no"<?php if ($filterApplied == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_APPLIED'); ?></option>
</select> </select>
<label class="selectlabel" for="filter_rtc"><?php echo JText::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></label> <label class="selectlabel" for="filter_rtc"><?php echo \JText::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></label>
<select name="filter_rtc" id="filter_rtc"> <select name="filter_rtc" id="filter_rtc">
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></option> <option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_RTC_PATCHES'); ?></option>
<option value="yes"<?php if ($filterRtc == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_RTC'); ?></option> <option value="yes"<?php if ($filterRtc == 'yes') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_RTC'); ?></option>
<option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option> <option value="no"<?php if ($filterRtc == 'no') echo ' selected="selected"'; ?>><?php echo \JText::_('COM_PATCHTESTER_NOT_RTC'); ?></option>
</select> </select>
<label class="selectlabel" for="filter_branch"><?php echo JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></label> <label class="selectlabel" for="filter_branch"><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></label>
<select name="filter_branch" id="filter_branch"> <select name="filter_branch" id="filter_branch">
<option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option> <option value=""><?php echo \JText::_('COM_PATCHTESTER_FILTER_BRANCH'); ?></option>
<?php echo \JHtml::_('select.options', $this->branches, 'text', 'text', $filterBranch, false);?> <?php echo \JHtml::_('select.options', $this->branches, 'text', 'text', $filterBranch, false);?>