<?php
	declare(strict_types = 1);
	namespace Kimendisch\Sbgg_Jetzt;
	use DateTimeImmutable;
	use Flake\Lang;
	use Flake\Lang_Dict;
	use Flake\Page;
	
	// HANDLE AUTHENTICATION //
	require("./page/admin/auth_handler.php");
	
	
	// LANGUAGE MANAGER //
	// hack: fake get param from constant
	$_GET["lang"] = "en";
	
	// initialize
	$lang = new Lang(list: ["de", "en"], default: "en");
	
	// load dict
	$dict = new Lang_Dict($lang);
	require("./page/strings.php");
	
	
	// PAGE INIT //
	Page::start();
	
	Page::title("SBGG.jetzt - Admin Area");
	Page::icon("./asset/logo-256.png");
	
	Page::lang($lang->get());
	Page::viewport(scale: 1, zoom: true);
	
	Page::robots(index: false, follow: false);
	Page::author("Kim Endisch");
	
	Page::$head["analytics"] = '<script defer data-domain="sbgg.jetzt" src="https://analytics.tjdev.de/js/script.js"></script>';
	Page::css("./page/start/style.css");
	
	Page::font("ubuntu");
	Page::font("tabler");
?>





<div class="page-container">
	<div class="page">
		<div class="section">
			<div class="content">
				<div class="button-list align-left">
					<a href="/admin" class="button on-bg">
						<span class="icon ti ti-arrow-left"></span>
						<span class="text">Go Back</span>
					</a>
				</div>
			</div>
		</div>
		
		<div class="section">
			<div class="header">
				<span class="icon ti ti-news"></span>
				<span class="text">Content</span>
			</div>
			<div class="content">
				<?php
					$content_list = Newsletter::content_list();
					rsort($content_list);
					foreach($content_list as $one_content_name){
						$date_raw = substr($one_content_name, 0, 10);
						if($date_raw === "0000-00-00"){
							$date_formatted = "System Message";
							
						} else {
							$date = new DateTimeImmutable($date_raw);
							$date_formatted = $date->format('d M Y');
						}
						
						$name_raw = substr($one_content_name, 11);
						$name_formatted = ucwords(str_replace("-", " ", basename($name_raw)));
				?>
						<a href="/admin/newsletter/<?= urlencode($one_content_name) ?>" class="box align-left">
							<span class="extra"><i class="ti ti-calendar"></i><?= $date_formatted ?></span>
							<span class="title"><?= $name_formatted ?></span>
						</a>
				<?php } ?>
			</div>
		</div>
	</div>
</div>



<?php require(dirname(__DIR__) . "/footer.php"); ?>
