-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathAbstractListViewBoxController.class.php
More file actions
114 lines (94 loc) · 2.99 KB
/
AbstractListViewBoxController.class.php
File metadata and controls
114 lines (94 loc) · 2.99 KB
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
<?php
namespace wcf\system\box;
use wcf\system\condition\IObjectListCondition;
use wcf\system\event\EventHandler;
use wcf\system\listView\AbstractListView;
use wcf\system\WCF;
/**
* Default implementation of a box controller based on a list view.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*
* @template TListView of AbstractListView
*/
abstract class AbstractListViewBoxController extends AbstractDatabaseObjectListBoxController
{
/**
* @var TListView
*/
protected AbstractListView $listView;
/**
* @return TListView
*/
protected function getListView(): AbstractListView
{
if (!isset($this->listView)) {
$this->listView = $this->createListView();
$this->listView->setAllowFiltering(false);
$this->listView->setAllowSorting(false);
$this->listView->setAllowBulkInteractions(false);
}
return $this->listView;
}
/**
* @return TListView
*/
protected abstract function createListView(): AbstractListView;
#[\Override]
public function hasContent()
{
EventHandler::getInstance()->fireAction($this, 'hasContent');
if ($this->objectList === null) {
$this->loadContent();
}
return $this->getListView()->countItems() > 0;
}
#[\Override]
protected function loadContent()
{
EventHandler::getInstance()->fireAction($this, 'beforeLoadContent');
if ($this->limit) {
$this->getListView()->setFixedNumberOfItems($this->limit);
}
if ($this->sortOrder && $this->sortField) {
$this->getListView()->setSortField($this->sortField);
$this->getListView()->getSortOrder($this->sortOrder);
}
$this->objectList = $this->getObjectList();
if ($this->conditionDefinition) {
foreach ($this->box->getControllerConditions() as $condition) {
$processor = $condition->getObjectType()->getProcessor();
if ($processor instanceof IObjectListCondition) {
$processor->addObjectListCondition($this->objectList, $condition->conditionData);
}
}
}
$this->content = $this->getTemplate();
EventHandler::getInstance()->fireAction($this, 'afterLoadContent');
}
#[\Override]
protected function getObjectList()
{
return $this->getListView()->getObjectList();
}
#[\Override]
protected function getTemplate()
{
return WCF::getTPL()->render('wcf', 'boxListView', [
'listView' => $this->listView,
'containerCssClassName' => $this->getContainerCssClassName(),
]);
}
public function getContainerCssClassName(): string
{
return '';
}
#[\Override]
protected function readObjects()
{
// Does nothing.
}
}