2025-04-08 06:37:14 +04:00
|
|
|
<?php
|
2025-04-10 12:07:56 +04:00
|
|
|
// Inclure la configuration
|
|
|
|
|
require_once 'includes/config.php';
|
|
|
|
|
|
2025-04-08 06:37:14 +04:00
|
|
|
// Récupération de l'ID de catégorie
|
|
|
|
|
$categoryId = isset($_GET['id']) ? intval($_GET['id']) : null;
|
|
|
|
|
|
2025-04-10 12:07:56 +04:00
|
|
|
// Récupérer les catégories disponibles
|
|
|
|
|
$allCategories = PEERTUBE_CATEGORIES;
|
2025-04-08 06:37:14 +04:00
|
|
|
|
2025-04-10 12:07:56 +04:00
|
|
|
// Récupérer les vidéos de la catégorie si un ID est fourni
|
|
|
|
|
if ($categoryId && isset($allCategories[$categoryId])) {
|
|
|
|
|
// Récupérer le nom de la catégorie
|
|
|
|
|
$categoryName = $allCategories[$categoryId];
|
2025-04-08 06:37:14 +04:00
|
|
|
|
2025-04-10 12:07:56 +04:00
|
|
|
// Récupérer les vidéos de cette catégorie via l'API PeerTube
|
|
|
|
|
$videos = getVideosByCategory($categoryId, CATEGORY_VIDEOS_COUNT); // Récupérer le nombre défini dans la config
|
2025-04-08 06:37:14 +04:00
|
|
|
} else {
|
2025-04-10 12:07:56 +04:00
|
|
|
// Si aucune catégorie valide n'est spécifiée, rediriger vers l'accueil
|
|
|
|
|
header('Location: index.php');
|
|
|
|
|
exit;
|
2025-04-08 06:37:14 +04:00
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="fr">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2025-04-10 12:07:56 +04:00
|
|
|
<title><?php echo htmlspecialchars($categoryName); ?> - Kaubuntu.re</title>
|
2025-04-08 06:37:14 +04:00
|
|
|
<link rel="stylesheet" href="css/styles.css">
|
|
|
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
2025-04-09 20:29:09 +04:00
|
|
|
|
|
|
|
|
<!-- Favicons -->
|
|
|
|
|
<link rel="apple-touch-icon" sizes="180x180" href="img/apple-touch-icon.png">
|
|
|
|
|
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
|
|
|
|
|
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">
|
|
|
|
|
<link rel="manifest" href="site.webmanifest">
|
|
|
|
|
<link rel="icon" type="image/x-icon" href="img/favicon.ico">
|
|
|
|
|
<meta name="theme-color" content="#ffffff">
|
2025-04-08 06:37:14 +04:00
|
|
|
</head>
|
|
|
|
|
<body>
|
2025-04-10 12:07:56 +04:00
|
|
|
<?php include 'includes/sidebar.php'; ?>
|
|
|
|
|
|
|
|
|
|
<!-- Contenu principal -->
|
|
|
|
|
<div class="main-content">
|
2025-04-08 06:37:14 +04:00
|
|
|
<?php include 'includes/header.php'; ?>
|
|
|
|
|
|
2025-04-10 12:07:56 +04:00
|
|
|
<!-- Section catégorie -->
|
|
|
|
|
<div class="video-section category-page" data-category-id="<?php echo $categoryId; ?>">
|
|
|
|
|
<div class="section-header">
|
|
|
|
|
<div class="section-logo">
|
|
|
|
|
<img src="img/logo.png" alt="Kaubuntu.re">
|
|
|
|
|
</div>
|
|
|
|
|
<h2 class="section-title">Catégorie : <?php echo htmlspecialchars($categoryName); ?></h2>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?php if (empty($videos)): ?>
|
|
|
|
|
<div class="no-videos-message">
|
|
|
|
|
<i class="fas fa-video-slash"></i>
|
|
|
|
|
<h3>Aucune vidéo dans cette catégorie</h3>
|
|
|
|
|
<p>Il n'y a pas encore de vidéos dans la catégorie "<?php echo htmlspecialchars($categoryName); ?>".</p>
|
|
|
|
|
<a href="index.php" class="btn-primary">Retour à l'accueil</a>
|
|
|
|
|
</div>
|
|
|
|
|
<?php else: ?>
|
|
|
|
|
<div class="video-grid category-videos">
|
|
|
|
|
<?php foreach ($videos as $video): ?>
|
|
|
|
|
<div class="video-card" data-video-id="<?php echo $video['id']; ?>">
|
|
|
|
|
<div class="video-thumbnail">
|
|
|
|
|
<img src="<?php echo $video['thumbnail']; ?>" alt="<?php echo htmlspecialchars($video['title']); ?>">
|
|
|
|
|
<div class="video-play-icon">
|
|
|
|
|
<i class="fas fa-play-circle"></i>
|
2025-04-08 06:37:14 +04:00
|
|
|
</div>
|
2025-04-10 12:07:56 +04:00
|
|
|
<span class="video-duration"><?php echo formatDuration($video['duration']); ?></span>
|
2025-04-08 06:37:14 +04:00
|
|
|
</div>
|
2025-04-10 12:07:56 +04:00
|
|
|
<div class="video-info">
|
|
|
|
|
<h3 class="video-title"><?php echo htmlspecialchars($video['title']); ?></h3>
|
|
|
|
|
<div class="video-meta">
|
|
|
|
|
<div class="channel-info">
|
|
|
|
|
<?php if (strpos($video['channelAvatar'], 'default-avatar') !== false || empty($video['channelAvatar'])): ?>
|
|
|
|
|
<div class="channel-avatar-placeholder">
|
|
|
|
|
<i class="fas fa-user-circle"></i>
|
2025-04-08 06:37:14 +04:00
|
|
|
</div>
|
2025-04-10 12:07:56 +04:00
|
|
|
<?php else: ?>
|
|
|
|
|
<img src="<?php echo $video['channelAvatar']; ?>" alt="<?php echo htmlspecialchars($video['channel']); ?>" class="channel-avatar">
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
<span class="channel-name"><?php echo htmlspecialchars($video['channel']); ?></span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="video-stats">
|
|
|
|
|
<span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span>
|
|
|
|
|
<span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span>
|
|
|
|
|
</div>
|
2025-04-08 06:37:14 +04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-04-10 12:07:56 +04:00
|
|
|
</div>
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?php if (count($videos) >= CATEGORY_VIDEOS_COUNT): ?>
|
|
|
|
|
<button class="view-more" data-page="1">Voir plus</button>
|
2025-04-08 06:37:14 +04:00
|
|
|
<?php endif; ?>
|
2025-04-10 12:07:56 +04:00
|
|
|
<?php endif; ?>
|
|
|
|
|
</div>
|
2025-04-08 06:37:14 +04:00
|
|
|
</div>
|
|
|
|
|
|
2025-04-10 12:07:56 +04:00
|
|
|
<?php include 'includes/footer.php'; ?>
|
|
|
|
|
<?php include 'includes/mobile-menu.php'; ?>
|
2025-04-08 06:37:14 +04:00
|
|
|
|
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
|
|
|
|
<script src="js/main.js"></script>
|
|
|
|
|
<script>
|
2025-04-10 12:07:56 +04:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
// Gestion des clics sur les vidéos
|
|
|
|
|
const videoCards = document.querySelectorAll('.video-card');
|
|
|
|
|
videoCards.forEach(card => {
|
|
|
|
|
card.addEventListener('click', function() {
|
|
|
|
|
const videoId = this.dataset.videoId;
|
|
|
|
|
if (videoId) {
|
|
|
|
|
window.location.href = 'video.php?id=' + videoId;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Gestion du bouton "Voir plus"
|
|
|
|
|
const viewMoreBtn = document.querySelector('.view-more');
|
|
|
|
|
if (viewMoreBtn) {
|
|
|
|
|
viewMoreBtn.addEventListener('click', function() {
|
|
|
|
|
const page = parseInt(this.dataset.page);
|
|
|
|
|
const categoryId = document.querySelector('.video-section').dataset.categoryId;
|
|
|
|
|
|
|
|
|
|
// Changer le texte du bouton pendant le chargement
|
|
|
|
|
this.textContent = 'Chargement...';
|
|
|
|
|
this.disabled = true;
|
|
|
|
|
|
|
|
|
|
// Faire la requête AJAX
|
|
|
|
|
fetch(`ajax/load-more-videos.php?type=category&page=${page}&category=${categoryId}`, {
|
|
|
|
|
headers: {
|
|
|
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(response => response.json())
|
|
|
|
|
.then(data => {
|
|
|
|
|
if (data.success) {
|
|
|
|
|
// Ajouter les nouvelles vidéos à la grille
|
|
|
|
|
const videoGrid = document.querySelector('.video-grid');
|
|
|
|
|
const tempDiv = document.createElement('div');
|
|
|
|
|
tempDiv.innerHTML = data.html;
|
|
|
|
|
|
|
|
|
|
// Ajouter chaque vidéo à la grille
|
|
|
|
|
while (tempDiv.firstChild) {
|
|
|
|
|
videoGrid.appendChild(tempDiv.firstChild);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mettre à jour le numéro de page
|
|
|
|
|
this.dataset.page = data.page + 1;
|
|
|
|
|
|
|
|
|
|
// Réinitialiser le texte du bouton
|
|
|
|
|
this.textContent = 'Voir plus';
|
|
|
|
|
this.disabled = false;
|
|
|
|
|
|
|
|
|
|
// Si plus de vidéos à charger, masquer le bouton
|
|
|
|
|
if (!data.hasMore) {
|
|
|
|
|
this.style.display = 'none';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialiser les clics sur les nouvelles vidéos
|
|
|
|
|
document.querySelectorAll('.video-card:not([data-click-initialized])').forEach(card => {
|
|
|
|
|
card.setAttribute('data-click-initialized', 'true');
|
|
|
|
|
card.addEventListener('click', function() {
|
|
|
|
|
const videoId = this.dataset.videoId;
|
|
|
|
|
if (videoId) {
|
|
|
|
|
window.location.href = 'video.php?id=' + videoId;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Gérer l'erreur
|
|
|
|
|
this.textContent = 'Erreur lors du chargement';
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.textContent = 'Voir plus';
|
|
|
|
|
this.disabled = false;
|
|
|
|
|
}, 2000);
|
2025-04-08 06:37:14 +04:00
|
|
|
}
|
2025-04-10 12:07:56 +04:00
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error('Erreur:', error);
|
|
|
|
|
this.textContent = 'Erreur lors du chargement';
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.textContent = 'Voir plus';
|
|
|
|
|
this.disabled = false;
|
|
|
|
|
}, 2000);
|
2025-04-08 06:37:14 +04:00
|
|
|
});
|
|
|
|
|
});
|
2025-04-10 12:07:56 +04:00
|
|
|
}
|
|
|
|
|
});
|
2025-04-08 06:37:14 +04:00
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|