You are here

function advanced_forum_style_lineage in Advanced Forum 6.2

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

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

5 calls to advanced_forum_style_lineage()
advanced_forum_add_template_suggestions in includes/style.inc
Manipulate the template suggestions to add in one for each style as well as the default.
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_theme_registry_alter in ./advanced_forum.module
Implementation of hook_theme_registry_alter().
_advanced_forum_add_files in includes/style.inc
Adds extra files needed for styling. This is currently just CSS files but was made generic to allow adding javascript in the future.

File

includes/style.inc, line 52
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();

    // 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];
}