3 namespace wcf\acp\page
;
5 use wcf\data\label\group\LabelGroup
;
6 use wcf\data\label\group\LabelGroupList
;
7 use wcf\data\label\LabelList
;
8 use wcf\data\language\item\LanguageItemList
;
9 use wcf\page\SortablePage
;
10 use wcf\system\exception\IllegalLinkException
;
11 use wcf\system\language\LanguageFactory
;
12 use wcf\system\request\LinkHandler
;
14 use wcf\util\HeaderUtil
;
15 use wcf\util\StringUtil
;
18 * Lists available labels
20 * @author Alexander Ebert
21 * @copyright 2001-2019 WoltLab GmbH
22 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
23 * @package WoltLabSuite\Core\Acp\Page
25 * @property LabelList $objectList
27 class LabelListPage
extends SortablePage
32 public $activeMenuItem = 'wcf.acp.menu.link.label.list';
37 public $defaultSortField = 'label';
42 public $itemsPerPage = 50;
47 public $validSortFields = ['labelID', 'label', 'groupName', 'showOrder'];
52 public $neededPermissions = ['admin.content.label.canManageLabel'];
57 public $objectListClassName = LabelList
::class;
60 * filter for css class name
63 public $cssClassName = '';
66 * if of the label group to which the displayed labels belong
72 * filter for label name
78 * label group to which the displayed labels belong
84 * list with available label groups
87 public $labelGroupList;
92 public function assignVariables()
94 parent
::assignVariables();
96 WCF
::getTPL()->assign([
97 'cssClassName' => $this->cssClassName
,
98 'groupID' => $this->groupID
,
99 'labelSearch' => $this->label
,
100 'labelGroup' => $this->labelGroup
,
101 'labelGroupList' => $this->labelGroupList
,
108 protected function initObjectList()
110 parent
::initObjectList();
112 $this->objectList
->sqlSelects
= "label_group.groupName, label_group.groupDescription";
113 $this->objectList
->sqlJoins
= "
114 LEFT JOIN wcf" . WCF_N
. "_label_group label_group
115 ON label_group.groupID = label.groupID";
116 if ($this->labelGroup
) {
117 $this->objectList
->getConditionBuilder()->add('label.groupID = ?', [$this->labelGroup
->groupID
]);
119 // Ramp up the limit to display all labels at once for easier
120 // drag & drop sorting. This isn't exactly infinite, but if
121 // you have a label group with more than 1k labels, being able
122 // to sort them is the least of your problems.
123 $this->itemsPerPage
= 1000;
125 if ($this->cssClassName
) {
126 $this->objectList
->getConditionBuilder()->add(
127 'label.cssClassName LIKE ?',
128 ['%' . \addcslashes
($this->cssClassName
, '_%') . '%']
133 $languageItemList = new LanguageItemList();
134 $languageItemList->getConditionBuilder()->add(
135 'languageCategoryID = ?',
136 [LanguageFactory
::getInstance()->getCategory('wcf.acp.label')->languageCategoryID
]
138 $languageItemList->getConditionBuilder()->add('languageID = ?', [WCF
::getLanguage()->languageID
]);
139 $languageItemList->getConditionBuilder()->add('languageItem LIKE ?', ['wcf.acp.label.label%']);
140 $languageItemList->getConditionBuilder()->add(
141 'languageItemValue LIKE ?',
142 ['%' . \addcslashes
($this->label
, '_%') . '%']
144 $languageItemList->readObjects();
147 foreach ($languageItemList as $languageItem) {
148 $labelIDs[] = \
str_replace('wcf.acp.label.label', '', $languageItem->languageItem
);
151 if (!empty($labelIDs)) {
152 $this->objectList
->getConditionBuilder()->add(
153 '(label LIKE ? OR labelID IN (?))',
154 ['%' . \addcslashes
($this->label
, '_%') . '%', $labelIDs]
157 $this->objectList
->getConditionBuilder()->add(
159 ['%' . \addcslashes
($this->label
, '_%') . '%']
168 public function readData()
172 $this->labelGroupList
= new LabelGroupList();
173 $this->labelGroupList
->readObjects();
179 public function readParameters()
181 parent
::readParameters();
183 if (!empty($_POST)) {
185 if (!empty($_POST['groupID'])) {
186 $parameters['id'] = \
intval($_POST['groupID']);
188 if (!empty($_POST['label'])) {
189 $parameters['label'] = StringUtil
::trim($_POST['label']);
191 if (!empty($_POST['cssClassName'])) {
192 $parameters['cssClassName'] = StringUtil
::trim($_POST['cssClassName']);
195 if (!empty($parameters)) {
196 HeaderUtil
::redirect(LinkHandler
::getInstance()->getLink('LabelList', $parameters));
202 if (isset($_REQUEST['id'])) {
203 $this->groupID
= \
intval($_REQUEST['id']);
205 if (isset($_REQUEST['label'])) {
206 $this->label
= StringUtil
::trim($_REQUEST['label']);
208 if (isset($_REQUEST['cssClassName'])) {
209 $this->cssClassName
= StringUtil
::trim($_REQUEST['cssClassName']);
212 if ($this->groupID
) {
213 $this->labelGroup
= new LabelGroup($this->groupID
);
214 if (!$this->labelGroup
->groupID
) {
215 throw new IllegalLinkException();
218 $this->defaultSortField
= 'showOrder';