Collections/config.php
Edwin Noorlander 9f9617ca45 Add development documentation and enhance SPA navigation with category/item detail views
- Add DEVELOPMENT.md with complete LXC environment setup guide
- Implement dynamic category tree with item navigation in sidebar
- Add category detail view with items list via AJAX
- Add item edit form with delete functionality
- Enhance SPA routing to support query parameters for categories/items
- Update Bootstrap styling with icons and improved navigation
- Include SQLite database in repository for development
2025-11-12 09:51:01 +01:00

52 lines
1.8 KiB
PHP
Executable File

<?php
// --- Application Configuration ---
const APP_NAME = 'Collections';
const DB_PATH = __DIR__ . '/collections.sqlite';
const DEFAULT_LOCALE = 'nl';
const SUPPORTED_LOCALES = ['nl', 'en'];
// --- Session Start ---
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// De autoloader moet geladen zijn voordat we hier komen.
// Gebruik FQCNs om afhankelijkheid van 'use' statements te vermijden.
// --- Twig Setup ---
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/templates');
$twig = new \Twig\Environment($loader, [
// 'cache' => __DIR__ . '/cache/twig', // Uncomment for production
'debug' => true,
]);
// --- Translation Setup ---
$translationService = new \App\Services\TranslationService(
__DIR__ . '/lang',
SUPPORTED_LOCALES,
DEFAULT_LOCALE
);
// Get current locale from session or default
$locale = $_SESSION['locale'] ?? DEFAULT_LOCALE;
$translator = $translationService->getTranslator($locale);
// Add translation function to Twig
$twig->addFunction(new \Twig\TwigFunction('trans', function (string $id, array $parameters = [], string $domain = null, string $locale = null) use ($translator) {
return $translator->trans($id, $parameters, $domain, $locale);
}));
// Add current locale to Twig globals
$twig->addGlobal('current_locale', $locale);
$twig->addGlobal('supported_locales', SUPPORTED_LOCALES);
$twig->addGlobal('app_name', APP_NAME);
// Add translated confirm messages for JS
$twig->addGlobal('delete_part_confirm', $translator->trans('Are you sure you want to delete this part?'));
$twig->addGlobal('delete_category_confirm', $translator->trans('Are you sure you want to delete this category?'));
// Sidebar will be built dynamically via AJAX
$sidebarHtml = '<div id="sidebar-tree">Loading...</div>';
$twig->addGlobal('sidebar_html', $sidebarHtml);