diff --git a/app/config/theme.php b/app/config/theme.php index 5482e96..92399f9 100644 --- a/app/config/theme.php +++ b/app/config/theme.php @@ -7,7 +7,8 @@ return [ // Available themes with their display names 'available_themes' => [ 'default' => 'Default built-in theme', - 'modern' => 'Modern Theme' + 'modern' => 'Modern theme', + 'retro' => 'Alternative retro theme' ], // Path configurations diff --git a/app/helpers/theme.php b/app/helpers/theme.php index 7ac4b09..d86b586 100644 --- a/app/helpers/theme.php +++ b/app/helpers/theme.php @@ -193,22 +193,21 @@ class Theme */ public static function getAvailableThemes(): array { + $config = self::getConfig(); + $availableThemes = $config['available_themes'] ?? []; $themes = []; - $themesDir = self::$config['path'] ?? (__DIR__ . '/../../themes'); - if (!is_dir($themesDir)) { - return []; + // Add default theme if not already present + if (!isset($availableThemes['default'])) { + $availableThemes['default'] = 'Default built-in theme'; } - foreach (scandir($themesDir) as $item) { - if ($item === '.' || $item === '..' || !is_dir("$themesDir/$item")) { - continue; - } - - $configFile = "$themesDir/$item/config.php"; - if (file_exists($configFile)) { - $config = include $configFile; - $themes[$item] = $config['name'] ?? ucfirst($item); + // Verify each theme exists and has a config file + $themesDir = $config['paths']['themes'] ?? (__DIR__ . '/../../themes'); + foreach ($availableThemes as $id => $name) { + if ($id === 'default' || + (is_dir("$themesDir/$id") && file_exists("$themesDir/$id/config.php"))) { + $themes[$id] = $name; } }