33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-12-25 12:10:02 +00:00
patchtester/administrator/components/com_patchtester/views/pulls/view.html.php

127 lines
2.5 KiB
PHP
Raw Normal View History

2011-10-11 13:02:57 +00:00
<?php
/**
2013-07-13 02:26:21 +00:00
* @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
2011-10-11 13:02:57 +00:00
*/
defined('_JEXEC') or die;
/**
* View class for a list of pull requests.
*
2013-07-13 02:26:21 +00:00
* @package PatchTester
* @since 1.0
2011-10-11 13:02:57 +00:00
*/
2012-09-09 01:53:44 +00:00
class PatchtesterViewPulls extends JViewLegacy
2011-10-11 13:02:57 +00:00
{
2013-07-13 02:26:21 +00:00
/**
* Array of open pull requests
*
* @var array
* @since 1.0
*/
2011-10-11 13:02:57 +00:00
protected $items;
2013-07-13 02:26:21 +00:00
/**
* Object containing data about applied patches
*
* @var object
* @since 1.0
*/
protected $patches;
/**
* State object
*
* @var JRegistry
* @since 1.0
*/
2011-10-11 13:02:57 +00:00
protected $state;
/**
2013-07-13 02:26:21 +00:00
* Pagination object
*
* @var JPagination
* @since 2.0
*/
protected $pagination;
/**
* 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
2011-10-11 13:02:57 +00:00
*/
public function display($tpl = null)
{
2013-07-13 02:26:21 +00:00
// TODO: move the check
$checkErrs = array();
2013-07-13 02:26:21 +00:00
if (!extension_loaded('openssl'))
{
$checkErrs[] = 'The OpenSSL extension must be installed and enabled in your php.ini';
2013-07-13 02:26:21 +00:00
}
2013-07-13 02:26:21 +00:00
if (!in_array('https', stream_get_wrappers()))
{
$checkErrs[] = 'https wrappers must be enabled';
2013-07-13 02:26:21 +00:00
}
if (count($checkErrs))
{
$application = JFactory::getApplication();
2013-07-13 02:26:21 +00:00
$application->enqueueMessage('Your system does not meet the requirements to run the PullTester extension:', 'error');
foreach ($checkErrs as $error)
{
$application->enqueueMessage($error, 'error');
}
return $this;
}
2013-07-13 02:26:21 +00:00
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->patches = $this->get('AppliedPatches');
$this->pagination = $this->get('Pagination');
2011-10-11 13:02:57 +00:00
// Check for errors.
2013-07-13 02:26:21 +00:00
$errors = $this->get('Errors');
2012-09-09 01:53:44 +00:00
if (count($errors))
2012-06-12 18:42:45 +00:00
{
2013-07-13 02:26:21 +00:00
JError::raiseError(500, implode("\n", $errors));
return false;
2011-10-11 13:02:57 +00:00
}
$this->addToolbar();
2013-07-13 02:26:21 +00:00
return parent::display($tpl);
2011-10-11 13:02:57 +00:00
}
/**
* Add the page title and toolbar.
2013-07-13 02:26:21 +00:00
*
* @return void
*
* @since 1.0
2011-10-11 13:02:57 +00:00
*/
protected function addToolbar()
{
2013-07-13 02:26:21 +00:00
JToolBarHelper::title(JText::_('COM_PATCHTESTER'), 'patchtester');
2011-10-11 13:02:57 +00:00
JToolBarHelper::preferences('com_patchtester');
2011-10-15 22:02:31 +00:00
JFactory::getDocument()->addStyleDeclaration(
'.icon-48-patchtester {background-image: url(components/com_patchtester/assets/images/icon-48-patchtester.png);}'
);
2011-10-11 13:02:57 +00:00
}
}