Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.478
diff -u -p -r1.478 system.module
--- modules/system/system.module	17 May 2007 07:28:42 -0000	1.478
+++ modules/system/system.module	19 May 2007 23:46:29 -0000
@@ -2307,19 +2307,30 @@ function system_theme_settings($key = ''
   }
 
   if ($key) {
-    // Template-specific settings
-    $function = $themes[$key]->prefix .'_settings';
+    // Switch themes when displaying the theme settings.
+    global $custom_theme;
+    $custom_theme = $key;
+    init_theme();
+    // 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');
