| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /bpkd/ |
Upload File : |
<?php
/**
* Halaman Utama Frontend
* Website Instansi - CMS
*/
ini_set('display_errors', 1);
error_reporting(E_ALL);
// =====================================================
// ROUTING MANUAL UNTUK URL ARTIKEL (DILETAKKAN PALING ATAS)
// =====================================================
require_once 'includes/config.php';
require_once 'includes/init.php';
require_once 'track-visitor.php';
$request_uri = $_SERVER['REQUEST_URI'];
// Hapus query string jika ada
if (strpos($request_uri, '?') !== false) {
$request_uri = substr($request_uri, 0, strpos($request_uri, '?'));
}
// Hapus BASE_PATH dari request (menggunakan BASE_URL yang sudah didefinisikan)
$base_path = parse_url(BASE_URL, PHP_URL_PATH); // Mendapatkan '/bpkd' atau ''
$request = preg_replace('#^' . preg_quote($base_path, '#') . '#', '', $request_uri);
$request = ltrim($request, '/');
// =====================================================
// HANDLE URL ARTIKEL: /artikel/hash
// =====================================================
if (preg_match('/^artikel\/([a-zA-Z0-9_-]+)$/', $request, $matches)) {
$hash = $matches[1];
header("Location: " . BASE_URL . "/detail-artikel.php?hash=" . $hash);
exit;
}
// =====================================================
// HANDLE URL ARTIKEL dengan SLUG: /artikel/nama-artikel
// =====================================================
if (preg_match('/^artikel\/([a-z0-9_-]+)$/', $request, $matches)) {
$slug = $matches[1];
header("Location: " . BASE_URL . "/detail-artikel.php?slug=" . $slug);
exit;
}
// =====================================================
// HANDLE URL PENGUMUMAN
// =====================================================
if ($request == 'pengumuman') {
header("Location: " . BASE_URL . "/announcements.php");
exit;
}
if (preg_match('/^pengumuman\/([0-9]+)$/', $request, $matches)) {
$id = $matches[1];
header("Location: " . BASE_URL . "/announcement.php?id=" . $id);
exit;
}
// =====================================================
// HANDLE URL BERITA
// =====================================================
if ($request == 'berita') {
header("Location: " . BASE_URL . "/berita.php");
exit;
}
// =====================================================
// HANDLE URL PROFIL
// =====================================================
if ($request == 'profil') {
header("Location: " . BASE_URL . "/profil.php");
exit;
}
// =====================================================
// HANDLE URL KONTAK
// =====================================================
if ($request == 'kontak') {
header("Location: " . BASE_URL . "/kontak.php");
exit;
}
// =====================================================
// HANDLE URL GALERI
// =====================================================
if ($request == 'galeri') {
header("Location: " . BASE_URL . "/galeri.php");
exit;
}
// =====================================================
// LANJUTKAN KE INDEX PHP (HALAMAN UTAMA)
// =====================================================
// Set page variables
$page_title = $settings['site_title'] ?? 'Website Instansi';
$meta_description = $settings['site_description'] ?? 'Website resmi instansi yang melayani masyarakat dengan profesional, transparan, dan akuntabel.';
$meta_keywords = $settings['site_keywords'] ?? 'instansi, pemerintah, layanan publik, berita, informasi';
// Additional CSS untuk carousel
$additional_css = ['assets/css/carousel.css'];
$carousel_object_fit = $settings['carousel_object_fit'] ?? 'cover';
$carousel_border_radius = $settings['carousel_border_radius'] ?? '0';
// Gunakan global $conn
global $conn;
// ===== AMBIL DATA CAROUSEL DARI DATABASE =====
$carousel_slides = getCarouselSlides($conn, 5);
// ===== AMBIL PENGUMUMAN TERBARU (untuk card kiri) =====
$latest_announcements = getLatestAnnouncements($conn, 5);
// ===== AMBIL BERITA TERBARU (untuk card kanan) =====
$latest_news = $conn->query("
SELECT a.*, c.name as category_name, u.full_name as author_name
FROM articles a
LEFT JOIN categories c ON a.category_id = c.id
LEFT JOIN users u ON a.author_id = u.id
WHERE a.status = 'published'
ORDER BY a.published_at DESC
LIMIT 5
");
// ===== AMBIL DATA LAYANAN =====
$services = [];
$table_check = $conn->query("SHOW TABLES LIKE 'services'");
if ($table_check && $table_check->num_rows > 0) {
$services_query = "SELECT * FROM services WHERE status = 'active' ORDER BY featured DESC, service_order ASC LIMIT 6";
$services_result = $conn->query($services_query);
if ($services_result && $services_result->num_rows > 0) {
while($row = $services_result->fetch_assoc()) {
$services[] = $row;
}
}
}
// Jika tidak ada data services, gunakan data statis
if (empty($services)) {
$services = [
['icon' => 'fas fa-file-alt', 'title' => 'Layanan Administrasi', 'description' => 'Pengurusan dokumen administrasi.', 'link' => 'layanan-administrasi.php'],
['icon' => 'fas fa-comments', 'title' => 'Layanan Pengaduan', 'description' => 'Wadah untuk menyampaikan aspirasi.', 'link' => 'layanan-pengaduan.php'],
['icon' => 'fas fa-info-circle', 'title' => 'Layanan Informasi', 'description' => 'Informasi publik terkini.', 'link' => 'layanan-informasi.php']
];
}
// ===== AMBIL ARTIKEL TERBARU =====
$latest_articles = $conn->query("
SELECT a.*, c.name as category_name, u.full_name as author_name
FROM articles a
LEFT JOIN categories c ON a.category_id = c.id
LEFT JOIN users u ON a.author_id = u.id
WHERE a.status = 'published'
ORDER BY a.published_at DESC
LIMIT 6
");
// ===== AMBIL ARTIKEL POPULER =====
$featured_articles = $conn->query("
SELECT a.*, c.name as category_name
FROM articles a
LEFT JOIN categories c ON a.category_id = c.id
WHERE a.status = 'published'
ORDER BY a.views DESC
LIMIT 3
");
// ===== AMBIL KATEGORI =====
$categories = $conn->query("
SELECT c.*, COUNT(a.id) as article_count
FROM categories c
LEFT JOIN articles a ON c.id = a.category_id AND a.status = 'published'
GROUP BY c.id
ORDER BY c.name
");
// ===== AMBIL TESTIMONIAL =====
$testimonials = $conn->query("
SELECT * FROM testimonials
WHERE status = 'published'
ORDER BY id DESC
LIMIT 5
");
// ===== AMBIL FAQ =====
$faqs = $conn->query("
SELECT * FROM faq
WHERE status = 'published'
ORDER BY faq_order
LIMIT 5
");
// ===== AMBIL VIDEO SHORTS TERBARU DARI GALLERY =====
// Cek dulu apakah tabel gallery punya kolom yang dibutuhkan
$gallery_check = $conn->query("SHOW TABLES LIKE 'gallery'");
$latest_videos = null;
$total_videos = 0;
if ($gallery_check && $gallery_check->num_rows > 0) {
// Ambil video (type = 'video') yang aktif, utamakan yang featured
$latest_videos = $conn->query("
SELECT id, title, description, image, video_url, category, featured, created_at
FROM gallery
WHERE type = 'video'
AND status = 'active'
ORDER BY featured DESC, created_at DESC
LIMIT 4
");
if ($latest_videos && $latest_videos->num_rows > 0) {
$total_videos = $latest_videos->num_rows;
}
}
// ===== AMBIL STATISTIK =====
/*$total_articles = $conn->query("SELECT COUNT(*) as total FROM articles WHERE status = 'published'")->fetch_assoc()['total'];
$total_visitors = $conn->query("SELECT COUNT(DISTINCT ip_address) as total FROM visitors")->fetch_assoc()['total'];
$total_services = count($services);
*/
// ===== TRACK VISITOR =====
/*$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$page = $_SERVER['REQUEST_URI'];
$today = date('Y-m-d');
$time = date('H:i:s');
*/
/*$check = $conn->query("SELECT id FROM visitors WHERE ip_address = '$ip' AND visit_date = '$today'");
if ($check->num_rows == 0) {
$conn->query("INSERT INTO visitors (ip_address, user_agent, page_visited, visit_date, visit_time)
VALUES ('$ip', '$user_agent', '$page', '$today', '$time')");
}
*/
$body_class = 'has-carousel';
include 'includes/header.php';
?>
<style>
/* FORCE STYLE UNTUK LINK TERKAIT, KATEGORI, FAQ */
.art-section {
display: block !important;
max-width: 1280px !important;
margin: 40px auto !important;
padding: 40px 20px !important;
background: #f8fafc !important;
border-radius: 20px !important;
}
.art-header-wrapper {
display: flex !important;
justify-content: space-between !important;
align-items: flex-end !important;
margin-bottom: 32px !important;
flex-wrap: wrap !important;
}
.art-header-left {
position: relative !important;
}
.art-section-title {
font-size: 1.8rem !important;
font-weight: 700 !important;
color: #1e293b !important;
margin-bottom: 12px !important;
}
.art-header-underline {
width: 60px !important;
height: 4px !important;
background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
border-radius: 4px !important;
}
.art-header-right {
margin-bottom: 8px !important;
}
.art-view-all {
display: inline-flex !important;
align-items: center !important;
gap: 8px !important;
padding: 8px 0 !important;
color: #3b82f6 !important;
font-weight: 600 !important;
text-decoration: none !important;
}
/* Shortcut Cards */
.shortcut-card {
display: block !important;
background: white !important;
border-radius: 12px !important;
padding: 15px !important;
text-align: center !important;
text-decoration: none !important;
box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
transition: all 0.3s !important;
}
.shortcut-icon i {
font-size: 40px !important;
color: #4e73df !important;
}
.shortcut-description {
font-size: 13px !important;
color: #495057 !important;
margin-top: 8px !important;
}
/* Category Cards */
.category-card {
display: block !important;
background: white !important;
padding: 20px !important;
border-radius: 15px !important;
text-align: center !important;
text-decoration: none !important;
box-shadow: 0 5px 15px rgba(0,0,0,0.08) !important;
}
.category-icon {
width: 60px !important;
height: 60px !important;
background: linear-gradient(135deg, #667eea, #764ba2) !important;
border-radius: 50% !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
margin: 0 auto 15px !important;
}
.category-icon i {
font-size: 24px !important;
color: white !important;
}
.category-card h3 {
font-size: 1rem !important;
color: #333 !important;
margin-top: 10px !important;
}
.category-count {
font-size: 0.8rem !important;
color: #666 !important;
}
/* FAQ Section */
.faq-section {
display: block !important;
padding: 60px 0 !important;
background: #f8fafc !important;
}
.section-title {
font-size: 2rem !important;
font-weight: 700 !important;
text-align: center !important;
margin-bottom: 15px !important;
}
.section-subtitle {
text-align: center !important;
color: #666 !important;
margin-bottom: 40px !important;
}
.accordion-item {
background: white !important;
border-radius: 12px !important;
margin-bottom: 15px !important;
overflow: hidden !important;
}
.accordion-button:not(.collapsed) {
background: linear-gradient(135deg, #667eea, #764ba2) !important;
color: white !important;
}
/* ===== STYLING TAMBAHAN UNTUK BADGE ===== */
.news-list-item .position-relative .badge {
padding: 6px 14px;
font-size: 12px;
font-weight: 500;
border-radius: 6px;
letter-spacing: 0.3px;
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
z-index: 2;
}
.news-list-item .position-relative .badge.bg-info {
background: #0dcaf0 !important;
color: #000 !important;
}
.news-list-item .position-relative .badge.bg-dark {
background: rgba(0,0,0,0.75) !important;
color: #fff !important;
}
/* ===== RESPONSIF UNTUK MOBILE ===== */
@media (max-width: 576px) {
.news-list-item .position-relative .badge {
padding: 4px 10px;
font-size: 10px;
border-radius: 4px;
}
.news-list-item .position-relative .badge.m-2 {
margin: 10px !important;
}
}
/* ===== RESPONSIF UNTUK TABLET ===== */
@media (min-width: 577px) and (max-width: 767px) {
.news-list-item .position-relative .badge.m-2 {
margin: 14px !important;
}
}
/* ===== ANIMASI HALUS ===== */
.news-list-item .position-relative img {
transition: transform 0.3s ease;
}
.news-list-item .position-relative:hover img {
transform: scale(1.02);
}
/* ===== GRADIENT OVERLAY AGAR BADGE LEBIH TERBACA ===== */
.news-list-item .position-relative::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, transparent 30%);
pointer-events: none;
border-radius: 0.25rem;
z-index: 1;
}
/* ============================================
YOUTUBE SHORTS SECTION
============================================ */
.shorts-section {
padding: 50px 0;
background: #f8fafc;
}
.shorts-header {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-bottom: 30px;
flex-wrap: wrap;
gap: 15px;
}
.shorts-header-left h2 {
font-size: 1.8rem;
font-weight: 700;
color: #1e293b;
margin-bottom: 12px;
}
.shorts-header-left .shorts-underline {
width: 60px;
height: 4px;
background: linear-gradient(135deg, #ef4444, #dc2626);
border-radius: 4px;
}
.shorts-view-all {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 0;
color: #3b82f6;
font-weight: 600;
text-decoration: none;
transition: all 0.3s;
}
.shorts-view-all:hover {
color: #1d4ed8;
gap: 12px;
}
/* Card Shorts */
.short-card {
position: relative;
display: block;
border-radius: 16px;
overflow: hidden;
background: #000;
aspect-ratio: 9 / 16;
box-shadow: 0 4px 15px rgba(0,0,0,0.15);
transition: transform 0.3s, box-shadow 0.3s;
text-decoration: none;
cursor: pointer;
}
.short-card:hover {
transform: translateY(-8px);
box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}
.short-card .short-thumb {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.5s;
}
.short-card:hover .short-thumb {
transform: scale(1.08);
}
/* Overlay gradient agar teks terbaca */
.short-card .short-overlay {
position: absolute;
inset: 0;
background: linear-gradient(
to bottom,
rgba(0,0,0,0.4) 0%,
transparent 25%,
transparent 55%,
rgba(0,0,0,0.85) 100%
);
pointer-events: none;
}
/* Play button di tengah */
.short-card .short-play {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 60px;
height: 60px;
background: rgba(255,255,255,0.95);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: #dc2626;
font-size: 22px;
transition: all 0.3s;
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.short-card:hover .short-play {
transform: translate(-50%, -50%) scale(1.15);
background: #dc2626;
color: #fff;
}
/* Konten bawah */
.short-card .short-content {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 15px;
color: white;
z-index: 2;
}
.short-card .short-title {
font-size: 0.95rem;
font-weight: 600;
margin-bottom: 6px;
line-height: 1.3;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.short-card .short-meta {
font-size: 0.75rem;
opacity: 0.85;
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.short-card .short-category {
position: absolute;
top: 12px;
left: 12px;
background: rgba(220, 38, 38, 0.95);
color: white;
padding: 4px 10px;
border-radius: 20px;
font-size: 0.7rem;
font-weight: 600;
z-index: 2;
}
.short-card .short-featured {
position: absolute;
top: 12px;
right: 12px;
background: rgba(245, 158, 11, 0.95);
color: white;
padding: 4px 8px;
border-radius: 20px;
font-size: 0.7rem;
font-weight: 600;
z-index: 2;
}
/* Label SHORTS */
.short-card .short-label {
position: absolute;
top: 50%;
right: 12px;
transform: translateY(-50%);
writing-mode: vertical-rl;
background: rgba(0,0,0,0.6);
color: white;
padding: 8px 5px;
border-radius: 6px;
font-size: 0.65rem;
letter-spacing: 2px;
font-weight: 700;
z-index: 2;
}
/* Empty state */
.shorts-empty {
text-align: center;
padding: 40px 20px;
background: white;
border-radius: 16px;
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.shorts-empty i {
font-size: 3rem;
color: #cbd5e1;
margin-bottom: 15px;
}
/* Responsive */
@media (max-width: 575px) {
.short-card .short-title { font-size: 0.85rem; }
.short-card .short-play { width: 50px; height: 50px; font-size: 18px; }
.short-card .short-label { display: none; }
}
</style>
<!-- Hero Section dengan Carousel -->
<section class="hero-carousel-section">
<div id="heroCarousel" class="carousel slide carousel-fade" data-bs-ride="carousel" data-bs-interval="5000">
<!-- Indicators -->
<div class="carousel-indicators">
<?php foreach ($carousel_slides as $index => $slide): ?>
<button type="button" data-bs-target="#heroCarousel" data-bs-slide-to="<?php echo $index; ?>"
class="<?php echo $index == 0 ? 'active' : ''; ?>"></button>
<?php endforeach; ?>
</div>
<!-- Carousel Items -->
<div class="carousel-inner">
<?php foreach ($carousel_slides as $index => $slide): ?>
<div class="carousel-item <?php echo $index == 0 ? 'active' : ''; ?>">
<!-- Background Images -->
<div class="carousel-bg desktop-bg" style="background-image: url('<?php echo $slide['image']; ?>');"></div>
<div class="carousel-bg mobile-bg" style="background-image: url('<?php echo $slide['image_mobile']; ?>');"></div>
<div class="carousel-gradient-top-bottom"></div>
<!-- Overlay -->
<div class="carousel-overlay"></div>
<!-- Caption -->
<div class="carousel-caption">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto text-center">
<?php if (!empty($slide['subtitle'])): ?>
<span class="carousel-subtitle"><?php echo htmlspecialchars($slide['subtitle']); ?></span>
<?php endif; ?>
<h1 class="carousel-title"><?php echo htmlspecialchars($slide['title']); ?></h1>
<?php if (!empty($slide['description'])): ?>
<p class="carousel-description"><?php echo htmlspecialchars($slide['description']); ?></p>
<?php endif; ?>
<div class="carousel-buttons">
<?php if (!empty($slide['button_text']) && !empty($slide['button_link'])): ?>
<a href="<?php echo $slide['button_link']; ?>" class="btn btn-primary btn-lg">
<?php echo htmlspecialchars($slide['button_text']); ?>
</a>
<?php endif; ?>
<!-- <a href="#main-content" class="btn btn-outline-light btn-lg">
Jelajahi <i class="fas fa-arrow-down ms-2"></i>
</a>
-->
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<!-- Controls -->
<button class="carousel-control-prev" type="button" data-bs-target="#heroCarousel" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#heroCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</section>
<!-- Featured Cards Section (Pengumuman & Berita) -->
<section class="featured-cards-section py-5">
<div class="container">
<div class="row g-4">
<!-- Kolom Kiri: Pengumuman Terbaru -->
<div class="col-lg-4">
<div class="card featured-card h-100">
<div class="card-header text-black mb-3">
<h3 class="h5 mb-0">
<i class="fas fa-bullhorn me-2"></i>Pengumuman
</h3>
</div>
<div class="card-body p-0">
<?php if (!empty($latest_announcements)): ?>
<div class="list-group list-group-flush">
<?php foreach ($latest_announcements as $ann):
$priority_class = '';
$priority_icon = '';
switch($ann['priority']) {
case 'high':
$priority_class = 'danger';
$priority_icon = 'exclamation-triangle';
break;
case 'low':
$priority_class = 'info';
$priority_icon = 'info-circle';
break;
default:
$priority_class = 'primary';
$priority_icon = 'bullhorn';
}
?>
<div class="list-group-item announcement-list-item">
<div class="d-flex justify-content-between align-items-start">
<div class="flex-grow-1">
<div class="d-flex align-items-center mb-2">
<span class="badge bg-<?php echo $priority_class; ?> me-2">
<i class="fas fa-<?php echo $priority_icon; ?> me-1"></i>
<?php echo ucfirst($ann['priority']); ?>
</span>
<small class="text-muted">
<i class="far fa-calendar-alt me-1"></i>
<?php echo date('d/m/Y', strtotime($ann['publish_date'])); ?>
</small>
</div>
<h5 class="mb-2">
<a href="announcement.php?id=<?php echo $ann['id']; ?>" class="text-decoration-none">
<?php echo htmlspecialchars($ann['title']); ?>
</a>
</h5>
<p class="text-muted small mb-2">
<?php echo substr(strip_tags($ann['content']), 0, 120); ?>...
</p>
<!-- Informasi Views -->
<div class="d-flex align-items-center gap-2">
<i class="fas fa-eye text-primary" style="font-size: 0.8rem;"></i>
<small class="text-muted">
<?php echo number_format($ann['views'] ?? 0); ?> |
</small>
<a href="announcement.php?id=<?php echo $ann['id']; ?>" class="btn-link">
Baca Selengkapnya <i class="fas fa-arrow-right ms-2"></i>
</a>
</div>
</div>
<?php if ($ann['file_count'] > 0): ?>
<span class="badge bg-info ms-2" title="Ada lampiran">
<i class="fas fa-paperclip"></i>
</span>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="card-footer bg-light text-center">
<a href="pengumuman" class="btn btn-outline-primary btn-sm">
Lihat Semua Pengumuman <i class="fas fa-arrow-right ms-2"></i>
</a>
</div>
<?php else: ?>
<div class="text-center py-5">
<i class="fas fa-bullhorn fa-3x text-muted mb-3"></i>
<p class="text-muted">Belum ada pengumuman</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
<!-- Kolom Kanan: Berita Terbaru -->
<div class="col-lg-8">
<div class="card featured-card h-100">
<div class="card-header text-black mb-3">
<h3 class="h5 mb-0">
<i class="fas fa-newspaper me-2"></i>Berita Terbaru
</h3>
</div>
<div class="card-body p-0">
<?php if ($latest_news && $latest_news->num_rows > 0): ?>
<div class="list-group list-group-flush">
<?php while($news = $latest_news->fetch_assoc()):
if (!empty($news['url_hash'])) {
$article_link = BASE_URL . '/artikel/' . $news['url_hash'];
} else {
$article_link = BASE_URL . '/detail-artikel.php?id=' . $news['id'];
}
?>
<div class="list-group-item news-list-item p-3">
<!-- ============================================================ -->
<!-- ===== MOBILE LAYOUT (gambar di atas dengan badge overlay) ===== -->
<!-- ============================================================ -->
<?php if (!empty($news['featured_image'])): ?>
<div class="d-block d-md-none mb-3 position-relative">
<img src="<?php echo $news['featured_image']; ?>"
alt="<?php echo htmlspecialchars($news['title']); ?>"
class="img-fluid rounded w-100"
style="height: 200px; object-fit: cover;">
<!-- BADGE KATEGORI DI DALAM GAMBAR (atas kiri) - HANYA MOBILE -->
<span class="badge bg-info position-absolute top-0 start-0 m-2">
<i class="fas fa-tag me-1"></i><?php echo htmlspecialchars($news['category_name']); ?>
</span>
<!-- BADGE TANGGAL DI DALAM GAMBAR (atas kanan) - HANYA MOBILE -->
<span class="badge bg-dark position-absolute top-0 end-0 m-2">
<i class="far fa-calendar-alt me-1"></i>
<?php echo date('d/m/Y', strtotime($news['published_at'])); ?>
</span>
</div>
<?php endif; ?>
<!-- ============================================================ -->
<!-- ===== KONTEN UTAMA ===== -->
<!-- ============================================================ -->
<div class="row g-3 flex-column-reverse flex-md-row">
<!-- ===== KOLOM KONTEN ===== -->
<div class="col-md-8 <?php echo !empty($news['featured_image']) ? '' : 'col-12'; ?>">
<!-- ===== BADGE & TANGGAL UNTUK DESKTOP (TAMPAK DI DESKTOP, SEMBUNYI DI MOBILE) ===== -->
<div class="d-none d-md-flex justify-content-between align-items-start flex-wrap mb-2">
<span class="badge bg-info mb-2 mb-md-0">
<i class="fas fa-tag me-1"></i><?php echo htmlspecialchars($news['category_name']); ?>
</span>
<small class="text-muted">
<i class="far fa-calendar-alt me-1"></i>
<?php echo date('d/m/Y', strtotime($news['published_at'])); ?>
</small>
</div>
<!-- Judul -->
<h5 class="mb-2">
<a href="<?php echo $article_link; ?>" class="text-decoration-none">
<?php echo htmlspecialchars($news['title']); ?>
</a>
</h5>
<!-- Excerpt -->
<p class="text-muted small mb-2">
<?php echo substr($news['excerpt'] ?? strip_tags($news['content']), 0, 100); ?>...
</p>
<!-- Informasi Penulis & Views -->
<div class="d-flex flex-wrap justify-content-between align-items-center mt-2">
<div class="d-flex align-items-center gap-3">
<div class="d-flex align-items-center gap-1">
<i class="fas fa-user-circle text-primary" style="font-size: 0.8rem;"></i>
<small class="text-muted">
<?php echo !empty($news['author_name']) ? htmlspecialchars($news['author_name']) : 'Admin'; ?>
</small>
</div>
<div class="d-flex align-items-center gap-1">
<i class="fas fa-eye text-primary" style="font-size: 0.8rem;"></i>
<small class="text-muted">
<?php echo number_format($news['views'] ?? 0); ?>
</small>
</div>
</div>
<a href="<?php echo $article_link; ?>" class="btn-link mt-2 mt-sm-0">
Baca Selengkapnya <i class="fas fa-arrow-right ms-2"></i>
</a>
</div>
</div>
<!-- ===== KOLOM GAMBAR (di samping kanan pada desktop) ===== -->
<?php if (!empty($news['featured_image'])): ?>
<div class="col-md-4 position-relative">
<img src="<?php echo $news['featured_image']; ?>"
alt="<?php echo htmlspecialchars($news['title']); ?>"
class="img-fluid rounded d-none d-md-block"
style="height: 180px; width: 100%; object-fit: cover;">
<!-- ===== BADGE DI DALAM GAMBAR UNTUK DESKTOP DISEMBUNYIKAN ===== -->
<!-- Tidak ada badge di dalam gambar untuk desktop -->
</div>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="card-footer bg-light text-center">
<a href="berita" class="btn btn-outline-primary btn-sm">
Lihat Semua Berita <i class="fas fa-arrow-right ms-2"></i>
</a>
</div>
<?php else: ?>
<div class="text-center py-5">
<i class="fas fa-newspaper fa-3x text-muted mb-3"></i>
<p class="text-muted">Belum ada berita</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- ============================================
YOUTUBE SHORTS SECTION
============================================ -->
<div class="container">
<section class="shorts-section">
<div class="container">
<!-- Header -->
<div class="shorts-header" data-aos="fade-up">
<div class="shorts-header-left">
<h2>
<i class="fab fa-youtube text-danger me-2"></i>
Video Terbaru
</h2>
<div class="shorts-underline"></div>
</div>
<div class="shorts-header-right">
<a href="<?php echo BASE_URL; ?>/video.php" class="shorts-view-all">
Lihat Semua Video
<i class="fas fa-arrow-right"></i>
</a>
</div>
</div>
<!-- Grid Video -->
<?php if ($latest_videos && $latest_videos->num_rows > 0): ?>
<div class="row g-3">
<?php
$delay = 0;
while ($video = $latest_videos->fetch_assoc()):
// Ambil YouTube ID dari video_url
$yt_id = getYouTubeId($video['video_url']);
// Thumbnail: coba dari kolom image dulu, fallback ke YouTube
$thumb_url = '';
if (!empty($video['image']) && preg_match('#^https?://#', $video['image'])) {
$thumb_url = $video['image'];
} elseif ($yt_id) {
// Untuk shorts, thumbnail maxresdefault paling bagus
$thumb_url = 'https://img.youtube.com/vi/' . $yt_id . '/maxresdefault.jpg';
// Fallback kalau maxres tidak ada
$thumb_url_fallback = 'https://img.youtube.com/vi/' . $yt_id . '/hqdefault.jpg';
}
// Link ke detail atau langsung YouTube
$video_link = BASE_URL . '/galeri/video/' . $video['id'];
// Atau kalau mau langsung YouTube:
// $video_link = 'https://www.youtube.com/shorts/' . $yt_id;
?>
<div class="col-lg-3 col-md-6 col-6" data-aos="fade-up" data-aos-delay="<?php echo $delay; ?>">
<a href="<?php echo $video_link; ?>"
class="short-card"
data-video-id="<?php echo htmlspecialchars($yt_id); ?>"
data-video-title="<?php echo htmlspecialchars($video['title']); ?>"
onclick="return openVideoModal(event, this);">
<!-- Category Badge -->
<?php if (!empty($video['category'])): ?>
<span class="short-category">
<i class="fas fa-tag me-1"></i><?php echo htmlspecialchars($video['category']); ?>
</span>
<?php endif; ?>
<!-- Featured Badge -->
<?php if (!empty($video['featured'])): ?>
<span class="short-featured">
<i class="fas fa-star"></i>
</span>
<?php endif; ?>
<!-- Thumbnail -->
<?php if ($thumb_url): ?>
<img src="<?php echo $thumb_url; ?>"
alt="<?php echo htmlspecialchars($video['title']); ?>"
class="short-thumb"
loading="lazy"
onerror="this.src='<?php echo $thumb_url_fallback ?? 'https://img.youtube.com/vi/' . $yt_id . '/hqdefault.jpg'; ?>'">
<?php else: ?>
<div class="short-thumb d-flex align-items-center justify-content-center bg-secondary">
<i class="fas fa-video fa-3x text-white"></i>
</div>
<?php endif; ?>
<!-- Overlay -->
<div class="short-overlay"></div>
<!-- Play Button -->
<div class="short-play">
<i class="fas fa-play"></i>
</div>
<!-- SHORTS Label -->
<span class="short-label">SHORTS</span>
<!-- Content -->
<div class="short-content">
<div class="short-title">
<?php echo htmlspecialchars($video['title']); ?>
</div>
<div class="short-meta">
<span>
<i class="far fa-calendar me-1"></i>
<?php echo date('d M Y', strtotime($video['created_at'])); ?>
</span>
</div>
</div>
</a>
</div>
<?php
$delay += 100;
endwhile;
?>
</div>
<?php else: ?>
<!-- Empty State -->
<div class="shorts-empty" data-aos="fade-up">
<i class="fab fa-youtube"></i>
<h5>Belum Ada Video</h5>
<p class="text-muted mb-0">Video akan muncul di sini setelah ditambahkan melalui admin.</p>
</div>
<?php endif; ?>
</div>
</section>
</div>
<!-- ============================================
MODAL PREVIEW VIDEO YOUTUBE
============================================ -->
<div class="modal fade" id="videoModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content border-0">
<div class="modal-header bg-dark text-white border-0">
<h5 class="modal-title">
<i class="fab fa-youtube text-danger me-2"></i>
<span id="videoModalTitle">Video</span>
</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body p-0 bg-black">
<div class="ratio ratio-16x9">
<iframe id="videoModalFrame"
src=""
title="YouTube video player"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen
referrerpolicy="strict-origin-when-cross-origin">
</iframe>
</div>
</div>
</div>
</div>
</div>
<!-- ===================== LIVE ABSENSI BPKD ===================== -->
<div style="max-width:100%;margin:30px auto;padding:0 16px;">
<iframe
id="live-absensi-frame"
src="https://bpkd.lumajangkab.go.id/live_widget.php"
style="width:100%;border:none;display:block;height:0;overflow:hidden;"
scrolling="no"
frameborder="0"
loading="lazy"
title="Live Presensi BPKD">
</iframe>
</div>
<?php include 'beritakab.php'; ?>
<div class="container">
<div class="art-section py-5">
<!-- Header Section dengan Link "Lihat Semua" di kanan -->
<div class="art-header-wrapper">
<div class="art-header-left">
<h2 class="art-section-title">Link Terkait</h2>
<div class="art-header-underline"></div>
</div>
</div>
<!-- Shortcut Cards Section (Quick Links) -->
<div class="container">
<div class="row justify-content-center">
<?php
// Ambil shortcut dari database
$shortcut_query = "SELECT * FROM shortcuts WHERE status = 'active' ORDER BY shortcut_order ASC, created_at ASC";
$shortcut_result = $conn->query($shortcut_query);
if ($shortcut_result && $shortcut_result->num_rows > 0):
$delay = 100;
while($shortcut = $shortcut_result->fetch_assoc()):
// Proses URL
if ($shortcut['link_type'] == 'internal') {
$link_url = '/' . ltrim($shortcut['link'], '/');
} else {
$link_url = $shortcut['link'];
}
$target = $shortcut['target'];
$is_external = ($target == '_blank');
$image_type = $shortcut['image_type'] ?? 'icon';
$image_path = !empty($shortcut['image']) ? $shortcut['image'] : '';
?>
<div class="col-lg-2 col-md-3 col-sm-4 col-6 mb-3" data-aos="fade-up" data-aos-delay="<?php echo $delay; ?>">
<a href="<?php echo $link_url; ?>" class="shortcut-card" target="<?php echo $target; ?>" <?php echo $is_external ? 'rel="noopener noreferrer"' : ''; ?>>
<div class="shortcut-icon">
<?php if ($image_type == 'image' && !empty($image_path)): ?>
<img src="<?php echo BASE_URL; ?>/uploads/shortcut/<?php echo $image_path; ?>" alt="<?php echo htmlspecialchars($shortcut['title']); ?>" class="shortcut-img">
<?php else: ?>
<i class="<?php echo htmlspecialchars($shortcut['icon']); ?>"></i>
<?php endif; ?>
</div>
<p class="shortcut-description"><?php echo htmlspecialchars($shortcut['title']); ?></p>
</a>
</div>
<?php
$delay += 100;
endwhile;
endif; ?>
</div>
</div>
</div>
</div>
<div class="container">
<div class="art-section">
<!-- Header Section dengan Link "Lihat Semua" di kanan -->
<div class="art-header-wrapper">
<div class="art-header-left">
<h2 class="art-section-title">Kategori Berita</h2>
<div class="art-header-underline"></div>
</div>
<div class="art-header-right">
<a href="berita.php" class="art-view-all">
Lihat Semua
<i class="fas fa-arrow-right"></i>
</a>
</div>
</div>
<!-- Grid Cards Container -->
<div class="container">
<div class="row">
<?php if ($categories && $categories->num_rows > 0): ?>
<?php while($category = $categories->fetch_assoc()):
//$category_url = ($category['slug'] ?: createSlug($category['name']));
?>
<div class="col-lg-3 col-md-6 mb-4" data-aos="fade-up" data-aos-delay="<?php echo $category['id'] * 50; ?>">
<a href="berita.php?slug=<?php echo $category['slug']; ?>" class="category-card text-decoration-none">
<div class="category-icon">
<i class="fas fa-folder"></i>
</div>
<h3 class="h5 mt-3"><?php echo $category['name']; ?></h3>
<p class="category-count text-muted"><?php echo $category['article_count']; ?> Artikel</p>
</a>
</div>
<?php endwhile; ?>
<?php else: ?>
<div class="col-12 text-center py-5">
<i class="fas fa-folder-open fa-4x text-muted mb-3"></i>
<p class="text-muted">Belum ada kategori.</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="container">
<!-- FAQ Section -->
<?php if ($faqs && $faqs->num_rows > 0): ?>
<section class="faq-section py-5">
<div class="container">
<div class="section-header text-center mb-5" data-aos="fade-up">
<h2 class="section-title">Pertanyaan Umum</h2>
<p class="section-subtitle">Informasi yang sering ditanyakan masyarakat</p>
</div>
<div class="row justify-content-center">
<div class="col-lg-8" data-aos="fade-up">
<div class="accordion" id="faqAccordion">
<?php $no = 1; while($faq = $faqs->fetch_assoc()): ?>
<div class="accordion-item mb-3 border-0">
<h2 class="accordion-header">
<button class="accordion-button <?php echo $no > 1 ? 'collapsed' : ''; ?>"
type="button" data-bs-toggle="collapse"
data-bs-target="#faq<?php echo $faq['id']; ?>"
aria-expanded="<?php echo $no == 1 ? 'true' : 'false'; ?>">
<?php echo $no++ . '. ' . htmlspecialchars($faq['question']); ?>
</button>
</h2>
<div id="faq<?php echo $faq['id']; ?>"
class="accordion-collapse collapse <?php echo $no == 2 ? 'collapsed' : ''; ?>"
data-bs-parent="#faqAccordion">
<div class="accordion-body">
<?php echo nl2br(htmlspecialchars($faq['answer'])); ?>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="text-center mt-4">
<a href="faq.php" class="btn btn-outline-primary">
Lihat Semua FAQ <i class="fas fa-arrow-right ms-2"></i>
</a>
</div>
</div>
</div>
</div>
</section>
<?php endif; ?>
</div>
<?php include 'includes/footer.php'; ?>