Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.384
diff -u -p -r1.384 theme.inc
--- includes/theme.inc	17 Sep 2007 11:11:57 -0000	1.384
+++ includes/theme.inc	23 Sep 2007 15:21:08 -0000
@@ -981,33 +981,67 @@ function theme_placeholder($text) {
  *   FALSE can be useful to postpone the messages to a subsequent page.
  */
 function theme_maintenance_page($content, $show_messages = TRUE) {
+
+  // Set up paths to check for various elements.
+  $paths[] = conf_path() .'/maintenance';
+  $paths[] = 'sites/all/maintenance';
+  $paths[] = 'misc';
+
+  // The order of discovery for each item is based on these paths:
+  // 1. sites/example.com/maintenance
+  // 2. sites/all/maintenance
+  // 3. misc (the defaults for favicon.ico and maintenance.tpl.php.)
+  foreach ($paths as $path) {
+    if (!isset($template) && file_exists($path .'/maintenance.tpl.php')) {
+      $template = $path .'/maintenance.tpl.php';
+      // Variable is dependent on the location of the template file.
+      $path_to_theme = $path;
+    }
+    if (!isset($maintenance_style) && file_exists($path .'/maintenance.css')) {
+      $maintenance_style = $path .'/maintenance.css';
+    }
+    if (!isset($favicon) && file_exists($path . '/favicon.ico')) {
+      $favicon = $path . '/favicon.ico';
+    }
+    if (!isset($theme_style) && file_exists($path .'/style.css')) {
+      $theme_style = $path .'/style.css';
+    }
+    if (!isset($logo) && file_exists($path .'/logo.png')) {
+      $logo = $path .'/logo.png';
+    }
+  }
+
   // Set required headers.
   drupal_set_header('Content-Type: text/html; charset=utf-8');
-  drupal_set_html_head('<link type="text/css" rel="stylesheet" media="all" href="'. base_path() .'misc/maintenance.css" />');
-  drupal_set_html_head('<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . drupal_get_path('module', 'system') .'/defaults.css" />');
-  drupal_set_html_head('<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . drupal_get_path('module', 'system') .'/system.css" />');
-  drupal_set_html_head('<link rel="shortcut icon" href="'. base_path() .'misc/favicon.ico" type="image/x-icon" />');
+  drupal_set_html_head('<link rel="shortcut icon" href="'. base_path() . $favicon .'" type="image/x-icon" />');
+
+  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($maintenance_style, 'module');
+  if (!isset($theme_style)) {
+    $theme_style = 'themes/garland/minnelli/style.css';
+  }
+  drupal_add_css($theme_style, 'theme');
 
   // Prepare variables.
   $variables = array(
     'head_title' => strip_tags(drupal_get_title()),
     'head' => drupal_get_html_head(),
-    'styles' => '',
+    'styles' => drupal_get_css(),
     'scripts' => drupal_get_js(),
     'left' => drupal_get_content('left'),
     'right' => drupal_get_content('right'),
     'base_path' => base_path(),
-    'path_to_theme' => base_path() .'themes/garland/minnelli',
-    'logo' => base_path() .'themes/garland/minnelli/logo.png',
-    'site_title' => t('Drupal'),
+    'path_to_theme' => $path_to_theme,
+    'paths' => $paths,
+    'logo' => base_path() . (isset($logo) ? $logo : 'themes/garland/minnelli/logo.png'),
+    'site_title' => variable_get('site_name', t('Drupal')),
     'title' => drupal_get_title(),
     'messages' => $show_messages ? theme('status_messages') : '',
     'content' => $content,
   );
 
-  $output = theme_render_template('misc/maintenance.tpl.php', $variables);
-
-  return $output;
+  return theme_render_template($template, $variables);
 }
 
 /**
Index: misc/maintenance.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/misc/maintenance.tpl.php,v
retrieving revision 1.5
diff -u -p -r1.5 maintenance.tpl.php
--- misc/maintenance.tpl.php	1 Sep 2007 05:42:48 -0000	1.5
+++ misc/maintenance.tpl.php	23 Sep 2007 15:21:08 -0000
@@ -1,6 +1,45 @@
 <?php
 // $Id: maintenance.tpl.php,v 1.5 2007/09/01 05:42:48 dries Exp $
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+
+/**
+ * @file maintenance.tpl.php
+ * Displays the site in off-line and update modes. Also when the database is
+ * not available.
+ *
+ * To override this template, copy it into either
+ * "sites/example.com/maintenance" or "sites/all/maintenance". If your
+ * running a multi-site installation, placing it into
+ * "sites/all/maintenance" will apply to all installations. Overriding
+ * through a specific installation will apply only to that installation.
+ *
+ * This also applies independently to the url of the logo, the "style.css"
+ * file and the "favicon.ico" file which is output through the $head variable.
+ * The style sheet and logo will default to the files inside
+ * "themes/garland/minnelli" when an override isn't found.
+ *
+ * Variables available:
+ * - $head_title: The title of the page for use inside the head tag.
+ * - $head: Outputs various header elements.
+ * - $styles: Style sheets for the page.
+ * - $scripts: Scripts for the page.
+ * - $site_title: The name of the site. When the database is offline, it will
+ *   default to "Drupal".
+ * - $logo: The url of the logo. This depends on where it's found first.
+ * - $title: The page title.
+ * - $content: Body content.
+ * - $messages: Messages indicating status or errors.
+ * - $left: Left block region. This is hard set so no matter what regions are
+ *   used inside your theme. This region will always exist.
+ * - $right: Right block region. The same above conditions apply.
+ * - $base_path: The base directory of the installation. At the very least, it
+ *   will output "/".
+ * - $path_to_theme: This will point to the directory where this template file
+ *   exists.
+ *
+ * @see theme_maintenance_page()
+ */
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
@@ -8,9 +47,8 @@
     <?php print $head ?>
     <?php print $styles ?>
     <?php print $scripts ?>
-    <link type="text/css" rel="stylesheet" media="all" href="<?php print $path_to_theme ?>/style.css" />
     <!--[if lt IE 7]>
-    <link type="text/css" rel="stylesheet" media="all" href="<?php print $path_to_theme ?>/fix-ie.css" />
+    <link type="text/css" rel="stylesheet" media="all" href="<?php print $base_path ?>themes/garland/minnelli/fix-ie.css" />
     <![endif]-->
   </head>
   <body class="<?php
@@ -26,7 +64,7 @@
 
       <div id="header">
         <div id="logo-floater">
-          <h1><a href="<?php print check_url($base_path) ?>"><img src="<?php print check_url($logo) ?>" alt="Drupal" id="logo" /><span><?php print $site_title ?></span></a></h1>
+          <h1><a href="<?php print $base_path ?>"><img src="<?php print $logo ?>" alt="Drupal" id="logo" /><span><?php print $site_title ?></span></a></h1>
         </div>
       </div> <!-- /header -->
 
