Switch PHP views to Twig and add 2FA/UI enhancements

Migrate many view templates from raw PHP to Twig and modernize UI/UX for 2FA and settings. Controllers updated to provide avatar data and two-factor info (ProfileController, UserController) and SettingsController now includes timezone lists, notification preset selection, cron path, cached update state and rollback availability. ErrorHandler now attempts to render error pages via a new Core\TwigService with a safe fallback to raw PHP views. TwoFactorService generation silences deprecated warnings during QR code creation. Numerous .php view files were removed and replaced with .twig equivalents (2fa setup/verify/backup-codes and many auth, dashboard, domains, errors, layout, users, tags, tld-registry, etc.), and core/TwigService was added. These changes move the app toward a Twig-based templating system, improve 2FA flows, surface avatar images in lists/profiles, and make error rendering more robust.
This commit is contained in:
Hosteroid
2026-03-03 18:21:32 +02:00
parent cd4e3e6bcc
commit 4818172bc6
73 changed files with 9948 additions and 10686 deletions

View File

@@ -297,7 +297,29 @@ class ErrorHandler
$session_data = json_decode($errorData['session_data'], true);
// Display debug page in development, clean 500 in production
if ($this->isDevelopment) {
$twigTemplate = $this->isDevelopment ? 'errors/debug.twig' : 'errors/500.twig';
$twigFile = __DIR__ . '/../Views/' . $twigTemplate;
if (file_exists($twigFile)) {
try {
$memory_usage_mb = round(($memory_usage ?? 0) / 1024 / 1024, 2);
$peak_memory_mb = round(memory_get_peak_usage(true) / 1024 / 1024, 2);
$errorContext = compact(
'error_id', 'error_type', 'error_message', 'error_file', 'error_line',
'stack_trace', 'request_method', 'request_uri', 'user_agent',
'ip_address', 'php_version', 'memory_usage', 'memory_usage_mb',
'peak_memory_mb', 'occurred_at', 'user_info', 'request_data', 'session_data'
);
echo \Core\TwigService::getInstance()->render($twigTemplate, $errorContext);
} catch (\Throwable $e) {
// Twig itself failed — fall back to raw PHP view
if ($this->isDevelopment) {
require __DIR__ . '/../Views/errors/debug.php';
} else {
require __DIR__ . '/../Views/errors/500.php';
}
}
} elseif ($this->isDevelopment) {
require __DIR__ . '/../Views/errors/debug.php';
} else {
require __DIR__ . '/../Views/errors/500.php';