Refine ACP general settings navigation and tabbed layout
All checks were successful
CI/CD Pipeline / deploy (push) Successful in 31s
CI/CD Pipeline / promote_stable (push) Successful in 2s

This commit is contained in:
2026-02-28 19:13:33 +01:00
parent 94f665192d
commit ef84b73cb5
12 changed files with 409 additions and 211 deletions

View File

@@ -32,8 +32,10 @@ class StatsController extends Controller
$avatarSizeBytes = $this->resolveAvatarDirectorySize();
$orphanAttachments = $this->resolveOrphanAttachments();
$version = Setting::query()->where('key', 'version')->value('value');
$build = Setting::query()->where('key', 'build')->value('value');
$composer = $this->readComposerMetadata();
$this->syncVersionBuildSettings($composer);
$version = $composer['version'] ?? Setting::query()->where('key', 'version')->value('value');
$build = $composer['build'] ?? Setting::query()->where('key', 'build')->value('value');
$boardVersion = $version
? ($build ? "{$version} (build {$build})" : $version)
: null;
@@ -158,4 +160,59 @@ class StatsController extends Controller
$value = ini_get('zlib.output_compression');
return in_array(strtolower((string) $value), ['1', 'on', 'true'], true);
}
private function readComposerMetadata(): array
{
$path = base_path('composer.json');
if (!is_file($path) || !is_readable($path)) {
return [];
}
$raw = file_get_contents($path);
if ($raw === false) {
return [];
}
$data = json_decode($raw, true);
if (!is_array($data)) {
return [];
}
$version = trim((string) ($data['version'] ?? ''));
$build = trim((string) ($data['build'] ?? ''));
return [
'version' => $version !== '' ? $version : null,
'build' => ctype_digit($build) ? (int) $build : null,
];
}
private function syncVersionBuildSettings(array $composer): void
{
$version = $composer['version'] ?? null;
$build = $composer['build'] ?? null;
if ($version === null && $build === null) {
return;
}
try {
if ($version !== null) {
$currentVersion = Setting::query()->where('key', 'version')->value('value');
if ((string) $currentVersion !== (string) $version) {
Setting::updateOrCreate(['key' => 'version'], ['value' => (string) $version]);
}
}
if ($build !== null) {
$buildString = (string) $build;
$currentBuild = Setting::query()->where('key', 'build')->value('value');
if ((string) $currentBuild !== $buildString) {
Setting::updateOrCreate(['key' => 'build'], ['value' => $buildString]);
}
}
} catch (\Throwable) {
// Stats endpoint should remain readable even if settings sync fails.
}
}
}