function drupal_find_theme_functions in Drupal 6
Same name and namespace in other branches
- 8 core/includes/theme.inc \drupal_find_theme_functions()
- 7 includes/theme.inc \drupal_find_theme_functions()
- 9 core/includes/theme.inc \drupal_find_theme_functions()
Find overridden theme functions. Called by themes and/or theme engines to easily discover theme functions.
Parameters
$cache: The existing cache of theme hooks to test against.
$prefixes: An array of prefixes to test, in reverse order of importance.
Return value
$templates The functions found, suitable for returning from hook_theme;
2 calls to drupal_find_theme_functions()
- chameleon_theme in themes/
chameleon/ chameleon.theme - Implementation of hook_theme. Auto-discover theme functions.
- phptemplate_theme in themes/
engines/ phptemplate/ phptemplate.engine - Implementation of hook_theme().
File
- includes/
theme.inc, line 808 - The theme system, which controls the output of Drupal.
Code
function drupal_find_theme_functions($cache, $prefixes) {
$templates = array();
$functions = get_defined_functions();
foreach ($cache as $hook => $info) {
foreach ($prefixes as $prefix) {
if (!empty($info['pattern'])) {
$matches = preg_grep('/^' . $prefix . '_' . $info['pattern'] . '/', $functions['user']);
if ($matches) {
foreach ($matches as $match) {
$new_hook = str_replace($prefix . '_', '', $match);
$templates[$new_hook] = array(
'function' => $match,
'arguments' => $info['arguments'],
'original hook' => $hook,
'include files' => $info['include files'],
);
}
}
}
if (function_exists($prefix . '_' . $hook)) {
$templates[$hook] = array(
'function' => $prefix . '_' . $hook,
'include files' => $info['include files'],
);
// Ensure that the pattern is maintained from base themes to its sub-themes.
// Each sub-theme will have their functions scanned so the pattern must be
// held for subsequent runs.
if (isset($info['pattern'])) {
$templates[$hook]['pattern'] = $info['pattern'];
}
// Also ensure that the 'file' property is maintained, because it probably
// contains the preprocess.
}
}
}
return $templates;
}