Bugfixes theme switcher
parent
1c93864567
commit
06f8229a8c
|
@ -7,7 +7,8 @@ return [
|
||||||
// Available themes with their display names
|
// Available themes with their display names
|
||||||
'available_themes' => [
|
'available_themes' => [
|
||||||
'default' => 'Default built-in theme',
|
'default' => 'Default built-in theme',
|
||||||
'modern' => 'Modern Theme'
|
'modern' => 'Modern theme',
|
||||||
|
'retro' => 'Alternative retro theme'
|
||||||
],
|
],
|
||||||
|
|
||||||
// Path configurations
|
// Path configurations
|
||||||
|
|
|
@ -193,22 +193,21 @@ class Theme
|
||||||
*/
|
*/
|
||||||
public static function getAvailableThemes(): array
|
public static function getAvailableThemes(): array
|
||||||
{
|
{
|
||||||
|
$config = self::getConfig();
|
||||||
|
$availableThemes = $config['available_themes'] ?? [];
|
||||||
$themes = [];
|
$themes = [];
|
||||||
$themesDir = self::$config['path'] ?? (__DIR__ . '/../../themes');
|
|
||||||
|
|
||||||
if (!is_dir($themesDir)) {
|
// Add default theme if not already present
|
||||||
return [];
|
if (!isset($availableThemes['default'])) {
|
||||||
|
$availableThemes['default'] = 'Default built-in theme';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (scandir($themesDir) as $item) {
|
// Verify each theme exists and has a config file
|
||||||
if ($item === '.' || $item === '..' || !is_dir("$themesDir/$item")) {
|
$themesDir = $config['paths']['themes'] ?? (__DIR__ . '/../../themes');
|
||||||
continue;
|
foreach ($availableThemes as $id => $name) {
|
||||||
}
|
if ($id === 'default' ||
|
||||||
|
(is_dir("$themesDir/$id") && file_exists("$themesDir/$id/config.php"))) {
|
||||||
$configFile = "$themesDir/$item/config.php";
|
$themes[$id] = $name;
|
||||||
if (file_exists($configFile)) {
|
|
||||||
$config = include $configFile;
|
|
||||||
$themes[$item] = $config['name'] ?? ucfirst($item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue