<?php
	declare(strict_types = 1);
	namespace Kimendisch\Sbgg_Jetzt;
	use Flake\Lang;
	use Flake\Lang_Dict;
	use Flake\Page;
	use Flake\Project;
	use Flake\Url;
	use Flake\Url_Redirect;
	use Flake\Request;
	use Flake\File;
	
	// COLLECT REQUEST DATA //
	// mail address
	$mail_address = $_GET["mail_address"] ?? null;
	if(!is_string($mail_address)){
		Url_Redirect::location("http" . (Request::has_ssl() ? "s" : "") . "://" . Request::domain_raw_full());
	}
	
	
	// LANGUAGE MANAGER //
	// hack: fake get param from url path
	$param_lang = $_GET["slang"] ?? "de";
	$_GET["lang"] = $param_lang;
	
	// initialize
	$lang = new Lang(list: ["de", "en"], default: "de");
	
	// load dict
	$dict = new Lang_Dict($lang);
	require("./page/strings.php");
	
	
	// PAGE INIT //
	Page::start();
	
	Page::title($dict->get("newsletter_subscribe_page_title"));
	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::js(__DIR__ . "/main.js");
	
	Page::font("ubuntu");
	Page::font("tabler");
?>





<div class="page-container">
	<div class="page">
		<div id="news" class="section">
			<div class="content rows">
				<div id="newsletter" class="box">
					<span class="title"><?= $dict->get("newsletter_subscribe_title") ?></span>
					
					<div id="newsletter-signup-form-container" class="form-container">
						<div id="newsletter-signup-form" class="form">
							<div class="key-value-pair">
								<div class="key">
									<span class="ti ti-at"></span>
								</div>
								<div class="value-list">
									<div class="inputwrapper">
										<input id="newsletter-signup-form-mail-address" class="value" type="text" value="<?= htmlspecialchars($mail_address) ?>" disabled />
									</div>
								</div>
							</div>
							
							<button id="newsletter-signup-form-submit" class="button primary">
								<span class="text"><?= $dict->get("newsletter_subscribe_submit") ?></span>
								<span class="icon ti ti-chevron-right"></span>
							</button>
						</div>
						
						<div id="newsletter-signup-form-feedback" class="form-feedback gone">
							<div id="newsletter-signup-form-feedback-wait" class="form-feedback-wait centertext gone">
								<span class="icon spinning ti ti-loader-2"></span>
								<span class="text"><?= $dict->get("newsletter_subscribe_feedback_wait") ?></span>
							</div>
							<div id="newsletter-signup-form-feedback-success" class="form-feedback-success centertext gone">
								<span class="icon ti ti-check"></span>
								<span class="text"><?= $dict->get("newsletter_subscribe_feedback_success") ?></span>
							</div>
							<div id="newsletter-signup-form-feedback-failure" class="form-feedback-failure centertext gone">
								<span class="icon ti ti-x"></span>
								<span class="text"><?= $dict->get("newsletter_subscribe_feedback_failure") ?></span>
							</div>
						</div>
					</div>
				</div>
				
				<div class="box align-left">
					<?php
						$newsletter_subscribe_privacy_note = $dict->get("newsletter_subscribe_privacy_note");
						foreach($newsletter_subscribe_privacy_note as $one_newsletter_subscribe_privacy_note_line){
							echo("<span class=\"align-left\">" . $one_newsletter_subscribe_privacy_note_line . "</span>");
						}
					?>
				</div>
			</div>
		</div>
	</div>
</div>



<div class="footer">
	<div class="brand">
		<img src="<?= File::file("./asset/logo-256.png") ?>" alt="logo" />
		<span>SBGG.jetzt</span>
		<a href="https://git.tjdev.de/kimendisch/sbgg.jetzt" target="_blank"><?= $dict->get("text_sourcecode") ?> <i class="ti ti-external-link"></i></a>
		<span class="version">v<?= Project::version() ?></span>
	</div>
	
	<div class="lang">
		<span><i class="ti ti-world"></i></span>
		<a <?= ($lang->get() === "de" ? "class=\"selected\"" : "") ?> href="<?= Url::query_modify(remove: ["slang"], add: ["slang=de"]) ?>">DE</a>
		<span class="delimiter">|</span>
		<a <?= ($lang->get() === "en" ? "class=\"selected\"" : "") ?> href="<?= Url::query_modify(remove: ["slang"], add: ["slang=en"]) ?>">EN</a>
	</div>
	
	<div class="legal">
		<span>&copy; 2024 Kim Endisch</span>
		<span class="delimiter">|</span>
		<a href="<?= $dict->get("link_imprint") ?>" target="_blank"><?= $dict->get("text_imprint") ?> <i class="ti ti-external-link"></i></a>
		<span class="delimiter">|</span>
		<a href="<?= $dict->get("link_privacy_policy") ?>" target="_blank"><?= $dict->get("text_privacy_policy") ?> <i class="ti ti-external-link"></i></a>
	</div>
</div>
