Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.474 diff -u -p -r1.474 system.module --- modules/system/system.module 6 May 2007 05:47:52 -0000 1.474 +++ modules/system/system.module 13 May 2007 10:04:12 -0000 @@ -2199,19 +2199,26 @@ function system_theme_settings($key = '' } if ($key) { - // Template-specific settings + // Custom theme settings $function = $themes[$key]->prefix .'_settings'; + global $custom_theme; + $custom_theme = $key; + init_theme(); 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))); + if (!empty($themes[$key]->template)) { + // Call engine-specific settings + $group = $function(); + if (!empty($group)) { + $form['engine_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))); + $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 + $group = $function($key); + 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'); Index: themes/engines/phptemplate/phptemplate.engine =================================================================== RCS file: /cvs/drupal/drupal/themes/engines/phptemplate/phptemplate.engine,v retrieving revision 1.65 diff -u -p -r1.65 phptemplate.engine --- themes/engines/phptemplate/phptemplate.engine 6 May 2007 05:47:52 -0000 1.65 +++ themes/engines/phptemplate/phptemplate.engine 13 May 2007 10:04:12 -0000 @@ -75,3 +75,26 @@ function phptemplate_engine_preprocess(& $variables['directory'] = path_to_theme(); $variables['is_front'] = drupal_is_front_page(); } + +/** + * Adds additional form elements to a theme settings page. + * + * @param $key + * The name of the theme. + */ +function phptemplate_settings($key = NULL) { + $form = array(); + if (!empty($key)) { + $themes = list_themes(); + if (function_exists($key.'_theme_settings')) { + $form = call_user_func($key.'_theme_settings', $key); + } + elseif (!empty($themes[$key]->base_theme) and function_exists($themes[$key]->base_theme.'_theme_settings')) { + $form = call_user_func($themes[$key]->base_theme.'_theme_settings', $key); + } + elseif (function_exists('phptemplate_theme_settings')) { + $form = phptemplate_theme_settings($key); + } + } + return $form; +}