33dc5406b2
- api/logout.php: destroys session + clears cookie, redirects to / - api/guest-session.php: sets guest flag, lets users explore without account - layout.php: removes hard PHP redirect; authenticated users see email + "Logg ut" in topbar; guests see guest banner (sticky, dismissible) and auth gate modal (dismissible via localStorage) instead of redirect - layout_footer.php: injects auth gate modal + JS for banner/modal dismiss - layout_dashboard.php: adds username + "Logg ut" to dash-topbar - index.php: adds "Utforsk uten konto" link under primary login CTA - tools.css: .guest-banner, .auth-gate-*, .topbar-user, .dash-topbar__user Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
140 lines
7.1 KiB
PHP
140 lines
7.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
// Required vars: $toolName (string), $toolTitle (string), $toolKind (string), $toolBadge (string)
|
|
require_once __DIR__ . '/bootstrap.php';
|
|
|
|
$layoutIsGuest = !dbnToolsIsAuthenticated();
|
|
|
|
$uiLang = dbnToolsCurrentLanguage();
|
|
$navItems = dbnToolsLaunchedTools($uiLang);
|
|
$toolName = $toolName ?? 'transcribe';
|
|
$toolMeta = $navItems[$toolName] ?? null;
|
|
$toolTitle = $toolMeta['label'] ?? ($toolTitle ?? dbnToolsT('suite_title', $uiLang));
|
|
$toolKind = $toolMeta['sub'] ?? ($toolKind ?? '');
|
|
$toolBadge = $toolMeta['badge'] ?? ($toolBadge ?? '');
|
|
$langPath = strtok((string)($_SERVER['REQUEST_URI'] ?? '/'), '?') ?: '/';
|
|
|
|
// Credit balance — only meaningful for authenticated free-tier users
|
|
$layoutFreeTierBalance = -1;
|
|
if (!$layoutIsGuest && dbnToolsIsFreeTier()) {
|
|
require_once __DIR__ . '/FreeTier.php';
|
|
$layoutFreeTierBalance = FreeTier::balance((int)$_SESSION['dbn_tools_sso_uid']);
|
|
}
|
|
|
|
// User identity for topbar (null for guests)
|
|
$layoutAuthUser = $layoutIsGuest ? null : dbnToolsAuthenticatedUser();
|
|
$layoutUserDisplay = '';
|
|
if ($layoutAuthUser !== null) {
|
|
$email = (string)($layoutAuthUser['email'] ?? '');
|
|
// Show only local part (before @) to keep topbar compact
|
|
$layoutUserDisplay = strstr($email, '@', true) ?: $email;
|
|
}
|
|
|
|
$layoutReturnUrl = urlencode($_SERVER['REQUEST_URI'] ?? '/');
|
|
?>
|
|
<!doctype html>
|
|
<html lang="<?= htmlspecialchars($uiLang) ?>">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title><?= htmlspecialchars($toolTitle) ?> - Do Better Norge</title>
|
|
<?php if ($layoutFreeTierBalance >= 0): ?>
|
|
<meta name="dbn-credits" content="<?= $layoutFreeTierBalance ?>">
|
|
<?php endif; ?>
|
|
<link rel="stylesheet" href="assets/css/tools.css">
|
|
</head>
|
|
<body data-authenticated="<?= $layoutIsGuest ? 'false' : 'true' ?>" data-active-tool="<?= htmlspecialchars($toolName) ?>">
|
|
<script>
|
|
window.DBN_TOOLS_AUTHENTICATED = <?= $layoutIsGuest ? 'false' : 'true' ?>;
|
|
window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
|
<?php if ($layoutFreeTierBalance >= 0): ?>
|
|
window.DBN_FREE_TIER_BALANCE = <?= $layoutFreeTierBalance ?>;
|
|
<?php endif; ?>
|
|
</script>
|
|
<?php if (date('m-d') === '05-17'): ?>
|
|
<div id="syttendeMaiBanner" class="syttende-mai-banner" role="banner">
|
|
<span>🇳🇴 Gratulerer med dagen! Free access today — explore our AI legal tools for Norwegian family law.</span>
|
|
<button onclick="this.parentElement.remove()" aria-label="Dismiss" class="syttende-mai-close">✕</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($layoutIsGuest): ?>
|
|
<div id="guestBanner" class="guest-banner" role="alert" aria-live="polite">
|
|
<span>Du er ikke innlogget — verktøyene krever konto for å fungere.</span>
|
|
<a href="/?return=<?= $layoutReturnUrl ?>" class="guest-banner__login">Logg inn</a>
|
|
<button id="guestBannerClose" class="guest-banner__close" aria-label="Lukk">✕</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<main id="appShell" class="app-shell">
|
|
<header class="topbar">
|
|
<div>
|
|
<p class="eyebrow"><?= htmlspecialchars(dbnToolsT('brand_line', $uiLang)) ?></p>
|
|
<h1><?= htmlspecialchars(dbnToolsT('suite_title', $uiLang)) ?> <span class="title-mark">.</span> <?= htmlspecialchars(dbnToolsT('workspace_title', $uiLang)) ?></h1>
|
|
<div class="case-no">
|
|
<span class="pulse"></span>
|
|
<span>family-legal</span>
|
|
<span class="case-sep">.</span>
|
|
<span><?= htmlspecialchars(dbnToolsT('retention', $uiLang)) ?></span>
|
|
</div>
|
|
</div>
|
|
<div class="topbar-actions">
|
|
<nav class="shell-lang-switcher" aria-label="Language">
|
|
<?php foreach (dbnToolsSupportedLanguages() as $langCode): ?>
|
|
<a href="<?= htmlspecialchars($langPath . '?lang=' . $langCode) ?>" class="<?= $langCode === $uiLang ? 'is-active' : '' ?>"><?= htmlspecialchars(dbnToolsLanguageLabel($langCode)) ?></a>
|
|
<?php endforeach; ?>
|
|
</nav>
|
|
<?php if ($layoutIsGuest): ?>
|
|
<a href="/?return=<?= $layoutReturnUrl ?>" class="secondary-button" style="text-decoration:none;">Logg inn</a>
|
|
<?php else: ?>
|
|
<a href="/dashboard/" class="secondary-button" style="text-decoration:none;">📚 Min korpus</a>
|
|
<span id="healthPill" class="status-pill"><?= htmlspecialchars(dbnToolsT('session_active', $uiLang)) ?></span>
|
|
<button id="healthButton" class="secondary-button" type="button"><?= htmlspecialchars(dbnToolsT('health', $uiLang)) ?></button>
|
|
<span class="topbar-user">
|
|
<?php if ($layoutUserDisplay !== ''): ?>
|
|
<span class="topbar-user__name" title="<?= htmlspecialchars($layoutAuthUser['email'] ?? '') ?>"><?= htmlspecialchars($layoutUserDisplay) ?></span>
|
|
<?php endif; ?>
|
|
<a href="/api/logout.php" class="topbar-user__logout">Logg ut</a>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</header>
|
|
|
|
<section class="manifesto" role="banner">
|
|
<div class="manifesto-copy">
|
|
<p class="manifesto-eyebrow"><?= htmlspecialchars(dbnToolsT('manifesto_eyebrow', $uiLang)) ?></p>
|
|
<h2 class="manifesto-title"><?= htmlspecialchars(dbnToolsT('manifesto_title', $uiLang)) ?></h2>
|
|
<p class="manifesto-sub"><?= htmlspecialchars(dbnToolsT('manifesto_sub', $uiLang)) ?></p>
|
|
</div>
|
|
<div class="manifesto-stats" aria-label="Headline statistics">
|
|
<div class="manifesto-stat"><strong>23</strong><span><?= htmlspecialchars(dbnToolsT('stat_echr', $uiLang)) ?></span></div>
|
|
<div class="manifesto-stat"><strong>64%</strong><span><?= htmlspecialchars(dbnToolsT('stat_loss', $uiLang)) ?></span></div>
|
|
<div class="manifesto-stat"><strong>1,731</strong><span><?= htmlspecialchars(dbnToolsT('stat_tribunal', $uiLang)) ?></span></div>
|
|
<div class="manifesto-stat"><strong>20+</strong><span><?= htmlspecialchars(dbnToolsT('stat_pending', $uiLang)) ?></span></div>
|
|
</div>
|
|
</section>
|
|
|
|
<div class="disclaimer" role="note">
|
|
<?= htmlspecialchars(dbnToolsT('disclaimer', $uiLang)) ?>
|
|
</div>
|
|
|
|
<section class="workspace" aria-label="Legal tools workspace">
|
|
<nav class="tool-rail" aria-label="Tools">
|
|
<?php foreach ($navItems as $slug => $item): ?>
|
|
<a href="<?= htmlspecialchars($item['url']) ?>" class="tool-tab<?= $slug === $toolName ? ' is-active' : '' ?>" data-tool="<?= htmlspecialchars($slug) ?>"<?= $slug === $toolName ? ' aria-current="page"' : '' ?>>
|
|
<span><?= htmlspecialchars($item['label']) ?></span>
|
|
<small><?= htmlspecialchars($item['sub']) ?></small>
|
|
<em><?= htmlspecialchars($item['icon']) ?></em>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</nav>
|
|
|
|
<section class="tool-panel" aria-labelledby="toolTitle">
|
|
<div class="tool-heading">
|
|
<div>
|
|
<p id="toolKind" class="eyebrow"><?= htmlspecialchars($toolKind) ?></p>
|
|
<h2 id="toolTitle"><?= htmlspecialchars($toolTitle) ?></h2>
|
|
</div>
|
|
<span id="toolBadge" class="tool-badge"><?= htmlspecialchars($toolBadge) ?></span>
|
|
</div>
|