Files
breadcrumb-the-shire/pages/admin/settings/branding(default).phtml
fs 69739c90d7 refactor(settings): split admin/settings into hub + per-section subpages
Splits the 755-line monolithic settings page into a tile-based landing hub
and six focused subpages (general, security, email, api, sso, branding),
each with its own form, CSRF scope and POST handler. Each subpage offers
Save / Save & close buttons plus a Cancel/back link to the hub.

Backend (AdminSettingsService, gateways, policies, DB schema) unchanged.
A new settingsSectionMergePost() helper overlays section POSTs onto the
current DB values so partial saves don't wipe unrelated fields (the
service defaults missing keys to 0/empty).

Sub-action files (logo/favicon/tokens/lifecycle) redirect to the matching
subpage, and architecture contracts now check the subpage files instead
of the removed monolithic index.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 22:43:12 +02:00

107 lines
4.3 KiB
PHTML

<?php
/**
* @var bool $canUpdateSettings
*/
use MintyPHP\Session;
$canUpdateSettings = (bool) ($canUpdateSettings ?? false);
$hasLogo = app(\MintyPHP\Service\Branding\BrandingLogoService::class)->hasLogo();
$hasFavicon = app(\MintyPHP\Service\Branding\BrandingFaviconService::class)->hasFavicon();
?>
<div class="app-details-container">
<section>
<?php
$titlebar = [
'title' => t('Branding settings'),
'backHref' => 'admin/settings',
'backTitle' => t('Cancel'),
'actions' => [],
];
require templatePath('partials/app-details-titlebar.phtml');
?>
<details class="app-details-card" name="settings-branding-logo" data-details-key="settings-branding-logo" open>
<summary>
<span class="app-details-card-summary-title"><?php e(t('App logo')); ?></span>
<span class="app-details-card-summary-meta">
<span class="badge" data-variant="neutral"><?php e($hasLogo ? t('Configured') : t('Default')); ?></span>
</span>
</summary>
<div class="app-details-card-container">
<div class="entity-avatar-block avatar-square avatar-ratio-16-9 avatar-borderless">
<a data-fslightbox="app-logo" href="<?php e(appLogoUrl(256)); ?>">
<img class="entity-avatar-image" src="<?php e(appLogoUrl(256)); ?>" alt="<?php e(t('App logo')); ?>">
</a>
</div>
<?php if ($canUpdateSettings): ?>
<form class="user-avatar-form" method="post" action="admin/settings/logo" enctype="multipart/form-data">
<?php
$fileUpload = [
'name' => 'logo',
'accept' => 'image/svg+xml,image/png,image/jpeg,image/webp',
'hint' => t('Allowed file types: SVG, PNG, JPG, WEBP'),
'currentSrc' => $hasLogo ? appLogoUrl(128) : '',
'deleteAction' => $hasLogo ? 'admin/settings/logo-delete' : '',
];
require templatePath('partials/app-file-upload.phtml');
?>
<div class="app-form-actions">
<button type="submit" name="action" value="save" class="secondary outline">
<?php e(t('Save')); ?>
</button>
<button type="submit" name="action" value="save_close" class="primary">
<?php e(t('Save & close')); ?>
</button>
</div>
<?php Session::getCsrfInput(); ?>
</form>
<?php endif; ?>
</div>
</details>
<details class="app-details-card" name="settings-branding-favicon" data-details-key="settings-branding-favicon">
<summary>
<span class="app-details-card-summary-title"><?php e(t('Favicon')); ?></span>
<span class="app-details-card-summary-meta">
<span class="badge" data-variant="neutral"><?php e($hasFavicon ? t('Configured') : t('Default')); ?></span>
</span>
</summary>
<div class="app-details-card-container">
<blockquote data-variant="info">
<small><?php e(t('Square images are recommended (icons are center-cropped).')); ?></small>
</blockquote>
<?php if ($canUpdateSettings): ?>
<form class="user-avatar-form" method="post" action="admin/settings/favicon" enctype="multipart/form-data">
<?php
$fileUpload = [
'name' => 'favicon',
'accept' => 'image/png',
'hint' => t('Allowed file types: PNG'),
'currentSrc' => $hasFavicon ? asset('favicon/favicon-32x32.png') : '',
'currentLabel' => t('Favicon'),
'deleteAction' => $hasFavicon ? 'admin/settings/favicon-delete' : '',
];
require templatePath('partials/app-file-upload.phtml');
?>
<div class="app-form-actions">
<button type="submit" name="action" value="save" class="secondary outline">
<?php e(t('Save')); ?>
</button>
<button type="submit" name="action" value="save_close" class="primary">
<?php e(t('Save & close')); ?>
</button>
</div>
<?php Session::getCsrfInput(); ?>
</form>
<?php endif; ?>
</div>
</details>
</section>
<aside id="app-details-aside-section">
<div class="app-details-aside-section"></div>
</aside>
</div>