2011-10-11 13:02:57 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2013-07-13 02:26:21 +00:00
|
|
|
* @package PatchTester
|
|
|
|
*
|
2014-01-03 02:48:28 +00:00
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2014 Open Source Matters, Inc. All rights reserved.
|
2013-07-13 02:26:21 +00:00
|
|
|
* @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
|
|
|
{
|
2014-05-01 13:07:13 +00:00
|
|
|
/**
|
|
|
|
* Array containing environment errors
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected $envErrors = array();
|
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* State object
|
|
|
|
*
|
2014-05-03 02:02:38 +00:00
|
|
|
* @var \Joomla\Registry\Registry
|
2013-07-13 02:26:21 +00:00
|
|
|
* @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.
|
|
|
|
*
|
|
|
|
* @since 1.0
|
2011-10-11 13:02:57 +00:00
|
|
|
*/
|
|
|
|
public function display($tpl = null)
|
|
|
|
{
|
2013-07-13 02:26:21 +00:00
|
|
|
if (!extension_loaded('openssl'))
|
|
|
|
{
|
2014-05-01 13:07:13 +00:00
|
|
|
$this->envErrors[] = JText::_('COM_PATCHTESTER_REQUIREMENT_OPENSSL');
|
2013-07-13 02:26:21 +00:00
|
|
|
}
|
2012-06-12 20:38:14 +00:00
|
|
|
|
2013-07-13 02:26:21 +00:00
|
|
|
if (!in_array('https', stream_get_wrappers()))
|
|
|
|
{
|
2014-05-01 13:07:13 +00:00
|
|
|
$this->envErrors[] = JText::_('COM_PATCHTESTER_REQUIREMENT_HTTPS');
|
2013-07-13 02:26:21 +00:00
|
|
|
}
|
2012-06-12 20:38:14 +00:00
|
|
|
|
2014-05-01 13:07:13 +00:00
|
|
|
// Only process the data if there are no environment errors
|
|
|
|
if (!count($this->envErrors))
|
2012-06-12 20:38:14 +00:00
|
|
|
{
|
2014-05-01 13:07:13 +00:00
|
|
|
$this->state = $this->get('State');
|
|
|
|
$this->items = $this->get('Items');
|
|
|
|
$this->pagination = $this->get('Pagination');
|
2012-06-12 20:38:14 +00:00
|
|
|
|
2014-05-01 13:07:13 +00:00
|
|
|
// Check for errors.
|
|
|
|
$errors = $this->get('Errors');
|
2012-06-12 20:38:14 +00:00
|
|
|
|
2014-05-01 13:07:13 +00:00
|
|
|
if (count($errors))
|
2012-06-12 20:38:14 +00:00
|
|
|
{
|
2014-05-01 13:07:13 +00:00
|
|
|
JError::raiseError(500, implode("\n", $errors));
|
2012-06-12 20:38:14 +00:00
|
|
|
|
2014-05-01 13:07:13 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-10-11 13:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->addToolbar();
|
2012-06-12 20:38:14 +00:00
|
|
|
|
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');
|
2014-05-01 13:07:13 +00:00
|
|
|
|
|
|
|
if (!count($this->envErrors))
|
|
|
|
{
|
2014-05-03 01:36:05 +00:00
|
|
|
JToolbarHelper::custom('pulls.fetch', 'refresh.png', 'refresh_f2.png', 'COM_PATCHTESTER_TOOLBAR_FETCH_DATA', false);
|
2014-05-01 13:07:13 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 13:02:57 +00:00
|
|
|
JToolBarHelper::preferences('com_patchtester');
|
|
|
|
}
|
2014-05-01 14:35:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of fields the table can be sorted by
|
|
|
|
*
|
|
|
|
* @return array Array containing the field name to sort by as the key and display text as value
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected function getSortFields()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'a.title' => JText::_('JGLOBAL_TITLE'),
|
|
|
|
'a.pull_id' => JText::_('COM_PATCHTESTER_PULL_ID'),
|
|
|
|
'applied' => JText::_('JSTATUS')
|
|
|
|
);
|
|
|
|
}
|
2011-10-11 13:02:57 +00:00
|
|
|
}
|