2007-11-30 12:19:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Theming for maintenance pages.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-04-20 08:19:01 +00:00
|
|
|
* Sets up the theming system for maintenance page.
|
2007-11-30 12:19:10 +00:00
|
|
|
*
|
2010-04-20 08:19:01 +00:00
|
|
|
* Used for site installs, updates and when the site is in maintenance mode.
|
|
|
|
* It also applies when the database is unavailable or bootstrap was not
|
|
|
|
* complete. Seven is always used for the initial install and update operations.
|
2010-08-08 19:35:49 +00:00
|
|
|
* In other cases, Bartik is used, but this can be overridden by setting a
|
2009-11-19 15:50:23 +00:00
|
|
|
* "maintenance_theme" key in the $conf variable in settings.php.
|
2007-11-30 12:19:10 +00:00
|
|
|
*/
|
|
|
|
function _drupal_maintenance_theme() {
|
2009-12-10 17:31:42 +00:00
|
|
|
global $theme, $theme_key, $conf;
|
2007-11-30 12:19:10 +00:00
|
|
|
|
|
|
|
// If $theme is already set, assume the others are set too, and do nothing.
|
|
|
|
if (isset($theme)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-31 04:05:57 +00:00
|
|
|
require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'core/includes/path.inc');
|
|
|
|
require_once DRUPAL_ROOT . '/core/includes/theme.inc';
|
|
|
|
require_once DRUPAL_ROOT . '/core/includes/common.inc';
|
|
|
|
require_once DRUPAL_ROOT . '/core/includes/unicode.inc';
|
|
|
|
require_once DRUPAL_ROOT . '/core/includes/file.inc';
|
|
|
|
require_once DRUPAL_ROOT . '/core/includes/module.inc';
|
2007-11-30 12:19:10 +00:00
|
|
|
unicode_check();
|
|
|
|
|
|
|
|
// Install and update pages are treated differently to prevent theming overrides.
|
|
|
|
if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
|
2009-12-10 17:31:42 +00:00
|
|
|
$custom_theme = (isset($conf['maintenance_theme']) ? $conf['maintenance_theme'] : 'seven');
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-04-20 08:19:01 +00:00
|
|
|
// The bootstrap was not complete. So we are operating in a crippled
|
|
|
|
// environment, we need to bootstrap just enough to allow hook invocations
|
|
|
|
// to work. See _drupal_log_error().
|
|
|
|
if (!class_exists('Database', FALSE)) {
|
2011-10-31 04:05:57 +00:00
|
|
|
require_once DRUPAL_ROOT . '/core/includes/database/database.inc';
|
2010-04-20 08:19:01 +00:00
|
|
|
}
|
|
|
|
|
2009-12-10 17:31:42 +00:00
|
|
|
// We use the default theme as the maintenance theme. If a default theme
|
2010-08-08 19:35:49 +00:00
|
|
|
// isn't specified in the database or in settings.php, we use Bartik.
|
2011-12-13 03:29:45 +00:00
|
|
|
// @todo Should use the actual default theme configured, but that depends on
|
|
|
|
// configuration being available while possibly not having a working
|
|
|
|
// database connection (yet). And only if that fails, should fall back to
|
|
|
|
// Stark otherwise. Since there is no low-level access to configuration
|
|
|
|
// currently, we only consult settings.php and fall back to Bartik
|
|
|
|
// otherwise, as it looks generic enough and way more user-friendly.
|
2010-07-08 03:41:27 +00:00
|
|
|
$custom_theme = variable_get('maintenance_theme', variable_get('theme_default', 'bartik'));
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
|
|
|
|
2010-06-01 17:48:15 +00:00
|
|
|
// Ensure that system.module is loaded.
|
|
|
|
if (!function_exists('_system_rebuild_theme_data')) {
|
2011-10-31 04:05:57 +00:00
|
|
|
$module_list['system']['filename'] = 'core/modules/system/system.module';
|
2010-06-01 17:48:15 +00:00
|
|
|
module_list(TRUE, FALSE, FALSE, $module_list);
|
|
|
|
drupal_load('module', 'system');
|
|
|
|
}
|
|
|
|
|
2007-11-30 23:09:14 +00:00
|
|
|
$themes = list_themes();
|
|
|
|
|
2009-10-27 19:29:12 +00:00
|
|
|
// list_themes() triggers a drupal_alter() in maintenance mode, but we can't
|
|
|
|
// let themes alter the .info data until we know a theme's base themes. So
|
|
|
|
// don't set global $theme until after list_themes() builds its cache.
|
|
|
|
$theme = $custom_theme;
|
|
|
|
|
2007-11-30 12:19:10 +00:00
|
|
|
// 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;
|
|
|
|
}
|
2009-07-14 10:22:17 +00:00
|
|
|
_drupal_theme_initialize($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');
|
2007-11-30 12:19:10 +00:00
|
|
|
|
|
|
|
// These are usually added from system_init() -except maintenance.css.
|
|
|
|
// When the database is inactive it's not called so we add it here.
|
2010-09-19 18:10:42 +00:00
|
|
|
$path = drupal_get_path('module', 'system');
|
|
|
|
drupal_add_css($path . '/system.base.css');
|
|
|
|
drupal_add_css($path . '/system.admin.css');
|
|
|
|
drupal_add_css($path . '/system.theme.css');
|
|
|
|
drupal_add_css($path . '/system.maintenance.css');
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This builds the registry when the site needs to bypass any database calls.
|
|
|
|
*/
|
|
|
|
function _theme_load_offline_registry($theme, $base_theme = NULL, $theme_engine = NULL) {
|
2010-08-22 12:46:21 +00:00
|
|
|
return _theme_build_registry($theme, $base_theme, $theme_engine);
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for a list of maintenance tasks to perform.
|
|
|
|
*
|
|
|
|
* @param $variables
|
|
|
|
* An associative array containing:
|
|
|
|
* - items: An associative array of maintenance tasks.
|
|
|
|
* - active: The key for the currently active maintenance task.
|
2007-12-08 14:06:23 +00:00
|
|
|
*
|
2007-12-06 09:58:34 +00:00
|
|
|
* @ingroup themeable
|
2007-11-30 12:19:10 +00:00
|
|
|
*/
|
2009-10-09 01:00:08 +00:00
|
|
|
function theme_task_list($variables) {
|
|
|
|
$items = $variables['items'];
|
|
|
|
$active = $variables['active'];
|
|
|
|
|
2007-11-30 12:19:10 +00:00
|
|
|
$done = isset($items[$active]) || $active == NULL;
|
2009-09-11 13:56:56 +00:00
|
|
|
$output = '<h2 class="element-invisible">Installation tasks</h2>';
|
|
|
|
$output .= '<ol class="task-list">';
|
|
|
|
|
2007-11-30 12:19:10 +00:00
|
|
|
foreach ($items as $k => $item) {
|
|
|
|
if ($active == $k) {
|
|
|
|
$class = 'active';
|
2009-09-11 13:56:56 +00:00
|
|
|
$status = '(' . t('active') . ')';
|
2008-09-19 07:53:59 +00:00
|
|
|
$done = FALSE;
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$class = $done ? 'done' : '';
|
2009-09-11 13:56:56 +00:00
|
|
|
$status = $done ? '(' . t('done') . ')' : '';
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
2009-09-11 13:56:56 +00:00
|
|
|
$output .= '<li';
|
|
|
|
$output .= ($class ? ' class="' . $class . '"' : '') . '>';
|
|
|
|
$output .= $item;
|
|
|
|
$output .= ($status ? '<span class="element-invisible">' . $status . '</span>' : '');
|
|
|
|
$output .= '</li>';
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
|
|
|
$output .= '</ol>';
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for the installation page.
|
2007-11-30 12:19:10 +00:00
|
|
|
*
|
|
|
|
* Note: this function is not themeable.
|
|
|
|
*
|
2009-10-09 01:00:08 +00:00
|
|
|
* @param $variables
|
|
|
|
* An associative array containing:
|
|
|
|
* - content: The page content to show.
|
2007-11-30 12:19:10 +00:00
|
|
|
*/
|
2009-10-09 01:00:08 +00:00
|
|
|
function theme_install_page($variables) {
|
2009-09-30 18:36:02 +00:00
|
|
|
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
|
2010-05-12 09:22:24 +00:00
|
|
|
return theme('maintenance_page', $variables);
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for the update page.
|
2007-11-30 12:19:10 +00:00
|
|
|
*
|
|
|
|
* Note: this function is not themeable.
|
|
|
|
*
|
2009-10-09 01:00:08 +00:00
|
|
|
* @param $variables
|
|
|
|
* An associative array containing:
|
|
|
|
* - content: The page content to show.
|
|
|
|
* - show_messages: Whether to output status and error messages.
|
|
|
|
* FALSE can be useful to postpone the messages to a subsequent page.
|
2007-11-30 12:19:10 +00:00
|
|
|
*/
|
2009-10-09 01:00:08 +00:00
|
|
|
function theme_update_page($variables) {
|
2009-09-30 18:36:02 +00:00
|
|
|
drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');
|
2010-05-12 09:22:24 +00:00
|
|
|
return theme('maintenance_page', $variables);
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
2009-10-15 21:19:31 +00:00
|
|
|
|
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for a report of the results from an operation run via authorize.php.
|
2009-10-15 21:19:31 +00:00
|
|
|
*
|
2010-04-13 15:23:03 +00:00
|
|
|
* @param $variables
|
|
|
|
* An associative array containing:
|
2009-10-15 21:19:31 +00:00
|
|
|
* - messages: An array of result messages.
|
2010-04-13 15:23:03 +00:00
|
|
|
*
|
|
|
|
* @ingroup themeable
|
2009-10-15 21:19:31 +00:00
|
|
|
*/
|
|
|
|
function theme_authorize_report($variables) {
|
|
|
|
$messages = $variables['messages'];
|
|
|
|
$output = '';
|
|
|
|
if (!empty($messages)) {
|
|
|
|
$output .= '<div id="authorize-results">';
|
|
|
|
foreach ($messages as $heading => $logs) {
|
2010-11-24 18:14:25 +00:00
|
|
|
$items = array();
|
2009-10-15 21:19:31 +00:00
|
|
|
foreach ($logs as $number => $log_message) {
|
|
|
|
if ($number === '#abort') {
|
|
|
|
continue;
|
|
|
|
}
|
2010-11-24 18:14:25 +00:00
|
|
|
$items[] = theme('authorize_message', array('message' => $log_message['message'], 'success' => $log_message['success']));
|
2009-10-15 21:19:31 +00:00
|
|
|
}
|
2010-11-24 18:14:25 +00:00
|
|
|
$output .= theme('item_list', array('items' => $items, 'title' => $heading));
|
2009-10-15 21:19:31 +00:00
|
|
|
}
|
|
|
|
$output .= '</div>';
|
|
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-04-13 15:23:03 +00:00
|
|
|
* Returns HTML for a single log message from the authorize.php batch operation.
|
2009-10-15 21:19:31 +00:00
|
|
|
*
|
|
|
|
* @param $variables
|
2010-04-13 15:23:03 +00:00
|
|
|
* An associative array containing:
|
2009-10-15 21:19:31 +00:00
|
|
|
* - message: The log message.
|
|
|
|
* - success: A boolean indicating failure or success.
|
2010-04-13 15:23:03 +00:00
|
|
|
*
|
|
|
|
* @ingroup themeable
|
2009-10-15 21:19:31 +00:00
|
|
|
*/
|
|
|
|
function theme_authorize_message($variables) {
|
|
|
|
$message = $variables['message'];
|
|
|
|
$success = $variables['success'];
|
|
|
|
if ($success) {
|
2010-11-24 18:14:25 +00:00
|
|
|
$item = array('data' => $message, 'class' => array('success'));
|
2009-10-15 21:19:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-11-24 18:14:25 +00:00
|
|
|
$item = array('data' => '<strong>' . $message . '</strong>', 'class' => array('failure'));
|
2009-10-15 21:19:31 +00:00
|
|
|
}
|
2010-11-24 18:14:25 +00:00
|
|
|
return $item;
|
2009-10-15 21:19:31 +00:00
|
|
|
}
|