Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.38 diff -u -p -r1.38 form.inc --- includes/form.inc 29 Dec 2005 03:59:30 -0000 1.38 +++ includes/form.inc 29 Dec 2005 05:49:10 -0000 @@ -103,10 +103,10 @@ function drupal_get_form($form_id, &$for } } - if (function_exists('theme_' . $form_id)) { + if (theme_get_function($form_id)) { $form['#theme'] = $form_id; } - elseif (function_exists('theme_' . $callback)) { + elseif (theme_get_function($callback)) { $form['#theme'] = $callback; } return form_render($form); Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.269 diff -u -p -r1.269 theme.inc --- includes/theme.inc 29 Dec 2005 04:46:40 -0000 1.269 +++ includes/theme.inc 29 Dec 2005 05:49:10 -0000 @@ -158,6 +158,23 @@ function list_theme_engines($refresh = F * An HTML string that generates the themed output. */ function theme() { + $args = func_get_args(); + $function = array_shift($args); + + if ($func = theme_get_function($function)) { + return call_user_func_array($func, $args); + } +} + +/** + * Determine if a theme function exists, and if so return which one was found. + * + * @param $function + * The name of the theme function to test. + * @return + * The name of the theme function that should be used, or false if no function exists. + */ +function theme_get_function($function) { global $theme, $theme_engine; if ($theme === NULL) { @@ -165,21 +182,19 @@ function theme() { $theme = init_theme(); } - $args = func_get_args(); - $function = array_shift($args); - if (($theme != '') && function_exists($theme .'_'. $function)) { // call theme function - return call_user_func_array($theme .'_'. $function, $args); + return $theme .'_'. $function; } elseif (($theme != '') && isset($theme_engine) && function_exists($theme_engine .'_'. $function)) { // call engine function - return call_user_func_array($theme_engine .'_'. $function, $args); + return $theme_engine .'_'. $function; } elseif (function_exists('theme_'. $function)){ // call Drupal function - return call_user_func_array('theme_'. $function, $args); + return 'theme_'. $function; } + return false; } /**