This commit is contained in:
2025-12-29 01:36:23 +01:00
parent 5157d70eb2
commit c9773db510
3 changed files with 73 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ $isDebug = defined('APP_DEBUG') && APP_DEBUG === true;
<nav class="nav-links" aria-label="Hauptmenü"> <nav class="nav-links" aria-label="Hauptmenü">
<a href="/">Start</a> <a href="/">Start</a>
<a href="/#events">Events</a> <a href="/#events">Events</a>
<a href="/search">Suche</a>
<a href="/#profil">Profil</a> <a href="/#profil">Profil</a>
<a href="/#faq">FAQ</a> <a href="/#faq">FAQ</a>
</nav> </nav>
@@ -35,6 +36,7 @@ $isDebug = defined('APP_DEBUG') && APP_DEBUG === true;
<div class="mobile-menu" id="mobileMenu"> <div class="mobile-menu" id="mobileMenu">
<a href="/">Start</a> <a href="/">Start</a>
<a href="/#events">Events</a> <a href="/#events">Events</a>
<a href="/search">Suche</a>
<a href="/#profil">Profil</a> <a href="/#profil">Profil</a>
<a href="/#faq">FAQ</a> <a href="/#faq">FAQ</a>
<?php if ($isLoggedIn): ?> <?php if ($isLoggedIn): ?>

View File

@@ -87,7 +87,7 @@ document.addEventListener('DOMContentLoaded', () => {
const renderCard = (item) => { const renderCard = (item) => {
const guest = !isLoggedIn; const guest = !isLoggedIn;
const access = item.visibility === 'members' && guest ? '<div class="event__access">Nur für Mitglieder</div>' : ''; const access = item.visibility === 'members' && guest ? '<div class="event__access">Nur für Mitglieder</div>' : '';
const desc = guest ? `<p class="muted">Melde dich an, um die volle Beschreibung zu sehen.</p>` : `<p>${item.description}</p>`; const desc = `<p class="muted">${item.teaser}</p>`;
const contact = !guest ? `<div class="muted small">Kontakt: ${item.contact}</div>` : ''; const contact = !guest ? `<div class="muted small">Kontakt: ${item.contact}</div>` : '';
const kids = item.allowKids ? 'Mit Kindern' : 'Ohne Kinder'; const kids = item.allowKids ? 'Mit Kindern' : 'Ohne Kinder';
const tags = [ const tags = [
@@ -164,6 +164,7 @@ document.addEventListener('DOMContentLoaded', () => {
el.modalBody.innerHTML = ` el.modalBody.innerHTML = `
<div class="muted small">${fmtDate(ev.startsAt)} · ${ev.region || ev.city || ''}</div> <div class="muted small">${fmtDate(ev.startsAt)} · ${ev.region || ev.city || ''}</div>
<p class="muted">${ev.teaser}</p> <p class="muted">${ev.teaser}</p>
<p>${ev.description}</p>
${ev.locationLabel ? `<p><strong>Ort:</strong> ${ev.locationLabel}</p>` : ''} ${ev.locationLabel ? `<p><strong>Ort:</strong> ${ev.locationLabel}</p>` : ''}
<p><strong>Kinder:</strong> ${ev.allowKids ? 'Mit Kindern' : 'Ohne Kinder'}</p> <p><strong>Kinder:</strong> ${ev.allowKids ? 'Mit Kindern' : 'Ohne Kinder'}</p>
<p><strong>Sichtbarkeit:</strong> ${ev.visibility === 'public' ? 'Öffentlich' : 'Nur Mitglieder'}</p> <p><strong>Sichtbarkeit:</strong> ${ev.visibility === 'public' ? 'Öffentlich' : 'Nur Mitglieder'}</p>

69
public/page/search.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
$app = app();
$pdo = $app->pdo();
$q = trim((string)($_GET['q'] ?? ''));
$results = [];
if ($q !== '' && $pdo) {
$like = '%' . $q . '%';
$stmt = $pdo->prepare(
'SELECT id, title, teaser_public, description, city, region, starts_at, visibility, allow_kids, location_label
FROM events
WHERE starts_at >= NOW()
AND status != "cancelled"
AND (title LIKE :q OR teaser_public LIKE :q OR description LIKE :q OR city LIKE :q OR region LIKE :q OR zip LIKE :q)
ORDER BY starts_at ASC
LIMIT 100'
);
$stmt->execute(['q' => $like]);
$results = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];
}
?>
<main class="section">
<div class="container">
<p class="eyebrow">Suche</p>
<h1>Events finden</h1>
<form method="get" class="form-grid single" style="margin: 14px 0;">
<div class="stack gap-6">
<label class="label" for="q">Suchbegriff (Titel, Ort, Beschreibung)</label>
<input id="q" name="q" class="input" value="<?= htmlspecialchars($q, ENT_QUOTES) ?>" placeholder="z. B. Berlin oder Spielplatz">
</div>
<button class="btn" type="submit">Suchen</button>
</form>
<?php if ($q === ''): ?>
<p class="muted">Bitte gib einen Suchbegriff ein.</p>
<?php else: ?>
<h3 style="margin-top: 16px;"><?= count($results) ?> Ergebnis(se) für „<?= htmlspecialchars($q, ENT_QUOTES) ?>“</h3>
<?php if (!$results): ?>
<p class="muted">Keine passenden Events gefunden.</p>
<?php else: ?>
<div class="stack gap-12" style="margin-top: 12px;">
<?php foreach ($results as $ev): ?>
<article class="card">
<div class="event__body">
<div class="event__meta">
<span><?= htmlspecialchars($ev['starts_at'], ENT_QUOTES) ?></span>
<span>📍 <?= htmlspecialchars($ev['region'] ?: $ev['city'], ENT_QUOTES) ?></span>
<span><?= $ev['visibility'] === 'public' ? 'Öffentlich' : 'Mitglieder' ?></span>
</div>
<h3><?= htmlspecialchars($ev['title'], ENT_QUOTES) ?></h3>
<p class="muted"><?= htmlspecialchars($ev['teaser_public'], ENT_QUOTES) ?></p>
<p><strong>Kinder:</strong> <?= ((int)$ev['allow_kids'] === 1) ? 'Mit Kindern' : 'Ohne Kinder' ?></p>
<?php if (!empty($ev['location_label'])): ?>
<p><strong>Ort:</strong> <?= htmlspecialchars($ev['location_label'], ENT_QUOTES) ?></p>
<?php endif; ?>
<details>
<summary style="cursor:pointer;">Details anzeigen</summary>
<p><?= nl2br(htmlspecialchars($ev['description'], ENT_QUOTES)) ?></p>
</details>
</div>
</article>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</main>