1e51ef7def
- Konzept/, didaktik_geografie/, didaktik_simulation/, v2-modules/, v2-platform/ - 12 code-workspace-Files - STATUS-*.md - viele M/D/R-Änderungen an bereits getrackten Files - .gitignore verstärkt: **/.humaninput/, **/secret_keys.txt Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* GET /api/glossary/<slug>?lang=de-AT-easy
|
|
*
|
|
* Wir nutzen die V1-glossar-Tabelle additiv (sie hat schon short/long/easy-Spalten).
|
|
* Pfad-Schema: /api/glossary.php?slug=intermodalverkehr (oder via .htaccess /api/glossary/intermodalverkehr)
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/../../bootstrap.php';
|
|
|
|
v2_validate_method('GET');
|
|
v2_auth_require('any');
|
|
|
|
// Slug kommt entweder als ?slug= oder via PATH_INFO
|
|
$slug = $_GET['slug'] ?? '';
|
|
if (!$slug && !empty($_SERVER['PATH_INFO'])) {
|
|
$slug = trim($_SERVER['PATH_INFO'], '/');
|
|
}
|
|
if (!$slug) {
|
|
v2_response_error(400, 'missing_slug', 'Glossar-Slug fehlt.');
|
|
}
|
|
|
|
$lang = $_GET['lang'] ?? 'de-AT-standard';
|
|
$useEasy = str_ends_with($lang, '-easy');
|
|
|
|
$row = v2_db_one("
|
|
SELECT slug, term, short, short_easy, text, text_easy, image_path
|
|
FROM glossar
|
|
WHERE slug = :slug
|
|
", [':slug' => $slug]);
|
|
|
|
if (!$row) {
|
|
v2_response_error(404, 'not_found', "Glossar-Eintrag '$slug' nicht gefunden.");
|
|
}
|
|
|
|
$shortText = $useEasy && !empty($row['short_easy']) ? $row['short_easy'] : $row['short'];
|
|
$longText = $useEasy && !empty($row['text_easy']) ? $row['text_easy'] : $row['text'];
|
|
|
|
v2_response_ok([
|
|
'slug' => $row['slug'],
|
|
'title' => $row['term'],
|
|
'shortText' => $shortText,
|
|
'longTextHtml' => $longText,
|
|
'imageUrl' => $row['image_path']
|
|
? V2_BASE_URL . '/../assets/img/glossar/' . basename($row['image_path'])
|
|
: null,
|
|
]);
|