Passed
Pull Request — develop (#922)
by Tito
07:09
created

RedcoreViewWebservice_History_Logs   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 122
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 48
c 2
b 0
f 0
dl 0
loc 122
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 3 1
A getToolbar() 0 25 2
A display() 0 41 3
1
<?php
2
/**
3
 * @package     Redcore.Admin
4
 * @subpackage  Views
5
 *
6
 * @copyright   Copyright (C) 2008 - 2018 redCOMPONENT.com. All rights reserved.
7
 * @license     GNU General Public License version 2 or later, see LICENSE.
8
 */
9
10
defined('_JEXEC') or die;
11
12
/**
13
 * Webservices View
14
 *
15
 * @package     Redcore.Admin
16
 * @subpackage  Views
17
 * @since       1.2
18
 */
19
class RedcoreViewWebservice_History_Logs extends RedcoreHelpersView
20
{
21
	/**
22
	 * @var  array
23
	 */
24
	public $items;
25
26
	/**
27
	 * @var  object
28
	 */
29
	public $state;
30
31
	/**
32
	 * @var  JPagination
33
	 */
34
	public $pagination;
35
36
	/**
37
	 * @var  JForm
38
	 */
39
	public $filterForm;
40
41
	/**
42
	 * @var array
43
	 */
44
	public $activeFilters;
45
46
	/**
47
	 * @var array
48
	 */
49
	public $stoolsOptions = array();
50
51
	/**
52
	 * Display method
53
	 *
54
	 * @param   string  $tpl  The template name
55
	 *
56
	 * @return  void
57
	 */
58
	public function display($tpl = null)
59
	{
60
		$model = $this->getModel();
61
62
		$this->activeFilters = $model->getActiveFilters();
63
		$this->state         = $model->getState();
64
		$this->filterForm    = $model->getForm();
65
		$this->pagination    = $model->getPagination();
66
		$this->items         = $model->getItems();
67
68
		$this->return = base64_encode('index.php?option=com_redcore&view=webservice_history_logs');
0 ignored issues
show
Bug Best Practice introduced by
The property return does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
69
70
		// Check if option is enabled
71
		if (RBootstrap::getConfig('enable_webservices', 0) == 0)
72
		{
73
			JFactory::getApplication()->enqueueMessage(
74
				JText::sprintf(
75
					'COM_REDCORE_WEBSERVICES_PLUGIN_LABEL_WARNING',
76
					'<a href="index.php?option=com_redcore&view=config&layout=edit&component=com_redcore&return=' . $this->return . '">'
77
					. JText::_('COM_REDCORE_CONFIGURE')
78
					. '</a>'
79
				),
80
				'error'
81
			);
82
		}
83
84
		// Check if option is enabled
85
		if (RBootstrap::getConfig('enable_webservice_history_log', 0) == 0)
86
		{
87
			JFactory::getApplication()->enqueueMessage(
88
				JText::sprintf(
89
					'COM_REDCORE_WEBSERVICES_HISTORY_LOGS_PLUGIN_LABEL_WARNING',
90
					'<a href="index.php?option=com_redcore&view=config&layout=edit&component=com_redcore&return=' . $this->return . '">'
91
					. JText::_('COM_REDCORE_CONFIGURE')
92
					. '</a>'
93
				),
94
				'error'
95
			);
96
		}
97
98
		parent::display($tpl);
99
	}
100
101
	/**
102
	 * Get the view title.
103
	 *
104
	 * @return  string  The view title.
105
	 */
106
	public function getTitle()
107
	{
108
		return JText::_('COM_REDCORE_WEBSERVICE_HISTORY_LOGS_TITLE');
109
	}
110
111
	/**
112
	 * Get the toolbar to render.
113
	 *
114
	 * @return RToolbar
115
	 */
116
	public function getToolbar()
117
	{
118
		$group       = new RToolbarButtonGroup;
119
		$secondGroup = new RToolbarButtonGroup;
120
		$user        = JFactory::getUser();
121
122
		if ($user->authorise('core.admin', 'com_redcore'))
123
		{
124
			$button = RToolbarBuilder::createStandardButton(
125
				'webservice_history_logs.downloadResponseData',
126
				'COM_REDCORE_WEBSERVICE_HISTORY_LOGS_DOWNLOAD_RESPONSE_DATA',
127
				'btn-default',
128
				'icon-download'
129
			);
130
			$group->addButton($button);
131
132
			$delete = RToolbarBuilder::createDeleteButton('webservice_history_logs.delete');
133
			$secondGroup->addButton($delete);
134
		}
135
136
		$toolbar = new RToolbar;
137
		$toolbar->addGroup($group)
138
			->addGroup($secondGroup);
139
140
		return $toolbar;
141
	}
142
}
143