2014-05-03 23:48:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Patch testing component for the Joomla! CMS
|
|
|
|
*
|
2018-09-01 14:32:23 +00:00
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
|
2014-05-03 23:48:08 +00:00
|
|
|
* @license GNU General Public License version 2 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace PatchTester\View\Pulls;
|
|
|
|
|
2017-08-17 23:22:01 +00:00
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
use Joomla\CMS\Pagination\Pagination;
|
|
|
|
use Joomla\CMS\Toolbar\Toolbar;
|
|
|
|
use Joomla\Registry\Registry;
|
2016-03-18 21:34:31 +00:00
|
|
|
use PatchTester\TrackerHelper;
|
2014-05-03 23:48:08 +00:00
|
|
|
use PatchTester\View\DefaultHtmlView;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* View class for a list of pull requests.
|
|
|
|
*
|
|
|
|
* @since 2.0
|
2015-12-05 17:43:54 +00:00
|
|
|
*
|
|
|
|
* @property-read \PatchTester\Model\PullsModel $model The model object.
|
2014-05-03 23:48:08 +00:00
|
|
|
*/
|
|
|
|
class PullsHtmlView extends DefaultHtmlView
|
|
|
|
{
|
2017-04-22 16:55:17 +00:00
|
|
|
/**
|
|
|
|
* Array containing the list of branches
|
|
|
|
*
|
|
|
|
* @var array
|
2017-05-31 08:06:00 +00:00
|
|
|
* @since 3.0.0
|
2017-04-22 16:55:17 +00:00
|
|
|
*/
|
|
|
|
protected $branches = array();
|
|
|
|
|
2014-05-03 23:48:08 +00:00
|
|
|
/**
|
|
|
|
* Array containing environment errors
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected $envErrors = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of open pull requests
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected $items;
|
|
|
|
|
|
|
|
/**
|
2016-03-18 21:34:31 +00:00
|
|
|
* Pagination object
|
|
|
|
*
|
2017-08-17 23:22:01 +00:00
|
|
|
* @var Pagination
|
2016-03-18 21:34:31 +00:00
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected $pagination;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The model state
|
2014-05-03 23:48:08 +00:00
|
|
|
*
|
2017-08-17 23:22:01 +00:00
|
|
|
* @var Registry
|
2014-05-03 23:48:08 +00:00
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected $state;
|
|
|
|
|
|
|
|
/**
|
2016-03-18 21:34:31 +00:00
|
|
|
* The issue tracker project alias
|
2014-05-03 23:48:08 +00:00
|
|
|
*
|
2016-03-18 21:34:31 +00:00
|
|
|
* @var string|boolean
|
2014-05-03 23:48:08 +00:00
|
|
|
* @since 2.0
|
|
|
|
*/
|
2016-03-18 21:34:31 +00:00
|
|
|
protected $trackerAlias;
|
2014-05-03 23:48:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to render the view.
|
|
|
|
*
|
|
|
|
* @return string The rendered view.
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
if (!extension_loaded('openssl'))
|
|
|
|
{
|
|
|
|
$this->envErrors[] = \JText::_('COM_PATCHTESTER_REQUIREMENT_OPENSSL');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in_array('https', stream_get_wrappers()))
|
|
|
|
{
|
|
|
|
$this->envErrors[] = \JText::_('COM_PATCHTESTER_REQUIREMENT_HTTPS');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only process the data if there are no environment errors
|
|
|
|
if (!count($this->envErrors))
|
|
|
|
{
|
2016-03-18 21:34:31 +00:00
|
|
|
$this->state = $this->model->getState();
|
|
|
|
$this->items = $this->model->getItems();
|
|
|
|
$this->pagination = $this->model->getPagination();
|
|
|
|
$this->trackerAlias = TrackerHelper::getTrackerAlias($this->state->get('github_user'), $this->state->get('github_repo'));
|
2017-04-22 16:55:17 +00:00
|
|
|
$this->branches = $this->model->getBranches();
|
2014-05-03 23:48:08 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 19:52:15 +00:00
|
|
|
// Change the layout if there are environment errors
|
|
|
|
if (count($this->envErrors))
|
|
|
|
{
|
|
|
|
$this->setLayout('errors');
|
|
|
|
}
|
|
|
|
|
2014-05-03 23:48:08 +00:00
|
|
|
$this->addToolbar();
|
|
|
|
|
2016-03-26 22:08:01 +00:00
|
|
|
// Make text strings available in the JavaScript API
|
|
|
|
\JText::script('COM_PATCHTESTER_CONFIRM_RESET');
|
|
|
|
|
2016-10-08 16:14:16 +00:00
|
|
|
// Set a warning on 4.0 branch
|
|
|
|
if (version_compare(JVERSION, '4.0', 'ge'))
|
|
|
|
{
|
2017-08-17 23:22:01 +00:00
|
|
|
Factory::getApplication()->enqueueMessage(\JText::_('COM_PATCHTESTER_40_WARNING'), 'warning');
|
2016-10-08 16:14:16 +00:00
|
|
|
}
|
|
|
|
|
2014-05-03 23:48:08 +00:00
|
|
|
return parent::render();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the page title and toolbar.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected function addToolbar()
|
|
|
|
{
|
2016-03-18 21:34:31 +00:00
|
|
|
\JToolbarHelper::title(\JText::_('COM_PATCHTESTER'), 'patchtester icon-apply');
|
2014-05-03 23:48:08 +00:00
|
|
|
|
|
|
|
if (!count($this->envErrors))
|
|
|
|
{
|
2017-08-17 23:22:01 +00:00
|
|
|
$toolbar = Toolbar::getInstance('toolbar');
|
2016-03-26 22:08:01 +00:00
|
|
|
|
|
|
|
$toolbar->appendButton(
|
2015-02-23 01:49:59 +00:00
|
|
|
'Popup',
|
|
|
|
'refresh',
|
|
|
|
'COM_PATCHTESTER_TOOLBAR_FETCH_DATA',
|
|
|
|
'index.php?option=com_patchtester&view=fetch&tmpl=component',
|
|
|
|
500,
|
|
|
|
210,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
'window.parent.location.reload()',
|
|
|
|
'COM_PATCHTESTER_HEADING_FETCH_DATA'
|
|
|
|
);
|
2016-03-26 22:08:01 +00:00
|
|
|
|
|
|
|
// Add a reset button.
|
|
|
|
$toolbar->appendButton('Standard', 'expired', 'COM_PATCHTESTER_TOOLBAR_RESET', 'reset', false);
|
2014-05-03 23:48:08 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 21:34:31 +00:00
|
|
|
\JToolbarHelper::preferences('com_patchtester');
|
2014-05-03 23:48:08 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 00:44:51 +00:00
|
|
|
/**
|
|
|
|
* Returns an array of values to be used for pagination limits
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*
|
|
|
|
* @since __DEPLOY_VERSION__
|
|
|
|
*/
|
|
|
|
protected function getLimitOptions()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
5 => \JText::_('J5'),
|
|
|
|
10 => \JText::_('J10'),
|
|
|
|
15 => \JText::_('J15'),
|
|
|
|
20 => \JText::_('J20'),
|
|
|
|
25 => \JText::_('J25'),
|
|
|
|
30 => \JText::_('J30'),
|
|
|
|
50 => \JText::_('J50'),
|
|
|
|
100 => \JText::_('J100'),
|
|
|
|
200 => \JText::_('J200'),
|
|
|
|
500 => \JText::_('J500'),
|
|
|
|
0 => \JText::_('JALL'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-05-03 23:48:08 +00:00
|
|
|
/**
|
|
|
|
* Returns an array of fields the table can be sorted by
|
|
|
|
*
|
2019-08-28 00:44:51 +00:00
|
|
|
* @return array
|
2014-05-03 23:48:08 +00:00
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected function getSortFields()
|
|
|
|
{
|
|
|
|
return array(
|
2019-08-28 00:44:51 +00:00
|
|
|
'a.title ASC' => \JText::_('JGLOBAL_TITLE_ASC'),
|
|
|
|
'a.title DESC' => \JText::_('JGLOBAL_TITLE_DESC'),
|
|
|
|
'a.pull_id ASC' => \JText::_('COM_PATCHTESTER_PULL_ID_ASC'),
|
|
|
|
'a.pull_id DESC' => \JText::_('COM_PATCHTESTER_PULL_ID_DESC'),
|
2014-05-03 23:48:08 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|