Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.507 diff -u -p -r1.507 system.module --- modules/system/system.module 3 Jul 2007 19:11:14 -0000 1.507 +++ modules/system/system.module 4 Jul 2007 05:49:43 -0000 @@ -453,11 +453,17 @@ function system_admin_theme_settings() { '#default_value' => variable_get('node_admin_theme', '0'), ); + $form['theme_settings_admin_theme'] = array( + '#type' => 'checkbox', + '#title' => t('Use administration theme when configuring theme settings'), + '#description' => t('If this setting is disabled or if using the "System default" theme, the theme settings pages will be switched to the theme being configured.'), + '#default_value' => variable_get('theme_settings_admin_theme', '1'), + ); + $form['#submit'][] = 'system_admin_theme_submit'; return system_settings_form($form); } - function system_admin_theme_submit($form, &$form_state) { // If we're changing themes, make sure the theme has its blocks initialized. if ($form_state['values']['admin_theme'] != variable_get('admin_theme', '0')) { @@ -2454,19 +2460,43 @@ function system_theme_settings(&$form_st } if ($key) { - // Template-specific settings - $function = $themes[$key]->prefix .'_settings'; + // If the administration theme is not used, switch themes when displaying the theme settings. + if (variable_get('admin_theme', '0') == '0' or variable_get('theme_settings_admin_theme', '1') == '0') { + global $custom_theme; + $custom_theme = $key; + init_theme(); + } + // Include the theme's settings.php file + $filename = './'. str_replace("/$key.info", '', $themes[$key]->filename) .'/settings.php'; + if (!file_exists($filename) and !empty($themes[$key]->info['base theme'])) { + // If the theme doesn't have a settings.php file, use the base theme's. + $base = $themes[$key]->info['base theme']; + $filename = './'. str_replace("/$base.info", '', $themes[$base]->filename) .'/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');