'← Zurück zu Neuigkeiten',
'es' => '← Volver a noticias',
'fr' => '← Retour aux actualités',
'it' => '← Torna alle news',
'pt' => '← Voltar às notícias',
'tr' => '← Haberlere dön',
'cs' => '← Zpět na novinky',
'pl' => '← Wróć do aktualności',
];
$_backLabel = $_backLabels[$currentLang] ?? '← Back to News';
$slug = $_GET['slug'] ?? '';
if (empty($slug) || !preg_match('/^[a-z0-9-]+$/', $slug)) {
header('Location: ' . $basePath . $_newsPath);
exit;
}
$post = null;
$newsDir = $_includeBase . 'content/news/';
if (is_dir($newsDir)) {
foreach (glob($newsDir . '*.json') as $file) {
$p = json_decode(file_get_contents($file), true);
if (!is_array($p)) continue;
if (($p['slug'] ?? '') !== $slug) continue;
if (!empty($p['hidden'])) continue;
$postLang = $p['lang'] ?? $_defaultLang;
if ($postLang !== $currentLang) continue;
$post = $p;
break;
}
}
// Preview of an unapplied change set: its posts replace the stored ones (shown even when hidden).
foreach (function_exists('raijuNewsOverlay') ? raijuNewsOverlay() : [] as $_overlayPost) {
if (is_array($_overlayPost) && ($_overlayPost['slug'] ?? '') === $slug && ($_overlayPost['lang'] ?? $_defaultLang) === $currentLang) {
$_overlayPost['hidden'] = false;
$post = $_overlayPost;
}
}
if (!$post) {
http_response_code(404);
$pageTitle = 'Not Found';
$pageDescription = '';
include $_includeBase . 'includes/header.php';
echo '';
include $_includeBase . 'includes/footer.php';
exit;
}
$pageTitle = (string)($post['title'] ?? '');
$pageDescription = (string)($post['excerpt'] ?? '');
$_isAdmin = isAdminLoggedIn();
$newsPostJson = $_isAdmin ? json_encode($post, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP) : '';
include $_includeBase . 'includes/header.php';
$_dateRaw = (string)($post['date'] ?? '');
$_dateMachine = $_dateRaw;
$_formattedDate = htmlspecialchars($_dateRaw);
if ($_dateRaw !== '') {
try {
$_dateObj = new DateTime($_dateRaw);
$_dateMachine = $_dateObj->format('Y-m-d');
$_formattedDate = $_dateObj->format('F j, Y');
} catch (Exception $e) {
$_dateMachine = '';
}
}
$_postBody = '';
if (isset($post['content']) && is_string($post['content'])) {
$_postBody = sanitizeHtml($post['content']);
} elseif (!empty($post['sections']) && is_array($post['sections'])) {
foreach ($post['sections'] as $_sectionIndex => $_section) {
if (is_array($_section)) {
$_postBody .= renderSection($_section, $_sectionIndex, false);
}
}
}
?>