diff --git a/inc/functions.php b/inc/functions.php index cec25137..f5c502f4 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -96,21 +96,28 @@ function loadThemeConfig($_theme) { global $config; - if(!file_exists($config['dir']['homepage'] . '/' . $_theme . '/theme.php')) + if(!file_exists($config['dir']['homepage'] . '/' . $_theme . '/info.php')) return false; // Load theme information into $theme - include $config['dir']['homepage'] . '/' . $_theme . '/theme.php'; + include $config['dir']['homepage'] . '/' . $_theme . '/info.php'; return $theme; } function rebuildTheme($action) { + global $config; + $query = query("SELECT `value` AS `theme` FROM `theme_settings` WHERE `name` = 'theme'") or error(db_error()); if($theme = $query->fetch()) { // A theme is installed + $_theme = $theme['theme']; - $theme = loadThemeConfig($theme['theme']); - $theme['build_function']($action, themeSettings()); + $theme = loadThemeConfig($_theme); + + if(file_exists($config['dir']['homepage'] . '/' . $_theme . '/theme.php')) { + include $config['dir']['homepage'] . '/' . $_theme . '/theme.php'; + $theme['build_function']($action, themeSettings()); + } } } diff --git a/templates/homepage/basic/theme.php b/templates/homepage/basic/theme.php index 401d3f5a..5782d63d 100644 --- a/templates/homepage/basic/theme.php +++ b/templates/homepage/basic/theme.php @@ -1,40 +1,15 @@ 'Title', - 'name' => 'title', - 'type' => 'text' - ); - - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text' - ); - - // Unique function name for building everything - $theme['build_function'] = 'basic_build'; - - if(!function_exists('basic_build')) { - function basic_build($action, $settings) { - // Possible values for $action: - // - all (rebuild everything, initialization) - // - news (news has been updated) - // - boards (board list changed) - - Basic::build($action, $settings); - } + function basic_build($action, $settings) { + // Possible values for $action: + // - all (rebuild everything, initialization) + // - news (news has been updated) + // - boards (board list changed) + + Basic::build($action, $settings); } + // Wrap functions in a class so they don't interfere with normal Tinyboard operations class Basic { public static function build($action, $settings) { diff --git a/templates/homepage/frameset/theme.php b/templates/homepage/frameset/theme.php index ff81608a..90af409c 100644 --- a/templates/homepage/frameset/theme.php +++ b/templates/homepage/frameset/theme.php @@ -1,44 +1,15 @@ 'Title', - 'name' => 'title', - 'type' => 'text' - ); - - $theme['config'][] = Array( - 'title' => 'Slogan', - 'name' => 'subtitle', - 'type' => 'text' - ); - - // Unique function name for building everything - $theme['build_function'] = 'frameset_build'; - - if(!function_exists('frameset_build')) { - function frameset_build($action, $settings) { - // Possible values for $action: - // - all (rebuild everything, initialization) - // - news (news has been updated) - // - boards (board list changed) - - Frameset::build($action, $settings); - } + function frameset_build($action, $settings) { + // Possible values for $action: + // - all (rebuild everything, initialization) + // - news (news has been updated) + // - boards (board list changed) + + Frameset::build($action, $settings); } - + // Wrap functions in a class so they don't interfere with normal Tinyboard operations class Frameset { public static function build($action, $settings) {