diff --git a/categories.php b/categories.php
index b0191ff..a99e33d 100644
--- a/categories.php
+++ b/categories.php
@@ -1,209 +1,24 @@
[
- 'id' => 1,
- 'name' => 'Technologie',
- 'description' => 'Vidéos sur la technologie, l\'informatique, et les innovations tech.',
- 'image' => 'img/categories/tech.jpg'
- ],
- 2 => [
- 'id' => 2,
- 'name' => 'Culture',
- 'description' => 'Culture locale et internationale, événements culturels, et arts.',
- 'image' => 'img/categories/culture.jpg'
- ],
- 3 => [
- 'id' => 3,
- 'name' => 'Éducation',
- 'description' => 'Tutoriels, cours, et vidéos éducatives pour apprendre de nouvelles compétences.',
- 'image' => 'img/categories/education.jpg'
- ],
- 4 => [
- 'id' => 4,
- 'name' => 'Divertissement',
- 'description' => 'Vidéos de divertissement, humour, jeux et loisirs.',
- 'image' => 'img/categories/entertainment.jpg'
- ],
- 5 => [
- 'id' => 5,
- 'name' => 'Cuisine',
- 'description' => 'Recettes, conseils culinaires, et découverte de la gastronomie locale et internationale.',
- 'image' => 'img/categories/cuisine.jpg'
- ],
- 6 => [
- 'id' => 6,
- 'name' => 'Voyage',
- 'description' => 'Découverte de destinations, conseils de voyage, et aventures autour du monde.',
- 'image' => 'img/categories/travel.jpg'
- ],
- 7 => [
- 'id' => 7,
- 'name' => 'Sport',
- 'description' => 'Événements sportifs, tutoriels d\'entraînement, et actualités sportives.',
- 'image' => 'img/categories/sport.jpg'
- ],
- 8 => [
- 'id' => 8,
- 'name' => 'Musique',
- 'description' => 'Clips musicaux, concerts, et actualités musicales locales et internationales.',
- 'image' => 'img/categories/music.jpg'
- ]
-];
+// Récupérer les catégories disponibles
+$allCategories = PEERTUBE_CATEGORIES;
-// Définition des vidéos (dans un vrai projet, ces données viendraient d'une API)
-$videos = [
- [
- 'id' => 1,
- 'title' => 'Introduction à la culture libre et aux logiciels open source',
- 'thumbnail' => 'img/video-thumbnails/featured-1.jpg',
- 'duration' => 1245,
- 'channel' => 'Tech Libre',
- 'views' => 15420,
- 'date' => '2023-11-15',
- 'category_id' => 1
- ],
- [
- 'id' => 2,
- 'title' => 'La Réunion: Découverte des sentiers cachés',
- 'thumbnail' => 'img/video-thumbnails/featured-2.jpg',
- 'duration' => 843,
- 'channel' => 'Île Aventure',
- 'views' => 8745,
- 'date' => '2023-12-02',
- 'category_id' => 6
- ],
- [
- 'id' => 3,
- 'title' => 'Comment installer Linux sur un ancien ordinateur',
- 'thumbnail' => 'img/video-thumbnails/featured-3.jpg',
- 'duration' => 723,
- 'channel' => 'Tech Libre',
- 'views' => 24680,
- 'date' => '2023-10-25',
- 'category_id' => 1
- ],
- [
- 'id' => 4,
- 'title' => 'Festival Sakifo 2023 - Les meilleurs moments',
- 'thumbnail' => 'img/video-thumbnails/recent-1.jpg',
- 'duration' => 1832,
- 'channel' => 'Culture 974',
- 'views' => 3420,
- 'date' => '2023-12-15',
- 'category_id' => 2
- ],
- [
- 'id' => 5,
- 'title' => 'Cuisine créole: Recette du rougail saucisse traditionnel',
- 'thumbnail' => 'img/video-thumbnails/recent-2.jpg',
- 'duration' => 685,
- 'channel' => 'Saveurs des Îles',
- 'views' => 7245,
- 'date' => '2023-12-10',
- 'category_id' => 5
- ],
- [
- 'id' => 6,
- 'title' => 'Tutoriel: Créer votre première application web avec PHP',
- 'thumbnail' => 'img/video-thumbnails/recent-3.jpg',
- 'duration' => 1540,
- 'channel' => 'CodeMastery',
- 'views' => 2180,
- 'date' => '2023-12-08',
- 'category_id' => 3
- ],
- [
- 'id' => 7,
- 'title' => 'Les plus belles plages de La Réunion en 2023',
- 'thumbnail' => 'img/video-thumbnails/recent-4.jpg',
- 'duration' => 925,
- 'channel' => 'Île Aventure',
- 'views' => 5690,
- 'date' => '2023-12-05',
- 'category_id' => 6
- ],
- [
- 'id' => 8,
- 'title' => 'Débat: L\'avenir du numérique à La Réunion',
- 'thumbnail' => 'img/video-thumbnails/recent-5.jpg',
- 'duration' => 3245,
- 'channel' => 'Tech Libre',
- 'views' => 1250,
- 'date' => '2023-12-01',
- 'category_id' => 1
- ],
- [
- 'id' => 9,
- 'title' => 'Concert live: Groupe Sakili au Téat Plein Air',
- 'thumbnail' => 'img/video-thumbnails/recent-6.jpg',
- 'duration' => 4512,
- 'channel' => 'Culture 974',
- 'views' => 4325,
- 'date' => '2023-11-28',
- 'category_id' => 8
- ]
-];
-
-// Filtrer les vidéos par catégorie si une catégorie est sélectionnée
-if ($categoryId) {
- $categoryVideos = array_filter($videos, function($video) use ($categoryId) {
- return $video['category_id'] == $categoryId;
- });
+// 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];
- $category = isset($categories[$categoryId]) ? $categories[$categoryId] : null;
+ // 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
} else {
- $categoryVideos = [];
- $category = null;
-}
-
-// Fonctions utilitaires
-function formatDuration($seconds) {
- $hours = floor($seconds / 3600);
- $minutes = floor(($seconds % 3600) / 60);
- $remainingSeconds = $seconds % 60;
-
- if ($hours > 0) {
- return sprintf('%d:%02d:%02d', $hours, $minutes, $remainingSeconds);
- } else {
- return sprintf('%d:%02d', $minutes, $remainingSeconds);
- }
-}
-
-function formatViewCount($views) {
- if ($views >= 1000000) {
- return round($views / 1000000, 1) . 'M';
- } elseif ($views >= 1000) {
- return round($views / 1000, 1) . 'K';
- } else {
- return $views;
- }
-}
-
-function formatDate($dateString) {
- $date = new DateTime($dateString);
- $now = new DateTime();
- $interval = $now->diff($date);
-
- if ($interval->days == 0) {
- return 'Aujourd\'hui';
- } elseif ($interval->days == 1) {
- return 'Hier';
- } elseif ($interval->days < 7) {
- return 'Il y a ' . $interval->days . ' jours';
- } elseif ($interval->days < 30) {
- $weeks = floor($interval->days / 7);
- return 'Il y a ' . $weeks . ' semaine' . ($weeks > 1 ? 's' : '');
- } elseif ($interval->days < 365) {
- $months = floor($interval->days / 30);
- return 'Il y a ' . $months . ' mois';
- } else {
- $years = floor($interval->days / 365);
- return 'Il y a ' . $years . ' an' . ($years > 1 ? 's' : '');
- }
+ // Si aucune catégorie valide n'est spécifiée, rediriger vers l'accueil
+ header('Location: index.php');
+ exit;
}
?>
@@ -212,9 +27,8 @@ function formatDate($dateString) {
- Kaubuntu.re
+ - Kaubuntu.re
-
@@ -226,94 +40,159 @@ function formatDate($dateString) {
-