diff options
author | David Rothstein <drothstein@gmail.com> | 2012-06-28 00:49:18 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2012-06-28 00:49:18 -0400 |
commit | 46cf23289a03b1c6379c75ec9d3e4d27d76a6ea0 (patch) | |
tree | 8578309d283b0ca9f98f669cb0b514ae562f03b2 /includes/theme.inc | |
parent | e1f366679ca13d2faf6d0d930d4c9fca92db1a30 (diff) | |
download | brdo-46cf23289a03b1c6379c75ec9d3e4d27d76a6ea0.tar.gz brdo-46cf23289a03b1c6379c75ec9d3e4d27d76a6ea0.tar.bz2 |
Issue #761608 by JohnAlbin, effulgentsia: Fixed Missing theme settings values because list_themes() has inconsistent theme object data.
Diffstat (limited to 'includes/theme.inc')
-rw-r--r-- | includes/theme.inc | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index 5552b0109..25f89f92e 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -737,7 +737,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) { * names of the themes and the values are objects having the following * properties: * - 'filename': The name of the .info file. - * - 'name': The name of the theme. + * - 'name': The machine name of the theme. * - 'status': 1 for enabled, 0 for disabled themes. * - 'info': The contents of the .info file. * - 'stylesheets': A two dimensional array, using the first key for the @@ -747,7 +747,10 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) { * - 'scripts': An associative array of JavaScripts, using the filename as key * and the complete filepath as value. * - 'engine': The name of the theme engine. - * - 'base theme': The name of the base theme. + * - 'base_theme': The name of the base theme. + * - 'base_themes': An ordered array of all the base themes. If the first item + * is NULL, a base theme is missing for this theme. + * - 'sub_themes': An unordered array of sub-themes of this theme. */ function list_themes($refresh = FALSE) { $list = &drupal_static(__FUNCTION__, array()); @@ -804,6 +807,47 @@ function list_themes($refresh = FALSE) { } /** + * Find all the base themes for the specified theme. + * + * Themes can inherit templates and function implementations from earlier themes. + * + * @param $themes + * An array of available themes. + * @param $key + * The name of the theme whose base we are looking for. + * @param $used_keys + * A recursion parameter preventing endless loops. + * @return + * Returns an array of all of the theme's ancestors; the first element's value + * will be NULL if an error occurred. + */ +function drupal_find_base_themes($themes, $key, $used_keys = array()) { + $base_key = $themes[$key]->info['base theme']; + // Does the base theme exist? + if (!isset($themes[$base_key])) { + return array($base_key => NULL); + } + + $current_base_theme = array($base_key => $themes[$base_key]->info['name']); + + // Is the base theme itself a child of another theme? + if (isset($themes[$base_key]->info['base theme'])) { + // Do we already know the base themes of this theme? + if (isset($themes[$base_key]->base_themes)) { + return $themes[$base_key]->base_themes + $current_base_theme; + } + // Prevent loops. + if (!empty($used_keys[$base_key])) { + return array($base_key => NULL); + } + $used_keys[$base_key] = TRUE; + return drupal_find_base_themes($themes, $base_key, $used_keys) + $current_base_theme; + } + // If we get here, then this is our parent theme. + return $current_base_theme; +} + +/** * Generates themed output. * * All requests for themed output must go through this function. It examines |