79 lines
3.1 KiB
PHP
79 lines
3.1 KiB
PHP
<?php
|
|
class BlueArchiveNewsBridge extends BridgeAbstract {
|
|
const MAINTAINER = 'Akamaru';
|
|
const NAME = 'Blue Archive News';
|
|
const URI = 'https://forum.nexon.com/bluearchive-en/';
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
|
const DESCRIPTION = 'Get the latest Announcements, Updates, and Events from Blue Archive (EN) Forum.';
|
|
|
|
public function getIcon() {
|
|
return 'https://img.ponywave.de/images/2025/07/18/Shiroko_Icon.png';
|
|
}
|
|
|
|
const PARAMETERS = [
|
|
[
|
|
'category' => [
|
|
'name' => 'Category',
|
|
'type' => 'list',
|
|
'values' => [
|
|
'All' => 'all',
|
|
'Announcements' => '3028',
|
|
'Updates' => '3217',
|
|
'Events' => '3218',
|
|
],
|
|
'defaultValue' => '3028',
|
|
],
|
|
],
|
|
];
|
|
|
|
public function collectData() {
|
|
$category = $this->getInput('category');
|
|
$boardIds = [];
|
|
if ($category === 'all') {
|
|
$boardIds = ['3028', '3217', '3218'];
|
|
} else {
|
|
$boardIds = [$category];
|
|
}
|
|
$allThreads = [];
|
|
foreach ($boardIds as $boardId) {
|
|
$jsonUrl = "https://forum.nexon.com/api/v1/board/{$boardId}/threads?alias=bluearchive-en&pageNo=1&paginationType=PAGING&pageSize=10&blockSize=5&hideType=WEB";
|
|
$json = getContents($jsonUrl);
|
|
if (!$json) continue;
|
|
$data = json_decode($json, true);
|
|
if (!isset($data['threads'])) continue;
|
|
foreach ($data['threads'] as $thread) {
|
|
$thread['boardId'] = $boardId; // sicherstellen, dass boardId korrekt ist
|
|
$allThreads[] = $thread;
|
|
}
|
|
}
|
|
// Nach createDate absteigend sortieren
|
|
usort($allThreads, function($a, $b) {
|
|
return $b['createDate'] <=> $a['createDate'];
|
|
});
|
|
// Maximal 10 insgesamt
|
|
$threads = array_slice($allThreads, 0, 10);
|
|
foreach ($threads as $thread) {
|
|
$item = array();
|
|
$item['title'] = html_entity_decode($thread['title']);
|
|
$item['uri'] = 'https://forum.nexon.com/bluearchive-en/board_view?board=' . $thread['boardId'] . '&thread=' . $thread['threadId'];
|
|
$item['author'] = $thread['user']['nickname'] ?? '';
|
|
$item['timestamp'] = $thread['createDate'];
|
|
$item['uid'] = $thread['threadId'];
|
|
$item['enclosures'] = array();
|
|
// Fetch thread content
|
|
$threadApiUrl = 'https://forum.nexon.com/api/v1/thread/' . $thread['threadId'] . '?alias=bluearchive-en';
|
|
$threadJson = @getContents($threadApiUrl);
|
|
if ($threadJson) {
|
|
$threadData = json_decode($threadJson, true);
|
|
if (isset($threadData['content']) && !empty($threadData['content'])) {
|
|
$item['content'] = $threadData['content'];
|
|
} else {
|
|
$item['content'] = '';
|
|
}
|
|
} else {
|
|
$item['content'] = '';
|
|
}
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
}
|