a3d46f9756
- Public landing page at / for unauthenticated users (EN/NO/UK/PL) - Authenticated / shows Case Workbench dashboard with manifesto strip, stats, and launched-tool grid (Transcribe, Timeline, BVJ, Advocate, Deep Research, Corpus) - Added includes/i18n.php with full 4-language translation layer - Extended layout.php to Case Workbench shell with tool rail, lang switcher - AI output language normalization extended to en/no/uk/pl in PHP agents - SSO token validation in bootstrap.php / index.php (dobetternorge.no bridge) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
217 lines
11 KiB
PHP
217 lines
11 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
|
|
function dbnToolsSafeReturn(mixed $value, string $default = '/'): string
|
|
{
|
|
$return = trim((string)$value);
|
|
if ($return === '') {
|
|
return $default;
|
|
}
|
|
if (!str_starts_with($return, '/') || str_starts_with($return, '//')) {
|
|
return $default;
|
|
}
|
|
if (preg_match('/[\r\n]/', $return)) {
|
|
return $default;
|
|
}
|
|
return $return;
|
|
}
|
|
|
|
$uiLang = dbnToolsCurrentLanguage();
|
|
$returnPath = dbnToolsSafeReturn($_GET['return'] ?? '/', '/');
|
|
|
|
// Handle SSO token from dobetternorge.no
|
|
if (isset($_GET['sso']) && !dbnToolsIsAuthenticated()) {
|
|
$ssoSecret = (string) dbnToolsEnv('DBN_SSO_SECRET', '');
|
|
if ($ssoSecret !== '') {
|
|
$tokenData = dbnToolsValidateSsoToken((string)$_GET['sso'], $ssoSecret);
|
|
if ($tokenData !== null) {
|
|
session_regenerate_id(true);
|
|
$_SESSION['dbn_tools_authenticated'] = true;
|
|
$_SESSION['dbn_tools_authenticated_at'] = time();
|
|
$_SESSION['dbn_tools_sso_uid'] = (int)$tokenData['uid'];
|
|
$_SESSION['dbn_tools_user_id'] = (int)$tokenData['uid'];
|
|
$_SESSION['dbn_tools_user_email'] = (string)$tokenData['email'];
|
|
$_SESSION['dbn_tools_user_role'] = 'sso';
|
|
header('Location: ' . $returnPath);
|
|
exit;
|
|
}
|
|
}
|
|
header('Location: https://dobetternorge.no/account.php?error=' . urlencode('Session expired. Please log in and try again.'));
|
|
exit;
|
|
}
|
|
|
|
$tools = dbnToolsLaunchedTools($uiLang);
|
|
$langPath = '/';
|
|
$toolsLogin = 'https://dobetternorge.no/tools-login.php?return=' . urlencode($returnPath);
|
|
?>
|
|
<!doctype html>
|
|
<html lang="<?= htmlspecialchars($uiLang) ?>">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title><?= htmlspecialchars(dbnToolsT('meta_title', $uiLang)) ?></title>
|
|
<meta name="description" content="AI legal preparation tools for Do Better Norge: transcribe, timeline, Barnevernet document analysis, advocate briefs, deep research, and corpus search.">
|
|
<meta name="robots" content="index, follow">
|
|
<link rel="canonical" href="https://tools.dobetternorge.no/">
|
|
<meta property="og:title" content="<?= htmlspecialchars(dbnToolsT('meta_title', $uiLang)) ?>">
|
|
<meta property="og:description" content="<?= htmlspecialchars(dbnToolsT('landing_sub', $uiLang)) ?>">
|
|
<meta property="og:type" content="website">
|
|
<meta property="og:url" content="https://tools.dobetternorge.no/">
|
|
<meta name="theme-color" content="#f6f2ea">
|
|
<link rel="stylesheet" href="assets/css/tools.css">
|
|
</head>
|
|
<body data-authenticated="<?= dbnToolsIsAuthenticated() ? 'true' : 'false' ?>">
|
|
<script>
|
|
window.DBN_TOOLS_AUTHENTICATED = <?= dbnToolsIsAuthenticated() ? 'true' : 'false' ?>;
|
|
window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
|
</script>
|
|
|
|
<?php if (dbnToolsIsAuthenticated()): ?>
|
|
<main id="appShell" class="app-shell dashboard-shell">
|
|
<header class="topbar">
|
|
<div>
|
|
<p class="eyebrow"><?= htmlspecialchars(dbnToolsT('brand_line', $uiLang)) ?></p>
|
|
<h1><?= htmlspecialchars(dbnToolsT('dashboard_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>
|
|
<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>
|
|
</div>
|
|
</header>
|
|
|
|
<section class="manifesto dashboard-manifesto">
|
|
<div class="manifesto-copy">
|
|
<p class="manifesto-eyebrow"><?= htmlspecialchars(dbnToolsT('dashboard_eyebrow', $uiLang)) ?></p>
|
|
<h2 class="manifesto-title"><?= htmlspecialchars(dbnToolsT('manifesto_title', $uiLang)) ?></h2>
|
|
<p class="manifesto-sub"><?= htmlspecialchars(dbnToolsT('dashboard_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="tool-dashboard-grid" aria-label="Available tools">
|
|
<?php foreach ($tools as $slug => $item): ?>
|
|
<a class="dashboard-tool-card" href="<?= htmlspecialchars($item['url']) ?>">
|
|
<span class="dashboard-tool-card__icon"><?= htmlspecialchars($item['icon']) ?></span>
|
|
<span class="dashboard-tool-card__badge"><?= htmlspecialchars($item['badge']) ?></span>
|
|
<h2><?= htmlspecialchars($item['label']) ?></h2>
|
|
<p><?= htmlspecialchars($item['description']) ?></p>
|
|
<strong><?= htmlspecialchars(dbnToolsT('open_tool', $uiLang)) ?></strong>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</section>
|
|
</main>
|
|
<?php else: ?>
|
|
<main id="publicLanding" class="showcase-page dbn-public-tools">
|
|
<header class="showcase-header">
|
|
<div class="showcase-header-inner">
|
|
<div class="showcase-brand">
|
|
<p class="eyebrow"><?= htmlspecialchars(dbnToolsT('landing_kicker', $uiLang)) ?></p>
|
|
<h1 class="showcase-title"><?= htmlspecialchars(dbnToolsT('landing_title', $uiLang)) ?></h1>
|
|
<p class="showcase-tagline"><?= htmlspecialchars(dbnToolsT('landing_sub', $uiLang)) ?></p>
|
|
</div>
|
|
<div class="showcase-header-actions">
|
|
<nav class="shell-lang-switcher" aria-label="Language">
|
|
<?php foreach (dbnToolsSupportedLanguages() as $langCode): ?>
|
|
<a href="<?= htmlspecialchars($langPath . '?lang=' . $langCode . '&return=' . urlencode($returnPath)) ?>" class="<?= $langCode === $uiLang ? 'is-active' : '' ?>"><?= htmlspecialchars(dbnToolsLanguageLabel($langCode)) ?></a>
|
|
<?php endforeach; ?>
|
|
</nav>
|
|
<a href="#access" class="cta-button"><?= htmlspecialchars(dbnToolsT('primary_access', $uiLang)) ?></a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<section class="landing-hero">
|
|
<div class="landing-hero__copy">
|
|
<p class="manifesto-eyebrow"><?= htmlspecialchars(dbnToolsT('manifesto_eyebrow', $uiLang)) ?></p>
|
|
<h2><?= htmlspecialchars(dbnToolsT('manifesto_title', $uiLang)) ?></h2>
|
|
<p><?= htmlspecialchars(dbnToolsT('manifesto_sub', $uiLang)) ?></p>
|
|
</div>
|
|
<div class="landing-hero__stats">
|
|
<div><strong>23</strong><span><?= htmlspecialchars(dbnToolsT('stat_echr', $uiLang)) ?></span></div>
|
|
<div><strong>1,731</strong><span><?= htmlspecialchars(dbnToolsT('stat_tribunal', $uiLang)) ?></span></div>
|
|
<div><strong>20+</strong><span><?= htmlspecialchars(dbnToolsT('stat_pending', $uiLang)) ?></span></div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="cap-section">
|
|
<div class="section-inner">
|
|
<p class="eyebrow"><?= htmlspecialchars(dbnToolsT('tools_title', $uiLang)) ?></p>
|
|
<div class="cap-grid cap-grid--six">
|
|
<?php foreach ($tools as $item): ?>
|
|
<article class="cap-card">
|
|
<span class="cap-label"><?= htmlspecialchars($item['badge']) ?></span>
|
|
<h3><?= htmlspecialchars($item['label']) ?></h3>
|
|
<p><?= htmlspecialchars($item['description']) ?></p>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="evidence-section">
|
|
<div class="section-inner evidence-inner">
|
|
<article>
|
|
<h2><?= htmlspecialchars(dbnToolsT('cause_title', $uiLang)) ?></h2>
|
|
<p><?= htmlspecialchars(dbnToolsT('cause_text', $uiLang)) ?></p>
|
|
</article>
|
|
<article>
|
|
<h2><?= htmlspecialchars(dbnToolsT('privacy_title', $uiLang)) ?></h2>
|
|
<p><?= htmlspecialchars(dbnToolsT('privacy_text', $uiLang)) ?></p>
|
|
</article>
|
|
<article>
|
|
<h2><?= htmlspecialchars(dbnToolsT('source_title', $uiLang)) ?></h2>
|
|
<p><?= htmlspecialchars(dbnToolsT('source_text', $uiLang)) ?></p>
|
|
</article>
|
|
</div>
|
|
</section>
|
|
|
|
<section id="access" class="access-section" aria-labelledby="accessTitle">
|
|
<div class="gate-panel">
|
|
<p class="eyebrow">Do Better Norge</p>
|
|
<h2 id="accessTitle"><?= htmlspecialchars(dbnToolsT('primary_access', $uiLang)) ?></h2>
|
|
<p class="gate-copy"><?= htmlspecialchars(dbnToolsT('member_note', $uiLang)) ?></p>
|
|
<a class="google-access-button" href="<?= htmlspecialchars($toolsLogin) ?>"><?= htmlspecialchars(dbnToolsT('primary_access', $uiLang)) ?></a>
|
|
<p class="gate-copy"><a href="https://dobetternorge.no/register.php"><?= htmlspecialchars(dbnToolsT('register', $uiLang)) ?></a></p>
|
|
|
|
<details class="fallback-login">
|
|
<summary><?= htmlspecialchars(dbnToolsT('secondary_access', $uiLang)) ?></summary>
|
|
<form id="passcodeForm" class="passcode-form">
|
|
<label for="loginEmail"><?= htmlspecialchars(dbnToolsT('email', $uiLang)) ?></label>
|
|
<input id="loginEmail" name="email" type="email" autocomplete="username email" required>
|
|
<label for="loginPassword"><?= htmlspecialchars(dbnToolsT('password', $uiLang)) ?></label>
|
|
<div class="passcode-row">
|
|
<input id="loginPassword" name="password" type="password" autocomplete="current-password" required>
|
|
<button type="submit"><?= htmlspecialchars(dbnToolsT('sign_in', $uiLang)) ?></button>
|
|
</div>
|
|
<p id="gateStatus" class="form-status" role="status" aria-live="polite"></p>
|
|
</form>
|
|
</details>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
<?php endif; ?>
|
|
|
|
<script src="assets/js/tools.js" defer></script>
|
|
</body>
|
|
</html>
|