Files
AudioCore/plugins/artists/views/admin/index.php
2026-03-04 20:46:11 +00:00

98 lines
4.7 KiB
PHP

<?php
$pageTitle = 'Artists';
$tableReady = $table_ready ?? false;
$artists = $artists ?? [];
$pageId = (int)($page_id ?? 0);
$pagePublished = (int)($page_published ?? 0);
$socialReady = (bool)($social_ready ?? false);
ob_start();
?>
<section class="admin-card">
<div class="badge">Artists</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;">Artists</h1>
<p style="color: var(--muted); margin-top:6px;">Artists plugin admin placeholder.</p>
</div>
<a href="/admin/artists/new" class="btn">New Artist</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 artists table before adding records.</div>
</div>
<form method="post" action="/admin/artists/install">
<button type="submit" class="btn small">Create Tables</button>
</form>
</div>
<?php else: ?>
<?php if (!$socialReady): ?>
<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;">Social links not enabled</div>
<div style="color: var(--muted); font-size:12px; margin-top:4px;">Click create tables to add the social links column.</div>
</div>
<form method="post" action="/admin/artists/install">
<button type="submit" class="btn small">Update Table</button>
</form>
</div>
<?php endif; ?>
<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;">Artists page</div>
<div style="color: var(--muted); font-size:12px; margin-top:4px;">
Slug: <code>artists</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 (!$artists): ?>
<div style="margin-top:18px; color: var(--muted); font-size:13px;">No artists yet.</div>
<?php else: ?>
<div style="margin-top:18px; display:grid; gap:12px;">
<?php foreach ($artists as $artist): ?>
<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($artist['avatar_url'])): ?>
<img src="<?= htmlspecialchars((string)$artist['avatar_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)$artist['name'], ENT_QUOTES, 'UTF-8') ?></div>
<div style="font-size:12px; color:var(--muted);"><?= htmlspecialchars((string)$artist['slug'], ENT_QUOTES, 'UTF-8') ?></div>
</div>
</div>
<div style="display:flex; gap:8px; align-items:center;">
<?php if ((int)$artist['is_active'] !== 1): ?>
<span class="pill">Inactive</span>
<?php endif; ?>
<a href="/admin/artists/edit?id=<?= (int)$artist['id'] ?>" class="btn outline small">Edit</a>
<form method="post" action="/admin/artists/delete" onsubmit="return confirm('Delete this artist?');">
<input type="hidden" name="id" value="<?= (int)$artist['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';