diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-10-04 18:51:04 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-10-04 18:51:04 +0000 |
commit | 560bd06f3b78f8ecd49a2b66acce06cb627d9027 (patch) | |
tree | dc94b06d81e53a2ed0cdf26ca449f7901ae21f9f /includes/theme.inc | |
parent | 5e771fa917f16acbcdce96f69d0f0af634eacbe2 (diff) | |
download | brdo-560bd06f3b78f8ecd49a2b66acce06cb627d9027.tar.gz brdo-560bd06f3b78f8ecd49a2b66acce06cb627d9027.tar.bz2 |
#178973 by merlinofchaos: proper style and script inheritance between themes more then two levels deep in the hierarchy
Diffstat (limited to 'includes/theme.inc')
-rw-r--r-- | includes/theme.inc | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index 9e15f21e6..e7fec486d 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -54,18 +54,8 @@ function init_theme() { $base_theme = array(); $ancestor = $theme; while ($ancestor && isset($themes[$ancestor]->base_theme)) { - if (isset($themes[$themes[$ancestor]->base_theme])) { - $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme]; - // stop if this is final ancestor. - if (!isset($new_base_theme->base_theme)) { - break; - } - $ancestor = $new_base_theme->base_theme; - } - // stop if ancestor didn't exist. - else { - break; - } + $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme]; + $ancestor = $themes[$ancestor]->base_theme; } _init_theme($themes[$theme], array_reverse($base_theme)); } @@ -100,21 +90,62 @@ function _init_theme($theme, $base_theme = array()) { $theme_path = dirname($theme->filename); + // Prepare stylesheets from this theme as well as all ancestor themes. + // We work it this way so that we can have child themes override parent + // theme stylesheets easily. + $final_stylesheets = array(); + + // Grab stylesheets from base theme + foreach ($base_theme as $base) { + if (!empty($base->stylesheets)) { + foreach ($base->stylesheets as $media => $stylesheets) { + foreach ($stylesheets as $name => $stylesheet) { + $final_stylesheets[$media][$name] = $stylesheet; + } + } + } + } + // Add stylesheets used by this theme. if (!empty($theme->stylesheets)) { foreach ($theme->stylesheets as $media => $stylesheets) { - foreach ($stylesheets as $stylesheet) { - drupal_add_css($stylesheet, 'theme', $media); + foreach ($stylesheets as $name => $stylesheet) { + $final_stylesheets[$media][$name] = $stylesheet; } } } + + // And now add the stylesheets properly + foreach ($final_stylesheets as $media => $stylesheets) { + foreach ($stylesheets as $stylesheet) { + drupal_add_css($stylesheet, 'theme', $media); + } + } + + // Do basically the same as the above for scripts + $final_scripts = array(); + + // Grab scripts from base theme + foreach ($base_theme as $base) { + if (!empty($base->scripts)) { + foreach ($base->scripts as $name => $script) { + $final_scripts[$name] = $script; + } + } + } + // Add scripts used by this theme. if (!empty($theme->scripts)) { - foreach ($theme->scripts as $script) { - drupal_add_js($script, 'theme'); + foreach ($theme->scripts as $name => $script) { + $final_scripts[$name] = $script; } } + // Add scripts used by this theme. + foreach ($final_scripts as $script) { + drupal_add_js($script, 'theme'); + } + $theme_engine = NULL; // Initialize the theme. |