You are here

function advanced_forum_style_lineage in Advanced Forum 7.2

Same name and namespace in other branches
  1. 6.2 includes/style.inc \advanced_forum_style_lineage()

Starting at a given style, return paths of it and all ancestor styles.

6 calls to advanced_forum_style_lineage()
advanced_forum_find_style_templates in includes/style.inc
Find style template.
advanced_forum_load_style_includes in includes/style.inc
Load any .inc files related to the style so that preprocess functions can run as appropriate.
advanced_forum_style_info in includes/style.inc
Get the info for a style, using an additive notation to include all items from the parent lineage.
advanced_forum_style_template_path in includes/style.inc
Starting at a given style, return path of template file.
advanced_forum_theme_registry_alter in ./advanced_forum.module
Implements hook_theme_registry_alter().

... See full list

File

includes/style.inc, line 57
Functions relating to the style system, not including core hooks and preprocess / theme functions.

Code

function advanced_forum_style_lineage($style = NULL) {
  static $lineages = array();
  if (empty($style)) {

    // If no style is passed in, assume the current style is wanted.
    $style = advanced_forum_get_current_style();
  }
  if (!array_key_exists($style, $lineages)) {
    $lineage = array();

    // Get an array with information from all styles.
    $all_styles = advanced_forum_get_all_styles();

    // Fallback.
    if (empty($all_styles[$style])) {
      $style = "silver_bells";
    }

    // Add the current style to the lineage first.
    $lineage[$style] = $all_styles[$style]['path'];

    // Check if there is an "extra style" listed. This allows you to grab the
    // CSS of one other style and toss it in as a pseudo parent. We do not
    // follow the path up its parent. The primary use is for adding in the
    // "stacked" CSS but could be used for other purposes as well.
    if (!empty($all_styles[$style]['extra style']) && !empty($all_styles[$all_styles[$style]['extra style']]['path'])) {
      $extra_style = $all_styles[$style]['extra style'];
      $lineage[$extra_style] = $all_styles[$extra_style]['path'];
    }

    // Grab the style we are looking at. This variable starts out as the current
    // style in use on the page but will change as we move up the chain.
    $current_style = $style;
    while (!empty($all_styles[$current_style]['base style'])) {

      // There is a parent style, so move up to it.
      $current_style = $all_styles[$current_style]['base style'];

      // Make sure the listed parent style actually exists.
      if (!empty($all_styles[$current_style]['path'])) {

        // Add the style to our list.
        $lineage[$current_style] = $all_styles[$current_style]['path'];
      }
    }
    $lineages[$style] = $lineage;
  }
  return $lineages[$style];
}