Files
AudioCore/plugins/releases/views/admin/index.php

88 lines
4.2 KiB
PHP
Raw Normal View History

<?php
$pageTitle = 'Releases';
$releases = $releases ?? [];
$tableReady = $table_ready ?? false;
$pageId = (int)($page_id ?? 0);
$pagePublished = (int)($page_published ?? 0);
ob_start();
?>
<section class="admin-card">
<div class="badge">Releases</div>
<div style="display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:16px;">
<div>
<h1 style="font-size:28px; margin:0;">Releases</h1>
<p style="color: var(--muted); margin-top:6px;">Manage singles, EPs, and albums.</p>
</div>
<a href="/admin/releases/new" class="btn">New Release</a>
</div>
<?php if (!$tableReady): ?>
<div class="admin-card" style="margin-top:16px; padding:16px; display:flex; align-items:center; justify-content:space-between; gap:16px;">
<div>
<div style="font-weight:600;">Database not initialized</div>
<div style="color: var(--muted); font-size:13px; margin-top:4px;">Create the releases table before adding records.</div>
</div>
<form method="post" action="/admin/releases/install">
<button type="submit" class="btn small">Create Tables</button>
</form>
</div>
<?php else: ?>
<div class="admin-card" style="margin-top:16px; padding:14px; display:flex; align-items:center; justify-content:space-between; gap:16px;">
<div>
<div style="font-weight:600;">Releases page</div>
<div style="color: var(--muted); font-size:12px; margin-top:4px;">
Slug: <code>releases</code>
<?php if ($pageId > 0): ?>
- Status: <?= $pagePublished === 1 ? 'Published' : 'Draft' ?>
<?php else: ?>
- Not created
<?php endif; ?>
</div>
</div>
<?php if ($pageId > 0): ?>
<a href="/admin/pages/edit?id=<?= $pageId ?>" class="btn outline small">Edit Page Content</a>
<?php else: ?>
<span class="pill">Re-enable plugin to create</span>
<?php endif; ?>
</div>
<?php if (!$releases): ?>
<div style="margin-top:18px; color: var(--muted); font-size:13px;">No releases yet.</div>
<?php else: ?>
<div style="margin-top:18px; display:grid; gap:12px;">
<?php foreach ($releases as $release): ?>
<div class="admin-card" style="padding:14px; display:flex; align-items:center; justify-content:space-between; gap:16px;">
<div style="display:flex; gap:12px; align-items:center;">
<div style="width:44px; height:44px; border-radius:12px; overflow:hidden; background:rgba(255,255,255,0.06); display:grid; place-items:center;">
<?php if (!empty($release['cover_url'])): ?>
<img src="<?= htmlspecialchars((string)$release['cover_url'], ENT_QUOTES, 'UTF-8') ?>" alt="" style="width:100%; height:100%; object-fit:cover;">
<?php else: ?>
<span style="font-size:12px; color:var(--muted);">N/A</span>
<?php endif; ?>
</div>
<div>
<div style="font-weight:600;"><?= htmlspecialchars((string)$release['title'], ENT_QUOTES, 'UTF-8') ?></div>
<div style="font-size:12px; color:var(--muted);"><?= htmlspecialchars((string)$release['slug'], ENT_QUOTES, 'UTF-8') ?></div>
</div>
</div>
<div style="display:flex; gap:8px; align-items:center;">
<?php if ((int)$release['is_published'] !== 1): ?>
<span class="pill">Draft</span>
<?php endif; ?>
<a href="/admin/releases/tracks?release_id=<?= (int)$release['id'] ?>" class="btn outline small">Tracks</a>
<a href="/admin/releases/edit?id=<?= (int)$release['id'] ?>" class="btn outline small">Edit</a>
<form method="post" action="/admin/releases/delete" onsubmit="return confirm('Delete this release?');">
<input type="hidden" name="id" value="<?= (int)$release['id'] ?>">
<button type="submit" class="btn outline small">Delete</button>
</form>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</section>
<?php
$content = ob_get_clean();
require __DIR__ . '/../../../../modules/admin/views/layout.php';