$style) { $style_paths[$key] = $style['path']; } } return $style_paths[$requested_style]; } /** * Starting at a given style, return paths of it and all ancestor styles. */ 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]; } /** * Starting at a given style, return path of template file. */ function advanced_forum_style_template_path($template_name, $style = NULL) { static $styles_files = array(); if (empty($styles_files)) { $styles_files = file_scan_directory(drupal_get_path('module', 'advanced_forum') . '/styles', '/(.*)/', array(), 2); } $lineage = advanced_forum_style_lineage($style); $path = ''; foreach ($lineage as $key => $path) { $template_path = ""; } return $path; } /** * Add basename of file. */ function advanced_forum_template_basename(&$file, $key, $extension) { $file->name = basename($file->uri, $extension); } /** * Find style template. */ function advanced_forum_find_style_templates($style = NULL) { // Get theme engine extension. global $theme_engine; $extension = '.tpl.php'; if (isset($theme_engine)) { $extension_function = $theme_engine . '_extension'; if (function_exists($extension_function)) { $extension = $extension_function(); } } // Most significant style template comes first in lineage array. $lineage = array_reverse(advanced_forum_style_lineage($style), TRUE); $templates = array(); // Loop through each style folder looking for templates. foreach ($lineage as $key => $path) { $styles_files = file_scan_directory($path, '/' . str_replace('.', '\.', $extension) . '$/', array('key' => 'filename')); foreach ($styles_files as $file) { $file->name = basename($file->uri, $extension); $theme_file = $file->name; $theme_path = advanced_forum_path_to_theme(); // Remove style name from file name. $theme_base_file = str_replace(".$key.", "-", $file->name); // Transform - in filenames to _ to match function naming scheme // and create proper hook name. $hook = strtr($theme_base_file, '-', '_'); // Check for user theme template override // 1. check for /