replace search by recherche
This commit is contained in:
+210
@@ -0,0 +1,210 @@
|
|||||||
|
<?php
|
||||||
|
// Inclure la configuration
|
||||||
|
require_once 'includes/config.php';
|
||||||
|
|
||||||
|
// Récupération de la requête de recherche et de la page courante
|
||||||
|
$query = isset($_GET['q']) ? trim($_GET['q']) : '';
|
||||||
|
$currentPage = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
|
||||||
|
|
||||||
|
// Déterminer si la recherche est par tag
|
||||||
|
$isTagSearch = !empty($query) && substr($query, 0, 1) === '#';
|
||||||
|
$searchTag = $isTagSearch ? substr($query, 1) : '';
|
||||||
|
|
||||||
|
// Rechercher les vidéos via l'API PeerTube si une requête est soumise
|
||||||
|
$searchResults = !empty($query) ? searchVideos($query, COUNT_VIDEO_SEARCH) : [];
|
||||||
|
|
||||||
|
// Définir le nombre total de résultats
|
||||||
|
$resultsCount = count($searchResults);
|
||||||
|
|
||||||
|
// Calculer le nombre total de pages
|
||||||
|
$totalPages = ceil($resultsCount / VIDEOS_PER_PAGE);
|
||||||
|
|
||||||
|
// S'assurer que la page actuelle est valide
|
||||||
|
$currentPage = min($currentPage, max(1, $totalPages));
|
||||||
|
|
||||||
|
// Calculer les indices de début et de fin pour la page actuelle
|
||||||
|
$startIndex = ($currentPage - 1) * VIDEOS_PER_PAGE;
|
||||||
|
$endIndex = min($startIndex + VIDEOS_PER_PAGE, $resultsCount);
|
||||||
|
|
||||||
|
// Extraire les vidéos pour la page actuelle
|
||||||
|
$currentPageVideos = [];
|
||||||
|
if ($resultsCount > 0) {
|
||||||
|
$currentPageVideos = array_slice($searchResults, $startIndex, VIDEOS_PER_PAGE);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title><?php echo !empty($query) ? 'Recherche: ' . htmlspecialchars($query) . ' - ' : 'Recherche - '; ?>Kaubuntu.re</title>
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<!-- 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">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php include 'includes/sidebar.php'; ?>
|
||||||
|
|
||||||
|
<!-- Contenu principal -->
|
||||||
|
<div class="main-content">
|
||||||
|
<?php include 'includes/header.php'; ?>
|
||||||
|
|
||||||
|
<!-- Section de recherche -->
|
||||||
|
<div class="video-section search-page" data-search-query="<?php echo htmlspecialchars($query); ?>">
|
||||||
|
<div class="section-header">
|
||||||
|
<div class="section-logo">
|
||||||
|
<img src="img/logo.png" alt="Kaubuntu.re">
|
||||||
|
</div>
|
||||||
|
<?php if (!empty($query)): ?>
|
||||||
|
<?php if ($isTagSearch): ?>
|
||||||
|
<h2 class="section-title">Vidéos avec le hashtag : "<?php echo htmlspecialchars($searchTag); ?>"</h2>
|
||||||
|
<?php else: ?>
|
||||||
|
<h2 class="section-title">Résultats pour : "<?php echo htmlspecialchars($query); ?>"</h2>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<h2 class="section-title">Rechercher des vidéos</h2>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (!empty($query)): ?>
|
||||||
|
<?php if ($resultsCount > 0): ?>
|
||||||
|
<div class="search-results-count">
|
||||||
|
<?php if ($isTagSearch): ?>
|
||||||
|
<p><?php echo $resultsCount; ?> vidéo<?php echo $resultsCount > 1 ? 's' : ''; ?> avec le hashtag #<?php echo htmlspecialchars($searchTag); ?></p>
|
||||||
|
<?php else: ?>
|
||||||
|
<p><?php echo $resultsCount; ?> résultat<?php echo $resultsCount > 1 ? 's' : ''; ?> trouvé<?php echo $resultsCount > 1 ? 's' : ''; ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="video-grid category-videos">
|
||||||
|
<?php foreach ($currentPageVideos 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>
|
||||||
|
</div>
|
||||||
|
<span class="video-duration"><?php echo formatDuration($video['duration']); ?></span>
|
||||||
|
</div>
|
||||||
|
<div class="video-info">
|
||||||
|
<h3 class="video-title"><?php echo htmlspecialchars($video['title']); ?></h3>
|
||||||
|
<div class="video-channel">
|
||||||
|
<?php if (strpos($video['channelAvatar'], 'default-avatar') !== false || empty($video['channelAvatar'])): ?>
|
||||||
|
<div class="channel-avatar-placeholder">
|
||||||
|
<i class="fas fa-user-circle"></i>
|
||||||
|
</div>
|
||||||
|
<?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-metadata">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($totalPages > 1): ?>
|
||||||
|
<div class="pagination">
|
||||||
|
<?php if ($currentPage > 1): ?>
|
||||||
|
<a href="recherche.php?q=<?php echo urlencode($query); ?>&page=<?php echo $currentPage - 1; ?>" class="page-link prev">
|
||||||
|
<i class="fas fa-chevron-left"></i> Précédent
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="page-numbers">
|
||||||
|
<?php
|
||||||
|
// Déterminer la plage de pages à afficher
|
||||||
|
$pageRange = 2; // Nombre de pages à afficher de chaque côté
|
||||||
|
$startPage = max(1, $currentPage - $pageRange);
|
||||||
|
$endPage = min($totalPages, $currentPage + $pageRange);
|
||||||
|
|
||||||
|
// Afficher le lien vers la première page si nécessaire
|
||||||
|
if ($startPage > 1) {
|
||||||
|
echo '<a href="recherche.php?q=' . urlencode($query) . '&page=1" class="page-number">1</a>';
|
||||||
|
if ($startPage > 2) {
|
||||||
|
echo '<span class="page-dots">...</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Afficher les liens de pagination
|
||||||
|
for ($i = $startPage; $i <= $endPage; $i++) {
|
||||||
|
if ($i == $currentPage) {
|
||||||
|
echo '<span class="page-number current">' . $i . '</span>';
|
||||||
|
} else {
|
||||||
|
echo '<a href="recherche.php?q=' . urlencode($query) . '&page=' . $i . '" class="page-number">' . $i . '</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Afficher le lien vers la dernière page si nécessaire
|
||||||
|
if ($endPage < $totalPages) {
|
||||||
|
if ($endPage < $totalPages - 1) {
|
||||||
|
echo '<span class="page-dots">...</span>';
|
||||||
|
}
|
||||||
|
echo '<a href="recherche.php?q=' . urlencode($query) . '&page=' . $totalPages . '" class="page-number">' . $totalPages . '</a>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($currentPage < $totalPages): ?>
|
||||||
|
<a href="recherche.php?q=<?php echo urlencode($query); ?>&page=<?php echo $currentPage + 1; ?>" class="page-link next">
|
||||||
|
Suivant <i class="fas fa-chevron-right"></i>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="no-videos-message">
|
||||||
|
<i class="fas fa-search-minus"></i>
|
||||||
|
<h3>Aucun résultat trouvé</h3>
|
||||||
|
<?php if ($isTagSearch): ?>
|
||||||
|
<p>Aucune vidéo n'a été trouvée avec le tag "#<?php echo htmlspecialchars($searchTag); ?>".</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<p>Aucune vidéo ne correspond à votre recherche "<?php echo htmlspecialchars($query); ?>".</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<p>Essayez avec d'autres termes ou consultez les vidéos populaires sur la <a href="index.php">page d'accueil</a>.</p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="search-instructions">
|
||||||
|
<i class="fas fa-search"></i>
|
||||||
|
<h3>Effectuez une recherche</h3>
|
||||||
|
<p>Utilisez le formulaire ci-dessus pour rechercher des vidéos par titre, description ou tags.</p>
|
||||||
|
<p class="mt-2"><strong>Astuce :</strong> Pour rechercher par tag, commencez votre recherche par # (exemple: #réunion)</p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include 'includes/footer.php'; ?>
|
||||||
|
<?php include 'includes/mobile-menu.php'; ?>
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||||
|
<script src="js/main.js"></script>
|
||||||
|
<script>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
-300
@@ -1,300 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Récupération de la requête de recherche
|
|
||||||
$query = isset($_GET['q']) ? htmlspecialchars($_GET['q']) : '';
|
|
||||||
|
|
||||||
// Dans un vrai projet, ces données viendraient d'une API PeerTube
|
|
||||||
// Pour cet exemple, on utilise des données statiques
|
|
||||||
$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',
|
|
||||||
'description' => 'Une introduction complète au monde de la culture libre et des logiciels open source. Découvrez les principes fondamentaux, les licences, et comment contribuer à des projets open source.',
|
|
||||||
'tags' => ['open source', 'logiciels libres', 'tech', 'formation']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
'description' => 'Partez à la découverte des sentiers cachés de La Réunion. Cette vidéo vous guide à travers des paysages magnifiques et peu connus de l\'île.',
|
|
||||||
'tags' => ['La Réunion', 'voyage', 'randonnée', 'nature']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
'description' => 'Tutoriel détaillé pour installer une distribution Linux légère sur un ancien ordinateur et lui donner une seconde vie.',
|
|
||||||
'tags' => ['linux', 'tutoriel', 'open source', 'recyclage']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
'description' => 'Revivez les meilleurs moments du Festival Sakifo 2023 à Saint-Pierre, avec les performances des artistes locaux et internationaux.',
|
|
||||||
'tags' => ['musique', 'festival', 'sakifo', 'La Réunion']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
'description' => 'Apprenez à préparer un délicieux rougail saucisse traditionnel de La Réunion, avec tous les secrets pour réussir ce plat emblématique.',
|
|
||||||
'tags' => ['cuisine', 'recette', 'La Réunion', 'créole']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
'description' => 'Un guide pas à pas pour créer votre première application web en PHP, depuis l\'installation de l\'environnement jusqu\'au déploiement.',
|
|
||||||
'tags' => ['php', 'web', 'programmation', 'tutoriel']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
'description' => 'Découvrez les plus belles plages de La Réunion, des lagons de l\'ouest aux côtes sauvages du sud, avec des conseils pour chaque site.',
|
|
||||||
'tags' => ['plages', 'La Réunion', 'voyage', 'mer']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
'description' => 'Un débat passionnant sur l\'avenir du numérique à La Réunion, avec des intervenants du secteur public et privé qui discutent des enjeux et opportunités.',
|
|
||||||
'tags' => ['numérique', 'La Réunion', 'débat', 'technologie']
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'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',
|
|
||||||
'description' => 'Le concert complet du groupe Sakili au Téat Plein Air de Saint-Gilles, un moment magique de musique traditionnelle réunionnaise revisitée.',
|
|
||||||
'tags' => ['concert', 'musique', 'La Réunion', 'maloya']
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
// Fonction de recherche simple (dans un vrai projet, ce serait géré par l'API)
|
|
||||||
function searchVideos($videos, $query) {
|
|
||||||
if (empty($query)) return [];
|
|
||||||
|
|
||||||
$results = [];
|
|
||||||
$lowercaseQuery = strtolower($query);
|
|
||||||
|
|
||||||
foreach ($videos as $video) {
|
|
||||||
// Recherche dans le titre
|
|
||||||
if (strpos(strtolower($video['title']), $lowercaseQuery) !== false) {
|
|
||||||
$results[] = $video;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recherche dans la description
|
|
||||||
if (strpos(strtolower($video['description']), $lowercaseQuery) !== false) {
|
|
||||||
$results[] = $video;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recherche dans les tags
|
|
||||||
foreach ($video['tags'] as $tag) {
|
|
||||||
if (strpos(strtolower($tag), $lowercaseQuery) !== false) {
|
|
||||||
$results[] = $video;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recherche dans le nom de la chaîne
|
|
||||||
if (strpos(strtolower($video['channel']), $lowercaseQuery) !== false) {
|
|
||||||
$results[] = $video;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
$searchResults = !empty($query) ? searchVideos($videos, $query) : [];
|
|
||||||
|
|
||||||
// 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' : '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title><?php echo !empty($query) ? 'Recherche: ' . htmlspecialchars($query) . ' - ' : 'Recherche - '; ?>Kaubuntu.re</title>
|
|
||||||
<link rel="stylesheet" href="css/styles.css">
|
|
||||||
<link rel="stylesheet" href="css/search.css">
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
|
||||||
|
|
||||||
<!-- 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">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<?php include 'includes/header.php'; ?>
|
|
||||||
|
|
||||||
<main class="search-page">
|
|
||||||
<div class="search-header">
|
|
||||||
<h1>Résultats de recherche pour "<?php echo $query; ?>"</h1>
|
|
||||||
<div class="search-container">
|
|
||||||
<form action="search.php" method="get">
|
|
||||||
<input type="text" name="q" value="<?php echo $query; ?>" placeholder="Rechercher des vidéos...">
|
|
||||||
<button type="submit"><i class="fas fa-search"></i></button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if (!empty($query)): ?>
|
|
||||||
<?php if (count($searchResults) > 0): ?>
|
|
||||||
<div class="search-results-count">
|
|
||||||
<p><?php echo count($searchResults); ?> résultat(s) trouvé(s)</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="search-results">
|
|
||||||
<?php foreach ($searchResults as $video): ?>
|
|
||||||
<div class="search-result-item" data-video-id="<?php echo $video['id']; ?>">
|
|
||||||
<div class="search-result-thumbnail">
|
|
||||||
<img src="<?php echo $video['thumbnail']; ?>" alt="<?php echo $video['title']; ?>">
|
|
||||||
<div class="video-duration"><?php echo formatDuration($video['duration']); ?></div>
|
|
||||||
</div>
|
|
||||||
<div class="search-result-info">
|
|
||||||
<h3 class="search-result-title"><?php echo $video['title']; ?></h3>
|
|
||||||
<div class="search-result-metadata">
|
|
||||||
<span class="search-result-views"><?php echo formatViewCount($video['views']); ?> vues</span>
|
|
||||||
<span class="search-result-date"><?php echo formatDate($video['date']); ?></span>
|
|
||||||
</div>
|
|
||||||
<div class="search-result-channel"><?php echo $video['channel']; ?></div>
|
|
||||||
<div class="search-result-description"><?php echo substr($video['description'], 0, 150); ?>...</div>
|
|
||||||
<div class="search-result-tags">
|
|
||||||
<?php foreach ($video['tags'] as $tag): ?>
|
|
||||||
<a href="search.php?q=<?php echo urlencode($tag); ?>" class="tag">#<?php echo $tag; ?></a>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="no-results">
|
|
||||||
<i class="fas fa-search fa-3x"></i>
|
|
||||||
<h2>Aucun résultat trouvé pour "<?php echo $query; ?>"</h2>
|
|
||||||
<p>Essayez avec d'autres mots-clés ou vérifiez l'orthographe.</p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php else: ?>
|
|
||||||
<div class="search-instructions">
|
|
||||||
<i class="fas fa-search fa-3x"></i>
|
|
||||||
<h2>Recherchez du contenu</h2>
|
|
||||||
<p>Utilisez la barre de recherche pour trouver des vidéos, des chaînes ou des mots-clés.</p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<?php include 'includes/footer.php'; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mobile-menu-overlay" id="mobileMenuOverlay">
|
|
||||||
<?php include 'includes/mobile-menu.php'; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
|
||||||
<script src="js/main.js"></script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
// Gestion des clics sur les résultats de recherche
|
|
||||||
const searchResultItems = document.querySelectorAll('.search-result-item');
|
|
||||||
|
|
||||||
searchResultItems.forEach(item => {
|
|
||||||
item.addEventListener('click', function() {
|
|
||||||
const videoId = this.dataset.videoId;
|
|
||||||
if (videoId) {
|
|
||||||
window.location.href = 'video.php?id=' + videoId;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user