summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-08-16 13:59:41 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-08-16 13:59:41 +0000
commit0321a2e9757bc7c349643e8be1ebc51d0094600c (patch)
tree85b4a7d32b2cc1676b26f35decacd3e530f530c4 /includes
parent6ecef0ee38457ec06889553ca97c43b5ffa9f637 (diff)
downloadbrdo-0321a2e9757bc7c349643e8be1ebc51d0094600c.tar.gz
brdo-0321a2e9757bc7c349643e8be1ebc51d0094600c.tar.bz2
#164122 by merlinofchaos: properly convert underscored to dashes, when constructing template file names matching hook names
Diffstat (limited to 'includes')
-rw-r--r--includes/theme.inc16
1 files changed, 12 insertions, 4 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index b4ef05708..10a582e97 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -673,8 +673,11 @@ function drupal_find_theme_templates($cache, $extension, $path) {
// have one extension chopped off, but there might be more than one,
// such as with .tpl.php
$template = substr($template, 0, strpos($template, '.'));
- if (isset($cache[$template])) {
- $templates[$template] = array(
+ // Transform - in filenames to _ to match function naming scheme
+ // for the purposes of searching.
+ $hook = strtr($template, '-', '_');
+ if (isset($cache[$hook])) {
+ $templates[$hook] = array(
'file' => $template,
'path' => dirname($file->filename),
);
@@ -685,11 +688,16 @@ function drupal_find_theme_templates($cache, $extension, $path) {
foreach ($cache as $hook => $info) {
if (!empty($info['pattern'])) {
- $matches = preg_grep('/^'. $info['pattern'] .'/', $patterns);
+ // Transform _ in pattern to - to match file naming scheme
+ // for the purposes of searching.
+ $pattern = strtr($info['pattern'], '_', '-');
+
+ $matches = preg_grep('/^'. $pattern .'/', $patterns);
if ($matches) {
foreach ($matches as $match) {
$file = substr($match, 0, strpos($match, '.'));
- $templates[$file] = array(
+ // Put the underscores back in for the hook name and register this pattern.
+ $templates[strtr($file, '-', '_')] = array(
'file' => $file,
'path' => dirname($files[$match]->filename),
'arguments' => $info['arguments'],