72 lines
3.0 KiB
PHP
72 lines
3.0 KiB
PHP
<?php
|
|
if (!file_exists('includes/config.php')) {
|
|
header('Location: install.php');
|
|
exit;
|
|
}
|
|
|
|
require_once 'includes/db.php';
|
|
require_once 'includes/settings_helper.php';
|
|
require_once 'includes/header.php';
|
|
|
|
$search = $_GET['q'] ?? '';
|
|
$tag_filter = $_GET['tag'] ?? '';
|
|
|
|
$query = "SELECT DISTINCT v.*, u.username as uploader FROM videos v
|
|
JOIN users u ON v.uploader_id = u.id
|
|
LEFT JOIN video_tags vt ON v.id = vt.video_id
|
|
LEFT JOIN tags t ON vt.tag_id = t.id";
|
|
$params = [];
|
|
|
|
if ($search) {
|
|
$query .= " WHERE (v.title LIKE ? OR v.description LIKE ? OR t.name LIKE ?)";
|
|
$params = ["%$search%", "%$search%", "%$search%"];
|
|
} elseif ($tag_filter) {
|
|
$query .= " WHERE t.name = ?";
|
|
$params = [$tag_filter];
|
|
}
|
|
|
|
$query .= " ORDER BY v.release_date DESC, v.created_at DESC";
|
|
$stmt = $pdo->prepare($query);
|
|
$stmt->execute($params);
|
|
$videos = $stmt->fetchAll();
|
|
|
|
// Get popular tags for chips
|
|
$popular_tags = $pdo->query("SELECT name FROM tags LIMIT 10")->fetchAll(PDO::FETCH_COLUMN);
|
|
?>
|
|
|
|
<div style="padding: 12px 24px; display: flex; gap: 12px; overflow-x: auto; border-bottom: 1px solid var(--glass-border); margin-bottom: 20px;">
|
|
<a href="index.php" class="btn" style="background: <?= !$tag_filter ? 'var(--primary-color)' : 'var(--glass)' ?>; border-radius: 20px; font-size: 0.85rem; padding: 6px 16px;">All</a>
|
|
<?php foreach ($popular_tags as $ptag): ?>
|
|
<a href="index.php?tag=<?= urlencode($ptag) ?>" class="btn" style="background: <?= $tag_filter === $ptag ? 'var(--primary-color)' : 'var(--glass)' ?>; border-radius: 20px; font-size: 0.85rem; padding: 6px 16px;"><?= htmlspecialchars($ptag) ?></a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<div class="video-grid">
|
|
<?php if (empty($videos)): ?>
|
|
<div style="grid-column: 1/-1; text-align: center; padding: 100px; color: var(--text-muted);">
|
|
<i class="fas fa-video-slash" style="font-size: 3rem; margin-bottom: 20px; display: block;"></i>
|
|
<h3>No sermons found.</h3>
|
|
<?php if (isEditor()): ?>
|
|
<p>Click <a href="admin/add_video.php" style="color: var(--primary-color);">here</a> to add your first video.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<?php foreach ($videos as $video): ?>
|
|
<a href="watch.php?id=<?= $video['id'] ?>" class="video-card">
|
|
<div class="video-thumbnail" style="background-image: url('<?= $video['thumbnail_url'] ?: 'assets/images/default_thumb.png' ?>');">
|
|
<!-- Placeholder thumbnail if none exists -->
|
|
</div>
|
|
<div class="video-info">
|
|
<h3 class="video-title"><?= htmlspecialchars($video['title']) ?></h3>
|
|
<div class="video-meta">
|
|
<span><?= htmlspecialchars($video['uploader']) ?></span> •
|
|
<span><?= date('M d, Y', strtotime($video['release_date'])) ?></span>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php require_once 'includes/footer.php'; ?>
|