function mailsystem_theme_swap_theme in Mail System 7.2
Same name and namespace in other branches
- 7.3 mailsystem.theme.inc \mailsystem_theme_swap_theme()
Helper to swap themes safely for use by mailsystem_theme_theme_registry_alter().
1 call to mailsystem_theme_swap_theme()
- mailsystem_theme_theme_registry_alter in ./mailsystem.theme.inc 
- Implements hook_theme_registry_alter().
File
- ./mailsystem.theme.inc, line 94 
- The theme system, which controls the output of email messages.
Code
function mailsystem_theme_swap_theme($new_theme) {
  // Make sure the theme exists.
  $themes = list_themes();
  if (empty($themes[$new_theme])) {
    return;
  }
  // Both theme/theme_key are set to the new theme.
  global $theme, $theme_key;
  $theme = $theme_key = $new_theme;
  // Create the base_theme_info.
  global $base_theme_info;
  $base_theme = array();
  $ancestor = $theme;
  while ($ancestor && isset($themes[$ancestor]->base_theme)) {
    $ancestor = $themes[$ancestor]->base_theme;
    $base_theme[] = $themes[$ancestor];
  }
  $base_theme_info = array_reverse($base_theme);
  // Some other theme related globals.
  global $theme_engine, $theme_info, $theme_path;
  $theme_engine = $themes[$theme]->engine;
  $theme_info = $themes[$theme];
  $theme_path = dirname($themes[$theme]->filename);
  // We need to reset the drupal_alter and module_implements statics.
  drupal_static_reset('drupal_alter');
  drupal_static_reset('module_implements');
}