%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
/**
* Admin: daftar & kelola Berita.
*/
require_once dirname(__DIR__) . '/config/config.php';
require_once dirname(__DIR__) . '/includes/auth.php';
require_once dirname(__DIR__) . '/includes/queries.php';
require_central();
$keyword = get_param('q');
$where = '';
$params = [];
if ($keyword !== '') {
$where = 'WHERE judul LIKE ?';
$params[] = '%' . $keyword . '%';
}
$stmt = db()->prepare("SELECT * FROM berita $where ORDER BY COALESCE(published_at, created_at) DESC");
$stmt->execute($params);
$rows = $stmt->fetchAll();
$pageTitle = 'Berita — CMS PPID';
$activeMenu = 'berita';
require __DIR__ . '/partials/head.php';
?>
<div class="flex flex-col md:flex-row md:items-center justify-between mb-6 gap-4">
<div>
<h2 class="text-2xl font-bold text-slate-900">Berita</h2>
<p class="text-sm text-slate-500 mt-1"><?= count($rows) ?> artikel berita.</p>
</div>
<div class="flex items-center gap-3">
<form method="get" class="flex items-center bg-white px-4 py-2 rounded-lg border border-slate-200 focus-within:border-mateng-blue transition-colors">
<i class="fas fa-search text-slate-400 mr-2"></i>
<input type="text" name="q" value="<?= e($keyword) ?>" placeholder="Cari judul..." class="bg-transparent outline-none text-sm w-40 lg:w-56 text-slate-700">
</form>
<a href="<?= e(url('admin/berita-form.php')) ?>" class="bg-mateng-blue hover:bg-sky-700 text-white px-4 py-2.5 rounded-lg text-sm font-semibold transition-colors flex items-center gap-2 shrink-0">
<i class="fas fa-plus"></i> <span class="hidden sm:inline">Tulis</span> Berita
</a>
</div>
</div>
<div class="bg-white border border-slate-100 rounded-xl shadow-sm overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full text-left border-collapse">
<thead>
<tr class="bg-slate-50 text-slate-500 text-xs uppercase tracking-wider">
<th class="px-6 py-4 font-semibold">Judul</th>
<th class="px-6 py-4 font-semibold">Tanggal</th>
<th class="px-6 py-4 font-semibold text-center">Dilihat</th>
<th class="px-6 py-4 font-semibold">Status</th>
<th class="px-6 py-4 font-semibold text-center">Aksi</th>
</tr>
</thead>
<tbody class="text-sm divide-y divide-slate-100 text-slate-700">
<?php if (empty($rows)): ?>
<tr><td colspan="5" class="px-6 py-12 text-center text-slate-400"><i class="fas fa-newspaper text-3xl mb-2 block"></i>Belum ada berita.</td></tr>
<?php else: foreach ($rows as $b):
$img = !empty($b['gambar']) && is_file(UPLOAD_PATH . '/berita/' . $b['gambar']) ? UPLOAD_URL . '/berita/' . $b['gambar'] : null; ?>
<tr class="hover:bg-slate-50/50 transition-colors">
<td class="px-6 py-4">
<div class="flex items-center gap-3">
<div class="w-12 h-12 rounded-lg bg-slate-100 overflow-hidden shrink-0 flex items-center justify-center">
<?php if ($img): ?><img src="<?= e($img) ?>" class="w-full h-full object-cover" alt=""><?php else: ?><i class="fas fa-newspaper text-slate-300"></i><?php endif; ?>
</div>
<div class="font-medium text-slate-800 max-w-md truncate"><?= e($b['judul']) ?></div>
</div>
</td>
<td class="px-6 py-4"><?= e(tanggal_id($b['published_at'] ?: $b['created_at'])) ?></td>
<td class="px-6 py-4 text-center"><?= (int) $b['views'] ?></td>
<td class="px-6 py-4">
<?php if ($b['status'] === 'publish'): ?>
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-green-50 text-mateng-green border border-green-200">Terbit</span>
<?php else: ?>
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-slate-100 text-slate-500 border border-slate-200">Draf</span>
<?php endif; ?>
</td>
<td class="px-6 py-4">
<div class="flex items-center justify-center gap-1">
<a href="<?= e(url('berita-detail.php?slug=' . urlencode($b['slug']))) ?>" target="_blank" class="p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700 rounded-lg transition-colors" title="Lihat"><i class="fas fa-eye"></i></a>
<a href="<?= e(url('admin/berita-form.php?id=' . $b['id'])) ?>" class="p-2 text-mateng-blue hover:bg-blue-50 rounded-lg transition-colors" title="Edit"><i class="fas fa-pen"></i></a>
<form method="post" action="<?= e(url('admin/berita-hapus.php')) ?>" onsubmit="return confirm('Hapus berita ini?');" class="inline">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= (int) $b['id'] ?>">
<button type="submit" class="p-2 text-red-500 hover:bg-red-50 rounded-lg transition-colors" title="Hapus"><i class="fas fa-trash"></i></button>
</form>
</div>
</td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>
</div>
</div>
<?php require __DIR__ . '/partials/foot.php'; ?>