function advanced_forum_find_style_templates in Advanced Forum 7.2
Find style template.
1 call to advanced_forum_find_style_templates()
- advanced_forum_theme in ./
advanced_forum.module - Implements hook_theme().
File
- includes/
style.inc, line 138 - Functions relating to the style system, not including core hooks and preprocess / theme functions.
Code
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 <theme>/<style>/advanced-forum.<style>.<template>.tpl.php
if (file_exists($theme_path . "/{$key}/" . $file->name . $extension)) {
$theme_path = $theme_path . "/{$key}";
}
elseif (file_exists($theme_path . "/" . $theme_base_file . $extension)) {
$theme_file = $theme_base_file;
}
else {
$theme_path = dirname($file->uri);
}
$templates[$hook] = array(
'template' => $theme_file,
'path' => $theme_path,
);
}
}
return $templates;
}