mirror of
https://github.com/joomla-extensions/patchtester.git
synced 2024-12-23 03:19:00 +00:00
Modify how environmental errors are rendered
This commit is contained in:
parent
7f7e445722
commit
435f8d1430
@ -40,6 +40,10 @@ COM_PATCHTESTER_PURGE_NA="No cache files to remove."
|
||||
COM_PATCHTESTER_PURGE_SUCCESS="Purge operation completed successfully, %s files removed."
|
||||
COM_PATCHTESTER_PURGE_SUCCESS_1="Purge operation completed successfully, %s file removed."
|
||||
COM_PATCHTESTER_REPO_IS_GONE="The patch could not be applied because the repository is missing"
|
||||
COM_PATCHTESTER_REQUIREMENT_HTTPS="HTTPS wrappers must be enabled"
|
||||
COM_PATCHTESTER_REQUIREMENT_OPENSSL="The OpenSSL extension must be installed and enabled in your php.ini"
|
||||
COM_PATCHTESTER_REQUIREMENTS_HEADING="Requirements Not Met"
|
||||
COM_PATCHTESTER_REQUIREMENTS_NOT_MET="Your system does not meet the requirements to run the Patch Tester extension:"
|
||||
COM_PATCHTESTER_REVERT_OK="Patch successfully reverted"
|
||||
COM_PATCHTESTER_REVERT_PATCH="Revert Patch"
|
||||
COM_PATCHTESTER_SEARCH_IN_PULL_ID="Pull ID"
|
||||
|
@ -8,12 +8,17 @@
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/** @type PatchtesterViewPulls $this */
|
||||
|
||||
JHtml::_('behavior.tooltip');
|
||||
JHtml::_('behavior.modal');
|
||||
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
|
||||
if (count($this->envErrors)) :
|
||||
$this->loadTemplate('errors');
|
||||
else :
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var submitpatch = function (task, id) {
|
||||
@ -83,3 +88,4 @@ $listDirn = $this->escape($this->state->get('list.direction'));
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif;
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* @package PatchTester
|
||||
*
|
||||
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2014 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/** @type PatchtesterViewPulls $this */
|
||||
?>
|
||||
<h3><?php echo JText::_('COM_PATCHTESTER_REQUIREMENTS_HEADING'); ?></h3>
|
||||
<p><?php echo JText::_('COM_PATCHTESTER_REQUIREMENTS_NOT_MET'); ?></p>
|
||||
<ul>
|
||||
<?php foreach ($this->envErrors as $error) : ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
@ -8,6 +8,8 @@
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/** @type PatchtesterViewPulls $this */
|
||||
|
||||
foreach ($this->items as $i => $item) :
|
||||
$status = '';
|
||||
|
||||
|
@ -16,6 +16,14 @@ defined('_JEXEC') or die;
|
||||
*/
|
||||
class PatchtesterViewPulls extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* Array containing environment errors
|
||||
*
|
||||
* @var array
|
||||
* @since 2.0
|
||||
*/
|
||||
protected $envErrors = array();
|
||||
|
||||
/**
|
||||
* Array of open pull requests
|
||||
*
|
||||
@ -55,51 +63,37 @@ class PatchtesterViewPulls extends JViewLegacy
|
||||
*
|
||||
* @return mixed A string if successful, otherwise a Error object.
|
||||
*
|
||||
* @see fetch()
|
||||
* @since 1.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// TODO: move the check
|
||||
$checkErrs = array();
|
||||
|
||||
if (!extension_loaded('openssl'))
|
||||
{
|
||||
$checkErrs[] = 'The OpenSSL extension must be installed and enabled in your php.ini';
|
||||
$this->envErrors[] = JText::_('COM_PATCHTESTER_REQUIREMENT_OPENSSL');
|
||||
}
|
||||
|
||||
if (!in_array('https', stream_get_wrappers()))
|
||||
{
|
||||
$checkErrs[] = 'https wrappers must be enabled';
|
||||
$this->envErrors[] = JText::_('COM_PATCHTESTER_REQUIREMENT_HTTPS');
|
||||
}
|
||||
|
||||
if (count($checkErrs))
|
||||
// Only process the data if there are no environment errors
|
||||
if (!count($this->envErrors))
|
||||
{
|
||||
$application = JFactory::getApplication();
|
||||
$this->state = $this->get('State');
|
||||
$this->items = $this->get('Items');
|
||||
$this->patches = $this->get('AppliedPatches');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
|
||||
$application->enqueueMessage('Your system does not meet the requirements to run the PullTester extension:', 'error');
|
||||
// Check for errors.
|
||||
$errors = $this->get('Errors');
|
||||
|
||||
foreach ($checkErrs as $error)
|
||||
if (count($errors))
|
||||
{
|
||||
$application->enqueueMessage($error, 'error');
|
||||
JError::raiseError(500, implode("\n", $errors));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$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');
|
||||
|
||||
if (count($errors))
|
||||
{
|
||||
JError::raiseError(500, implode("\n", $errors));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
@ -117,7 +111,12 @@ class PatchtesterViewPulls extends JViewLegacy
|
||||
protected function addToolbar()
|
||||
{
|
||||
JToolBarHelper::title(JText::_('COM_PATCHTESTER'), 'patchtester');
|
||||
JToolbarHelper::custom('purge', 'delete.png', 'delete_f2.png', 'COM_PATCHTESTER_PURGE_CACHE', false);
|
||||
|
||||
if (!count($this->envErrors))
|
||||
{
|
||||
JToolbarHelper::custom('purge', 'delete.png', 'delete_f2.png', 'COM_PATCHTESTER_PURGE_CACHE', false);
|
||||
}
|
||||
|
||||
JToolBarHelper::preferences('com_patchtester');
|
||||
|
||||
JFactory::getDocument()->addStyleDeclaration(
|
||||
|
Loading…
Reference in New Issue
Block a user