<?php $pageTitle='News — Almost Heaven Radio'; include __DIR__ . '/header.php'; include __DIR__ . '/menu.php'; $items=[]; $newsDir=__DIR__.'/data/news'; if(is_dir($newsDir)){ foreach(glob($newsDir.'/*.json') ?: [] as $f){ $j=json_decode((string)file_get_contents($f),true); if(is_array($j)) $items[]=$j; } usort($items, fn($a,$b)=>strcmp((string)($b['date'] ?? ''),(string)($a['date'] ?? ''))); } if(!$items && file_exists(__DIR__.'/data/news.txt')){ $raw=trim((string)file_get_contents(__DIR__.'/data/news.txt')); foreach(preg_split('/
\s*---\s*
/',$raw) as $chunk){ $chunk=trim($chunk); if($chunk==='') continue; $lines=preg_split('/\R+/',$chunk); $items[]=['title'=>trim(strip_tags($lines[0] ?? 'Station update')),'content'=>trim(implode("
",array_slice($lines,1)))]; } } ?>
<main class="content-area"><div class="content-wrapper page-shell"><section class="content-card"><h1>📰 Station News</h1><p>Latest updates from Almost Heaven Radio.</p></section><div class="page-shell"><?php foreach($items as $item): ?><article class="content-card"><h2><?= htmlspecialchars($item['title'] ?? 'Station update') ?></h2><?php if(!empty($item['date'])): ?><p class="text-muted"><?= htmlspecialchars($item['date']) ?></p><?php endif; ?><div class="page-copy" style="white-space:pre-wrap;"><?= htmlspecialchars((string)($item['content'] ?? $item['body'] ?? '')) ?></div></article><?php endforeach; if(!$items): ?><section class="content-card"><p>No news posts yet.</p></section><?php endif; ?></div></div></main>
<?php include __DIR__ . '/footer.php'; ?>