Commit | Line | Data |
---|---|---|
04c06e85 | 1 | <?php |
a9229942 | 2 | |
04c06e85 | 3 | namespace wcf\acp\page; |
a9229942 | 4 | |
157054c9 | 5 | use wcf\data\tag\TagList; |
04c06e85 | 6 | use wcf\page\SortablePage; |
ea3185a0 | 7 | use wcf\system\clipboard\ClipboardHandler; |
04c06e85 MW |
8 | use wcf\system\WCF; |
9 | use wcf\util\StringUtil; | |
10 | ||
11 | /** | |
12 | * Shows a list of tags. | |
a9229942 TD |
13 | * |
14 | * @author Tim Duesterhus | |
15 | * @copyright 2001-2019 WoltLab GmbH | |
16 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
a9229942 TD |
17 | * |
18 | * @property TagList $objectList | |
04c06e85 | 19 | */ |
a9229942 TD |
20 | class TagListPage extends SortablePage |
21 | { | |
22 | /** | |
23 | * @inheritDoc | |
24 | */ | |
25 | public $activeMenuItem = 'wcf.acp.menu.link.tag.list'; | |
26 | ||
27 | /** | |
28 | * @inheritDoc | |
29 | */ | |
30 | public $neededPermissions = ['admin.content.tag.canManageTag']; | |
31 | ||
32 | /** | |
33 | * @inheritDoc | |
34 | */ | |
35 | public $neededModules = ['MODULE_TAGGING']; | |
36 | ||
37 | /** | |
38 | * @inheritDoc | |
39 | */ | |
40 | public $defaultSortField = 'name'; | |
41 | ||
42 | /** | |
43 | * @inheritDoc | |
44 | */ | |
45 | public $validSortFields = ['tagID', 'languageID', 'name', 'usageCount']; | |
46 | ||
47 | /** | |
48 | * @inheritDoc | |
49 | */ | |
50 | public $objectListClassName = TagList::class; | |
51 | ||
52 | /** | |
53 | * search-query | |
54 | * @var string | |
55 | */ | |
56 | public $search = ''; | |
57 | ||
58 | /** | |
59 | * @inheritDoc | |
60 | */ | |
61 | public function assignVariables() | |
62 | { | |
63 | parent::assignVariables(); | |
64 | ||
65 | WCF::getTPL()->assign([ | |
66 | 'hasMarkedItems' => ClipboardHandler::getInstance()->hasMarkedItems(ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.tag')), | |
67 | 'search' => $this->search, | |
68 | ]); | |
69 | } | |
70 | ||
71 | /** | |
72 | * @inheritDoc | |
73 | */ | |
74 | public function readParameters() | |
75 | { | |
76 | parent::readParameters(); | |
77 | ||
78 | if (isset($_REQUEST['search'])) { | |
79 | $this->search = StringUtil::trim($_REQUEST['search']); | |
80 | } | |
81 | } | |
82 | ||
83 | /** | |
84 | * @inheritDoc | |
85 | */ | |
86 | protected function initObjectList() | |
87 | { | |
88 | parent::initObjectList(); | |
89 | ||
94d12f75 MS |
90 | $this->objectList->sqlSelects = "( |
91 | SELECT COUNT(*) | |
92 | FROM wcf" . WCF_N . "_tag_to_object t2o | |
93 | WHERE t2o.tagID = tag.tagID | |
94 | ) AS usageCount"; | |
a9229942 TD |
95 | $this->objectList->sqlSelects .= ", language.languageName, language.languageCode"; |
96 | $this->objectList->sqlSelects .= ", synonym.name AS synonymName"; | |
97 | ||
d3bd0a85 MS |
98 | $this->objectList->sqlJoins = " |
99 | LEFT JOIN wcf" . WCF_N . "_language language | |
100 | ON tag.languageID = language.languageID | |
101 | LEFT JOIN wcf" . WCF_N . "_tag synonym | |
102 | ON tag.synonymFor = synonym.tagID"; | |
a9229942 TD |
103 | |
104 | if ($this->search !== '') { | |
105 | $this->objectList->getConditionBuilder()->add('tag.name LIKE ?', [$this->search . '%']); | |
106 | } | |
107 | } | |
04c06e85 | 108 | } |