/
list.php
121 lines (108 loc) · 2.61 KB
/
list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* @package Monitor
* @subpackage admin
*
* @copyright Copyright (C) 2015 Constantin Romankiewicz.
* @license Apache License 2.0; see LICENSE
*/
defined('_JEXEC') or die;
/**
* Abstract class providing functionality common to all list views.
*
* @author Constantin Romankiewicz <constantin@zweiiconkram.de>
* @since 1.0
*/
abstract class MonitorViewList extends MonitorViewAbstract
{
/**
* @var mixed Set of items to be displayed.
*/
protected $items;
/**
* @var string Suffix to append to the title for plural form.
*/
protected $pluralSuffix = 's';
/**
* @var JForm The filter form.
*/
public $filterForm;
/**
* Sets up the toolbar for backend editing.
*
* @return void
*/
protected function addToolbar()
{
$user = JFactory::getUser();
JToolbarHelper::title(JText::_('COM_MONITOR_' . strtoupper($this->name . $this->pluralSuffix)), $this->icon);
if ($user->authorise($this->name . '.create', 'com_monitor'))
{
JToolbarHelper::addNew($this->name . '.edit');
}
if ($user->authorise($this->name . '.edit', 'com_monitor'))
{
JToolbarHelper::editList($this->name . '.edit');
}
if ($user->authorise($this->name . '.delete', 'com_monitor'))
{
JToolbarHelper::deleteList('', $this->name . '.delete');
}
if ($user->authorise('core.admin', 'com_monitor'))
{
JToolBarHelper::preferences('com_monitor');
}
}
/**
* Method to render the view.
*
* @return string The rendered view.
*
* @throws RuntimeException
*/
public function render()
{
// Add sidebar
$this->addSidebar();
$this->sidebar = JHtmlSidebar::render();
if ($this->model)
{
$this->filterForm = $this->model->getFilterForm();
$this->activeFilters = $this->model->getActiveFilters();
}
return parent::render();
}
/**
* Adds a sidebar with links to the admin menu items.
*
* @return null
*/
public function addSidebar()
{
JHtmlSidebar::addEntry(
JText::_('COM_MONITOR_MENU_PROJECTS'),
'?option=com_monitor&view=projects',
$this->name == 'project'
);
JHtmlSidebar::addEntry(
JText::_('COM_MONITOR_MENU_ISSUES'),
'?option=com_monitor&view=issues',
$this->name == 'issue'
);
JHtmlSidebar::addEntry(
JText::_('COM_MONITOR_MENU_COMMENTS'),
'?option=com_monitor&view=comments',
$this->name == 'comment'
);
JHtmlSidebar::addEntry(
JText::_('COM_MONITOR_MENU_STATUS'),
'?option=com_monitor&view=status',
$this->name == 'status'
);
JHtmlSidebar::addEntry(
JText::_('COM_MONITOR_MENU_CLASSIFICATIONS'),
'?option=com_monitor&view=classifications',
$this->name == 'classification'
);
}
}