Prepare LaySite 1.5.1 page routing and template updates

This commit is contained in:
2026-11-28 03:07:14 +08:00
parent 50fb30ff3b
commit 474cb766be
41 changed files with 354 additions and 146 deletions
+8 -4
View File
@@ -63,16 +63,20 @@ final class SiteDesign
});
}
public static function unsetSystemPage(PDO $pdo, string $slug): void
public static function replaceSystemPage(PDO $pdo, string $slug, ?string $replacement = null): void
{
$site = json_decode((string) $pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
$type = array_search($slug, $site['system_pages'] ?? [], true);
if ($type === false) {
return;
}
unset($site['system_pages'][$type]);
if ($type === 'maintenance') {
$site['maintenance_enabled'] = false;
if ($replacement !== null) {
$site['system_pages'][$type] = $replacement;
} else {
unset($site['system_pages'][$type]);
if ($type === 'maintenance') {
$site['maintenance_enabled'] = false;
}
}
$site['revisions']['general'] = ($site['revisions']['general'] ?? 0) + 1;
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);