Skip to content

Commit

Permalink
#117018: Use Garland theme for installer/maintenance pages, and add t…
Browse files Browse the repository at this point in the history
…ask list in the sidebar.

- Refactor partial-page handling for the maintenance page. It's an exotic quirk for update.php and belongs there.
  • Loading branch information
Steven Wittens committed Mar 2, 2007
1 parent 7cfde27 commit ba0ff1a
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 98 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Drupal 6.0, xxxx-xx-xx (development version)
- Made it easier to theme the forum overview page.
- Drupal works with error reporting set to E_ALL.
- Added scripts/drupal.sh to execute Drupal code from the command line. Useful to use Drupal as a framework to build command-line tools.
- Used the Garland theme for the installation and maintenance pages.

Drupal 5.0, 2007-01-15
----------------------
Expand Down
124 changes: 84 additions & 40 deletions includes/theme.inc
Original file line number Diff line number Diff line change
Expand Up @@ -423,72 +423,116 @@ function theme_page($content) {
return $output;
}

function theme_maintenance_page($content, $messages = TRUE, $partial = FALSE) {
/**
* Generate a themed maintenance page.
*
* Note: this function is not themable.
*
* @param $content
* The page content to show.
* @param $messages
* Whether to output status and error messages.
*/
function theme_maintenance_page($content, $messages = TRUE) {
// Set required headers.
drupal_set_header('Content-Type: text/html; charset=utf-8');
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() .'misc/maintenance.css";</style>');
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/defaults.css";</style>');
drupal_set_html_head('<style type="text/css" media="all">@import "'. base_path() . drupal_get_path('module', 'system') .'/system.css";</style>');
drupal_set_html_head('<link rel="shortcut icon" href="'. base_path() .'misc/favicon.ico" type="image/x-icon" />');

$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
$output .= '<html xmlns="http://www.w3.org/1999/xhtml">';
$output .= '<head>';
$output .= ' <title>'. strip_tags(drupal_get_title()) .'</title>';
$output .= drupal_get_html_head();
$output .= drupal_get_js();
$output .= '</head>';
$output .= '<body>';
$output .= '<h1>' . drupal_get_title() . '</h1>';

if ($messages) {
$output .= theme('status_messages');
}
// Prepare variables.
$variables = array(
'head_title' => strip_tags(drupal_get_title()),
'head' => drupal_get_html_head(),
'styles' => '',
'scripts' => drupal_get_js(),
'sidebar_left' => drupal_get_content('left'),
'sidebar_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'),
'title' => drupal_get_title(),
'messages' => theme('status_messages'),
'content' => $content,
);

$output .= "\n<!-- begin content -->\n";
$output .= $content;
$output .= "\n<!-- end content -->\n";

if (!$partial) {
$output .= '</body></html>';
}
// Render simplified PHPTemplate.
include_once './themes/engines/phptemplate/phptemplate.engine';
$output = _phptemplate_render('misc/maintenance.tpl.php', $variables);

return $output;
}

/**
* Generate a themed installation page.
*
* Note: this function is not themable.
*
* @param $content
* The page content to show.
*/
function theme_install_page($content) {
drupal_set_header('Content-Type: text/html; charset=utf-8');
drupal_add_css('misc/maintenance.css', 'module', 'all', FALSE);
drupal_set_html_head('<link rel="shortcut icon" href="'. base_path() .'misc/favicon.ico" type="image/x-icon" />');
$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
$output .= '<html xmlns="http://www.w3.org/1999/xhtml">';
$output .= '<head>';
$output .= ' <title>'. strip_tags(drupal_get_title()) .'</title>';
$output .= drupal_get_html_head();
$output .= drupal_get_css();
$output .= drupal_get_js();
$output .= '</head>';
$output .= '<body>';
$output .= '<h1>' . drupal_get_title() . '</h1>';

$variables = array(
'head_title' => strip_tags(drupal_get_title()),
'head' => drupal_get_html_head(),
'styles' => drupal_get_css(),
'scripts' => drupal_get_js(),
'sidebar_left' => drupal_get_content('left'),
'sidebar_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' => st('Drupal Installation'),
'title' => drupal_get_title(),
'messages' => '',
'content' => $content,
);

// Special handling of error messages
$messages = drupal_set_message();
if (isset($messages['error'])) {
$title = count($messages['error']) > 1 ? st('The following errors must be resolved before you can continue the installation process') : st('The following error must be resolved before you can continue the installation process');
$output .= '<h3>' .$title. ':</h3>';
$output .= theme('status_messages', 'error');
$variables['messages'] .= '<h3>'. $title .':</h3>';
$variables['messages'] .= theme('status_messages', 'error');
}

// Special handling of status messages
if (isset($messages['status'])) {
$warnings = count($messages['status']) > 1 ? st('The following installation warnings should be carefully reviewed, but in most cases may be safely ignored') : st('The following installation warning should be carefully reviewed, but in most cases may be safely ignored');
$output .= '<h4>' .$title. ':</h4>';
$output .= theme('status_messages', 'status');
$variables['messages'] .= '<h4>'. $title .':</h4>';
$variables['messages'] .= theme('status_messages', 'status');
}

$output .= "\n<!-- begin content -->\n";
$output .= $content;
$output .= "\n<!-- end content -->\n";

$output .= '</body></html>';
// Render simplified PHPTemplate.
include_once './themes/engines/phptemplate/phptemplate.engine';
return _phptemplate_render('misc/maintenance.tpl.php', $variables);
}

/**
* Return a themed list of maintenance tasks to perform.
*
* Note: this function is not themable.
*/
function theme_task_list($items, $active = NULL) {
$done = isset($items[$active]) || $active == NULL;
$output = '<ol class="task-list">';
foreach ($items as $k => $item) {
if ($active == $k) {
$class = 'active';
$done = false;
}
else {
$class = $done ? 'done' : '';
}
$output .= '<li class="'. $class .'">'. $item .'</li>';
}
$output .= '</ol>';
return $output;
}

Expand Down
60 changes: 54 additions & 6 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function install_change_settings($profile = 'default', $install_locale = '') {
// We always need this because we want to run form_get_errors.
include_once './includes/form.inc';
drupal_maintenance_theme();
install_task_list('database');

// The existing database settings are not working, so we need write access
// to settings.php to change them.
Expand Down Expand Up @@ -375,15 +376,22 @@ function install_settings_form_submit($form_id, $form_values) {
}

/**
* Find all .profile files and allow admin to select which to install.
* Find all .profile files.
*/
function install_find_profiles() {
return file_scan_directory('./profiles', '\.profile$', array('.', '..', 'CVS'), 0, TRUE, 'name', 0);
}

/**
* Allow admin to select which profile to install.
*
* @return
* The selected profile.
*/
function install_select_profile() {
include_once './includes/form.inc';

$profiles = file_scan_directory('./profiles', '\.profile$', array('.', '..', 'CVS'), 0, TRUE, 'name', 0);
$profiles = install_find_profiles();
// Don't need to choose profile if only one available.
if (sizeof($profiles) == 1) {
$profile = array_pop($profiles);
Expand All @@ -398,6 +406,7 @@ function install_select_profile() {
}

drupal_maintenance_theme();
install_task_list('profile');

drupal_set_title(st('Select an installation profile'));
print theme('install_page', drupal_get_form('install_select_profile_form', $profiles));
Expand Down Expand Up @@ -432,7 +441,16 @@ function install_select_profile_form($profiles) {
}

/**
* Find all .po files for the current profile and allow admin to select which to use.
* Find all .po files for the current profile.
*/
function install_find_locales($profilename) {
$locales = file_scan_directory('./profiles/'. $profilename, '\.po$', array('.', '..', 'CVS'), 0, FALSE);
array_unshift($locales, (object) array('name' => 'en'));
return $locales;
}

/**
* Allow admin to select which locale to use for the current profile.
*
* @return
* The selected language.
Expand All @@ -441,9 +459,8 @@ function install_select_locale($profilename) {
include_once './includes/file.inc';
include_once './includes/form.inc';

// Collect possible locales, add default
$locales = file_scan_directory('./profiles/' . $profilename, '\.po$', array('.', '..', 'CVS'), 0, FALSE);
array_unshift($locales, (object) array('name' => 'en'));
// Find all available locales.
$locales = install_find_locales($profilename);

// Don't need to choose locale if only one (English) is available.
if (sizeof($locales) == 1) {
Expand All @@ -456,6 +473,7 @@ function install_select_locale($profilename) {
}

drupal_maintenance_theme();
install_task_list('locale');

drupal_set_title(st('Choose your preferred language'));
print theme('install_page', drupal_get_form('install_select_locale_form', $locales));
Expand Down Expand Up @@ -492,6 +510,7 @@ function install_select_locale_form($locales) {
*/
function install_no_profile_error() {
drupal_maintenance_theme();
install_task_list('profile');
drupal_set_title(st('No profiles available'));
print theme('install_page', '<p>'. st('We were unable to find any installer profiles. Installer profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.') .'</p>');
exit;
Expand All @@ -517,6 +536,7 @@ function install_missing_modules_error($profile) {
global $base_url;

drupal_maintenance_theme();
install_task_list('install');
drupal_set_title(st('Modules missing'));
print theme('install_page', '<p>'. st('One or more required modules are missing. Please check the error messages and <a href="!url">try again</a>.', array('!url' => "install.php?profile=$profile")) .'</p>');
exit;
Expand All @@ -537,6 +557,7 @@ function install_complete($profile) {

// Build final page.
drupal_maintenance_theme();
install_task_list();
drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name())));
$output .= '<p>'. st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) .'</p>';

Expand Down Expand Up @@ -570,6 +591,7 @@ function install_check_requirements($profile) {
// If there are issues, report them.
if ($severity == REQUIREMENT_ERROR) {
drupal_maintenance_theme();
install_task_list('requirements');

foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
Expand All @@ -583,4 +605,30 @@ function install_check_requirements($profile) {
}
}

/**
* Add the installation task list to the current page.
*/
function install_task_list($active = NULL) {
// Default list of tasks.
$tasks = array(
'profile' => st('Choose profile'),
'locale' => st('Choose language'),
'requirements' => st('Verify requirements'),
'database' => st('Database setup'),
'install' => st('Installation'),
);

// Remove profiles if only one profile exists.
if (count(install_find_profiles()) == 1) {
unset($tasks['profile']);
}

// Remove locale if no install profiles use them.
if (count(install_find_locales('.')) == 1) {
unset($tasks['locale']);
}

drupal_set_content('left', theme_task_list($tasks, $active));
}

install_main();
40 changes: 0 additions & 40 deletions misc/maintenance.css
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
/* $Id$ */

body {
background: url(druplicon.png) 4.2em 4em no-repeat #fff;
color: #000;
border: 1px solid #bbb;
margin: 3em;
padding: 1em 1em 1em 128px;
line-height: 1.2;
}
h1 {
margin: 1.6em 0 1.1em 0;
}
h1, h2, h3, h4, h5, h6 {
font-family: sans-serif;
}
:link {
color: #0073ba;
font-weight: bold;
}
:visited {
color: #004975;
font-weight: bold;
}

div.messages {
border: 1px solid #ddd;
padding: 0.4em;
margin-top: 1em;
}

div.messages li {
margin-top: 0.5em;
margin-bottom: 0.5em;
}

div.error {
background: #fdd;
border: 1px solid #daa;
color: #400;
}

/* Update styles */
#update-results {
margin-top: 3em;
Expand Down
Loading

0 comments on commit ba0ff1a

Please sign in to comment.