-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathContactOptionGridView.class.php
More file actions
118 lines (106 loc) · 3.88 KB
/
ContactOptionGridView.class.php
File metadata and controls
118 lines (106 loc) · 3.88 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
115
116
117
118
<?php
namespace wcf\system\gridView\admin;
use wcf\acp\form\ContactOptionEditForm;
use wcf\data\contact\option\ContactOption;
use wcf\data\contact\option\ContactOptionList;
use wcf\event\gridView\admin\ContactOptionGridViewInitialized;
use wcf\system\form\option\FormOptionHandler;
use wcf\system\gridView\AbstractGridView;
use wcf\system\gridView\GridViewColumn;
use wcf\system\gridView\GridViewRowLink;
use wcf\system\gridView\renderer\NumberColumnRenderer;
use wcf\system\gridView\renderer\ObjectIdColumnRenderer;
use wcf\system\gridView\renderer\PhraseColumnRenderer;
use wcf\system\interaction\admin\ContactOptionInteractions;
use wcf\system\interaction\Divider;
use wcf\system\interaction\EditInteraction;
use wcf\system\interaction\ToggleInteraction;
use wcf\system\view\filter\I18nTextFilter;
use wcf\system\view\filter\IntegerFilter;
use wcf\system\view\filter\SelectFilter;
use wcf\system\WCF;
/**
* Grid view for the list of contact options.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*
* @extends AbstractGridView<ContactOption, ContactOptionList>
*/
final class ContactOptionGridView extends AbstractGridView
{
public function __construct()
{
$this->addColumns([
GridViewColumn::for("optionID")
->label("wcf.global.objectID")
->renderer(new ObjectIdColumnRenderer())
->sortable(),
GridViewColumn::for("optionTitle")
->label("wcf.global.name")
->renderer(new PhraseColumnRenderer())
->filter(I18nTextFilter::class)
->titleColumn()
->sortable(sortByDatabaseColumn: $this->subqueryOptionTitle()),
GridViewColumn::for("optionType")
->label("wcf.acp.customOption.optionType")
->filter(new SelectFilter(
FormOptionHandler::getInstance()->getSortedOptionTypes(),
'optionType',
'wcf.acp.customOption.optionType'
))
->sortable(),
GridViewColumn::for("showOrder")
->label("wcf.acp.customOption.showOrder")
->filter(IntegerFilter::class)
->renderer(new NumberColumnRenderer())
->sortable(),
]);
$provider = new ContactOptionInteractions();
$provider->addInteractions([
new Divider(),
new EditInteraction(ContactOptionEditForm::class),
]);
$this->setInteractionProvider($provider);
$this->addQuickInteraction(
new ToggleInteraction(
'enable',
'core/contact/options/%s/enable',
'core/contact/options/%s/disable'
)
);
$this->addRowLink(new GridViewRowLink(ContactOptionEditForm::class));
$this->setDefaultSortField("showOrder");
$this->setDefaultSortOrder("ASC");
}
#[\Override]
public function isAccessible(): bool
{
return \MODULE_CONTACT_FORM
&& WCF::getSession()->getPermission("admin.contact.canManageContactForm");
}
#[\Override]
protected function createObjectList(): ContactOptionList
{
return new ContactOptionList();
}
private function subqueryOptionTitle(): string
{
$languageID = WCF::getLanguage()->languageID;
return "
COALESCE((
SELECT languageItemValue
FROM wcf1_language_item
WHERE languageItem = contact_option.optionTitle
AND languageID = {$languageID}
), contact_option.optionTitle)
";
}
#[\Override]
protected function getInitializedEvent(): ContactOptionGridViewInitialized
{
return new ContactOptionGridViewInitialized($this);
}
}