diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-09 22:01:29 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-09 22:01:29 +0000 |
commit | d6c286a5936f618bfb14640185ae874e87ead7e8 (patch) | |
tree | e2ada119efefbd8dee7347d1b743c20e27462e08 | |
parent | 8e765744e863811b9835b29dfb11247c5ad77c89 (diff) | |
download | brdo-d6c286a5936f618bfb14640185ae874e87ead7e8.tar.gz brdo-d6c286a5936f618bfb14640185ae874e87ead7e8.tar.bz2 |
#206778 by dvessel: prevent themes from using their sub-theme's templates, when not intended
-rw-r--r-- | includes/theme.inc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index b9b1d2772..cc372afa6 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -757,10 +757,24 @@ function drupal_find_theme_templates($cache, $extension, $path) { // Escape the periods in the extension. $regex = str_replace('.', '\.', $extension) .'$'; + // Collect sub-themes for the current theme. This allows base themes to have + // sub-themes in its folder hierarchy without affecting the base theme. + global $theme; + $sub_themes = array(); + foreach (list_themes() as $theme_info) { + if (!empty($theme_info->base_theme) && $theme_info->base_theme == $theme) { + $sub_themes[] = dirname($theme_info->filename); + } + } + // Because drupal_system_listing works the way it does, we check for real // templates separately from checking for patterns. $files = drupal_system_listing($regex, $path, 'name', 0); foreach ($files as $template => $file) { + // Catch sub-themes and skip. + if (strpos($file->filename, str_replace($sub_themes, '', $file->filename)) !== 0) { + continue; + } // Chop off the remaining extensions if there are any. $template already // has the rightmost extension removed, but there might still be more, // such as with .tpl.php, which still has .tpl in $template at this point. |