LuminaWebsite/includes/map_links.php
Maaxxs 342301b082 Consilium: guests see only their shared tactic and go back to the session list when the share ends
Asked for: when the share for the Consilium ends, everyone from the Consilium is sent back to the live overview
(so far only the live view ended and the map stayed open); during the session they may not switch maps or see the
categories - really only the tactic.

- map_frame.php: Consilium guests get the map viewer only for a running shared session (?karte=...&taktik=...),
  otherwise the whole page goes back to the session list; the viewer gets LUMINA_GUEST.
- Viewer guest mode (body.guest-mode): no map picker, no markers or categories (not even loaded), no location
  sharing, no tactic list - only the tactic of the session (tactics_api.php ?taktik=).
- When the share ends (relay event, tactic gone, no ticket), TacticController.endGuestSession() sends the top page
  to map.php?beendet=stopped|ended with a note why; the page around the map also checks every 15 s.
- Calendar: no location picker for guests, meeting points are plain text for them (map_link_html()).
- README, patch note text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 02:04:24 +02:00

98 lines
3.7 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
declare(strict_types=1);
/**
* Links auf Orte der Karte (/map.php?karte=verteron&x=1234&y=2345&zoom=5&ort=Treffpunkt, bei
* Dungeon-Karten /raidplan.php?...), erzeugt ueber "Ort teilen" bzw. "Ort auswaehlen"
* (assets/map/js/controllers/LocationController.js).
* Hier: erkennen, pruefen und als "📍 Verteron – Treffpunkt" anzeigen.
*/
require_once __DIR__ . '/dungeon_maps.php';
// Anzeigenamen der Weltkarten (wie data/maps.json + CONFIG.MAP_NAMES im Viewer) - die Dungeon-Karten
// des Raidplaners kommen aus assets/map/dungeons/dungeons.json dazu (map_link_names)
const MAP_LINK_NAMES = [
'verteron' => 'Verteron',
'elthen' => 'Eltnen',
'poeta' => 'Poeta',
'altgard' => 'Altgard',
'morheim' => 'Morheim',
'ishalgen' => 'Ishalgen',
'abyss-reshanta-a' => 'Abyss Reshanta A',
'abyss-reshanta-b' => 'Abyss Reshanta B',
'chaotic-middle-reshanta' => 'Chaotic Middle Reshanta',
'chaotic-upper-reshanta' => 'Chaotic Upper Reshanta',
];
/** Slug => Anzeigename aller Karten, auf die ein Ort-Link zeigen kann. @return array<string, string> */
function map_link_names(): array
{
return MAP_LINK_NAMES + dungeon_map_names();
}
/** Seite, die eine Karte oeffnet: Dungeon-Karten der Raidplaner, alle anderen die Karte. */
function map_link_page(string $slug): string
{
return isset(dungeon_map_names()[$slug]) ? '/raidplan.php' : '/map.php';
}
/** Regex fuer Karten-Links dieser Website (absolut mit unserer Domain oder relativ). */
function map_link_pattern(): string
{
$host = preg_quote((string) ($_SERVER['HTTP_HOST'] ?? 'lumina-ascendens.de'), '~');
return '~(?:https?://(?:www\.)?' . $host . ')?/(?:map|raidplan)\.php\?[^\s<>"\']+~i';
}
/**
* Karten-Link zerlegen und pruefen.
*
* @return array{slug: string, x: int, y: int, zoom: int, ort: string, path: string}|null
*/
function map_link_parse(string $url): ?array
{
$url = html_entity_decode(trim($url), ENT_QUOTES | ENT_HTML5, 'UTF-8');
if (!preg_match(map_link_pattern(), $url, $match) || $match[0] !== $url) {
return null;
}
parse_str((string) parse_url($url, PHP_URL_QUERY), $query);
$slug = (string) ($query['karte'] ?? '');
if (!isset(map_link_names()[$slug]) || !is_numeric($query['x'] ?? null) || !is_numeric($query['y'] ?? null)) {
return null;
}
$link = [
'slug' => $slug,
'x' => max(0, min(4096, (int) $query['x'])),
'y' => max(0, min(4096, (int) $query['y'])),
'zoom' => max(2, min(6, (int) ($query['zoom'] ?? 5))),
'ort' => mb_substr(trim((string) ($query['ort'] ?? '')), 0, 60),
];
$params = ['karte' => $link['slug'], 'x' => $link['x'], 'y' => $link['y'], 'zoom' => $link['zoom']];
if ($link['ort'] !== '') {
$params['ort'] = $link['ort'];
}
$link['path'] = map_link_page($slug) . '?' . http_build_query($params);
return $link;
}
/** "Verteron – Treffpunkt Brücke" */
function map_link_label(array $link): string
{
return map_link_names()[$link['slug']] . ($link['ort'] !== '' ? ' – ' . $link['ort'] : '');
}
/** Huebscher Link mit Pin fuer Texte (Kommentare, Termine). */
function map_link_html(array $link): string
{
// Gaeste des Consiliums sehen die Karte nur in freigegebenen Live-Sitzungen - fuer sie der Ort ohne Link
if (consilium_only()) {
return '<span class="map-link">📍 ' . e(map_link_label($link)) . '</span>';
}
return '<a class="map-link" href="' . e($link['path']) . '" title="Auf der Karte zeigen">📍 ' . e(map_link_label($link)) . '</a>';
}
/** Text ohne eigene Karten-Links - die zaehlen fuer die Moderation nicht als "Link". */
function map_links_strip(string $text): string
{
return (string) preg_replace(map_link_pattern(), ' ', $text);
}