60 lines
2.4 KiB
PHP
60 lines
2.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
$app = app();
|
|
$pdo = $app->pdo();
|
|
$q = trim((string)($_GET['q'] ?? ''));
|
|
$results = [];
|
|
|
|
if ($q !== '' && $pdo) {
|
|
$search = new \App\Search($pdo);
|
|
$results = $search->searchEvents($q, 100);
|
|
}
|
|
?>
|
|
<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>
|
|
<span class="badge"><?= ((int)$ev['allow_kids'] === 1) ? 'Mit Kindern' : 'Ohne Kinder' ?></span>
|
|
</div>
|
|
<h3><?= htmlspecialchars($ev['title'], ENT_QUOTES) ?></h3>
|
|
<p class="muted"><?= htmlspecialchars($ev['teaser_public'], ENT_QUOTES) ?></p>
|
|
<?php if (!empty($ev['location_label'])): ?>
|
|
<p class="muted small"><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>
|