Update legal documents and localization for compliance and clarity
- Updated .env.example with legal operator details for compliance. - Refactored Impressum, Privacy, and Terms pages to utilize a new LegalDocument component for improved structure and maintainability. - Enhanced localization files to include legal content in both German and English, ensuring accurate representation of legal information. - Improved i18n handling to support locale detection from Accept-Language headers.
This commit is contained in:
77
landingpage/includes/bootstrap.php
Normal file
77
landingpage/includes/bootstrap.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
$config = require dirname(__DIR__) . '/config.php';
|
||||
|
||||
function h(?string $value): string
|
||||
{
|
||||
return htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 'de'|'en'
|
||||
*/
|
||||
function detect_locale(): string
|
||||
{
|
||||
if (isset($_GET['lang']) && ($_GET['lang'] === 'de' || $_GET['lang'] === 'en')) {
|
||||
return $_GET['lang'];
|
||||
}
|
||||
|
||||
$header = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '';
|
||||
if ($header === '') {
|
||||
return 'de';
|
||||
}
|
||||
|
||||
$preferred = [];
|
||||
foreach (explode(',', $header) as $part) {
|
||||
$part = trim($part);
|
||||
if ($part === '') {
|
||||
continue;
|
||||
}
|
||||
[$tag, $q] = array_pad(explode(';q=', $part, 2), 2, '1');
|
||||
$lang = strtolower(substr(trim($tag), 0, 2));
|
||||
$preferred[$lang] = (float) $q;
|
||||
}
|
||||
|
||||
arsort($preferred);
|
||||
foreach (array_keys($preferred) as $lang) {
|
||||
if ($lang === 'de' || $lang === 'en') {
|
||||
return $lang;
|
||||
}
|
||||
}
|
||||
|
||||
return 'de';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
function load_messages(string $locale): array
|
||||
{
|
||||
$path = dirname(__DIR__) . '/lang/' . $locale . '.php';
|
||||
/** @var array<string, mixed> $messages */
|
||||
$messages = require $path;
|
||||
return $messages;
|
||||
}
|
||||
|
||||
function t(array $messages, string $key, ?string $fallback = null): string
|
||||
{
|
||||
$parts = explode('.', $key);
|
||||
$value = $messages;
|
||||
foreach ($parts as $part) {
|
||||
if (!is_array($value) || !array_key_exists($part, $value)) {
|
||||
return $fallback ?? $key;
|
||||
}
|
||||
$value = $value[$part];
|
||||
}
|
||||
return is_string($value) ? $value : ($fallback ?? $key);
|
||||
}
|
||||
|
||||
function bot_invite_url(array $config): string
|
||||
{
|
||||
return 'https://discord.com/api/oauth2/authorize?' . http_build_query([
|
||||
'client_id' => (string) $config['bot_client_id'],
|
||||
'permissions' => '8',
|
||||
'scope' => 'bot applications.commands',
|
||||
], '', '&', PHP_QUERY_RFC3986);
|
||||
}
|
||||
143
landingpage/includes/layout.php
Normal file
143
landingpage/includes/layout.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $config
|
||||
* @param array<string, mixed> $messages
|
||||
* @param 'de'|'en' $locale
|
||||
*/
|
||||
function render_header(array $config, array $messages, string $locale, string $title, string $description): void
|
||||
{
|
||||
$inviteUrl = bot_invite_url($config);
|
||||
$dashboardUrl = rtrim((string) $config['dashboard_url'], '/');
|
||||
$loginUrl = $dashboardUrl . '/login';
|
||||
$supportUrl = isset($config['support_url']) && $config['support_url'] !== ''
|
||||
? (string) $config['support_url']
|
||||
: null;
|
||||
$statusUrl = (string) $config['status_url'];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= h($locale) ?>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><?= h($title) ?></title>
|
||||
<meta name="description" content="<?= h($description) ?>">
|
||||
<link rel="icon" href="assets/nexumi-logo.svg" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="shell">
|
||||
<header class="border-b">
|
||||
<div class="container bar">
|
||||
<a class="brand" href="index.php">
|
||||
<img src="assets/nexumi-logo.svg" alt="Nexumi" width="28" height="28">
|
||||
Nexumi
|
||||
</a>
|
||||
<nav>
|
||||
<a class="btn btn-ghost" href="<?= h($statusUrl) ?>"><?= h(t($messages, 'nav.status')) ?></a>
|
||||
<a class="btn btn-ghost" href="<?= h($inviteUrl) ?>" target="_blank" rel="noreferrer"><?= h(t($messages, 'nav.invite')) ?></a>
|
||||
<?php if ($supportUrl): ?>
|
||||
<a class="btn btn-ghost" href="<?= h($supportUrl) ?>" target="_blank" rel="noreferrer"><?= h(t($messages, 'nav.support')) ?></a>
|
||||
<?php endif; ?>
|
||||
<a class="btn btn-primary" href="<?= h($loginUrl) ?>"><?= h(t($messages, 'nav.login')) ?></a>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $config
|
||||
* @param array<string, mixed> $messages
|
||||
*/
|
||||
function render_footer(array $config, array $messages): void
|
||||
{
|
||||
$dashboardUrl = rtrim((string) $config['dashboard_url'], '/');
|
||||
$year = (int) date('Y');
|
||||
?>
|
||||
</main>
|
||||
<footer class="border-t">
|
||||
<div class="container bar">
|
||||
<p>© <?= $year ?> Nexumi</p>
|
||||
<nav>
|
||||
<a href="<?= h((string) $config['status_url']) ?>"><?= h(t($messages, 'nav.status')) ?></a>
|
||||
<a href="impressum.php"><?= h(t($messages, 'nav.impressum')) ?></a>
|
||||
<a href="datenschutz.php"><?= h(t($messages, 'nav.privacy')) ?></a>
|
||||
<a href="nutzungsbedingungen.php"><?= h(t($messages, 'nav.terms')) ?></a>
|
||||
<a href="<?= h($dashboardUrl . '/dashboard') ?>"><?= h(t($messages, 'nav.dashboard')) ?></a>
|
||||
</nav>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $sections
|
||||
*/
|
||||
function render_legal_sections(array $sections): void
|
||||
{
|
||||
foreach ($sections as $section) {
|
||||
$heading = (string) ($section['heading'] ?? '');
|
||||
echo '<section class="legal-section">';
|
||||
if ($heading !== '') {
|
||||
echo '<h2>' . h($heading) . '</h2>';
|
||||
}
|
||||
foreach (($section['paragraphs'] ?? []) as $paragraph) {
|
||||
echo '<p>' . h((string) $paragraph) . '</p>';
|
||||
}
|
||||
if (!empty($section['lines']) && is_array($section['lines'])) {
|
||||
echo '<p class="legal-lines">';
|
||||
foreach ($section['lines'] as $i => $line) {
|
||||
if ($i > 0) {
|
||||
echo '<br>';
|
||||
}
|
||||
echo h((string) $line);
|
||||
}
|
||||
echo '</p>';
|
||||
}
|
||||
if (!empty($section['list']) && is_array($section['list'])) {
|
||||
echo '<ul>';
|
||||
foreach ($section['list'] as $item) {
|
||||
echo '<li>' . h((string) $item) . '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '</section>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $config
|
||||
* @param array<string, mixed> $messages
|
||||
* @param 'de'|'en' $locale
|
||||
* @param 'impressum'|'privacy'|'terms' $pageKey
|
||||
*/
|
||||
function render_legal_page(array $config, array $messages, string $locale, string $pageKey): void
|
||||
{
|
||||
/** @var array<string, mixed> $page */
|
||||
$page = $messages['legal'][$pageKey];
|
||||
$title = (string) $page['title'];
|
||||
$description = t($messages, 'meta.description');
|
||||
render_header($config, $messages, $locale, $title . ' · Nexumi', $description);
|
||||
?>
|
||||
<div class="container legal-layout">
|
||||
<aside class="legal-nav">
|
||||
<p class="legal-nav-title"><?= h(t($messages, 'legal.nav_title')) ?></p>
|
||||
<a href="impressum.php" class="<?= $pageKey === 'impressum' ? 'active' : '' ?>"><?= h(t($messages, 'nav.impressum')) ?></a>
|
||||
<a href="datenschutz.php" class="<?= $pageKey === 'privacy' ? 'active' : '' ?>"><?= h(t($messages, 'nav.privacy')) ?></a>
|
||||
<a href="nutzungsbedingungen.php" class="<?= $pageKey === 'terms' ? 'active' : '' ?>"><?= h(t($messages, 'nav.terms')) ?></a>
|
||||
</aside>
|
||||
<article class="legal-article">
|
||||
<h1><?= h($title) ?></h1>
|
||||
<p class="legal-updated"><?= h(t($messages, 'legal.updated')) ?></p>
|
||||
<?php render_legal_sections($page['sections']); ?>
|
||||
</article>
|
||||
</div>
|
||||
<?php
|
||||
render_footer($config, $messages);
|
||||
}
|
||||
Reference in New Issue
Block a user