function advanced_forum_theme_registry_alter in Advanced Forum 7.2
Same name and namespace in other branches
- 6.2 advanced_forum.module \advanced_forum_theme_registry_alter()
- 6 advanced_forum.module \advanced_forum_theme_registry_alter()
Implements hook_theme_registry_alter().
File
- ./
advanced_forum.module, line 236 - Enables the look and feel of other popular forum software.
Code
function advanced_forum_theme_registry_alter(&$theme_registry) {
advanced_forum_load_style_includes();
// Don't let core do its basic preprocess for forums, as we want to do
// other stuff now.
if (isset($theme_registry['forums']['preprocess functions'])) {
foreach ($theme_registry['forums']['preprocess functions'] as $key => $value) {
if ($value == 'template_preprocess_forums') {
unset($theme_registry['forums']['preprocess functions'][$key]);
}
}
}
// We duplicate all of core's forum list preprocessing so no need to run
// it twice. Running twice also causes problems with & in forum name.
if (isset($theme_registry['forum_list']['preprocess functions'])) {
foreach ($theme_registry['forum_list']['preprocess functions'] as $key => $value) {
if ($value == 'template_preprocess_forum_list') {
unset($theme_registry['forum_list']['preprocess functions'][$key]);
}
}
}
// Views handles the topic list pages so remove the core template preprocess.
if (isset($theme_registry['forum_topic_list']['preprocess functions'])) {
foreach ($theme_registry['forum_topic_list']['preprocess functions'] as $key => $value) {
if ($value == 'template_preprocess_forum_topic_list') {
unset($theme_registry['forum_topic_list']['preprocess functions'][$key]);
}
}
}
// --- The following section manipulates the theme registry so the .tpl files
// --- for the given templates can be found first in the (sub)theme directory
// --- then in ancestor themes, if any, then in the active style directory
// --- for advanced forum or any ancestor styles.
// Affected templates.
$templates = array(
'node',
'comment',
'comment_wrapper',
'forums',
'forum_list',
'forum_topic_list',
'forum_icon',
'forum_submitted',
'author_pane',
);
// Get the sequence of styles to look in for templates.
$lineage = advanced_forum_style_lineage();
if (!array_key_exists('naked', $lineage)) {
// Add naked in at the end of the line to prevent problems if a style
// doesn't include all needed templates.
$lineage['naked'] = drupal_get_path('module', 'advanced_forum') . '/styles/naked';
}
// 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();
}
}
foreach ($templates as $template) {
// Sanity check in case the template is not being used.
if (!empty($theme_registry[$template])) {
// There are preprocess functions to add, so figure out where we want to add
// them.
if (!empty($preprocess)) {
$position = 0;
foreach ($theme_registry[$template]['preprocess functions'] as $function) {
$position++;
// If we see either of these items, that means we can place our
// preprocess functions after this.
if (substr($function, 0, 25) == 'advanced_forum_preprocess' || substr($function, 0, 34) == 'template_preprocess_advanced_forum') {
break;
}
}
// Add in our new preprocess functions:
if (isset($theme_registry[$template]['preprocess functions'])) {
array_splice($theme_registry[$template]['preprocess functions'], $position, 0, $preprocess);
}
}
}
}
// Temp workaround.
if (isset($theme_registry['views_view__advanced_forum_topic_list']['preprocess functions'])) {
array_splice($theme_registry['views_view__advanced_forum_topic_list']['preprocess functions'], 1, 0, 'template_preprocess_views_view');
}
if (isset($theme_registry['views_view__advanced_forum_group_topic_list']['preprocess functions'])) {
array_splice($theme_registry['views_view__advanced_forum_group_topic_list']['preprocess functions'], 1, 0, 'template_preprocess_views_view');
}
}