diff --git a/com.woltlab.wcf/templates/deletedContentList.tpl b/com.woltlab.wcf/templates/deletedContentList.tpl index 8041634ba62..60fa0949626 100644 --- a/com.woltlab.wcf/templates/deletedContentList.tpl +++ b/com.woltlab.wcf/templates/deletedContentList.tpl @@ -1,19 +1,7 @@ {capture assign='pageTitle'}{lang}wcf.moderation.deletedContent.{@$objectType}{/lang}{/capture} {capture assign='sidebarRight'} -
-

{lang}wcf.moderation.deletedContent.objectTypes{/lang}

- -
- -
-
+ {unsafe:$deletedItemsBox->render()} {/capture} {capture assign='contentTitle'}{lang}wcf.moderation.deletedContent.{@$objectType}{/lang}{/capture} diff --git a/com.woltlab.wcf/templates/deletedItemsBox.tpl b/com.woltlab.wcf/templates/deletedItemsBox.tpl new file mode 100644 index 00000000000..773bf4b6f43 --- /dev/null +++ b/com.woltlab.wcf/templates/deletedItemsBox.tpl @@ -0,0 +1,15 @@ +
+

{lang}wcf.moderation.deletedContent.objectTypes{/lang}

+ +
+ +
+
diff --git a/wcfsetup/install/files/lib/event/moderation/DeletedItemsCollecting.class.php b/wcfsetup/install/files/lib/event/moderation/DeletedItemsCollecting.class.php new file mode 100644 index 00000000000..f26ed8897ed --- /dev/null +++ b/wcfsetup/install/files/lib/event/moderation/DeletedItemsCollecting.class.php @@ -0,0 +1,61 @@ + + * @since 6.2 + */ +final class DeletedItemsCollecting implements IPsr14Event +{ + /** + * @var list + */ + private array $types = []; + + public function __construct() + { + $this->loadLegacyProviders(); + } + + public function register(DeletedItems $type): void + { + $this->types[] = $type; + } + + /** + * @return list + */ + public function getTypes(): array + { + return $this->types; + } + + /** + * @deprecated 6.2 + */ + private function loadLegacyProviders(): void + { + $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.deletedContent'); + foreach ($objectTypes as $objectType) { + $this->register(new DeletedItems( + $objectType->objectType, + 'wcf.moderation.deletedContent.objectType.' . $objectType->objectType, + LinkHandler::getInstance()->getControllerLink( + DeletedContentListPage::class, + ['objectType' => $objectType->objectType] + ) + )); + } + } +} diff --git a/wcfsetup/install/files/lib/page/DeletedContentListPage.class.php b/wcfsetup/install/files/lib/page/DeletedContentListPage.class.php index 81c021df51a..cc5d5aa6350 100644 --- a/wcfsetup/install/files/lib/page/DeletedContentListPage.class.php +++ b/wcfsetup/install/files/lib/page/DeletedContentListPage.class.php @@ -2,10 +2,14 @@ namespace wcf\page; +use Laminas\Diactoros\Response\RedirectResponse; use wcf\data\DatabaseObject; use wcf\data\DatabaseObjectList; use wcf\data\object\type\ObjectTypeCache; +use wcf\event\moderation\DeletedItemsCollecting; +use wcf\system\event\EventHandler; use wcf\system\exception\IllegalLinkException; +use wcf\system\moderation\DeletedItemsBoxComponent; use wcf\system\WCF; /** @@ -42,23 +46,36 @@ public function readParameters() { parent::readParameters(); - // get object type if (isset($_REQUEST['objectType'])) { $this->objectType = ObjectTypeCache::getInstance()->getObjectTypeByName( 'com.woltlab.wcf.deletedContent', $_REQUEST['objectType'] ); + + if ($this->objectType === null) { + throw new IllegalLinkException(); + } } else { - // use first object type - $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.deletedContent'); - if (!empty($objectTypes)) { - $this->objectType = \reset($objectTypes); + $link = $this->getFirstTypeLink(); + if ($link === null) { + throw new IllegalLinkException(); } + + return new RedirectResponse($link); } + } - if ($this->objectType === null) { - throw new IllegalLinkException(); + private function getFirstTypeLink(): ?string + { + $event = new DeletedItemsCollecting(); + EventHandler::getInstance()->fire($event); + $types = $event->getTypes(); + + if ($types === []) { + return null; } + + return reset($types)->link; } /** @@ -77,7 +94,7 @@ public function assignVariables() parent::assignVariables(); WCF::getTPL()->assign([ - 'availableObjectTypes' => ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.deletedContent'), + 'deletedItemsBox' => new DeletedItemsBoxComponent($this->objectType->objectType), 'objectType' => $this->objectType->objectType, 'resultListTemplateName' => $this->objectType->getProcessor()->getTemplateName(), 'resultListApplication' => $this->objectType->getProcessor()->getApplication(), diff --git a/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php b/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php index 8e08cf33b71..51abd091296 100644 --- a/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php +++ b/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php @@ -11,6 +11,7 @@ * @author Matthias Schmidt * @copyright 2001-2019 WoltLab GmbH * @license GNU Lesser General Public License + * @deprecated 6.2 Use `DeletedItems` instead * * @template T of DatabaseObjectList * @implements IDeletedContentProvider diff --git a/wcfsetup/install/files/lib/system/moderation/DeletedItems.class.php b/wcfsetup/install/files/lib/system/moderation/DeletedItems.class.php new file mode 100644 index 00000000000..323bf9d6e9e --- /dev/null +++ b/wcfsetup/install/files/lib/system/moderation/DeletedItems.class.php @@ -0,0 +1,20 @@ + + * @since 6.2 + */ +class DeletedItems +{ + public function __construct( + public readonly string $id, + public readonly string $languageItem, + public readonly string $link + ) {} +} diff --git a/wcfsetup/install/files/lib/system/moderation/DeletedItemsBoxComponent.class.php b/wcfsetup/install/files/lib/system/moderation/DeletedItemsBoxComponent.class.php new file mode 100644 index 00000000000..bc4fd3aa367 --- /dev/null +++ b/wcfsetup/install/files/lib/system/moderation/DeletedItemsBoxComponent.class.php @@ -0,0 +1,45 @@ + + * @since 6.2 + */ +class DeletedItemsBoxComponent +{ + public function __construct( + public readonly string $activeId, + ) {} + + public function render(): string + { + return WCF::getTPL()->render( + 'wcf', + 'deletedItemsBox', + [ + 'types' => $this->getTypes(), + 'activeId' => $this->activeId, + ], + ); + } + + /** + * @return list + */ + private function getTypes(): array + { + $event = new DeletedItemsCollecting(); + EventHandler::getInstance()->fire($event); + + return $event->getTypes(); + } +} diff --git a/wcfsetup/install/files/lib/system/moderation/IDeletedContentProvider.class.php b/wcfsetup/install/files/lib/system/moderation/IDeletedContentProvider.class.php index f28ba639622..353de73a906 100644 --- a/wcfsetup/install/files/lib/system/moderation/IDeletedContentProvider.class.php +++ b/wcfsetup/install/files/lib/system/moderation/IDeletedContentProvider.class.php @@ -10,6 +10,7 @@ * @author Marcel Werk * @copyright 2001-2019 WoltLab GmbH * @license GNU Lesser General Public License + * @deprecated 6.2 Use `DeletedItems` instead * * @template T of DatabaseObjectList */