A lot of things

This commit is contained in:
2026-06-16 16:21:43 +02:00
parent 4f9f6c63b3
commit 7e1e26f20b
126 changed files with 7917 additions and 204 deletions

View File

@@ -3,6 +3,8 @@
namespace App\Helpers;
use App\Models\Entry;
use App\Models\EntryFile;
use App\Models\News;
use App\Services\XenforoApiService;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
@@ -62,13 +64,16 @@ class EntryHelpers {
};
}
public static function getLatestComments(Entry $entry, int $limit = 20): array {
public static function getLatestComments(Entry|News $entry, int $limit = 20): array {
if( !$entry->comments_thread_id ){
return [];
}
$cacheKey = "entry_comments_{$entry->id}";
if( is_a( $entry, News::class ) )
$cacheKey = "news_comments_{$entry->id}";
else
$cacheKey = "entry_comments_{$entry->id}";
return Cache::remember($cacheKey, now()->addDays(1), function () use ($entry, $limit) {
$service = app(XenforoApiService::class);
@@ -93,6 +98,25 @@ class EntryHelpers {
public static function enableOnlinePatcherBasedOnExtension(string $filename): bool
{
return Str::endsWith(Str::lower($filename), ['.ips', '.bps', '.xdelta', '.zip' ]);
return Str::endsWith(Str::lower($filename), ['.ips', '.bps', '.xdelta', '.ups', '.aps', '.ppf', '.zip' ]);
}
public static function getYoutubeVideoId(string $url): ?string
{
$pattern = '%(?:https?://)?(?:www\.|m\.)?(?:youtu\.be/|youtube(?:-nocookie)?\.com/(?:watch\?.*v=|embed/|v/|shorts/|live/))([\w-]{11})%i';
preg_match($pattern, $url, $matches);
return $matches[1] ?? null;
}
public static function fileAlreadyDownloaded(EntryFile $entryFile): bool
{
return session("downloaded_file_{$entryFile->file_uuid}", null ) !== null;
}
public static function markFileAsDownloaded(EntryFile $entryFile): bool
{
session(["downloaded_file_{$entryFile->file_uuid}" => 1]);
return true;
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace App\Helpers;
class PlayOnlineHelpers
{
public static function getCoreLists(): array
{
return [
'nes',
'fceumm',
'nestopia',
'snes',
'snes9x',
'bsnes',
'gb',
'gambatte',
'gba',
'mgba',
'nds',
'melonds',
'desmume2015',
'desmume',
'a5200',
'mame2003',
'mame2003_plus',
'fbneo',
'psx',
'pcsx_rearmed',
'mednafen_psx_hw',
'segaSaturn',
'yabuase',
'segaMD',
'segaGG',
'segaCD',
'genesis_plus_gx',
'n64',
'mupen64plus_next',
'parallel-n64',
'atari7800',
'prosystem',
'atari2600',
'stella2014',
'sega32x',
'picodrive',
'segaMS',
'smsplus',
'c64',
'vice_x64sc',
'same_cdi',
'psp',
'ppsspp',
'3ds',
'azahar'
];
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Helpers;
use App\Auth\XenForoUser;
use App\Models\Entry;
use App\Models\News;
use App\Services\XenforoApiService;
class XenForoHelpers {
@@ -44,7 +45,7 @@ class XenForoHelpers {
$service->updateEntriesCount( $count, $userId );
}
public static function entryApproved( Entry $entry ): void
public static function entryApproved( Entry|News $entry ): void
{
// 1. Update XF Entry count.
self::updateEntriesCount( $entry->user_id );
@@ -58,6 +59,29 @@ class XenForoHelpers {
$title = "Entry approved : {$entry->title}";
$message = "Your entry {$entry->title} has been approved by {$moderator}.";
$service = app(XenForoApiService::class);
$service->createConversation([ $entry->user_id ], $title, $message, false, false);
}
public static function entryRejected( Entry|News $entry ): void
{
// 1. Update XF Entry count.
self::updateEntriesCount( $entry->user_id );
// 2. Send a private message
/*
if( \Auth::user()->user_id === $entry->user_id ) {
return;
}
*/
$moderator = \Auth::user()->username;
$title = "Entry rejected : {$entry->title}";
$message = "Your entry {$entry->title} has been rejected by {$moderator}.\nReason: {$entry->staff_comment}\n\nYou have 7 days to edit your entry before it is permanently deleted.";
$service = app(XenForoApiService::class);
$service->createConversation([ $entry->user_id ], $title, $message, false, false);
}
}