87 lines
4.1 KiB
PHP
87 lines
4.1 KiB
PHP
|
|
<?php /** @var array $items */ ?>
|
|||
|
|
<?php /** @var int $total */ ?>
|
|||
|
|
<?php /** @var int $page */ ?>
|
|||
|
|
<?php /** @var int $pages */ ?>
|
|||
|
|
<?php /** @var string $query */ ?>
|
|||
|
|
<?php
|
|||
|
|
$linkFor = static function (int $targetPage) use ($query): string {
|
|||
|
|
$params = [];
|
|||
|
|
if ($query !== '') {
|
|||
|
|
$params['q'] = $query;
|
|||
|
|
}
|
|||
|
|
if ($targetPage > 1) {
|
|||
|
|
$params['page'] = $targetPage;
|
|||
|
|
}
|
|||
|
|
return url('/admin/routines') . ($params ? '?' . http_build_query($params) : '');
|
|||
|
|
};
|
|||
|
|
?>
|
|||
|
|
<div class="page-head">
|
|||
|
|
<div>
|
|||
|
|
<h1>Verwaltung</h1>
|
|||
|
|
<p class="muted"><?= (int) $total ?> Küren insgesamt, auch versteckte.</p>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<?php $active = 'routines'; require HUB_ROOT . '/views/_admin_nav.php'; ?>
|
|||
|
|
|
|||
|
|
<div class="toolbar">
|
|||
|
|
<form method="get" action="<?= e(url('/admin/routines')) ?>" class="search">
|
|||
|
|
<input type="search" name="q" value="<?= e_attr($query) ?>" placeholder="Titel, Skater, Benutzer …">
|
|||
|
|
<button type="submit">Suchen</button>
|
|||
|
|
</form>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<?php if (!$items): ?>
|
|||
|
|
<div class="empty"><p>Keine Küren gefunden.</p></div>
|
|||
|
|
<?php else: ?>
|
|||
|
|
<div class="table-wrap">
|
|||
|
|
<table class="list compact">
|
|||
|
|
<thead>
|
|||
|
|
<tr><th>Titel</th><th>Von</th><th>Status</th><th>Rev.</th><th>Aktualisiert</th><th>Downloads</th><th>Aktionen</th></tr>
|
|||
|
|
</thead>
|
|||
|
|
<tbody>
|
|||
|
|
<?php foreach ($items as $item): ?>
|
|||
|
|
<tr>
|
|||
|
|
<td><a href="<?= e(url('/routines/' . (int) $item['id'])) ?>"><?= e($item['title']) ?></a></td>
|
|||
|
|
<td><?= e($item['owner_username']) ?></td>
|
|||
|
|
<td><span class="status status-<?= $item['status'] === 'published' ? 'open' : 'expired' ?>"><?= e($item['status']) ?></span></td>
|
|||
|
|
<td><?= $item['revision'] !== null ? (int) $item['revision'] : '–' ?></td>
|
|||
|
|
<td><?= e(fmt_dt($item['updated_at'])) ?></td>
|
|||
|
|
<td><?= (int) $item['download_count'] ?></td>
|
|||
|
|
<td>
|
|||
|
|
<div class="row-actions">
|
|||
|
|
<form class="inline" method="post" action="<?= e(url('/admin/routines/action')) ?>">
|
|||
|
|
<?= csrf_field() ?>
|
|||
|
|
<input type="hidden" name="routine_id" value="<?= (int) $item['id'] ?>">
|
|||
|
|
<input type="hidden" name="action" value="<?= $item['status'] === 'published' ? 'hide' : 'publish' ?>">
|
|||
|
|
<button class="link-button" type="submit"><?= $item['status'] === 'published' ? 'verstecken' : 'veröffentlichen' ?></button>
|
|||
|
|
</form>
|
|||
|
|
<details class="danger-zone">
|
|||
|
|
<summary>löschen</summary>
|
|||
|
|
<form method="post" action="<?= e(url('/admin/routines/action')) ?>" class="stack-tight">
|
|||
|
|
<?= csrf_field() ?>
|
|||
|
|
<input type="hidden" name="routine_id" value="<?= (int) $item['id'] ?>">
|
|||
|
|
<input type="hidden" name="action" value="delete">
|
|||
|
|
<label class="check small">
|
|||
|
|
<input type="checkbox" name="confirm" value="1" required>
|
|||
|
|
endgültig löschen
|
|||
|
|
</label>
|
|||
|
|
<button class="link-button danger" type="submit">Löschen bestätigen</button>
|
|||
|
|
</form>
|
|||
|
|
</details>
|
|||
|
|
</div>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</tbody>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<?php if ($pages > 1): ?>
|
|||
|
|
<nav class="pagination">
|
|||
|
|
<?php if ($page > 1): ?><a href="<?= e($linkFor($page - 1)) ?>">← Zurück</a><?php endif; ?>
|
|||
|
|
<span>Seite <?= (int) $page ?> von <?= (int) $pages ?></span>
|
|||
|
|
<?php if ($page < $pages): ?><a href="<?= e($linkFor($page + 1)) ?>">Weiter →</a><?php endif; ?>
|
|||
|
|
</nav>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
<?php endif; ?>
|