|
2 | 2 |
|
3 | 3 | namespace wcf\page; |
4 | 4 |
|
| 5 | +use Laminas\Diactoros\Response\RedirectResponse; |
5 | 6 | use wcf\data\DatabaseObject; |
6 | 7 | use wcf\data\DatabaseObjectList; |
7 | 8 | use wcf\data\object\type\ObjectType; |
|
10 | 11 | use wcf\data\tag\TagList; |
11 | 12 | use wcf\system\exception\IllegalLinkException; |
12 | 13 | use wcf\system\exception\PermissionDeniedException; |
| 14 | +use wcf\system\request\LinkHandler; |
13 | 15 | use wcf\system\tagging\ICombinedTaggable; |
| 16 | +use wcf\system\tagging\ITaggedListViewProvider; |
14 | 17 | use wcf\system\tagging\TypedTagCloud; |
15 | 18 | use wcf\system\WCF; |
16 | 19 | use wcf\util\ArrayUtil; |
|
23 | 26 | * @copyright 2001-2019 WoltLab GmbH |
24 | 27 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
25 | 28 | * @since 5.2 |
| 29 | + * @deprecated 6.2 Use `TaggedListViewPage` instead. |
26 | 30 | * |
27 | 31 | * @extends MultipleLinkPage<DatabaseObjectList<DatabaseObject>> |
28 | 32 | */ |
@@ -104,10 +108,6 @@ public function readParameters() |
104 | 108 | if (!$objectType->validateOptions() || !$objectType->validatePermissions()) { |
105 | 109 | unset($this->availableObjectTypes[$key]); |
106 | 110 | } |
107 | | - |
108 | | - if (!($objectType->getProcessor() instanceof ICombinedTaggable)) { |
109 | | - unset($this->availableObjectTypes[$key]); |
110 | | - } |
111 | 111 | } |
112 | 112 |
|
113 | 113 | if (empty($this->availableObjectTypes)) { |
@@ -135,7 +135,16 @@ public function readParameters() |
135 | 135 | } |
136 | 136 | } |
137 | 137 |
|
138 | | - $this->processor = $this->objectType->getProcessor(); |
| 138 | + if ($this->objectType->getProcessor() instanceof ITaggedListViewProvider) { |
| 139 | + return new RedirectResponse( |
| 140 | + LinkHandler::getInstance()->getControllerLink(TaggedListViewPage::class, [ |
| 141 | + 'objectType' => $this->objectType->objectType, |
| 142 | + 'tagIDs' => $this->tagIDs, |
| 143 | + ]), |
| 144 | + ); |
| 145 | + } else { |
| 146 | + $this->processor = $this->objectType->getProcessor(); |
| 147 | + } |
139 | 148 | } |
140 | 149 |
|
141 | 150 | /** |
@@ -171,19 +180,58 @@ public function assignVariables() |
171 | 180 | 'resultListTemplateName' => $this->processor->getTemplateName(), |
172 | 181 | 'resultListApplication' => $this->processor->getApplication(), |
173 | 182 | 'itemsPerType' => $this->itemsPerType, |
| 183 | + 'objectTypeLinks' => $this->getObjectTypeLinks(), |
174 | 184 | ]); |
175 | 185 |
|
176 | 186 | if (\count($this->objectList) === 0) { |
177 | 187 | @\header('HTTP/1.1 404 Not Found'); |
178 | 188 | } |
179 | 189 | } |
180 | 190 |
|
181 | | - private function readItemsPerType(): void |
| 191 | + protected function getObjectTypeLinks(): array |
| 192 | + { |
| 193 | + $links = []; |
| 194 | + foreach ($this->availableObjectTypes as $objectType) { |
| 195 | + if ($objectType->getProcessor() instanceof ITaggedListViewProvider) { |
| 196 | + $processor = $objectType->getProcessor(); |
| 197 | + \assert($processor instanceof ITaggedListViewProvider); |
| 198 | + |
| 199 | + $title = $processor->getObjectTypeTitle(); |
| 200 | + $controller = TaggedListViewPage::class; |
| 201 | + } else { |
| 202 | + $title = WCF::getLanguage()->get('wcf.tagging.objectType.' . $objectType->objectType); |
| 203 | + $controller = CombinedTaggedPage::class; |
| 204 | + } |
| 205 | + |
| 206 | + $links[] = [ |
| 207 | + 'objectType' => $objectType->objectType, |
| 208 | + 'title' => $title, |
| 209 | + 'link' => LinkHandler::getInstance()->getControllerLink( |
| 210 | + $controller, |
| 211 | + [ |
| 212 | + 'objectType' => $objectType->objectType, |
| 213 | + 'tagIDs' => $this->tagIDs |
| 214 | + ] |
| 215 | + ), |
| 216 | + 'items' => $this->itemsPerType[$objectType->objectType] ?? 0, |
| 217 | + ]; |
| 218 | + } |
| 219 | + |
| 220 | + return $links; |
| 221 | + } |
| 222 | + |
| 223 | + protected function readItemsPerType(): void |
182 | 224 | { |
183 | 225 | foreach ($this->availableObjectTypes as $key => $objectType) { |
184 | | - $objectList = $objectType->getProcessor()->getObjectListFor($this->tags); |
185 | | - \assert($objectList instanceof DatabaseObjectList); |
186 | | - $this->itemsPerType[$key] = $objectList->countObjects(); |
| 226 | + if ($objectType->getProcessor() instanceof ITaggedListViewProvider) { |
| 227 | + $processor = $objectType->getProcessor(); |
| 228 | + \assert($processor instanceof ITaggedListViewProvider); |
| 229 | + $this->itemsPerType[$key] = $processor->getListView($this->tagIDs)->countItems(); |
| 230 | + } else { |
| 231 | + $objectList = $objectType->getProcessor()->getObjectListFor($this->tags); |
| 232 | + \assert($objectList instanceof DatabaseObjectList); |
| 233 | + $this->itemsPerType[$key] = $objectList->countObjects(); |
| 234 | + } |
187 | 235 | } |
188 | 236 | } |
189 | 237 | } |
0 commit comments