Files
breadcrumb-the-shire/pages/admin/settings/general(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

184 lines
8.3 KiB
PHTML

<?php
/**
* @var array $tenants
* @var array $roles
* @var array $departments
* @var array $values
* @var array $settings
* @var bool $canUpdateSettings
*/
use MintyPHP\Session;
$values = $values ?? [];
$settings = $settings ?? [];
$defaultTenantId = (int) ($values['default_tenant_id'] ?? 0);
$defaultRoleId = (int) ($values['default_role_id'] ?? 0);
$defaultDepartmentId = (int) ($values['default_department_id'] ?? 0);
$appTitle = (string) ($values['app_title'] ?? '');
$appLocale = (string) ($values['app_locale'] ?? '');
$defaultTenantDesc = $settings['default_tenant']['description'] ?? 'setting.default_tenant';
$defaultRoleDesc = $settings['default_role']['description'] ?? 'setting.default_role';
$defaultDepartmentDesc = $settings['default_department']['description'] ?? 'setting.default_department';
$appTitleDesc = $settings['app_title']['description'] ?? 'setting.app_title';
$appLocaleDesc = $settings['app_locale']['description'] ?? 'setting.app_locale';
$locales = defined('APP_LOCALES') ? APP_LOCALES : [];
$canUpdateSettings = (bool) ($canUpdateSettings ?? false);
$isReadOnly = !$canUpdateSettings;
$readonlyAttr = $isReadOnly ? 'readonly' : '';
$disabledAttr = $isReadOnly ? 'disabled' : '';
?>
<div class="app-details-container">
<section>
<?php
$titlebar = [
'title' => t('General settings'),
'backHref' => 'admin/settings',
'backTitle' => t('Cancel'),
'actions' => $canUpdateSettings ? [
[
'form' => 'settings-general-form',
'name' => 'action',
'value' => 'save',
'class' => 'secondary outline',
'label' => t('Save'),
],
[
'form' => 'settings-general-form',
'name' => 'action',
'value' => 'save_close',
'class' => 'primary',
'label' => t('Save & close'),
],
] : [],
];
require templatePath('partials/app-details-titlebar.phtml');
?>
<form id="settings-general-form" method="post" data-details-storage="settings-general-details-v1" data-standard-detail-form="1">
<details class="app-details-card" name="settings-general-app-identity" data-details-key="settings-general-app-identity" open>
<summary>
<span class="app-details-card-summary-title"><?php e(t('App identity')); ?></span>
<span class="app-details-card-summary-meta">
<span class="badge" data-variant="neutral"><?php e($appTitle !== '' ? t('Configured') : t('Default')); ?></span>
</span>
</summary>
<div class="app-details-card-container">
<blockquote data-variant="info">
<small><?php e(t('This setting controls the application name shown across the UI.')); ?></small>
</blockquote>
<label class="app-field">
<span><?php e(t('App title')); ?> <span class="badge" data-variant="info"><?php e(t('Cached')); ?></span></span>
<input type="text" name="app_title" value="<?php e($appTitle); ?>" placeholder="<?php e(appTitle()); ?>" <?php e($readonlyAttr); ?>>
<small><?php e(t($appTitleDesc)); ?></small>
<small class="muted"><?php e(t('Leave empty to use the runtime default title.')); ?></small>
</label>
</div>
</details>
<details class="app-details-card" name="internationalization" data-details-key="internationalization">
<summary>
<span class="app-details-card-summary-title"><?php e(t('Internationalization')); ?></span>
<span class="app-details-card-summary-meta">
<span class="badge" data-variant="neutral"><?php e($appLocale !== '' ? strtoupper($appLocale) : t('Default')); ?></span>
</span>
</summary>
<div class="app-details-card-container">
<blockquote data-variant="info">
<small><?php e(t('This setting controls the default language for users without a personal preference.')); ?></small>
</blockquote>
<label class="app-field">
<span><?php e(t('Default language')); ?> <span class="badge" data-variant="info"><?php e(t('Cached')); ?></span></span>
<select name="app_locale" <?php e($disabledAttr); ?>>
<option value=""><?php e(t('None')); ?></option>
<?php foreach ($locales as $locale): ?>
<?php
$label = strtoupper($locale);
if ($locale === 'de') {
$label = t('German');
} elseif ($locale === 'en') {
$label = t('English');
}
?>
<option value="<?php e($locale); ?>" <?php e($appLocale === $locale ? 'selected' : ''); ?>>
<?php e($label); ?>
</option>
<?php endforeach; ?>
</select>
<small><?php e(t($appLocaleDesc)); ?></small>
</label>
</div>
</details>
<?php $configuredDefaultsCount = (int) ($defaultTenantId > 0) + (int) ($defaultDepartmentId > 0) + (int) ($defaultRoleId > 0); ?>
<details class="app-details-card" name="user-creation" data-details-key="user-creation">
<summary>
<span class="app-details-card-summary-title"><?php e(t('User creation rules')); ?></span>
<span class="app-details-card-summary-meta">
<span class="badge" data-variant="neutral"><?php e(sprintf(t('%d defaults configured'), $configuredDefaultsCount)); ?></span>
</span>
</summary>
<div class="app-details-card-container">
<blockquote data-variant="info">
<small><?php e(t('These defaults prefill tenant, department and role when new users are created.')); ?></small>
</blockquote>
<div class="grid">
<label class="app-field">
<span><?php e(t('Default tenant')); ?></span>
<select name="default_tenant_id" <?php e($disabledAttr); ?>>
<option value=""><?php e(t('None')); ?></option>
<?php foreach ($tenants ?? [] as $tenant): ?>
<?php $tenantId = (int) ($tenant['id'] ?? 0); ?>
<?php if ($tenantId > 0): ?>
<option value="<?php e((string) $tenantId); ?>" <?php e($tenantId === $defaultTenantId ? 'selected' : ''); ?>>
<?php e($tenant['description'] ?? ''); ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<small><?php e(t($defaultTenantDesc)); ?></small>
</label>
<label class="app-field">
<span><?php e(t('Default department')); ?></span>
<select name="default_department_id" <?php e($disabledAttr); ?>>
<option value=""><?php e(t('None')); ?></option>
<?php foreach ($departments ?? [] as $department): ?>
<?php $departmentId = (int) ($department['id'] ?? 0); ?>
<?php if ($departmentId > 0): ?>
<option value="<?php e((string) $departmentId); ?>" <?php e($departmentId === $defaultDepartmentId ? 'selected' : ''); ?>>
<?php e($department['description'] ?? ''); ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<small><?php e(t($defaultDepartmentDesc)); ?></small>
</label>
</div>
<label class="app-field">
<span><?php e(t('Default role')); ?></span>
<select name="default_role_id" <?php e($disabledAttr); ?>>
<option value=""><?php e(t('None')); ?></option>
<?php foreach ($roles ?? [] as $role): ?>
<?php $roleId = (int) ($role['id'] ?? 0); ?>
<?php if ($roleId > 0): ?>
<option value="<?php e((string) $roleId); ?>" <?php e($roleId === $defaultRoleId ? 'selected' : ''); ?>>
<?php e($role['description'] ?? ''); ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<small><?php e(t($defaultRoleDesc)); ?></small>
</label>
</div>
</details>
<?php Session::getCsrfInput(); ?>
</form>
</section>
<aside id="app-details-aside-section">
<div class="app-details-aside-section"></div>
</aside>
</div>