Files
geograsim/App/pages/_partials/buch_helpers.php
T
Adminator c4276083a2 Glossar visuell komplett: 162 Bilder, 13 Kapitel-Icons, 12 interaktive Widgets
- 162 neue Glossar-Bilder (Flat-Scandinavian, gpt-image-1) → alle 402 Einträge bebildert;
  image_path-Update: App/Don_t_Deploy/2026-07-16-glossar-bilder.sql
- 13 Kapitel-Icons (icon-<id>.webp) ersetzen die Emojis in Buch-Übersicht + Kapitel-h1
  (buchKapIcon-Helper mit Emoji-Fallback)
- 12 interaktive Glossar-Experimente in 2 Modulen:
  natur (Mondrotation, Kernschatten, Keeling-Kurve, Pegel/HQ100, Wärmeausdehnung,
  Klimaträgheit) + wirtschaft (Preiselastizität, Engpass, Skaleneffekt, Modal Split,
  Netzfrequenz/Hertz, Lageenergie/Pumpspeicher); Registry via Object.assign,
  Script-Einbindung in glossar.php

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 00:59:30 +02:00

76 lines
3.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Schulbuch — gemeinsame Helfer für alle Kapitel (buch-<sim>.php)
* ---------------------------------------------------------------
* Verwendung im Kapitel:
* define('BUCH_SIM', 'tourismustal'); // Ordner für Foto-Slots
* require __DIR__ . '/_partials/buch_helpers.php';
*
* Stellt bereit:
* $MODE 'schueler' | 'leicht' | 'lehrer' (?leicht=1 / ?lehrer=1)
* $LEHRER, $LEICHT Bequemlichkeits-Booleans
* buchBild($slug, $vorschlag, $unterschrift, $klein) Foto-Slot
* g($slug, $label) Glossar-Tooltip
* buchNav($links) Kopfzeile mit Modus-Umschalter
*
* Fotos: echte Bilder unter assets/img/buch/<BUCH_SIM>/<slug>.jpg ablegen —
* Platzhalter tauschen sich automatisch aus. Bild-Exporte immer ohne
* EXIF/GPS (magick -strip).
*/
$MODE = 'schueler';
if (isset($_GET['lehrer']) && $_GET['lehrer'] === '1') $MODE = 'lehrer';
if (isset($_GET['leicht']) && $_GET['leicht'] === '1') $MODE = 'leicht';
$LEHRER = ($MODE === 'lehrer');
$LEICHT = ($MODE === 'leicht');
/** Foto-Slot: echtes Bild, sobald es existiert sonst Platzhalter mit Vorschlag. */
function buchBild(string $slug, string $vorschlag, string $unterschrift = '', bool $klein = false): string {
global $bp;
$cls = $klein ? 'b-foto b-klein' : 'b-foto';
foreach (['jpg', 'jpeg', 'webp', 'png'] as $ext) {
$rel = 'assets/img/buch/' . BUCH_SIM . "/{$slug}.{$ext}";
if (is_file(__DIR__ . '/../../' . $rel)) {
$cap = $unterschrift !== '' ? "<figcaption>{$unterschrift}</figcaption>" : '';
return "<figure class=\"{$cls}\"><img src=\"{$bp}/{$rel}\" alt=\"" . htmlspecialchars($unterschrift ?: $slug) . "\" loading=\"lazy\">{$cap}</figure>";
}
}
return "<div class=\"b-foto-platzhalter\"><span>📷</span><b>Foto gesucht</b><small>" . htmlspecialchars($vorschlag) . "</small><code>assets/img/buch/" . BUCH_SIM . "/{$slug}.jpg</code></div>";
}
/** Kapitel-Symbol: generiertes Icon-Bild, solange keins da ist das Emoji. */
function buchKapIcon(string $emoji): string {
global $bp;
$rel = 'assets/img/buch/icon-' . BUCH_SIM . '.webp';
if (is_file(__DIR__ . '/../../' . $rel)) {
return '<img class="b-kapicon" src="' . $bp . '/' . $rel . '" alt="">';
}
return $emoji;
}
/** Glossar-Begriff mit Tooltip */
function g(string $slug, string $label): string {
return "<span class=\"ggs-g\" data-glossar=\"{$slug}\">{$label}</span>";
}
/**
* Kopfzeile: Links + Modus-Umschalter.
* $links: Array [Label => href-relativ-zu-BASE_PATH], z. B.
* ['Modulseite' => 'modul-tourismustal', '🎮 Simulation starten' => 'tourismustal', ...]
*/
function buchNav(array $links): void {
global $bp, $MODE;
echo '<nav class="b-nav"><a href="' . $bp . '/buch">📖 Schulbuch</a>';
foreach ($links as $label => $href) {
echo ' · <a href="' . $bp . '/' . $href . '">' . $label . '</a>';
}
echo '<span class="spacer"></span>';
echo '<a class="b-mode ' . ($MODE === 'schueler' ? 'active' : '') . '" href="?">👩‍🎓 Schüler:innen</a>';
echo '<a class="b-mode ' . ($MODE === 'leicht' ? 'active' : '') . '" href="?leicht=1">🌱 Leichte Sprache</a>';
echo '<a class="b-mode ' . ($MODE === 'lehrer' ? 'active' : '') . '" href="?lehrer=1">👩‍🏫 Lehrperson</a>';
echo '</nav>';
if ($MODE === 'leicht') {
echo '<div class="b-leicht-hinweis">🌱 Dieses Heft ist in <b>Leichter Sprache</b>. Kurze Sätze. Einfache Wörter. Die Bilder und Zahlen sind die gleichen wie im großen Heft.</div>';
}
}