2007-11-30 12:19:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Theming for maintenance pages.
|
|
|
|
*/
|
|
|
|
|
2013-05-07 23:29:47 +00:00
|
|
|
use Drupal\Component\Utility\Unicode;
|
|
|
|
|
2007-11-30 12:19:10 +00:00
|
|
|
/**
|
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
|
2013-01-10 23:50:55 +00:00
|
|
|
* complete. Seven is always used for the initial install and update
|
|
|
|
* operations. In other cases, Bartik is used, but this can be overridden by
|
|
|
|
* setting a "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;
|
|
|
|
}
|
|
|
|
|
2013-01-07 11:45:26 +00:00
|
|
|
require_once DRUPAL_ROOT . '/' . settings()->get('path_inc', 'core/includes/path.inc');
|
2013-05-09 09:25:10 +00:00
|
|
|
require_once __DIR__ . '/theme.inc';
|
|
|
|
require_once __DIR__ . '/common.inc';
|
|
|
|
require_once __DIR__ . '/unicode.inc';
|
|
|
|
require_once __DIR__ . '/file.inc';
|
|
|
|
require_once __DIR__ . '/module.inc';
|
2013-05-07 23:29:47 +00:00
|
|
|
Unicode::check();
|
2007-11-30 12:19:10 +00:00
|
|
|
|
|
|
|
// Install and update pages are treated differently to prevent theming overrides.
|
|
|
|
if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
|
2013-10-04 18:59:43 +00:00
|
|
|
$custom_theme = settings()->get('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().
|
2012-04-24 02:15:56 +00:00
|
|
|
if (!class_exists('Drupal\Core\Database\Database', FALSE)) {
|
2013-05-09 09:25:10 +00:00
|
|
|
require_once __DIR__ . '/database.inc';
|
2010-04-20 08:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-10-04 18:59:43 +00:00
|
|
|
// Use the maintenance theme if specified, otherwise attempt to use the
|
|
|
|
// default site theme.
|
|
|
|
try {
|
|
|
|
$custom_theme = settings()->get('maintenance_theme', '');
|
|
|
|
if (!$custom_theme) {
|
|
|
|
$config = \Drupal::config('system.theme');
|
2013-04-07 20:06:33 +00:00
|
|
|
$custom_theme = $config->get('default');
|
|
|
|
}
|
|
|
|
}
|
2013-10-04 18:59:43 +00:00
|
|
|
catch (\Exception $e) {
|
|
|
|
// Whatever went wrong (often a database connection problem), we are
|
|
|
|
// about to fall back to a sensible theme so there is no need for special
|
|
|
|
// handling.
|
|
|
|
}
|
|
|
|
if (!$custom_theme) {
|
|
|
|
// We have been unable to identify the configured theme, so fall back to
|
|
|
|
// a safe default. Bartik is reasonably user friendly and fairly generic.
|
2013-04-07 20:06:33 +00:00
|
|
|
$custom_theme = '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')) {
|
2013-01-21 19:21:34 +00:00
|
|
|
$module_list['system'] = 'core/modules/system/system.module';
|
2013-09-16 03:58:06 +00:00
|
|
|
$module_handler = \Drupal::moduleHandler();
|
2013-01-21 19:21:34 +00:00
|
|
|
$module_handler->setModuleList($module_list);
|
|
|
|
$module_handler->load('system');
|
2010-06-01 17:48:15 +00:00
|
|
|
}
|
|
|
|
|
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
|
2013-03-06 22:51:39 +00:00
|
|
|
// let themes alter the .info.yml data until we know a theme's base themes. So
|
2009-10-27 19:29:12 +00:00
|
|
|
// 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');
|
2013-11-16 21:30:33 +00:00
|
|
|
_drupal_theme_initialize($themes[$theme], array_reverse($base_theme));
|
|
|
|
// Prime the theme registry.
|
|
|
|
// @todo Remove global theme variables.
|
|
|
|
Drupal::service('theme.registry');
|
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.
|
2013-06-27 19:03:01 +00:00
|
|
|
* - variant: A variant name to be used for a CSS class.
|
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'];
|
2013-06-27 19:03:01 +00:00
|
|
|
if (isset($variables['variant'])) {
|
|
|
|
$class = $variables['variant'] . '-task-list';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$class = 'task-list';
|
|
|
|
}
|
2009-10-09 01:00:08 +00:00
|
|
|
|
2007-11-30 12:19:10 +00:00
|
|
|
$done = isset($items[$active]) || $active == NULL;
|
2013-06-17 19:58:27 +00:00
|
|
|
$output = '<h2 class="visually-hidden">Installation tasks</h2>';
|
2013-06-27 19:03:01 +00:00
|
|
|
$output .= '<ol class="' . $class . '">';
|
2009-09-11 13:56:56 +00:00
|
|
|
|
2007-11-30 12:19:10 +00:00
|
|
|
foreach ($items as $k => $item) {
|
|
|
|
if ($active == $k) {
|
|
|
|
$class = 'active';
|
2013-06-17 13:35:07 +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' : '';
|
2013-06-17 13:35:07 +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;
|
2013-06-22 19:41:26 +00:00
|
|
|
$output .= ($status ? '<span class="visually-hidden"> ' . $status . '</span>' : '');
|
2009-09-11 13:56:56 +00:00
|
|
|
$output .= '</li>';
|
2007-11-30 12:19:10 +00:00
|
|
|
}
|
|
|
|
$output .= '</ol>';
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2009-10-15 21:19:31 +00:00
|
|
|
/**
|
2013-01-10 23:50:55 +00:00
|
|
|
* Returns HTML for a results report of an operation run by 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
|
|
|
}
|