LuminaWebsite/wiki.php
Maaxxs c4f94bf84a Member feedback: raid input checks and fixed raid points, premades in the raid form, live raid page, Lumina-style dialogs, leadership calendar entries, class-based weapon picker, map and tactics fixes
- Raids: "Max. Spieler" only whole numbers up to groups x 5 (max. 10 groups / 50), gearscore only a number; fixed +1 Lumipunkt per participation, other values only with the new raids.points permission; pick an existing premade per group when creating a raid; unchanged legacy values no longer block editing
- Raid page updates itself every 15 s while visible (raids_live.php, cards rendered by includes/raid_card.php), open editors and confirm dialogs are kept
- Restore takes the new raid_id from the bot (archived messages are now deleted in Discord) and moves settings, attendance and awards; website signups send the server display name
- Premades: dissolve by leadership needs a reason, lead gets DMs on join/assign/decline/remove (source/actor_id sent to the bot), transfer picker skips players who already lead a group, website accept keeps the one-group rule, no commas in names
- Site-wide Lumina dialog (assets/js/confirm-dialog.js) replaces confirm/prompt/alert via data-confirm; error flashes are a dialog you confirm with OK
- Calendar: audience per entry (all / leadership takes part / internal) with the new calendar.leadership permission; day cells list all entries and scroll
- Gear planner: main-hand picker filtered by the set's class, mismatches marked, "keine Klasse" option, link to an external skill/Daevanion plan per set
- Map: correct kisk icons (Elyos on Verteron/Abyss, Altgard fixed), per-map max zoom and bounded panning, German texts, data source note
- Tactics: toolbar as a uniform grid, whole-tactic copy, automatic versions with restore and a 90-day trash, official tactics protected
- Global thin gold scrollbars, readable hover colours, "Sedes Luminis" spelling, patch notes and README, schema version 34

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 16:12:18 +02:00

338 lines
18 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
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/wiki.php';
require_permission('wiki.view');
$canEdit = wiki_can_edit();
$canManage = wiki_can_manage();
$tree = wiki_tree();
$slug = (string) ($_GET['page'] ?? '');
$query = trim((string) ($_GET['q'] ?? ''));
$page = $slug !== '' ? wiki_page_by_slug($slug) : null;
if ($slug !== '' && !$page) {
show_not_found();
}
// Position der Seite im Baum: Nummer, Kapitel, Vorgaenger/Nachfolger in Lesereihenfolge
$flat = [];
foreach ($tree as $chapter) {
$flat[] = $chapter;
foreach ($chapter['children'] as $child) {
$flat[] = $child + ['chapter' => $chapter];
}
}
$current = null;
$prev = null;
$next = null;
$chapterOfPage = null;
if ($page) {
foreach ($flat as $index => $entry) {
if ((int) $entry['id'] === (int) $page['id']) {
$current = $entry;
$prev = $flat[$index - 1] ?? null;
$next = $flat[$index + 1] ?? null;
$chapterOfPage = $entry['chapter'] ?? null;
break;
}
}
}
$childrenOfPage = [];
if ($page && $page['parent_id'] === null) {
foreach ($tree as $chapter) {
if ((int) $chapter['id'] === (int) $page['id']) {
$childrenOfPage = $chapter['children'];
}
}
}
$results = $query !== '' ? wiki_search($query) : [];
// Mitwirkende: hinzugefuegte Mitglieder
$contributors = db()->query(
"SELECT u.id, u.username, u.display_name, u.discord_id, u.avatar_filename, u.class_name
FROM wiki_contributors c JOIN users u ON u.id = c.user_id
ORDER BY COALESCE(NULLIF(u.display_name, ''), u.username)"
)->fetchAll();
$addableMembers = [];
if ($canManage && !$page && $query === '') {
$addableMembers = db()->query(
"SELECT u.id, COALESCE(NULLIF(u.display_name, ''), u.username) AS name, u.avatar_filename, u.class_name,
(SELECT COALESCE(NULLIF(r.display_name, ''), r.name) FROM user_roles ur JOIN roles r ON r.id = ur.role_id
WHERE ur.user_id = u.id ORDER BY COALESCE(r.roster_order, 999), r.name LIMIT 1) AS top_role
FROM users u
WHERE u.status = 'active' AND u.id NOT IN (SELECT user_id FROM wiki_contributors)
ORDER BY name"
)->fetchAll();
}
// Fuer die Suchliste (assets/js/item-picker.js): Avatar, Name, Gruppe und Klasse
$contributorPickerItems = [];
foreach ($addableMembers as $member) {
$contributorPickerItems[] = [
'id' => (int) $member['id'],
'name' => (string) $member['name'],
'category' => trim(($member['top_role'] ?? 'Mitglied') . (!empty($member['class_name']) ? ' · ' . $member['class_name'] : '')),
'icon' => !empty($member['avatar_filename']) ? '/assets/uploads/avatars/' . rawurlencode((string) $member['avatar_filename']) : null,
'qty' => null,
];
}
$pageCount = count($flat);
$pageTitle = $page ? $page['title'] . ' - Wiki' : 'Wiki';
$containerWide = true;
include __DIR__ . '/includes/header.php';
$nameOf = static fn (array $u): string => $u['display_name'] !== '' ? $u['display_name'] : $u['username'];
?>
<div class="wiki-layout">
<aside class="panel wiki-nav" aria-label="Inhaltsverzeichnis">
<a class="wiki-nav-home<?= !$page && $query === '' ? ' active' : '' ?>" href="/wiki.php"><?= icon('book') ?> Einsteiger-Guide</a>
<form class="wiki-search" method="get" action="/wiki.php" role="search">
<input type="search" name="q" value="<?= e($query) ?>" placeholder="Im Wiki suchen …" aria-label="Im Wiki suchen">
</form>
<details class="wiki-toc-wrap" id="wiki-toc-wrap" open>
<summary class="wiki-toc-summary">Inhaltsverzeichnis</summary>
<nav class="wiki-toc">
<?php foreach ($tree as $chapter): ?>
<?php $open = $page && ((int) $chapter['id'] === (int) $page['id'] || (int) $chapter['id'] === (int) ($page['parent_id'] ?? 0)); ?>
<details class="wiki-toc-chapter"<?= $open ? ' open' : '' ?>>
<summary>
<a href="/wiki.php?page=<?= e(rawurlencode($chapter['slug'])) ?>" class="<?= $page && (int) $page['id'] === (int) $chapter['id'] ? 'active' : '' ?>">
<span class="wiki-num"><?= e($chapter['number']) ?></span>
<span class="wiki-toc-title"><?= e($chapter['title']) ?></span>
<?php if ($chapter['is_wip']): ?><span class="wiki-wip">WIP</span><?php endif; ?>
</a>
</summary>
<?php if (!empty($chapter['children'])): ?>
<ul>
<?php foreach ($chapter['children'] as $child): ?>
<li>
<a href="/wiki.php?page=<?= e(rawurlencode($child['slug'])) ?>" class="<?= $page && (int) $page['id'] === (int) $child['id'] ? 'active' : '' ?>">
<span class="wiki-num"><?= e($child['number']) ?></span>
<span class="wiki-toc-title"><?= e($child['title']) ?></span>
<?php if ($child['is_wip']): ?><span class="wiki-wip">WIP</span><?php endif; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</details>
<?php endforeach; ?>
</nav>
<?php if ($canEdit): ?>
<a class="button button-secondary button-small wiki-new-chapter" href="/wiki_edit.php?new=1">+ Neues Kapitel</a>
<?php endif; ?>
</details>
<?php if ($page || $query !== ''): ?>
<script>
// Handy: beim Lesen einer Seite das Inhaltsverzeichnis zuklappen, damit der Text oben steht.
if (window.matchMedia('(max-width: 900px)').matches) {
document.getElementById('wiki-toc-wrap').open = false;
}
</script>
<?php endif; ?>
</aside>
<main class="wiki-main">
<?php if ($query !== ''): ?>
<div class="panel">
<h1>Suche: „<?= e($query) ?>“</h1>
<?php if (mb_strlen($query) < 2): ?>
<p class="text-muted">Bitte mindestens zwei Zeichen eingeben.</p>
<?php elseif (empty($results)): ?>
<p class="text-muted">Nichts gefunden. Vielleicht mit einem anderen Begriff?</p>
<?php else: ?>
<ul class="wiki-results">
<?php foreach ($results as $result): ?>
<li>
<a href="/wiki.php?page=<?= e(rawurlencode($result['slug'])) ?>"><?= e($result['title']) ?></a>
<p class="text-muted"><?= e($result['snippet']) ?></p>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<?php elseif ($page): ?>
<article class="panel wiki-article">
<nav class="wiki-breadcrumb" aria-label="Pfad">
<a href="/wiki.php">Wiki</a>
<?php if ($chapterOfPage): ?>
<span>›</span> <a href="/wiki.php?page=<?= e(rawurlencode($chapterOfPage['slug'])) ?>"><?= e($chapterOfPage['title']) ?></a>
<?php endif; ?>
</nav>
<header class="wiki-article-head">
<h1><span class="wiki-num"><?= e($current['number'] ?? '') ?></span> <?= e($page['title']) ?>
<?php if ($page['is_wip']): ?><span class="wiki-wip wiki-wip-large" title="Dieser Abschnitt ist noch in Arbeit">WIP</span><?php endif; ?>
</h1>
<div class="wiki-article-actions">
<?php if ($canEdit): ?>
<a class="button button-small" href="/wiki_edit.php?id=<?= (int) $page['id'] ?>"><?= icon('edit') ?> Bearbeiten</a>
<?php if ($page['parent_id'] === null): ?>
<a class="button button-secondary button-small" href="/wiki_edit.php?parent=<?= (int) $page['id'] ?>">+ Unterseite</a>
<?php endif; ?>
<?php endif; ?>
<a class="button button-secondary button-small" href="/wiki_history.php?id=<?= (int) $page['id'] ?>">Verlauf</a>
<?php if ($canManage): ?>
<form method="post" action="/wiki_action.php" class="inline-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="move">
<input type="hidden" name="id" value="<?= (int) $page['id'] ?>">
<button type="submit" name="direction" value="up" class="icon-button" title="Nach oben verschieben">▲</button>
<button type="submit" name="direction" value="down" class="icon-button" title="Nach unten verschieben">▼</button>
</form>
<form method="post" action="/wiki_action.php" class="inline-form"
data-confirm="Diese Seite<?= $page['parent_id'] === null ? ' samt allen Unterseiten' : '' ?> wirklich löschen?" data-confirm-title="Wiki-Seite löschen" data-confirm-danger data-confirm-ok="Löschen">
<?= csrf_field() ?>
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" value="<?= (int) $page['id'] ?>">
<button type="submit" class="icon-button icon-button-danger" title="Löschen"><?= icon('trash') ?></button>
</form>
<?php endif; ?>
</div>
</header>
<?php if (trim($page['content']) === ''): ?>
<p class="wiki-empty">Dieser Abschnitt ist noch leer.<?= $canEdit ? ' Magst du ihn schreiben?' : ' Er wird gerade noch geschrieben.' ?></p>
<?php else: ?>
<div class="wiki-content"><?= wiki_render($page['content']) ?></div>
<?php endif; ?>
<?php if (!empty($childrenOfPage)): ?>
<div class="wiki-subpages">
<h2>In diesem Kapitel</h2>
<div class="wiki-subpage-grid">
<?php foreach ($childrenOfPage as $child): ?>
<a class="wiki-subpage" href="/wiki.php?page=<?= e(rawurlencode($child['slug'])) ?>">
<span class="wiki-num"><?= e($child['number']) ?></span>
<span class="wiki-subpage-title"><?= e($child['title']) ?></span>
<?php if ($child['is_wip']): ?><span class="wiki-wip">WIP</span><?php endif; ?>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<footer class="wiki-article-foot">
<span class="text-muted">
Zuletzt bearbeitet<?= $page['updated_by_name'] ? ' von ' . e($page['updated_by_name']) : '' ?>
am <?= e(date('d.m.Y H:i', strtotime($page['updated_at']))) ?> Uhr
</span>
<nav class="wiki-pager">
<?php if ($prev): ?>
<a href="/wiki.php?page=<?= e(rawurlencode($prev['slug'])) ?>">← <?= e($prev['number'] . ' ' . $prev['title']) ?></a>
<?php endif; ?>
<?php if ($next): ?>
<a href="/wiki.php?page=<?= e(rawurlencode($next['slug'])) ?>"><?= e($next['number'] . ' ' . $next['title']) ?> →</a>
<?php endif; ?>
</nav>
</footer>
</article>
<?php else: ?>
<div class="panel wiki-hero">
<h1><?= icon('book') ?> Einsteiger-Guide</h1>
<p>Informationen und Tipps rund um Aion 2 - von Mitgliedern für Mitglieder. Der Guide wächst mit jedem, der mitschreibt.</p>
<p class="text-muted"><?= $pageCount ?> Seiten<?= !empty($contributors) ? ' · ' . count($contributors) . ' Mitwirkende' : '' ?></p>
</div>
<?php if (empty($tree)): ?>
<div class="panel">
<p>Das Wiki ist noch leer.</p>
<div class="actions">
<?php if ($canManage): ?>
<form method="post" action="/wiki_action.php" class="inline-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="import">
<button type="submit">Einsteiger-Guide aus dem Spreadsheet übernehmen</button>
</form>
<?php endif; ?>
<?php if ($canEdit): ?>
<a class="button button-secondary" href="/wiki_edit.php?new=1">Erstes Kapitel schreiben</a>
<?php endif; ?>
</div>
</div>
<?php else: ?>
<div class="wiki-chapter-grid">
<?php foreach ($tree as $chapter): ?>
<a class="panel wiki-chapter-card" href="/wiki.php?page=<?= e(rawurlencode($chapter['slug'])) ?>">
<span class="wiki-chapter-no"><?= e(rtrim($chapter['number'], '.')) ?></span>
<h2><?= e($chapter['title']) ?><?php if ($chapter['is_wip']): ?> <span class="wiki-wip">WIP</span><?php endif; ?></h2>
<?php if (!empty($chapter['children'])): ?>
<p class="text-muted"><?= e(implode(' · ', array_map(static fn ($c) => $c['title'], $chapter['children']))) ?></p>
<?php endif; ?>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="panel wiki-contributors" id="mitwirkende">
<h2>Mitwirkende</h2>
<p class="text-muted">Diese Mitglieder schreiben am Guide mit. <?= $canManage ? 'Weitere Mitglieder kannst du unten hinzufügen - sie dürfen dann Seiten anlegen und bearbeiten.' : 'Du möchtest mithelfen? Sprich die Leitung an.' ?></p>
<?php if (empty($contributors)): ?>
<p class="text-muted">Noch niemand hinzugefügt.</p>
<?php else: ?>
<div class="wiki-contributor-list">
<?php foreach ($contributors as $contributor): ?>
<div class="wiki-contributor">
<?= avatar_html($contributor, 34) ?>
<span><?= e($nameOf($contributor)) ?></span>
<?= class_badge_html($contributor['class_name'] ?? null, 18) ?>
<?php if ($canManage): ?>
<form method="post" action="/wiki_action.php" class="inline-form" data-confirm="<?= e($nameOf($contributor) . ' als Mitwirkende/n entfernen?') ?>" data-confirm-title="Mitwirkende entfernen" data-confirm-danger data-confirm-ok="Entfernen">
<?= csrf_field() ?>
<input type="hidden" name="action" value="contributor_remove">
<input type="hidden" name="user_id" value="<?= (int) $contributor['id'] ?>">
<button type="submit" class="icon-button icon-button-danger" title="Entfernen"><?= icon('x') ?></button>
</form>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($canManage && !empty($addableMembers)): ?>
<form method="post" action="/wiki_action.php" class="wiki-contributor-add">
<?= csrf_field() ?>
<input type="hidden" name="action" value="contributor_add">
<div class="item-picker" data-picker-items="wiki-contributor-list" data-picker-mode="id" data-picker-round data-picker-empty="Kein Mitglied gefunden." data-picker-invalid="Bitte ein Mitglied aus der Liste wählen.">
<input type="hidden" name="user_id">
<label class="search-field">
<span class="item-picker-icon"><?= icon('search') ?></span>
<input type="text" class="item-picker-input" id="wiki-contributor-search" required placeholder="Mitglied suchen …" aria-label="Mitglied auswählen">
</label>
</div>
<button type="submit">+ Hinzufügen</button>
</form>
<script type="application/json" id="wiki-contributor-list"><?= json_encode($contributorPickerItems, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP) ?></script>
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
<?php endif; ?>
</div>
<?php endif; ?>
</main>
</div>
<script>
// "In diesem Kapitel": Kacheln gleichmaessig auf die Zeilen verteilen (8 bei Platz fuer 5 -> 4/4 statt 5/3)
(function () {
var grids = document.querySelectorAll('.wiki-subpage-grid');
if (!grids.length) return;
var MIN_WIDTH = 220; // wie minmax(220px, 1fr) im CSS
function balance(grid) {
var count = grid.children.length;
var gap = parseFloat(getComputedStyle(grid).columnGap) || 0;
var maxCols = Math.max(1, Math.floor((grid.clientWidth + gap) / (MIN_WIDTH + gap)));
// Am liebsten eine Spaltenzahl, die glatt aufgeht (8 -> 4/4 oder 2/2/2/2) - solange sie
// mindestens die halbe Breite nutzt. Sonst so gleichmaessig wie moeglich (7 -> 4/3).
var cols = 0;
for (var c = Math.min(maxCols, count); c >= Math.ceil(Math.min(maxCols, count) / 2); c--) {
if (count % c === 0) { cols = c; break; }
}
if (!cols) cols = Math.ceil(count / Math.ceil(count / maxCols));
grid.style.gridTemplateColumns = 'repeat(' + cols + ', minmax(0, 1fr))';
}
grids.forEach(function (grid) {
balance(grid);
if (window.ResizeObserver) new ResizeObserver(function () { balance(grid); }).observe(grid);
});
})();
</script>
<?php include __DIR__ . '/includes/footer.php'; ?>