From db081c14483f54577bbb82aad11ff43a4aafb2b0 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Tue, 2 Jun 2009 03:57:22 +0000 Subject: #422116 by JohnAlbin: Kill off theme_engine_name prefix for theme functions to assist with theme inheritance and TX (Themer eXperience). --- includes/theme.inc | 50 +++++++++------------------ themes/engines/phptemplate/phptemplate.engine | 3 +- themes/garland/template.php | 2 +- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/includes/theme.inc b/includes/theme.inc index c5e8d91a4..f82e9b00d 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -381,8 +381,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { elseif ($type == 'theme_engine' || $type == 'base_theme_engine') { // Theme engines get an extra set that come before the normally named variable processors. $prefixes[] = $name . '_engine'; - // The theme engine also registers on behalf of the theme. The theme or engine name can be used. - $prefixes[] = $name; + // The theme engine registers on behalf of the theme using the theme's name. $prefixes[] = $theme; } else { @@ -605,26 +604,11 @@ function list_themes($refresh = FALSE) { * This is the same as the previous function, but it is called for a single * theming hook. * - * - ENGINE_preprocess(&$variables) - * This is meant to be used by themes that utilize a theme engine. It is - * provided so that the preprocessor is not locked into a specific theme. - * This makes it easy to share and transport code but theme authors must be - * careful to prevent fatal re-declaration errors when using sub-themes that - * have their own preprocessor named exactly the same as its base theme. In - * the default theme engine (PHPTemplate), sub-themes will load their own - * template.php file in addition to the one used for its parent theme. This - * increases the risk for these errors. A good practice is to use the engine - * name for the base theme and the theme name for the sub-themes to minimize - * this possibility. - * - * - ENGINE_preprocess_HOOK(&$variables) - * The same applies from the previous function, but it is called for a - * specific hook. - * * - THEME_preprocess(&$variables) - * These functions are based upon the raw theme; they should primarily be - * used by themes that do not use an engine or by sub-themes. It serves the - * same purpose as ENGINE_preprocess(). + * This is for themes that want to alter or provide extra variables. For + * example, if a theme named "foo" wanted to alter the $submitted variable for + * the hook "node" a preprocess function of foo_preprocess_node() can be + * created to intercept and alter the variable. * * - THEME_preprocess_HOOK(&$variables) * The same applies from the previous function, but it is called for a @@ -1197,19 +1181,17 @@ function theme_render_template($template_file, $variables) { * Drupal and implemented in phptemplate.engine, which uses Drupal's default * template renderer. * - * In order to create theme-specific implementations of these hooks, - * themes can implement their own version of theme hooks, either as functions - * or templates. These implementations will be used instead of the default - * implementation. If using a pure .theme without an engine, the .theme is - * required to implement its own version of hook_theme() to tell Drupal what - * it is implementing; themes utilizing an engine will have their well-named - * theming functions automatically registered for them. While this can vary - * based upon the theme engine, the standard set by phptemplate is that theme - * functions should be named either phptemplate_HOOK or THEMENAME_HOOK. For - * example, for Drupal's default theme (Garland) to implement the 'table' hook, - * the phptemplate.engine would find phptemplate_table() or garland_table(). - * The ENGINE_HOOK() syntax is preferred, as this can be used by sub-themes - * (which are themes that share code but use different stylesheets). + * In order to create theme-specific implementations of these hooks, themes can + * implement their own version of theme hooks, either as functions or templates. + * These implementations will be used instead of the default implementation. If + * using a pure .theme without an engine, the .theme is required to implement + * its own version of hook_theme() to tell Drupal what it is implementing; + * themes utilizing an engine will have their well-named theming functions + * automatically registered for them. While this can vary based upon the theme + * engine, the standard set by phptemplate is that theme functions should be + * named THEMENAME_HOOK. For example, for Drupal's default theme (Garland) to + * implement the 'table' hook, the phptemplate.engine would find + * garland_table(). * * The theme system is described and defined in theme.inc. * diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine index e0feb580d..23d86854e 100644 --- a/themes/engines/phptemplate/phptemplate.engine +++ b/themes/engines/phptemplate/phptemplate.engine @@ -20,8 +20,7 @@ function phptemplate_init($template) { * we need to. */ function phptemplate_theme($existing, $type, $theme, $path) { - $templates = drupal_find_theme_functions($existing, array('phptemplate', $theme)); + $templates = drupal_find_theme_functions($existing, array($theme)); $templates += drupal_find_theme_templates($existing, '.tpl.php', $path); return $templates; } - diff --git a/themes/garland/template.php b/themes/garland/template.php index cce7c2659..24d1e64e3 100644 --- a/themes/garland/template.php +++ b/themes/garland/template.php @@ -66,7 +66,7 @@ function garland_menu_local_tasks() { /** * Format the "Submitted by username on date/time" for each comment. */ -function phptemplate_comment_submitted($comment) { +function garland_comment_submitted($comment) { return t('!datetime — !username', array( '!username' => theme('username', $comment), -- cgit v1.2.3