You are here

function _drupal_maintenance_theme in Drupal 6

Same name and namespace in other branches
  1. 8 core/includes/theme.maintenance.inc \_drupal_maintenance_theme()
  2. 7 includes/theme.maintenance.inc \_drupal_maintenance_theme()
  3. 9 core/includes/theme.maintenance.inc \_drupal_maintenance_theme()

Sets up the theming system for site installs, updates and when the site is in off-line mode. It also applies when the database is unavailable.

Minnelli is always used for the initial install and update operations. In other cases, "settings.php" must have a "maintenance_theme" key set for the $conf variable in order to change the maintenance theme.

1 call to _drupal_maintenance_theme()
drupal_maintenance_theme in includes/bootstrap.inc
Enables use of the theme system without requiring database access.

File

includes/theme.maintenance.inc, line 16
Theming for maintenance pages.

Code

function _drupal_maintenance_theme() {
  global $theme, $theme_key;

  // If $theme is already set, assume the others are set too, and do nothing.
  if (isset($theme)) {
    return;
  }
  require_once './includes/path.inc';
  require_once './includes/theme.inc';
  require_once './includes/common.inc';
  require_once './includes/unicode.inc';
  require_once './includes/file.inc';
  require_once './includes/module.inc';
  require_once './includes/database.inc';
  unicode_check();

  // Install and update pages are treated differently to prevent theming overrides.
  if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
    $theme = 'minnelli';
  }
  else {
    if (!db_is_active()) {

      // Because we are operating in a crippled environment, we need to
      // bootstrap just enough to allow hook invocations to work.
      $module_list['system']['filename'] = 'modules/system/system.module';
      $module_list['filter']['filename'] = 'modules/filter/filter.module';
      module_list(TRUE, FALSE, FALSE, $module_list);
      drupal_load('module', 'system');
      drupal_load('module', 'filter');
    }
    $theme = variable_get('maintenance_theme', 'minnelli');
  }
  $themes = list_themes();

  // Store the identifier for retrieving theme settings with.
  $theme_key = $theme;

  // Find all our ancestor themes and put them in an array.
  $base_theme = array();
  $ancestor = $theme;
  while ($ancestor && isset($themes[$ancestor]->base_theme)) {
    $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
    $ancestor = $themes[$ancestor]->base_theme;
  }
  _init_theme($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');

  // These are usually added from system_init() -except maintenance.css.
  // When the database is inactive it's not called so we add it here.
  drupal_add_css(drupal_get_path('module', 'system') . '/defaults.css', 'module');
  drupal_add_css(drupal_get_path('module', 'system') . '/system.css', 'module');
  drupal_add_css(drupal_get_path('module', 'system') . '/system-menus.css', 'module');
  drupal_add_css(drupal_get_path('module', 'system') . '/maintenance.css', 'module');
}