Files
kaubuntu.re/includes/sidebar.php
T
2025-09-17 22:30:09 +04:00

83 lines
4.2 KiB
PHP

<!-- Sidebar de navigation -->
<nav class="sidebar" role="navigation" aria-label="Navigation principale">
<a href="/" class="logo" aria-label="Retour à l'accueil">
<img src="img/logo.png" alt="Logo kaubuntu.re">
</a>
<?php
// Détecter la page courante et ses paramètres
$currentPage = basename($_SERVER['PHP_SELF']);
$currentCategoryId = isset($_GET['id']) ? intval($_GET['id']) : null;
$currentQuery = isset($_GET['q']) ? trim($_GET['q']) : '';
$isTagSearch = !empty($currentQuery) && substr($currentQuery, 0, 1) === '#';
$currentTag = $isTagSearch ? substr($currentQuery, 1) : '';
?>
<div class="sidebar-nav">
<a href="/" class="nav-item <?php echo ($currentPage === 'index.php') ? 'active' : ''; ?>" data-title="Accueil" aria-current="<?php echo ($currentPage === 'index.php') ? 'page' : 'false'; ?>">
<i class="fas fa-home" aria-hidden="true"></i> <span>Accueil</span>
</a>
<a href="direct.php" class="nav-item <?php echo ($currentPage === 'direct.php') ? 'active' : ''; ?>" data-title="Direct" aria-current="<?php echo ($currentPage === 'direct.php') ? 'page' : 'false'; ?>">
<i class="fas fa-broadcast-tower" aria-hidden="true"></i> <span>Direct</span>
</a>
<div class="nav-divider"></div>
<?php
// Afficher les catégories prioritaires
if (defined('PRIORITY_CATEGORIES') && !empty(PRIORITY_CATEGORIES)) {
// Tableau associatif des icônes pour les catégories
$categoryIcons = [
1 => 'fas fa-music', // Musique
2 => 'fas fa-film', // Films
3 => 'fas fa-car', // Véhicules
4 => 'fas fa-palette', // Jeux
5 => 'fas fa-running', // Sport
6 => 'fas fa-laugh', // Humour
7 => 'fas fa-gamepad', // Art
8 => 'fas fa-person', // Personnalités
9 => 'fas fa-face-grin-tears', // Comédie
10 => 'fas fa-tv', // Divertissement
11 => 'fas fa-globe', // Actualité & Politique
12 => 'fas fa-chalkboard-user', // Tutoriel
13 => 'fas fa-graduation-cap', // Education
14 => 'fas fa-fist-raised', // Activisme
15 => 'fas fa-microscope', // Science & Technologie
16 => 'fas fa-paw', // Animaux
17 => 'fas fa-child', // Enfants
18 => 'fas fa-utensils' // Cuisine
];
foreach (PRIORITY_CATEGORIES as $id => $name) {
$isActive = ($currentPage === 'categories.php' && $currentCategoryId === $id);
$icon = isset($categoryIcons[$id]) ? $categoryIcons[$id] : 'fas fa-folder';
echo '<a href="categories.php?id=' . $id . '" class="nav-item ' . ($isActive ? 'active' : '') . '" data-title="' . htmlspecialchars($name) . '" aria-current="' . ($isActive ? 'page' : 'false') . '">';
echo '<i class="' . $icon . '" aria-hidden="true"></i> <span>' . htmlspecialchars($name) . '</span>';
echo '</a>';
}
}
?>
<div class="nav-divider"></div>
<div class="category-title" role="heading" aria-level="2">
<i class="fas fa-hashtag" aria-hidden="true"></i> <span>Hashtags</span>
</div>
<?php
if (defined('IMPORTANT_TAGS') && !empty(IMPORTANT_TAGS)):
foreach (IMPORTANT_TAGS as $tag):
$encodedTag = urlencode('#' . $tag);
$isActive = ($isTagSearch && strtolower($currentTag) === strtolower($tag));
?>
<a href="recherche.php?q=<?php echo $encodedTag; ?>" class="tag-item <?php echo $isActive ? 'active' : ''; ?>" data-title="<?php echo htmlspecialchars($tag); ?>" aria-current="<?php echo $isActive ? 'page' : 'false'; ?>">
<i class="fas fa-hashtag tag-icon" aria-hidden="true"></i> <span><?php echo htmlspecialchars($tag); ?></span>
</a>
<?php
endforeach;
endif;
?>
</div>
</nav>