v2.0.0.1
Publisium
- <?php
-
- declare(strict_types=1);
-
- $db = Database::site();
-
- $myArticleCount = 0;
- $pendingCount = 0;
- $publishedCount = 0;
-
- if (Auth::isAdministrative()) {
- $publishedCount = (int) $db->query("SELECT COUNT(*) AS c FROM articles WHERE status = 'published'")->fetch()['c'];
- $pendingCount = (int) $db->query("SELECT COUNT(*) AS c FROM articles WHERE status = 'pending_review'")->fetch()['c'];
- } else {
- $statement = $db->prepare("SELECT COUNT(*) AS c FROM articles WHERE author_id = :id AND deleted_at IS NULL");
- $statement->execute(['id' => $currentUser['id']]);
- $myArticleCount = (int) $statement->fetch()['c'];
-
- $statement = $db->prepare("SELECT COUNT(*) AS c FROM articles WHERE author_id = :id AND status = 'published'");
- $statement->execute(['id' => $currentUser['id']]);
- $publishedCount = (int) $statement->fetch()['c'];
- }
-
- $recentStatement = $db->prepare(
- Auth::isAdministrative()
- ? 'SELECT a.*, COALESCE(t.display_name, a.author_name) AS display_name, a.author_id AS owner_id FROM articles a LEFT JOIN team_accounts t ON t.id = a.author_id WHERE a.deleted_at IS NULL ORDER BY a.updated_at DESC LIMIT 8'
- : 'SELECT a.*, COALESCE(t.display_name, a.author_name) AS display_name, a.author_id AS owner_id FROM articles a LEFT JOIN team_accounts t ON t.id = a.author_id WHERE a.author_id = :id AND a.deleted_at IS NULL ORDER BY a.updated_at DESC LIMIT 8'
- );
- if (!Auth::isAdministrative()) {
- $recentStatement->execute(['id' => $currentUser['id']]);
- } else {
- $recentStatement->execute();
- }
- $recentArticles = $recentStatement->fetchAll();
-
- ?>
- <h1 class="dash-title"><?= Icons::icon("overview", "icon icon-lg") ?>Overview</h1>
-
- <div class="dash-cards">
- <?php if (Auth::isAdministrative()): ?>
- <div class="dash-card"><div class="dash-card-value"><?= $publishedCount ?></div><div class="dash-card-label">Published articles</div></div>
- <div class="dash-card"><div class="dash-card-value"><?= $pendingCount ?></div><div class="dash-card-label">Waiting for review</div></div>
- <?php else: ?>
- <div class="dash-card"><div class="dash-card-value"><?= $myArticleCount ?></div><div class="dash-card-label">Your articles</div></div>
- <div class="dash-card"><div class="dash-card-value"><?= $publishedCount ?></div><div class="dash-card-label">Published</div></div>
- <?php endif; ?>
- </div>
-
- <h2 class="dash-subtitle"><?= Icons::icon('activity', 'icon icon-sm') ?>Recently updated</h2>
- <table class="dash-table">
- <thead><tr><th><?= Icons::icon('heading', 'icon icon-sm') ?>Title</th><th><?= Icons::icon('user', 'icon icon-sm') ?>Author</th><th><?= Icons::icon('flag', 'icon icon-sm') ?>Status</th><th><?= Icons::icon('clock', 'icon icon-sm') ?>Updated</th></tr></thead>
- <tbody>
- <?php foreach ($recentArticles as $article): ?>
- <tr>
- <td><a href="dashboard.php?view=article-edit&id=<?= (int) $article['id'] ?>"><?= htmlspecialchars($article['title']) ?></a></td>
- <td><?= htmlspecialchars((string) ($article['display_name'] ?? 'System')) ?><?php if ($article['owner_id'] === null): ?> <span class="status-pill status-draft" title="The author's account was removed. The article stays on the site under their name.">system</span><?php endif; ?></td>
- <td><span class="status-pill status-<?= htmlspecialchars($article['status']) ?>"><?= htmlspecialchars(dashStatusLabel((string) $article['status'])) ?></span></td>
- <td><?= htmlspecialchars($article['updated_at']) ?></td>
- </tr>
- <?php endforeach; ?>
- <?php if (empty($recentArticles)): ?>
- <tr><td colspan="4">Nothing here yet. Your latest articles will show up here.</td></tr>
- <?php endif; ?>
- </tbody>
- </table>
-