33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-12-22 19:09:00 +00:00

A once over on things

This commit is contained in:
Michael Babker 2015-12-05 12:43:54 -05:00
parent 95f62b498d
commit 43d92ba64c
16 changed files with 52 additions and 51 deletions

View File

@ -14,6 +14,8 @@ use Joomla\Registry\Registry;
* Default display controller
*
* @since 2.0
*
* @method \JApplicationCms getApplication() getApplication() Get the application object.
*/
class DisplayController extends \JControllerBase
{
@ -62,7 +64,7 @@ class DisplayController extends \JControllerBase
parent::__construct($input, $app);
// Set the context for the controller
$this->context = \JApplicationHelper::getComponentName() . '.' . $this->getInput()->getCmd('view', $this->defaultView);
$this->context = 'com_patchtester.' . $this->getInput()->getCmd('view', $this->defaultView);
}
/**
@ -83,10 +85,10 @@ class DisplayController extends \JControllerBase
$paths = new \SplPriorityQueue;
// Add the path for template overrides
$paths->insert(JPATH_THEMES . '/' . $this->getApplication()->getTemplate() . '/html/' . \JApplicationHelper::getComponentName() . '/' . $view, 2);
$paths->insert(JPATH_THEMES . '/' . $this->getApplication()->getTemplate() . '/html/com_patchtester/' . $view, 2);
// Add the path for the default layouts
$paths->insert(JPATH_BASE . '/components/' . \JApplicationHelper::getComponentName() . '/PatchTester/View/' . ucfirst($view) . '/tmpl', 1);
$paths->insert(dirname(__DIR__) . '//View/' . ucfirst($view) . '/tmpl', 1);
// Build the class names for the model and view
$viewClass = '\\PatchTester\\View\\' . ucfirst($view) . '\\' . ucfirst($view) . ucfirst($format) . 'View';

View File

@ -27,9 +27,10 @@ class FetchController extends DisplayController
public function execute()
{
// We don't want this request to be cached.
header('Pragma: no-cache');
header('Cache-Control: no-cache');
header('Expires: -1');
$this->getApplication()->setHeader('Pragma: no-cache');
$this->getApplication()->setHeader('Cache-Control: no-cache');
$this->getApplication()->setHeader('Expires: -1');
$this->getApplication()->setHeader('Content-Type', $this->getApplication()->mimeType . '; charset=' . $this->getApplication()->charSet);
try
{
@ -48,6 +49,7 @@ class FetchController extends DisplayController
{
$response = new \JResponseJson($e);
$this->getApplication()->sendHeaders();
echo json_encode($response);
$this->getApplication()->close(1);
@ -68,6 +70,7 @@ class FetchController extends DisplayController
$response = new \JResponseJson($status, $message, false, true);
$this->getApplication()->sendHeaders();
echo json_encode($response);
$this->getApplication()->close();

View File

@ -28,15 +28,17 @@ class StartfetchController extends DisplayController
public function execute()
{
// We don't want this request to be cached.
header('Pragma: no-cache');
header('Cache-Control: no-cache');
header('Expires: -1');
$this->getApplication()->setHeader('Pragma: no-cache');
$this->getApplication()->setHeader('Cache-Control: no-cache');
$this->getApplication()->setHeader('Expires: -1');
$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.
if (!\JSession::checkToken('request'))
{
$response = new \JResponseJson(new \Exception(\JText::_('JINVALID_TOKEN'), 403));
$this->getApplication()->sendHeaders();
echo json_encode($response);
$this->getApplication()->close(1);
@ -59,6 +61,7 @@ class StartfetchController extends DisplayController
)
);
$this->getApplication()->sendHeaders();
echo json_encode($response);
$this->getApplication()->close(1);
@ -74,6 +77,7 @@ class StartfetchController extends DisplayController
)
);
$this->getApplication()->sendHeaders();
echo json_encode($response);
$this->getApplication()->close(1);
@ -92,6 +96,7 @@ class StartfetchController extends DisplayController
{
$response = new \JResponseJson(new \Exception(\JText::_('COM_PATCHTESTER_ERROR_APPLIED_PATCHES'), 500));
$this->getApplication()->sendHeaders();
echo json_encode($response);
$this->getApplication()->close(1);
@ -101,6 +106,7 @@ class StartfetchController extends DisplayController
{
$response = new \JResponseJson($e);
$this->getApplication()->sendHeaders();
echo json_encode($response);
$this->getApplication()->close(1);
@ -116,6 +122,7 @@ class StartfetchController extends DisplayController
true
);
$this->getApplication()->sendHeaders();
echo json_encode($response);
$this->getApplication()->close();

View File

@ -43,7 +43,7 @@ class PullModel extends \JModelBase
$lines = explode("\n", $patch);
foreach ($lines AS $line)
foreach ($lines as $line)
{
switch ($state)
{
@ -169,11 +169,10 @@ class PullModel extends \JModelBase
$options->set('userAgent', 'JPatchTester/2.0');
$options->set('timeout', 120);
$transport = \JHttpFactory::getHttp($options);
try
{
$patch = $transport->get($pull->diff_url)->body;
$transport = \JHttpFactory::getHttp($options);
$patch = $transport->get($pull->diff_url)->body;
}
catch (\Exception $e)
{
@ -262,6 +261,7 @@ class PullModel extends \JModelBase
}
}
/** @var \PatchTester\Table\TestsTable $table */
$table = \JTable::getInstance('TestsTable', '\\PatchTester\\Table\\');
$table->pull_id = $pull->number;
$table->data = json_encode($files);
@ -289,6 +289,7 @@ class PullModel extends \JModelBase
*/
public function revert($id)
{
/** @var \PatchTester\Table\TestsTable $table */
$table = \JTable::getInstance('TestsTable', '\\PatchTester\\Table\\');
$table->load($id);

View File

@ -145,14 +145,7 @@ class PullsModel extends \JModelDatabase
if (!empty($applied))
{
// Not applied patches have a NULL value, so build our value part of the query based on this
if ($applied == 'no')
{
$value = ' IS NULL';
}
else
{
$value = ' = 1';
}
$value = $applied == 'no' ? ' IS NULL' : ' = 1';
$query->where($db->quoteName('applied') . $value);
}
@ -400,9 +393,8 @@ class PullsModel extends \JModelDatabase
protected function _getList($query, $limitstart = 0, $limit = 0)
{
$this->getDb()->setQuery($query, $limitstart, $limit);
$result = $this->getDb()->loadObjectList();
return $result;
return $this->getDb()->loadObjectList();
}
/**

View File

@ -28,7 +28,13 @@ class DefaultHtmlView extends \JViewHtml
public function loadTemplate($tpl = null)
{
// Get the path to the file
$file = isset($tpl) ? $this->getLayout() . '_' . $tpl : $this->getLayout();
$file = $this->getLayout();
if (isset($tpl))
{
$file .= '_' . $tpl;
}
$path = $this->getPath($file);
if (!$path)

View File

@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later
*/
/** @type \PatchTester\View\DefaultHtmlView $this */
/** @var \PatchTester\View\DefaultHtmlView $this */
JHtml::_('jquery.framework');
JHtml::_('behavior.core');

View File

@ -14,6 +14,8 @@ use PatchTester\View\DefaultHtmlView;
* View class for a list of pull requests.
*
* @since 2.0
*
* @property-read \PatchTester\Model\PullsModel $model The model object.
*/
class PullsHtmlView extends DefaultHtmlView
{
@ -33,14 +35,6 @@ class PullsHtmlView extends DefaultHtmlView
*/
protected $items;
/**
* The model object - redeclared for proper type hinting.
*
* @var \PatchTester\Model\PullsModel
* @since 2.0
*/
protected $model;
/**
* State object
*
@ -102,8 +96,7 @@ class PullsHtmlView extends DefaultHtmlView
if (!count($this->envErrors))
{
$toolbar = \JToolbar::getInstance('toolbar');
$toolbar->appendButton(
\JToolbar::getInstance('toolbar')->appendButton(
'Popup',
'refresh',
'COM_PATCHTESTER_TOOLBAR_FETCH_DATA',

View File

@ -6,15 +6,14 @@
* @license GNU General Public License version 2 or later
*/
/** @type \PatchTester\View\Pulls\PullsHtmlView $this */
/** @var \PatchTester\View\Pulls\PullsHtmlView $this */
\JHtml::_('bootstrap.tooltip');
\JHtml::_('formbehavior.chosen', 'select');
\JHtml::_('stylesheet', 'com_patchtester/octicons.css', array(), true);
if (count($this->envErrors)) :
echo $this->loadTemplate('errors');
if (count($this->envErrors)) : echo $this->loadTemplate('errors');
else :
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));

View File

@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later
*/
/** @type \PatchTester\View\Pulls\PullsHtmlView $this */
/** @var \PatchTester\View\DefaultHtmlView $this */
?>
<h3><?php echo \JText::_('COM_PATCHTESTER_REQUIREMENTS_HEADING'); ?></h3>
<p><?php echo \JText::_('COM_PATCHTESTER_REQUIREMENTS_NOT_MET'); ?></p>

View File

@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later
*/
/** @type \PatchTester\View\Pulls\PullsHtmlView $this */
/** @var \PatchTester\View\DefaultHtmlView $this */
foreach ($this->items as $i => $item) :
$status = '';
@ -31,7 +31,7 @@ foreach ($this->items as $i => $item) :
</a>
</td>
<td class="center">
<a class="btn btn-small btn-warning" href="http://issues.joomla.org/tracker/joomla-cms/<?php echo $item->pull_id; ?>" target="_blank">
<a class="btn btn-small btn-warning" href="https://issues.joomla.org/tracker/joomla-cms/<?php echo $item->pull_id; ?>" target="_blank">
<i class="icon-joomla"></i> <?php echo \JText::_('COM_PATCHTESTER_JISSUE'); ?>
</a>
</td>

View File

@ -1,6 +1,6 @@
<?php
/**
* @package PatchTester
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
@ -11,7 +11,7 @@ defined('_JEXEC') or die;
// Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_patchtester'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
return JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Application reference

View File

@ -6,7 +6,7 @@
<copyright>(C) 2011 - 2012 Ian MacLennan, (C) 2013 - 2015 Open Source Matters, Inc. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>http://www.joomla.org</authorUrl>
<authorUrl>https://www.joomla.org</authorUrl>
<version>2.0.0.beta4.dev</version>
<description>COM_PATCHTESTER_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>

View File

@ -1,6 +1,6 @@
<?php
/**
* @package PatchTester
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
@ -9,8 +9,7 @@
/**
* Installation class to perform additional changes during install/uninstall/update
*
* @package Patchtester
* @since 2.0
* @since 2.0
*/
class Com_PatchtesterInstallerScript
{

View File

@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later
*/
/** @type \PatchTester\View\Pulls\PullsHtmlView $this */
/** @var \PatchTester\View\DefaultHtmlView $this */
\JHtml::_('behavior.core');
\JHtml::_('bootstrap.tooltip');

View File

@ -6,7 +6,7 @@
* @license GNU General Public License version 2 or later
*/
/** @type \PatchTester\View\Pulls\PullsHtmlView $this */
/** @var \PatchTester\View\DefaultHtmlView $this */
foreach ($this->items as $i => $item) :
$status = '';
@ -14,7 +14,6 @@ foreach ($this->items as $i => $item) :
if ($item->applied) :
$status = ' success';
endif;
?>
<tr class="row<?php echo $i % 2; ?><?php echo $status ?>">
<td class="center">
@ -31,7 +30,7 @@ foreach ($this->items as $i => $item) :
</a>
</td>
<td>
<a class="btn btn-small btn-warning" href="http://issues.joomla.org/tracker/joomla-cms/<?php echo $item->pull_id; ?>" target="_blank">
<a class="btn btn-small btn-warning" href="https://issues.joomla.org/tracker/joomla-cms/<?php echo $item->pull_id; ?>" target="_blank">
<i class="icon-joomla"></i> <?php echo \JText::_('COM_PATCHTESTER_JISSUE'); ?>
</a>
</td>