enable view
Deploy HouseHub / deploy (push) Successful in 2s

This commit is contained in:
FeFeClochette committed 2026-09-17 10:49:49 +02:00
1 parent 693b277002
commit a7a8244a33
12 files changed
+273 -119

No files matched your search

+38 -6
View File
@@ -5,8 +5,26 @@ require __DIR__ . '/includes/db.php';
require_once __DIR__ . '/includes/i18n.php';
require_login('/login.php');
// Gestion de l'onglet actif
$tab = $_GET['tab'] ?? 'meals';
// 1. Détection des vues actives
$enabledViews = $_SESSION['enabled_views'] ?? ['food_meals', 'food_liste'];
$allowedTabs = [];
if (in_array('food_meals', $enabledViews)) $allowedTabs[] = 'meals';
if (in_array('food_liste', $enabledViews)) $allowedTabs[] = 'liste';
// 2. Fallback intelligent de l'onglet actif
if (empty($allowedTabs)) {
$tab = 'empty'; // L'utilisateur a désactivé les deux vues
} else {
// Par défaut, on prend le premier onglet disponible (Meals, ou Liste si Meals est désactivé)
$defaultTab = $allowedTabs[0];
$tab = $_GET['tab'] ?? $defaultTab;
// Sécurité URL : Si on force un onglet non autorisé
if (!in_array($tab, $allowedTabs)) {
$tab = $defaultTab;
}
}
$pageTitle = tr('mod_food_name');
$activePage = "food";
@@ -21,30 +39,44 @@ require __DIR__ . '/header.php';
<h1>🍳 <?= tr('mod_food_name') ?></h1>
</div>
<?php if ($tab !== 'empty'): ?>
<nav class="budget-tabs-container">
<?php if (in_array('meals', $allowedTabs)): ?>
<a href="?tab=meals" class="tab-item <?= $tab == 'meals' ? 'active' : '' ?>">
<span class="tab-icon">🍽️</span>
<span><?= tr('food_tab_meals') ?></span>
</a>
<?php endif; ?>
<?php if (in_array('liste', $allowedTabs)): ?>
<a href="?tab=liste" class="tab-item <?= $tab == 'liste' ? 'active' : '' ?>">
<span class="tab-icon">🛒</span>
<span><?= tr('food_tab_list') ?></span>
</a>
<?php endif; ?>
</nav>
<?php endif; ?>
</div>
<section class="pf-section">
<?php
$allowedTabs = ['meals', 'liste'];
if (in_array($tab, $allowedTabs)) {
if ($tab === 'empty') {
// État Vide Intégré (Zéro vue activée)
echo "
<div class='pf-empty-state' style='text-align:center; padding: 60px 20px; max-width: 600px; margin: 0 auto; background: var(--bg-panel); border-radius: 16px; border: 1px dashed var(--border-strong); box-shadow: var(--shadow-sm);'>
<div style='font-size: 4rem; margin-bottom: 20px; opacity: 0.5;'>👀</div>
<h3 style='color: var(--text-main); margin-bottom: 10px; font-size: 1.3rem;'>" . tr('food_err_no_views') . "</h3>
<p style='color: var(--text-muted); margin-bottom: 30px; font-size: 0.95rem; line-height: 1.5;'>" . tr('food_err_no_views_desc') . "</p>
<a href='/settings.php' class='pf-btn'>⚙️ " . tr('settings') . "</a>
</div>";
} else {
// Routage classique
$viewPath = __DIR__ . "/modules/food/views/{$tab}.php";
if (file_exists($viewPath)) {
require $viewPath;
} else {
echo "<p>Vue introuvable : " . htmlspecialchars($tab) . "</p>";
}
} else {
echo "<p>" . tr('error_occured') . "</p>";
}
?>
</section>