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
2 changes: 1 addition & 1 deletion .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.3'
extensions: ctype, dom, exif, gd, gmp, hash, intl, json, libxml, mbstring, opcache, pcre, pdo, pdo_mysql, zlib
tools: cs2pr, phpcs, php-cs-fixer
- name: phpcs
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
Expand Down
10 changes: 0 additions & 10 deletions acpMenu.xml

This file was deleted.

6 changes: 0 additions & 6 deletions acpTemplateDelete.xml

This file was deleted.

78 changes: 3 additions & 75 deletions acptemplates/discordBotList.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,80 +13,8 @@
</nav>
</header>

{hascontent}
<div class="paginationTop">
{content}
{pages print=true assign=pagesLinks controller='DiscordBotList' link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}
{/content}
</div>
{/hascontent}

{if $objects|count}
<div class="section tabularBox">
<table class="table jsObjectActionContainer" data-object-action-class-name="wcf\data\discord\bot\DiscordBotAction">
<thead>
<tr>
<th class="columnIcon"></th>
<th class="columnID columnBotID{if $sortField == 'botID'} active {$sortOrder}{/if}"><a href="{link controller='DiscordBotList'}pageNo={$pageNo}&sortField=botID&sortOrder={if $sortField == 'botID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
<th class="columnTitle columnBotName{if $sortField == 'botName'} active {$sortOrder}{/if}"><a href="{link controller='DiscordBotList'}pageNo={$pageNo}&sortField=botName&sortOrder={if $sortField == 'botName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.discordBotList.botName{/lang}</a></th>
<th class="columnText columnGuildName{if $sortField == 'guildName'} active {$sortOrder}{/if}"><a href="{link controller='DiscordBotList'}pageNo={$pageNo}&sortField=guildName&sortOrder={if $sortField == 'guildName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.discordBotList.server{/lang}</a></th>
<th class="columnDate columnBotTime{if $sortField == 'botTime'} active {$sortOrder}{/if}"><a href="{link controller='DiscordBotList'}pageNo={$pageNo}&sortField=botTime&sortOrder={if $sortField == 'botTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.date{/lang}</a></th>

{event name='columns'}
</tr>
</thead>

<tbody>
{foreach from=$objects item=discordBot}
<tr class="jsObjectActionObject" data-object-id="{$discordBot->botID}">
<td class="columnIcon">
<a href="{link controller='DiscordBotEdit' id=$discordBot->botID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip">{icon size=16 name='pencil'}</a>
{objectAction action="delete" objectTitle=$discordBot->botName}

{event name='icons'}
</td>
<td class="columnID">
{#$discordBot->botID}
</td>
<td class="columnTitle">
{$discordBot->botName}
</td>
<td class="columnText">
{if !$discordBot->guildIcon|empty}
<img src="https://cdn.discordapp.com/icons/{$discordBot->guildID}/{$discordBot->guildIcon}.png" style="max-width: 32px; border-radius: 50%; margin-right: 10px;">
{/if}
{$discordBot->guildName}
</td>
<td class="columnDate">
{time time=$discordBot->botTime}
</td>

{event name='columnsItem'}
</tr>
{/foreach}
</tbody>
</table>
</div>

<footer class="contentFooter">
{hascontent}
<div class="paginationBottom">
{content}{unsafe:$pagesLinks}{/content}
</div>
{/hascontent}

{hascontent}
<nav class="contentFooterNavigation">
<ul>
{content}
{event name='contentFooterNavigation'}
{/content}
</ul>
</nav>
{/hascontent}
</footer>
{else}
<p class="info">{lang}wcf.global.noItems{/lang}</p>
{/if}
<div class="section">
{unsafe:$gridView->render()}
</div>

{include file='footer'}
89 changes: 3 additions & 86 deletions acptemplates/discordWebhookList.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,91 +6,8 @@
</div>
</header>

{hascontent}
<div class="paginationTop">
{content}
{pages print=true assign=pagesLinks controller='DiscordWebhookList' link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}
{/content}
</div>
{/hascontent}

{if $objects|count}
<div class="section tabularBox">
<table class="table jsObjectActionContainer" data-object-action-class-name="wcf\data\discord\webhook\DiscordWebhookAction">
<thead>
<tr>
<th class="columnIcon"></th>
<th class="columnText columnWebhookID{if $sortField == 'webhookID'} active {$sortOrder}{/if}"><a href="{link controller='DiscordWebhookList'}pageNo={$pageNo}&sortField=webhookID&sortOrder={if $sortField == 'webhookID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
<th class="columnText columnChannelID{if $sortField == 'channelID'} active {$sortOrder}{/if}"><a href="{link controller='DiscordWebhookList'}pageNo={$pageNo}&sortField=channelID&sortOrder={if $sortField == 'channelID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.discordWebhookList.channelID{/lang}</a></th>
<th class="columnText columnWebhookTitle{if $sortField == 'webhookTitle'} active {$sortOrder}{/if}"><a href="{link controller='DiscordWebhookList'}pageNo={$pageNo}&sortField=webhookTitle&sortOrder={if $sortField == 'webhookTitle' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.discordWebhookList.webhookTitle{/lang}</a></th>
<th class="columnText columnWebhook-Name{if $sortField == 'webhookName'} active {$sortOrder}{/if}"><a href="{link controller='DiscordWebhookList'}pageNo={$pageNo}&sortField=webhookName&sortOrder={if $sortField == 'webhookName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.discordWebhookList.webhookName{/lang}</a></th>
<th class="columnText columnBotID{if $sortField == 'botID'} active {$sortOrder}{/if}"><a href="{link controller='DiscordWebhookList'}pageNo={$pageNo}&sortField=botID&sortOrder={if $sortField == 'botID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.discordBotList.server{/lang}</a></th>
<th class="columnDate columnWebhookTime{if $sortField == 'webhookTime'} active {$sortOrder}{/if}"><a href="{link controller='DiscordWebhookList'}pageNo={$pageNo}&sortField=webhookTime&sortOrder={if $sortField == 'webhookTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.date{/lang}</a></th>

{event name='columns'}
</tr>
</thead>

<tbody>
{foreach from=$objects item=webhook}
<tr class="jsObjectActionObject" data-object-id="{$webhook->webhookID}">
<td class="columnIcon">
{objectAction action="delete" objectTitle=$webhook->webhookName}

{event name='icons'}
</td>
<td class="webhookID">
{$webhook->webhookID}
</td>
<td class="webhookID">
{if $channels[$webhook->botID][$webhook->channelID]|isset}
{$channels[$webhook->botID][$webhook->channelID]['name']}<br>({$webhook->channelID})
{else}
{$webhook->channelID}
{/if}
</td>
<td class="columnText">
{$webhook->webhookTitle}
</td>
<td class="columnText">
{$webhook->webhookName}
</td>
<td class="columnText">
{if !$webhook->getDiscordBot()->guildIcon|empty}
<img src="https://cdn.discordapp.com/icons/{$webhook->getDiscordBot()->guildID}/{$webhook->getDiscordBot()->guildIcon}.png" style="max-width: 32px; border-radius: 50%; margin-right: 10px;">
{/if}
{$webhook->getDiscordBot()->guildName}
</td>
<td class="columnDate">
{time time=$webhook->webhookTime}
</td>

{event name='columnsItem'}
</tr>
{/foreach}
</tbody>
</table>
</div>

<footer class="contentFooter">
{hascontent}
<div class="paginationBottom">
{content}{unsafe:$pagesLinks}{/content}
</div>
{/hascontent}

{hascontent}
<nav class="contentFooterNavigation">
<ul>
{content}
{event name='contentFooterNavigation'}
{/content}
</ul>
</nav>
{/hascontent}
</footer>
{else}
<p class="info">{lang}wcf.global.noItems{/lang}</p>
{/if}
<div class="section">
{unsafe:$gridView->render()}
</div>

{include file='footer'}
6 changes: 0 additions & 6 deletions fileDelete.xml

This file was deleted.

32 changes: 10 additions & 22 deletions files/lib/acp/page/DiscordBotListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace wcf\acp\page;

use wcf\data\discord\bot\DiscordBotList;
use wcf\page\SortablePage;
use Override;
use wcf\page\AbstractGridViewPage;
use wcf\system\gridView\AbstractGridView;
use wcf\system\gridView\admin\DiscordBotGridView;

/**
* Übersicht aller Discord-Bots
Expand All @@ -13,7 +15,7 @@
* @license Freie Lizenz (https://hanashi.dev/freie-lizenz/)
* @package WoltLabSuite\Core\Acp\Page
*/
class DiscordBotListPage extends SortablePage
final class DiscordBotListPage extends AbstractGridViewPage
{
/**
* @inheritDoc
Expand All @@ -25,23 +27,9 @@ class DiscordBotListPage extends SortablePage
*/
public $activeMenuItem = 'wcf.acp.menu.link.configuration.discord.discordBotList';

/**
* @inheritDoc
*/
public $objectListClassName = DiscordBotList::class;

/**
* @inheritDoc
*/
public $defaultSortField = 'botID';

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

/**
* @inheritDoc
*/
public $validSortFields = ['botID', 'botName', 'guildID', 'guildName', 'botTime'];
#[Override]
protected function createGridView(): AbstractGridView
{
return new DiscordBotGridView();
}
}
47 changes: 6 additions & 41 deletions files/lib/acp/page/DiscordWebhookListPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
namespace wcf\acp\page;

use Override;
use wcf\data\discord\webhook\DiscordWebhookList;
use wcf\page\SortablePage;
use wcf\system\cache\builder\DiscordGuildChannelsCacheBuilder;
use wcf\system\WCF;
use wcf\page\AbstractGridViewPage;
use wcf\system\gridView\AbstractGridView;
use wcf\system\gridView\admin\DiscordWebhookGridView;

/**
* Übersicht der erstellten Discord-Webhooks
Expand All @@ -16,7 +15,7 @@
* @license Freie Lizenz (https://hanashi.dev/freie-lizenz/)
* @package WoltLabSuite\Core\Acp\Page
*/
class DiscordWebhookListPage extends SortablePage
final class DiscordWebhookListPage extends AbstractGridViewPage
{
/**
* @inheritDoc
Expand All @@ -28,43 +27,9 @@ class DiscordWebhookListPage extends SortablePage
*/
public $activeMenuItem = 'wcf.acp.menu.link.configuration.discord.discordWebhookList';

/**
* @inheritDoc
*/
public $objectListClassName = DiscordWebhookList::class;

/**
* @inheritDoc
*/
public $defaultSortField = 'webhookID';

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

/**
* @inheritDoc
*/
public $validSortFields = ['channelID', 'botID', 'webhookID', 'webhookName', 'webhookTitle', 'webhookTime'];

protected array $channels = [];

#[Override]
public function readData()
protected function createGridView(): AbstractGridView
{
parent::readData();

$this->channels = DiscordGuildChannelsCacheBuilder::getInstance()->getData();
}

#[Override]
public function assignVariables()
{
parent::assignVariables();

WCF::getTPL()->assign([
'channels' => $this->channels,
]);
return new DiscordWebhookGridView();
}
}
11 changes: 11 additions & 0 deletions files/lib/bootstrap/dev.hanashi.wsc.discord-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
use wcf\acp\page\DiscordWebhookListPage;
use wcf\event\acp\dashboard\box\PHPExtensionCollecting;
use wcf\event\acp\menu\item\ItemCollecting;
use wcf\event\endpoint\ControllerCollecting;
use wcf\event\worker\RebuildWorkerCollecting;
use wcf\system\endpoint\controller\hanashi\discord\bot\DeleteBot;
use wcf\system\endpoint\controller\hanashi\discord\webhook\DeleteWebhook;
use wcf\system\event\EventHandler;
use wcf\system\menu\acp\AcpMenuItem;
use wcf\system\request\LinkHandler;
Expand Down Expand Up @@ -77,4 +80,12 @@ static function (RebuildWorkerCollecting $event) {
$event->register(DiscordWebhookAvatarRebuildDataWorker::class, 0);
}
);

EventHandler::getInstance()->register(
ControllerCollecting::class,
static function (ControllerCollecting $event) {
$event->register(new DeleteBot());
$event->register(new DeleteWebhook());
}
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace wcf\event\interaction\admin;

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

final class DiscordBotInteractionCollecting implements IPsr14Event
{
public function __construct(public readonly DiscordBotInteractions $provider)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace wcf\event\interaction\admin;

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

final class DiscordWebhookInteractionCollecting implements IPsr14Event
{
public function __construct(public readonly DiscordWebhookInteractions $provider)
{
}
}
Loading