Index: devel.module =================================================================== RCS file: /cvs/drupal/contributions/modules/devel/devel.module,v retrieving revision 1.184 diff -u -p -r1.184 devel.module --- devel.module 13 Aug 2007 02:37:39 -0000 1.184 +++ devel.module 14 Aug 2007 22:03:42 -0000 @@ -759,6 +759,31 @@ function devel_cache_clear() { cache_clear_all('*', $table, TRUE); } + // This is definitely in the wrang spot. + if (variable_get('dev_template_log', 0)) { + init_theme(); // Doesn't fully initialize. + global $theme; // cannot get theme information. Being called too early? + $theme_registry = theme_get_registry(); + foreach ($theme_registry as $hook => $data) { + // Add in devel_preprocess so it's used as the last variable preprocessor. + // This way, it can gather *all* template suggestions, not just the ones set by modules. + if (!isset($data['function']) && !in_array('devel_preprocess', $data['preprocess functions'])) { + $theme_registry[$hook]['preprocess functions'][] = 'devel_preprocess'; + } + elseif (isset($data['function'])) { + // For intercepting theme functions not connected to template files. + // Copy over original registry of the hook so it can be caught later. + $theme_registry[$hook]['devel'] = $theme_registry[$hook]; + // Replace the defaults to be intercepted. + $theme_registry[$hook]['function'] = 'devel_catch_theme_function'; + $theme_registry[$hook]['type'] = 'module'; + $theme_registry[$hook]['theme path'] = drupal_get_path('module', 'devel'); + } + } + //_theme_save_registry('garland', $theme_registry); // Can't get this to work due to init_theme(). + cache_set("theme_registry:garland", $theme_registry); // Hard coded just to test. + } + drupal_clear_css_cache(); menu_rebuild(); @@ -901,13 +926,38 @@ function devel_get_theme_extension() { * * If you use an engine other than phptemplate, just define ENGINE_preprocess() function using same code as this function. */ -function phptemplate_preprocess($vars, $function) { +function devel_preprocess($vars, $function) { $GLOBALS['devel_theme_functions'][] = array( 'function' => $function, 'template_files' => $vars['template_files'] ); } +/** + * Intercepts theme *functions*. It doesn't do anything at this point. + */ +function devel_catch_theme_function() { + $args = func_get_args(); + + // Get the function that is normally called. + $trace = debug_backtrace(); + $call_theme_func = $trace[2]['args'][0]; + + // Get registry for the original function data. + $theme_registry = theme_get_registry(); + $hook_registry_data = $theme_registry[$call_theme_func]['devel']; + + // Include a file if this theme function is held elsewhere. Partial copy of theme(). + if (!empty($hook_registry_data['file'])) { + $function_file = $hook_registry_data['file']; + if (isset($hook_registry_data['path'])) { + $function_file = $hook_registry_data['path'] .'/'. $function_file; + } + include_once($function_file); + } + + return call_user_func_array($hook_registry_data['function'], $args); +} // menu callback function devel_theme_registry() {