Compare commits
No commits in common. "dfcc1dc7d87feb067c700e80dda177d9cd5c2a90" and "3e725681410ab9c881d554f2f5d8db72736a08d5" have entirely different histories.
dfcc1dc7d8
...
3e72568141
|
@ -1,12 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Theme Configuration
|
|
||||||
*
|
|
||||||
* This file is auto-generated. Do not edit it manually.
|
|
||||||
* Use the theme management interface to modify theme settings.
|
|
||||||
*/
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// Active theme (can be overridden by user preference)
|
// Active theme (can be overridden by user preference)
|
||||||
'active_theme' => 'default',
|
'active_theme' => 'default',
|
||||||
|
|
|
@ -31,67 +31,8 @@ class Theme
|
||||||
*/
|
*/
|
||||||
public static function getConfig()
|
public static function getConfig()
|
||||||
{
|
{
|
||||||
$configFile = __DIR__ . '/../config/theme.php';
|
// Always reload the config to get the latest changes
|
||||||
|
self::$config = require __DIR__ . '/../config/theme.php';
|
||||||
// Create default config if it doesn't exist
|
|
||||||
if (!file_exists($configFile)) {
|
|
||||||
$configDir = dirname($configFile);
|
|
||||||
if (!is_dir($configDir)) {
|
|
||||||
mkdir($configDir, 0755, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate the config file with proper formatting
|
|
||||||
$configContent = <<<'EOT'
|
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Theme Configuration
|
|
||||||
*
|
|
||||||
* This file is auto-generated. Do not edit it manually.
|
|
||||||
* Use the theme management interface to modify theme settings.
|
|
||||||
*/
|
|
||||||
|
|
||||||
return [
|
|
||||||
// Active theme (can be overridden by user preference)
|
|
||||||
'active_theme' => 'modern',
|
|
||||||
|
|
||||||
// Available themes with their display names
|
|
||||||
'available_themes' => [
|
|
||||||
'default' => 'Default built-in theme',
|
|
||||||
'modern' => 'Modern theme',
|
|
||||||
'retro' => 'Alternative retro theme'
|
|
||||||
],
|
|
||||||
|
|
||||||
// Path configurations
|
|
||||||
'paths' => [
|
|
||||||
// Base directory for all external themes
|
|
||||||
'themes' => __DIR__ . '/../../themes',
|
|
||||||
|
|
||||||
// Default templates location (built-in fallback)
|
|
||||||
'templates' => __DIR__ . '/../templates',
|
|
||||||
|
|
||||||
// Public assets directory (built-in fallback)
|
|
||||||
'public' => __DIR__ . '/../../public_html'
|
|
||||||
],
|
|
||||||
|
|
||||||
// Theme configuration defaults
|
|
||||||
'default_config' => [
|
|
||||||
'name' => 'Unnamed Theme',
|
|
||||||
'description' => 'A Jilo Web theme',
|
|
||||||
'version' => '1.0.0',
|
|
||||||
'author' => 'Lindeas Inc.',
|
|
||||||
'screenshot' => 'screenshot.png',
|
|
||||||
'options' => []
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
EOT;
|
|
||||||
|
|
||||||
file_put_contents($configFile, $configContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration
|
|
||||||
self::$config = require $configFile;
|
|
||||||
return self::$config;
|
return self::$config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,21 +50,8 @@ EOT;
|
||||||
{
|
{
|
||||||
// Only load config if not already loaded
|
// Only load config if not already loaded
|
||||||
if (self::$config === null) {
|
if (self::$config === null) {
|
||||||
try {
|
self::$config = require __DIR__ . '/../config/theme.php';
|
||||||
self::getConfig(); // This will create default config if needed
|
|
||||||
} catch (Exception $e) {
|
|
||||||
error_log('Failed to load theme configuration: ' . $e->getMessage());
|
|
||||||
// Fallback to default configuration
|
|
||||||
self::$config = [
|
|
||||||
'active_theme' => 'modern',
|
|
||||||
'available_themes' => [
|
|
||||||
'modern' => ['name' => 'Modern'],
|
|
||||||
'retro' => ['name' => 'Retro']
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$currentTheme = self::getCurrentThemeName();
|
self::$currentTheme = self::getCurrentThemeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,52 +148,25 @@ EOT;
|
||||||
|
|
||||||
// Update config file
|
// Update config file
|
||||||
$configFile = __DIR__ . '/../config/theme.php';
|
$configFile = __DIR__ . '/../config/theme.php';
|
||||||
|
if (file_exists($configFile) && is_writable($configFile)) {
|
||||||
|
$config = file_get_contents($configFile);
|
||||||
|
// Update the active_theme in the config
|
||||||
|
$newConfig = preg_replace(
|
||||||
|
"/'active_theme'\s*=>\s*'[^']*'/",
|
||||||
|
"'active_theme' => '" . addslashes($themeName) . "'",
|
||||||
|
$config
|
||||||
|
);
|
||||||
|
|
||||||
// Check if config file exists and is writable
|
if ($newConfig !== $config) {
|
||||||
if (!file_exists($configFile)) {
|
if (file_put_contents($configFile, $newConfig) === false) {
|
||||||
error_log("Theme config file not found: $configFile");
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_writable($configFile)) {
|
|
||||||
error_log("Theme config file is not writable: $configFile");
|
|
||||||
if (isset($GLOBALS['feedback_messages'])) {
|
|
||||||
$GLOBALS['feedback_messages'][] = [
|
|
||||||
'type' => 'error',
|
|
||||||
'message' => 'Cannot save theme preference: configuration file is not writable.'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$config = file_get_contents($configFile);
|
|
||||||
if ($config === false) {
|
|
||||||
error_log("Failed to read theme config file: $configFile");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the active_theme in the config
|
|
||||||
$newConfig = preg_replace(
|
|
||||||
"/'active_theme'\s*=>\s*'[^']*'/",
|
|
||||||
"'active_theme' => '" . addslashes($themeName) . "'",
|
|
||||||
$config
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($newConfig !== $config) {
|
|
||||||
if (file_put_contents($configFile, $newConfig) === false) {
|
|
||||||
error_log("Failed to write to theme config file: $configFile");
|
|
||||||
if (isset($GLOBALS['feedback_messages'])) {
|
|
||||||
$GLOBALS['feedback_messages'][] = [
|
|
||||||
'type' => 'error',
|
|
||||||
'message' => 'Failed to save theme preference due to a system error.'
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
self::$currentTheme = $themeName;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$currentTheme = $themeName;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue