Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.633
diff -u -p -r1.633 common.inc
--- includes/common.inc 24 Apr 2007 13:53:10 -0000 1.633
+++ includes/common.inc 24 Apr 2007 18:35:03 -0000
@@ -2307,6 +2307,7 @@ function drupal_common_themes() {
),
'page' => array(
'arguments' => array('content' => NULL, 'show_blocks' => TRUE),
+ 'file' => 'page',
),
'maintenance_page' => array(
'arguments' => array('content' => NULL, 'messages' => TRUE),
@@ -2334,6 +2335,7 @@ function drupal_common_themes() {
),
'node' => array(
'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE),
+ 'file' => 'node',
),
'submenu' => array(
'arguments' => array('links' => NULL),
@@ -2349,9 +2351,11 @@ function drupal_common_themes() {
),
'box' => array(
'arguments' => array('title' => NULL, 'content' => NULL, 'region' => 'main'),
+ 'file' => 'box',
),
'block' => array(
'arguments' => array('block' => NULL),
+ 'file' => 'block',
),
'mark' => array(
'arguments' => array('type' => MARK_NEW),
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.350
diff -u -p -r1.350 theme.inc
--- includes/theme.inc 17 Apr 2007 07:19:38 -0000 1.350
+++ includes/theme.inc 24 Apr 2007 18:35:05 -0000
@@ -166,6 +166,32 @@ function _theme_process_registry(&$cache
if (!isset($info['arguments']) && isset($cache[$hook])) {
$result[$hook]['arguments'] = $cache[$hook]['arguments'];
}
+ // Check for default _preprocess_ functions. Ensure arrayness.
+ if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) {
+ $info['preprocess functions'] = array();
+ $prefix = ($type == 'module' ? 'template' : $name);
+ // It would be too much of a performance hit to let every module have
+ // a generic preprocess function; themes and theme engines can do that.
+ if ($type != 'module' && function_exists($prefix .'_preprocess')) {
+ $info['preprocess functions'][] = $prefix .'_preprocess';
+ }
+ if (function_exists($prefix .'_preprocess_'. $hook)) {
+ $info['preprocess functions'][] = $prefix .'_preprocess_'. $hook;
+ }
+ // theme engines get an extra set.
+ if ($type == 'theme_engine') {
+ if (function_exists($prefix .'_engine_preprocess')) {
+ $info['preprocess functions'][] = $prefix .'_engine_preprocess';
+ }
+ if (function_exists($prefix .'_engine_preprocess_'. $hook)) {
+ $info['preprocess functions'][] = $prefix .'_engine_preprocess_'. $hook;
+ }
+ }
+ }
+ if (isset($cache[$hook]['preprocess functions']) && is_array($cache[$hook]['preprocess functions']) && empty($cache[$hook]['override preprocess functions'])) {
+ $info['preprocess functions'] = array_merge($cache[$hook]['preprocess functions'], $info['preprocess functions']);
+ }
+ $result[$hook]['preprocess functions'] = $info['preprocess functions'];
}
$cache = array_merge($cache, $result);
@@ -264,24 +290,30 @@ function list_theme_engines($refresh = F
* applicable) and the theme. The following functions may be used to modify
* the $variables array:
*
- * ENGINE_engine_variables(&$variables)
+ * ENGINE_engine_preprocess(&$variables)
* This function should only be implemented by theme engines and is exists
* so that the theme engine can set necessary variables. It is commonly
* used to set global variables such as $directory and $is_front_page.
- * ENGINE_engine_variables_HOOK(&$variables)
+ * ENGINE_engine_preprocess_HOOK(&$variables)
* This is the same as the previous function, but is called only per hook.
- * ENGINE_variables_HOOK(&$variables)
- * ENGINE_variables(&$variables)
+ * ENGINE_preprocess_HOOK(&$variables)
+ * ENGINE_preprocess(&$variables)
* This is meant to be used by themes that utilize a theme engine; as it is
* good practice for these themes to use the theme engine's name for
* their functions so that they may share code. In PHPTemplate, these
* functions will appear in template.php
- * THEME_variables_HOOK(&$variables)
- * THEME_variables(&$variables)
+ * THEME_preprocess_HOOK(&$variables)
+ * 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 themes that need small
* changes to what has already been established in the theme engine version
* of the function.
+ * template_preprocess(&$variables)
+ * This function will only be called for theme functions registered by
+ * the named module. In general it is preferred to use the following
+ * function if possible, but it may not always be the case.
+ * template_preprocess_HOOK(&$variables)
+ * This is the same as the previous function, but is called only per hook.
*
* There are two special variables that these hooks can set:
* 'template_file' and 'template_files'. These will be merged together
@@ -337,18 +369,10 @@ function theme() {
// default render function and extension.
$render_function = 'theme_render_template';
$extension = '.tpl.php';
- $variables_list = array();
// Run through the theme engine variables, if necessary
global $theme_engine;
if (isset($theme_engine)) {
- // Call each of our variable override functions. We allow
- // several to create cleaner code.
- $variables_list[] = $theme_engine .'_engine_variables';
- $variables_list[] = $theme_engine .'_engine_variables_'. $hook;
- $variables_list[] = $theme_engine .'_variables';
- $variables_list[] = $theme_engine .'_variables_'. $hook;
-
// If theme or theme engine is implementing this, it may have
// a different extension and a different renderer.
if ($hooks[$hook]['type'] != 'module') {
@@ -362,17 +386,14 @@ function theme() {
}
}
- // Add theme specific variable substitution:
- global $theme;
- $variables_list[] = $theme .'_variables';
- $variables_list[] = $theme .'_variables_'. $hook;
-
- // This construct ensures that we can keep a reference through
- // call_user_func_array.
- $args = array(&$variables, $hook);
- foreach ($variables_list as $variables_function) {
- if (function_exists($variables_function)) {
- call_user_func_array($variables_function, $args);
+ if (isset($info['preprocess functions']) && is_array($info['preprocess functions'])) {
+ // This construct ensures that we can keep a reference through
+ // call_user_func_array.
+ $args = array(&$variables, $hook);
+ foreach ($info['preprocess functions'] as $preprocess_function) {
+ if (function_exists($preprocess_function)) {
+ call_user_func_array($preprocess_function, $args);
+ }
}
}
@@ -655,56 +676,6 @@ function theme_placeholder($text) {
}
/**
- * Return an entire Drupal page displaying the supplied content.
- *
- * @param $content
- * A string to display in the main content area of the page.
- * @return
- * A string containing the entire HTML page.
- */
-function theme_page($content) {
- // Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
- $blocks = theme('blocks', 'all');
-
- $output = "\n";
- $output .= '';
- $output .= '
';
- $output .= theme('closure');
- $output .= '';
-
- return $output;
-}
-
-/**
* Generate a themed maintenance page.
*
* Note: this function is not themable.
@@ -955,66 +926,6 @@ function theme_help() {
}
/**
- * Return a themed node.
- *
- * @param $node
- * An object providing all relevant information for displaying a node:
- * - $node->nid: The ID of the node.
- * - $node->type: The content type (story, blog, forum...).
- * - $node->title: The title of the node.
- * - $node->created: The creation date, as a UNIX timestamp.
- * - $node->teaser: A shortened version of the node body.
- * - $node->body: The entire node contents.
- * - $node->changed: The last modification date, as a UNIX timestamp.
- * - $node->uid: The ID of the author.
- * - $node->username: The username of the author.
- * @param $teaser
- * Whether to display the teaser only, as on the main page.
- * @param $page
- * Whether to display the node as a standalone page. If TRUE, do not display
- * the title because it will be provided by the menu system.
- * @return
- * A string containing the node output.
- */
-function theme_node($node, $teaser = FALSE, $page = FALSE) {
- if (!$node->status) {
- $output = '