get(); foreach ($pages as $page) { $key = $page->config_index_key; // Verifica se o arquivo físico existe $fileExists = false; if ($key === 'index') { $fileExists = true; } else { $possiblePaths = [ $indexViewsDir . '/' . $key . '.twig', $indexViewsDir . '/' . $key . '.php', $themeViewsDir . '/' . $key . '.twig', $themeViewsDir . '/' . $key . '.php', $baseDir . '/themes/' . $activeTheme . '/' . $key . '.twig', $baseDir . '/themes/' . $activeTheme . '/' . $key . '.php', $baseDir . '/modules/' . $key . '/views/index.twig', ]; foreach ($possiblePaths as $path) { if (is_file($path)) { $fileExists = true; break; } } } $visibility[$key] = [ 'public' => (bool) $page->config_index_show_public_nav && $fileExists, 'dashboard' => (bool) $page->config_index_show_dashboard_nav && $fileExists, 'title' => $page->config_index_title ?: ucfirst($key) ]; } } // Garante que as páginas padrão tenham uma configuração inicial, mas respeita o banco de dados foreach (['about', 'contact', 'services'] as $key) { if (!isset($visibility[$key])) { // Se não estiver no banco, o padrão é VISÍVEL (true) para manter compatibilidade // Mas agora as alterações via admin/configindex PERSISTEM no banco $visibility[$key] = ['public' => true, 'dashboard' => true, 'title' => ucfirst($key)]; } } $view = new View(); $view->getEngine()->addGlobal('config_pages_visibility', $visibility); } catch (\Throwable $e) { $view = new View(); $view->getEngine()->addGlobal('config_pages_visibility', [ 'about' => ['public' => false, 'dashboard' => false, 'title' => 'About'], 'contact' => ['public' => false, 'dashboard' => false, 'title' => 'Contact'], 'services' => ['public' => false, 'dashboard' => false, 'title' => 'Services'], ]); } } }