Add configurable legal pages and admin settings

This commit is contained in:
2026-03-23 16:26:45 +01:00
parent eb3723c4a7
commit 1478aa932b
6 changed files with 645 additions and 120 deletions
+87
View File
@@ -28,6 +28,93 @@ function save_recipes(array $recipes): bool {
return (bool) file_put_contents($path, $json);
}
/**
* Default settings for imprint and privacy pages.
*/
function default_site_settings(): array {
$today = date('Y-m-d');
return [
'imprint' => [
'de' => [
'owner_name' => 'FlixCooks (bitte anpassen)',
'address' => 'Straße Hausnummer, PLZ Ort, Österreich',
'email' => 'contact@flixcooks.at',
'phone' => '+43 660 0000000',
'legal_form' => 'Kleines Impressum; kein Firmenbucheintrag/UID hinterlegt.',
'business_purpose' => 'Foodblog & Rezeptmarketing.',
'wko_membership' => '',
'authority' => '',
'uid' => '',
'odr' => 'https://ec.europa.eu/consumers/odr',
'last_updated' => $today,
],
'en' => [
'owner_name' => 'FlixCooks (please update)',
'address' => 'Street number, ZIP City, Austria',
'email' => 'contact@flixcooks.at',
'phone' => '+43 660 0000000',
'legal_form' => 'Small website notice; no commercial register/UID provided.',
'business_purpose' => 'Food blog & recipe marketing.',
'wko_membership' => '',
'authority' => '',
'uid' => '',
'odr' => 'https://ec.europa.eu/consumers/odr',
'last_updated' => $today,
],
],
'privacy' => [
'de' => [
'controller' => 'FlixCooks (bitte anpassen)',
'contact_email' => 'contact@flixcooks.at',
'contact_phone' => '+43 660 0000000',
'address' => 'Straße Hausnummer, PLZ Ort, Österreich',
'hosting_provider' => 'Hetzner Online GmbH, Industriestr. 25, 91710 Gunzenhausen, Deutschland',
'log_retention_days' => 30,
'cookie_statement' => 'Keine Tracking- oder Marketing-Cookies; nur technisch notwendige.',
'purposes' => 'Betrieb und Bereitstellung der Website, Beantwortung von Kontaktanfragen.',
'last_updated' => $today,
],
'en' => [
'controller' => 'FlixCooks (please update)',
'contact_email' => 'contact@flixcooks.at',
'contact_phone' => '+43 660 0000000',
'address' => 'Street number, ZIP City, Austria',
'hosting_provider' => 'Hetzner Online GmbH, Industriestr. 25, 91710 Gunzenhausen, Germany',
'log_retention_days' => 30,
'cookie_statement' => 'No tracking or marketing cookies; only technically necessary cookies.',
'purposes' => 'Operating and providing the website, responding to contact requests.',
'last_updated' => $today,
],
],
];
}
/**
* Load site-wide settings for legal pages, merging with defaults.
*/
function load_site_settings(): array {
$defaults = default_site_settings();
$path = __DIR__ . '/data/site.json';
if (!file_exists($path)) {
return $defaults;
}
$raw = file_get_contents($path);
$data = json_decode($raw, true);
if (!is_array($data)) {
return $defaults;
}
return array_replace_recursive($defaults, $data);
}
/**
* Persist site-wide settings for legal pages.
*/
function save_site_settings(array $settings): bool {
$path = __DIR__ . '/data/site.json';
$json = json_encode($settings, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
return (bool) file_put_contents($path, $json);
}
function slugify(string $text): string {
$text = strtolower($text);
$text = preg_replace('~[^a-z0-9]+~', '-', $text);