diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-01-10 19:37:27 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-01-10 19:37:27 +0000 |
commit | 57447dc57165a6322db2de9f369e278dca9724bc (patch) | |
tree | b28b165fb26316584b63a817689ddce457697c27 | |
parent | c128aae63875d73494d7710c77eb1f0d81fbb4d1 (diff) | |
download | brdo-57447dc57165a6322db2de9f369e278dca9724bc.tar.gz brdo-57447dc57165a6322db2de9f369e278dca9724bc.tar.bz2 |
- Patch #42105 by chx / merlinofchaos: made form elements themable.
-rw-r--r-- | includes/form.inc | 4 | ||||
-rw-r--r-- | includes/theme.inc | 27 |
2 files changed, 23 insertions, 8 deletions
diff --git a/includes/form.inc b/includes/form.inc index 0839a90b1..d0db80c9f 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -103,10 +103,10 @@ function drupal_get_form($form_id, &$form, $callback = NULL) { } } - 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); diff --git a/includes/theme.inc b/includes/theme.inc index e025299e6..13f2e6d48 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -159,6 +159,23 @@ function list_theme_engines($refresh = FALSE) { * 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; // Because theme() is called a lot, calling init_theme() only to have it @@ -167,21 +184,19 @@ function 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; } /** |