diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 2dd1b57..96a49f4 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -82,6 +82,62 @@ */ const NODE_ACCESS_IGNORE = NULL; + +/** + * Implements hook_init(). + */ +function node_init() { + + // This script converts information gathered from hook_theme() of all enabled + // modules into a comma-separated list. + $return = array(); + $idx = 0; + print ",Module name,Render element,Where in code,Theme function,File name,Template,Variables"; + foreach (module_implements('theme') as $module) { + if (function_exists($module . '_theme')) { + $themable = call_user_func_array($module . '_theme', array()); + + // Sadly, the array returned by module_invoke_all('theme') doesn't tell + // us which module a given theme function belongs to. + $return[$module] = $themable; + + foreach ($themable as $function => $args) { + $idx++; + $function = "theme_$function"; + $element = isset($args['render element']) ? $args['render element'] : ''; + $file = isset($args['file']) ? $args['file'] : ''; + $template = isset($args['template']) ? $args['template'] : ''; + $variables = isset($args['variables']) ? implode(':', array_keys($args['variables'])) : ''; + + // First, be sure the referenced file is included. + if (!empty($file)) { + include_once drupal_get_path('module', $module) . '/' . $file; + } + // Then, test to confirm the theme function exists. + if (function_exists($function) ) { + $where = 'function'; + } + // If a theme function doesnt exist, but a template name was specified, + // then assume the theming is done in a template. + elseif (!empty($template)) { + $where = 'template'; + } + // Otherwise, no file, no template, no function name provided means + // detecting the location of themable is not possible with hook_theme(). + // Perhaps the theme function is in a separate file, eg + // module.admin.inc, or core includes like theme.maintenance.inc + else { + $where = 'unclear'; + } + + print "$idx,$module,$element,$where,$function,$file,$template,$variables\n"; + + } + } + } + //print_r($return); +} + /** * Implements hook_rebuild(). */