You are here

function themekey_debug_init in ThemeKey 7

Same name and namespace in other branches
  1. 7.3 themekey_debug.module \themekey_debug_init()
  2. 7.2 themekey_debug.module \themekey_debug_init()

Implements hook_init().

Detects if hook_custom_theme() has been skipped because a different module already initialized the theme engine.

File

./themekey_debug.module, line 112
Provides a debug mode for module ThemeKey.

Code

function themekey_debug_init() {
  if (variable_get('themekey_debug_trace_rule_switching', FALSE)) {
    if (!in_array('system', variable_get('themekey_compat_modules_enabled', array())) && path_is_admin($_GET['q']) && variable_get('admin_theme', '0')) {
      themekey_set_debug_message('"%admin_theme" is configured as administration theme at !link. This setting is more powerful than a corresponding ThemeKey rule.', array(
        '%admin_theme' => variable_get('admin_theme', '0'),
        '!link' => l(t('!path', array(
          '!path' => 'admin/appearance',
        )), 'admin/appearance'),
      ), TRUE, TRUE);
    }
    $custom_theme_called =& drupal_static('themekey_custom_theme_called', FALSE);
    if (!$custom_theme_called) {
      themekey_set_debug_message("Consider to activate the module ThemeKey Compatibility to integrate a different theme switching module into ThemeKey's theme switching rule chain", array(), TRUE, TRUE);
      themekey_set_debug_message('Skipped rule checking because another module already initialized the theme engine.', array(), TRUE, TRUE);
    }
    else {
      global $theme;
      $themekey_custom_theme =& drupal_static('themekey_custom_theme', '');
      if (!empty($themekey_custom_theme) && 'default' != $themekey_custom_theme) {
        if ($theme != $themekey_custom_theme) {
          themekey_set_debug_message('Theme switching to custom theme "%custom_theme" did not work because theme has been set to "%theme" by another module.', array(
            '%custom_theme' => $themekey_custom_theme,
            '%theme' => $theme,
          ), TRUE, TRUE);
        }
      }
      else {
        if (variable_get('theme_default', 'bartik') != $theme) {
          themekey_set_debug_message('ThemeKey did not switch the theme because no rule matched. But something else set the theme to "%theme".', array(
            '%theme' => $theme,
          ), TRUE, TRUE);
        }
      }
    }
  }
}