Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions com.woltlab.wcf/templates/deletedContentList.tpl
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
{capture assign='pageTitle'}{lang}wcf.moderation.deletedContent.{@$objectType}{/lang}{/capture}

{capture assign='sidebarRight'}
<section class="box" data-static-box-identifier="com.woltlab.wcf.DeletedContentListMenu">
<h2 class="boxTitle">{lang}wcf.moderation.deletedContent.objectTypes{/lang}</h2>

<div class="boxContent">
<nav>
<ul class="boxMenu">
{foreach from=$availableObjectTypes item=availableObjectType}
<li{if $objectType == $availableObjectType->objectType} class="active"{/if}><a class="boxMenuLink" href="{link controller='DeletedContentList'}objectType={@$availableObjectType->objectType}{/link}">{lang}wcf.moderation.deletedContent.objectType.{@$availableObjectType->objectType}{/lang}</a></li>
{/foreach}
</ul>
</nav>
</div>
</section>
{unsafe:$deletedItemsBox->render()}
{/capture}

{capture assign='contentTitle'}{lang}wcf.moderation.deletedContent.{@$objectType}{/lang}{/capture}
Expand Down
15 changes: 15 additions & 0 deletions com.woltlab.wcf/templates/deletedItemsBox.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<section class="box" data-static-box-identifier="com.woltlab.wcf.DeletedContentListMenu">
<h2 class="boxTitle">{lang}wcf.moderation.deletedContent.objectTypes{/lang}</h2>

<div class="boxContent">
<nav>
<ul class="boxMenu">
{foreach from=$types item=type}
<li{if $type->id === $activeId} class="active"{/if}>
<a class="boxMenuLink" href="{$type->link}">{lang}{$type->languageItem}{/lang}</a>
</li>
{/foreach}
</ul>
</nav>
</div>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace wcf\event\moderation;

use wcf\data\object\type\ObjectTypeCache;
use wcf\event\IPsr14Event;
use wcf\page\DeletedContentListPage;
use wcf\system\moderation\DeletedItems;
use wcf\system\request\LinkHandler;

/**
* Requests the collection of deleted item types.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class DeletedItemsCollecting implements IPsr14Event
{
/**
* @var list<DeletedItems>
*/
private array $types = [];

public function __construct()
{
$this->loadLegacyProviders();
}

public function register(DeletedItems $type): void
{
$this->types[] = $type;
}

/**
* @return list<DeletedItems>
*/
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]
)
));
}
}
}
33 changes: 25 additions & 8 deletions wcfsetup/install/files/lib/page/DeletedContentListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @author Matthias Schmidt
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @deprecated 6.2 Use `DeletedItems` instead
*
* @template T of DatabaseObjectList
* @implements IDeletedContentProvider<T>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace wcf\system\moderation;

/**
* Represents a type of deleted items.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
class DeletedItems
{
public function __construct(
public readonly string $id,
public readonly string $languageItem,
public readonly string $link
) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace wcf\system\moderation;

use wcf\event\moderation\DeletedItemsCollecting;
use wcf\system\event\EventHandler;
use wcf\system\WCF;

/**
* Represents the deleted items box.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @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<DeletedItems>
*/
private function getTypes(): array
{
$event = new DeletedItemsCollecting();
EventHandler::getInstance()->fire($event);

return $event->getTypes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @author Marcel Werk
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @deprecated 6.2 Use `DeletedItems` instead
*
* @template T of DatabaseObjectList
*/
Expand Down