From 55a297d9da5e28f8bc44d9ed01ac1ee2bc2e3baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Wed, 29 Aug 2007 18:09:36 +0000 Subject: #57676 by JohnAlbin et al: properly support theme engine and theme specific settings via a theme-settings.php file --- modules/system/system.admin.inc | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index fb71b4762..8d62dfdd0 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -451,19 +451,37 @@ function system_theme_settings(&$form_state, $key = '') { } if ($key) { - // Template-specific settings - $function = $themes[$key]->prefix .'_settings'; + // Include the theme's theme-settings.php file + $filename = './'. str_replace("/$key.info", '', $themes[$key]->filename) .'/theme-settings.php'; + if (!file_exists($filename) and !empty($themes[$key]->info['base theme'])) { + // If the theme doesn't have a theme-settings.php file, use the base theme's. + $base = $themes[$key]->info['base theme']; + $filename = './'. str_replace("/$base.info", '', $themes[$base]->filename) .'/theme-settings.php'; + } + if (file_exists($filename)) { + require_once $filename; + } + + // Call engine-specific settings. + $function = $themes[$key]->prefix .'_engine_settings'; if (function_exists($function)) { - if ($themes[$key]->template) { - // file is a template or a style of a template - $form['specific'] = array('#type' => 'fieldset', '#title' => t('Engine-specific settings'), '#description' => t('These settings only exist for all the templates and styles based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix))); + $group = $function($settings); + if (!empty($group)) { + $form['engine_specific'] = array('#type' => 'fieldset', '#title' => t('Theme-engine-specific settings'), '#description' => t('These settings only exist for all the templates and styles based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix))); + $form['engine_specific'] = array_merge($form['engine_specific'], $group); } - else { - // file is a theme or a style of a theme - $form['specific'] = array('#type' => 'fieldset', '#title' => t('Theme-specific settings'), '#description' => t('These settings only exist for the %theme theme and all the styles based on it.', array('%theme' => $themes[$key]->prefix))); + } + // Call theme-specific settings. + $function = $key .'_settings'; + if (!function_exists($function)) { + $function = $themes[$key]->prefix .'_settings'; + } + if (function_exists($function)) { + $group = $function($settings); + if (!empty($group)) { + $form['theme_specific'] = array('#type' => 'fieldset', '#title' => t('Theme-specific settings'), '#description' => t('These settings only exist for the %theme theme and all the styles based on it.', array('%theme' => $themes[$key]->info['name']))); + $form['theme_specific'] = array_merge($form['theme_specific'], $group); } - $group = $function(); - $form['specific'] = array_merge($form['specific'], (is_array($group) ? $group : array())); } } $form['#attributes'] = array('enctype' => 'multipart/form-data'); -- cgit v1.2.3