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
81 changes: 19 additions & 62 deletions wcfsetup/install/files/acp/templates/trophyList.tpl
Original file line number Diff line number Diff line change
@@ -1,82 +1,39 @@
{include file='header' pageTitle='wcf.acp.menu.link.trophy.list'}

<script data-relocate="true">
require(['WoltLabSuite/Core/Ui/Sortable/List'], function (UiSortableList) {
new UiSortableList({
containerId: 'trophyList',
className: 'wcf\\data\\trophy\\TrophyAction',
offset: {@$startIndex}
});
});
</script>

<header class="contentHeader">
<div class="contentHeaderTitle">
<h1 class="contentTitle">{lang}wcf.acp.menu.link.trophy.list{/lang}{if $items} <span class="badge badgeInverse">{#$items}</span>{/if}</h1>
<h1 class="contentTitle">{lang}wcf.acp.menu.link.trophy.list{/lang} <span class="badge badgeInverse">{#$gridView->countRows()}</span></h1>
</div>

<nav class="contentHeaderNavigation">
<ul>
{if $gridView->countRows() > 1}
<li>
<button type="button" class="button jsChangeShowOrder">{icon name='up-down'} <span>{lang}wcf.global.changeShowOrder{/lang}</span></button>
</li>
{/if}
<li><a href="{link controller='TrophyAdd'}{/link}" class="button">{icon name='plus'} <span>{lang}wcf.acp.menu.link.trophy.add{/lang}</span></a></li>

{event name='contentHeaderNavigation'}
</ul>
</nav>
</header>
{hascontent}
<div class="paginationTop">
{content}
{pages print=true assign=pagesLinks controller='TrophyList' link="pageNo=%d"}
{/content}
</div>
{/hascontent}

{if $objects|count}
<div class="section sortableListContainer" id="trophyList">
<ol class="sortableList jsReloadPageWhenEmpty jsObjectActionContainer" data-object-action-class-name="wcf\data\trophy\TrophyAction" data-object-id="0" start="{@($pageNo - 1) * $itemsPerPage + 1}">
{foreach from=$objects item='trophy'}
<li class="sortableNode sortableNoNesting trophyRow jsObjectActionObject" data-object-id="{@$trophy->getObjectID()}">
<span class="sortableNodeLabel">
{@$trophy->renderTrophy(32)}
<a href="{link controller='TrophyEdit' object=$trophy}{/link}">{$trophy->getTitle()}</a>

<span class="statusDisplay sortableButtonContainer">
<span class="sortableNodeHandle">
{icon name='arrows-up-down-left-right'}
</span>
{objectAction action="toggle" isDisabled=$trophy->isDisabled}
<a href="{link controller='TrophyEdit' object=$trophy}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip">{icon name='pencil'}</a>
{objectAction action="delete" objectTitle=$trophy->getTitle()}

{event name='itemButtons'}
</span>
</span>
</li>
{/foreach}
</ol>
</div>

<div class="formSubmit">
<button type="button" class="button buttonPrimary" data-type="submit">{lang}wcf.global.button.saveSorting{/lang}</button>
</div>

<footer class="contentFooter">
{hascontent}
<div class="paginationBottom">
{content}{@$pagesLinks}{/content}
</div>
{/hascontent}
<div class="section">
{unsafe:$gridView->render()}
</div>

<nav class="contentFooterNavigation">
<ul>
<li><a href="{link controller='TrophyAdd'}{/link}" class="button">{icon name='plus'} <span>{lang}wcf.acp.menu.link.trophy.add{/lang}</span></a></li>
{if $gridView->countRows() > 1}
<script data-relocate="true">
require(["WoltLabSuite/Core/Component/ChangeShowOrder"], ({ setup }) => {
{jsphrase name='wcf.global.changeShowOrder'}

{event name='contentHeaderNavigation'}
</ul>
</nav>
</footer>
{else}
<woltlab-core-notice type="info">{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
setup(
document.querySelector('.jsChangeShowOrder'),
'core/trophies/show-order',
);
});
</script>
{/if}

{include file='footer'}
34 changes: 13 additions & 21 deletions wcfsetup/install/files/lib/acp/page/TrophyListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

namespace wcf\acp\page;

use wcf\data\trophy\TrophyList;
use wcf\page\MultipleLinkPage;
use wcf\page\AbstractGridViewPage;
use wcf\system\gridView\AbstractGridView;
use wcf\system\gridView\admin\TrophyGridView;

/**
* Trophy list page.
*
* @author Joshua Ruesweg
* @copyright 2001-2019 WoltLab GmbH
* @author Olaf Braun, Joshua Ruesweg
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 3.1
* @since 3.1
*
* @extends MultipleLinkPage<TrophyList>
* @extends AbstractGridViewPage<TrophyGridView>
*/
class TrophyListPage extends MultipleLinkPage
class TrophyListPage extends AbstractGridViewPage
{
/**
* @inheritDoc
Expand All @@ -32,18 +33,9 @@ class TrophyListPage extends MultipleLinkPage
*/
public $neededPermissions = ['admin.trophy.canManageTrophy'];

/**
* @inheritDoc
*/
public $sortField = 'trophy.showOrder';

/**
* @inheritDoc
*/
public $sortOrder = 'ASC';

/**
* @inheritDoc
*/
public $objectListClassName = TrophyList::class;
#[\Override]
protected function createGridView(): AbstractGridView
{
return new TrophyGridView();
}
}
5 changes: 5 additions & 0 deletions wcfsetup/install/files/lib/bootstrap/com.woltlab.wcf.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ static function (\wcf\event\endpoint\ControllerCollecting $event) {
$event->register(new \wcf\system\endpoint\controller\core\users\groups\assignment\DisableAssignment());
$event->register(new \wcf\system\endpoint\controller\core\users\groups\DeleteGroup());
$event->register(new \wcf\system\endpoint\controller\core\menus\DeleteMenu());
$event->register(new \wcf\system\endpoint\controller\core\trophies\EnableTrophy());
$event->register(new \wcf\system\endpoint\controller\core\trophies\DisableTrophy());
$event->register(new \wcf\system\endpoint\controller\core\trophies\DeleteTrophy());
$event->register(new \wcf\system\endpoint\controller\core\trophies\GetShowOrder());
$event->register(new \wcf\system\endpoint\controller\core\trophies\ChangeShowOrder());
}
);

Expand Down
28 changes: 28 additions & 0 deletions wcfsetup/install/files/lib/data/trophy/I18nTrophyList.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace wcf\data\trophy;

use wcf\data\I18nDatabaseObjectList;

/**
* Represents a trophy list.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*
* @extends I18nDatabaseObjectList<Trophy>
*/
class I18nTrophyList extends I18nDatabaseObjectList
{
/**
* @inheritDoc
*/
public $i18nFields = ['title' => 'titleI18n'];

/**
* @inheritDoc
*/
public $className = Trophy::class;
}
45 changes: 1 addition & 44 deletions wcfsetup/install/files/lib/data/trophy/TrophyAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace wcf\data\trophy;

use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
use wcf\data\IToggleAction;
use wcf\data\IUploadAction;
use wcf\data\TDatabaseObjectToggle;
Expand All @@ -29,7 +28,7 @@
*
* @extends AbstractDatabaseObjectAction<Trophy, TrophyEditor>
*/
class TrophyAction extends AbstractDatabaseObjectAction implements IToggleAction, IUploadAction, ISortableAction
class TrophyAction extends AbstractDatabaseObjectAction implements IToggleAction, IUploadAction
{
use TDatabaseObjectToggle;

Expand Down Expand Up @@ -310,46 +309,4 @@ protected function updateTrophyImage(Trophy $trophy)
}
}
}

/**
* @inheritDoc
*/
public function validateUpdatePosition()
{
WCF::getSession()->checkPermissions($this->permissionsUpdate);

if (!isset($this->parameters['data']['structure']) || !\is_array($this->parameters['data']['structure'])) {
throw new UserInputException('structure');
}

$trophyList = new TrophyList();
$trophyList->setObjectIDs($this->parameters['data']['structure'][0]);
$trophyList->readObjects();
if (\count($trophyList) !== \count($this->parameters['data']['structure'][0])) {
throw new UserInputException('structure');
}

$this->readInteger('offset', true, 'data');
}

/**
* @inheritDoc
*/
public function updatePosition()
{
$sql = "UPDATE wcf1_trophy
SET showOrder = ?
WHERE trophyID = ?";
$statement = WCF::getDB()->prepare($sql);

$showOrder = $this->parameters['data']['offset'];
WCF::getDB()->beginTransaction();
foreach ($this->parameters['data']['structure'][0] as $trophyID) {
$statement->execute([
$showOrder++,
$trophyID,
]);
}
WCF::getDB()->commitTransaction();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\gridView\admin;

use wcf\event\IPsr14Event;
use wcf\system\gridView\admin\TrophyGridView;

/**
* Indicates that the trophy grid view has been initialized.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class TrophyGridViewInitialized implements IPsr14Event
{
public function __construct(public readonly TrophyGridView $param)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\interaction\admin;

use wcf\event\IPsr14Event;
use wcf\system\interaction\admin\TrophyInteractions;

/**
* Indicates that the provider for trophies is collecting interactions.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class TrophyInteractionCollecting implements IPsr14Event
{
public function __construct(public readonly TrophyInteractions $param)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace wcf\event\interaction\bulk\admin;

use wcf\event\IPsr14Event;
use wcf\system\interaction\bulk\admin\TrophyBulkInteractions;

/**
* Indicates that the provider for trophy bulk interactions is collecting interactions.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class TrophyBulkInteractionCollecting implements IPsr14Event
{
public function __construct(public readonly TrophyBulkInteractions $param)
{
}
}
Loading