install.php 22.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
// $Id$

require_once './includes/install.inc';

/**
 * The Drupal installation happens in a series of steps. We begin by verifying
 * that the current environment meets our minimum requirements. We then go
 * on to verify that settings.php is properly configured. From there we
 * connect to the configured database and verify that it meets our minimum
 * requirements. Finally we can allow the user to select an installation
 * profile and complete the installation process.
 *
 * @param $phase
 *   The installation phase we should proceed to.
 */
function install_main() {
drumm's avatar
drumm committed
18
  global $profile, $install_locale;
19 20 21
  require_once './includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
  require_once './modules/system/system.install';
22
  require_once './includes/file.inc';
23

24 25 26
  // Ensure correct page headers are sent (e.g. caching)
  drupal_page_header();

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
  // Check existing settings.php.
  $verify = install_verify_settings();

  // Drupal may already be installed.
  if ($verify) {
    // Establish a connection to the database.
    require_once './includes/database.inc';
    db_set_active();
    // Check if Drupal is installed.
    if (install_verify_drupal()) {
      install_already_done_error();
    }
  }

  // Load module basics (needed for hook invokes).
  include_once './includes/module.inc';
  $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');

  // Decide which profile to use.
  if (!empty($_GET['profile'])) {
    $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
  }
  elseif ($profile = install_select_profile()) {
54
    install_goto("install.php?profile=$profile");
55 56
  }
  else {
57
    install_no_profile_error();
58
  }
drumm's avatar
drumm committed
59 60 61 62 63 64 65 66 67

  // Locale selection
  if (!empty($_GET['locale'])) {
    $install_locale = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['locale']);
  }
  elseif (($install_locale = install_select_locale($profile)) !== FALSE) {
    install_goto("install.php?profile=$profile&locale=$install_locale");
  }

68
  // Load the profile.
69
  require_once "./profiles/$profile/$profile.profile";
70

71 72 73
  // Check the installation requirements for Drupal and this profile.
  install_check_requirements($profile);

74
  // Change the settings.php information if verification failed earlier.
75
  // Note: will trigger a redirect if database credentials change.
76
  if (!$verify) {
77
    install_change_settings($profile, $install_locale);
78 79
  }

80
  // Verify existence of all required modules.
drumm's avatar
drumm committed
81
  $modules = drupal_verify_profile($profile, $install_locale);
82 83 84 85 86
  if (!$modules) {
    install_missing_modules_error($profile);
  }

  // Perform actual installation defined in the profile.
Steven Wittens's avatar
Steven Wittens committed
87
  drupal_install_profile($profile, $modules);
88 89 90 91 92 93

  // Warn about settings.php permissions risk
  $settings_file = './'. conf_path() .'/settings.php';
  if (!drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE)) {
    drupal_set_message(st('All necessary changes to %file have been made, so you should now remove write permissions to this file. Failure to remove write permissions to this file is a security risk.', array('%file' => $settings_file)), 'error');
  }
94 95 96
  else {
    drupal_set_message(st('All necessary changes to %file have been made. It has been set to read-only for security.', array('%file' => $settings_file)));
  }
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116

  // Show end page.
  install_complete($profile);
}

/**
 * Verify if Drupal is installed.
 */
function install_verify_drupal() {
  $result = @db_query("SELECT name FROM {system} WHERE name = 'system'");
  return $result && db_result($result) == 'system';
}

/**
 * Verify existing settings.php
 */
function install_verify_settings() {
  global $db_prefix, $db_type, $db_url;

  // Verify existing settings (if any).
117
  if ($_SERVER['REQUEST_METHOD'] == 'GET' && !empty($db_url)) {
118 119 120
    // We need this because we want to run form_get_errors.
    include_once './includes/form.inc';

121
    $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
122 123 124
    $db_user = urldecode($url['user']);
    $db_pass = urldecode($url['pass']);
    $db_host = urldecode($url['host']);
125
    $db_port = isset($url['port']) ? urldecode($url['port']) : '';
126 127 128
    $db_path = ltrim(urldecode($url['path']), '/');
    $settings_file = './'. conf_path() .'/settings.php';

129
    _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file);
130 131 132 133 134 135 136 137 138 139
    if (!form_get_errors()) {
      return TRUE;
    }
  }
  return FALSE;
}

/**
 * Configure and rewrite settings.php.
 */
140 141
function install_change_settings($profile = 'default', $install_locale = '') {
  global $db_url, $db_type, $db_prefix;
142

143
  $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
144 145 146
  $db_user = urldecode($url['user']);
  $db_pass = urldecode($url['pass']);
  $db_host = urldecode($url['host']);
147
  $db_port = isset($url['port']) ? urldecode($url['port']) : '';
148
  $db_path = ltrim(urldecode($url['path']), '/');
149 150
  $conf_path = './'. conf_path();
  $settings_file = $conf_path .'/settings.php';
151 152 153

  // We always need this because we want to run form_get_errors.
  include_once './includes/form.inc';
154
  drupal_maintenance_theme();
155
  install_task_list('database');
156 157 158

  // The existing database settings are not working, so we need write access
  // to settings.php to change them.
159
  $writable = FALSE;
160 161 162 163 164
  $file = $conf_path;
  // Verify the directory exists.
  if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
    // Check to see if a settings.php already exists
    if (drupal_verify_install_file($settings_file, FILE_EXIST)) {
165 166
      // If it does, make sure it is writable
      $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
167 168 169 170
      $file = $settings_file;
    }
    else {
      // If not, makes sure the directory is.
171
      $writable = drupal_verify_install_file($conf_path, FILE_READABLE|FILE_WRITABLE, 'dir');
172 173 174
    }
  }

175
  if (!$writable) {
176
    drupal_set_message(st('The @drupal installer requires write permissions to %file during the installation process.', array('@drupal' => drupal_install_profile_name(), '%file' => $file)), 'error');
177

drumm's avatar
drumm committed
178
    drupal_set_title(st('Drupal database setup'));
179 180 181 182
    print theme('install_page', '');
    exit;
  }

183
  $output = drupal_get_form('install_settings_form', $profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path);
drumm's avatar
drumm committed
184
  drupal_set_title(st('Database configuration'));
185 186 187
  print theme('install_page', $output);
  exit;
}
188

189

190 191 192
/**
 * Form API array definition for install_settings.
 */
193
function install_settings_form($profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path) {
194 195 196
  if (empty($db_host)) {
    $db_host = 'localhost';
  }
197 198 199
  $db_types = drupal_detect_database_types();
  if (count($db_types) == 0) {
    $form['no_db_types'] = array(
drumm's avatar
drumm committed
200
      '#value' => st('Your web server does not appear to support any common database types. Check with your hosting provider to see if they offer any databases that <a href="@drupal-databases">Drupal supports</a>.', array('@drupal-databases' => 'http://drupal.org/node/270#database')),
201 202 203 204 205
    );
  }
  else {
    $form['basic_options'] = array(
      '#type' => 'fieldset',
drumm's avatar
drumm committed
206
      '#title' => st('Basic options'),
207
      '#description' => '<p>'. st('To set up your @drupal database, enter the following information.', array('@drupal' => drupal_install_profile_name())) .'</p>',
208 209 210 211
    );

    if (count($db_types) > 1) {
      // Database type
212
      $db_types = drupal_detect_database_types();
213 214
      $form['basic_options']['db_type'] = array(
        '#type' => 'radios',
drumm's avatar
drumm committed
215
        '#title' => st('Database type'),
216
        '#required' => TRUE,
217 218
        '#options' => $db_types,
        '#default_value' => ($db_type ? $db_type : current($db_types)),
219
        '#description' => st('The type of database your @drupal data will be stored in.', array('@drupal' => drupal_install_profile_name())),
220
      );
221
      $db_path_description = st('The name of the database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('@drupal' => drupal_install_profile_name()));
222 223 224
    }
    else {
      if (count($db_types) == 1) {
225
        $db_types = array_values($db_types);
226 227 228 229
        $form['basic_options']['db_type'] = array(
          '#type' => 'hidden',
          '#value' => $db_types[0],
        );
230
        $db_path_description = st('The name of the %db_type database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('%db_type' => $db_types[0], '@drupal' => drupal_install_profile_name()));
231 232 233 234 235 236
      }
    }

    // Database name
    $form['basic_options']['db_path'] = array(
      '#type' => 'textfield',
drumm's avatar
drumm committed
237
      '#title' => st('Database name'),
238 239 240 241 242 243 244 245 246 247
      '#default_value' => $db_path,
      '#size' => 45,
      '#maxlength' => 45,
      '#required' => TRUE,
      '#description' => $db_path_description
    );

    // Database username
    $form['basic_options']['db_user'] = array(
      '#type' => 'textfield',
drumm's avatar
drumm committed
248
      '#title' => st('Database username'),
249 250 251 252 253 254 255 256 257
      '#default_value' => $db_user,
      '#size' => 45,
      '#maxlength' => 45,
      '#required' => TRUE,
    );

    // Database username
    $form['basic_options']['db_pass'] = array(
      '#type' => 'password',
drumm's avatar
drumm committed
258
      '#title' => st('Database password'),
259 260 261 262 263 264 265
      '#default_value' => $db_pass,
      '#size' => 45,
      '#maxlength' => 45,
    );

    $form['advanced_options'] = array(
      '#type' => 'fieldset',
drumm's avatar
drumm committed
266
      '#title' => st('Advanced options'),
267 268
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
269
      '#description' => st("These options are only necessary for some sites. If you're not sure what you should enter here, leave the default settings or check with your hosting provider.")
270 271 272 273 274
    );

    // Database host
    $form['advanced_options']['db_host'] = array(
      '#type' => 'textfield',
drumm's avatar
drumm committed
275
      '#title' => st('Database host'),
276 277 278 279
      '#default_value' => $db_host,
      '#size' => 45,
      '#maxlength' => 45,
      '#required' => TRUE,
drumm's avatar
drumm committed
280
      '#description' => st('If your database is located on a different server, change this.'),
281 282
    );

283 284 285 286 287 288 289 290 291 292
    // Database port
    $form['advanced_options']['db_port'] = array(
      '#type' => 'textfield',
      '#title' => st('Database port'),
      '#default_value' => $db_port,
      '#size' => 45,
      '#maxlength' => 45,
      '#description' => st('If your database server is listening to a non-standard port, enter its number.'),
    );

293
    // Table prefix
294 295
    $form['advanced_options']['db_prefix'] = array(
      '#type' => 'textfield',
296
      '#title' => st('Table prefix'),
297 298 299
      '#default_value' => $db_prefix,
      '#size' => 45,
      '#maxlength' => 45,
300
      '#description' => st('If more than one @drupal website will be sharing this database, enter a table prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_name())),
301 302 303 304
    );

    $form['save'] = array(
      '#type' => 'submit',
drumm's avatar
drumm committed
305
      '#value' => st('Save configuration'),
306 307 308 309 310
    );

    $form['errors'] = array();
    $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file);
    $form['_db_url'] = array('#type' => 'value');
drumm's avatar
drumm committed
311
    $form['#action'] = "install.php?profile=$profile" . ($install_locale ? "&locale=$install_locale" : '');
312 313
    $form['#redirect'] = NULL;
  }
314
  return $form;
315 316 317 318
}
/**
 * Form API validate for install_settings form.
 */
319
function install_settings_form_validate($form_id, $form_values, $form) {
320
  global $db_url;
321
  _install_settings_form_validate($form_values['db_prefix'], $form_values['db_type'], $form_values['db_user'], $form_values['db_pass'], $form_values['db_host'], $form_values['db_port'], $form_values['db_path'], $form_values['settings_file'], $form);
322 323 324 325 326
}

/**
 * Helper function for install_settings_validate.
 */
327
function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, $form = NULL) {
328 329
  global $db_url;

330
  // Verify the table prefix
331 332
  if (!empty($db_prefix) && is_string($db_prefix) && !preg_match('/^[A-Za-z0-9_.]+$/', $db_prefix)) {
    form_set_error('db_prefix', st('The database table prefix you have entered, %db_prefix, is invalid. The table prefix can only contain alphanumeric characters, underscores or dots.', array('%db_prefix' => $db_prefix)), 'error');
333 334
  }

335 336 337 338
  if (!empty($db_port) && !is_numeric($db_port)) {
    form_set_error('db_port', st('Database port must be a number.'));
  }

339 340
  // Check database type
  if (!isset($form)) {
341 342
    $_db_url = is_array($db_url) ? $db_url['default'] : $db_url;
    $db_type = substr($_db_url, 0, strpos($_db_url, '://'));
343 344 345
  }
  $databases = drupal_detect_database_types();
  if (!in_array($db_type, $databases)) {
346
    form_set_error('db_type', st("In your %settings_file file you have configured @drupal to use a %db_type server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_name(), '%db_type' => $db_type)));
347 348 349
  }
  else {
    // Verify
350
    $db_url = $db_type .'://'. urlencode($db_user) . ($db_pass ? ':'. urlencode($db_pass) : '') .'@'. ($db_host ? urlencode($db_host) : 'localhost') . ($db_port ? ":$db_port" : '') .'/'. urlencode($db_path);
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
    if (isset($form)) {
      form_set_value($form['_db_url'], $db_url);
    }
    $success = array();

    $function = 'drupal_test_'. $db_type;
    if (!$function($db_url, $success)) {
      if (isset($success['CONNECT'])) {
        form_set_error('db_type', st('In order for Drupal to work and to proceed with the installation process you must resolve all permission issues reported above. We were able to verify that we have permission for the following commands: %commands. For more help with configuring your database server, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what any of this means you should probably contact your hosting provider.', array('%commands' => implode($success, ', '))));
      }
      else {
        form_set_error('db_type', '');
      }
    }
  }
}

/**
 * Form API submit for install_settings form.
 */
371
function install_settings_form_submit($form_id, $form_values) {
drumm's avatar
drumm committed
372
  global $profile, $install_locale;
373 374 375 376 377 378 379 380 381 382 383 384 385

  // Update global settings array and save
  $settings['db_url'] = array(
    'value'    => $form_values['_db_url'],
    'required' => TRUE,
  );
  $settings['db_prefix'] = array(
    'value'    => $form_values['db_prefix'],
    'required' => TRUE,
  );
  drupal_rewrite_settings($settings);

  // Continue to install profile step
drumm's avatar
drumm committed
386
  install_goto("install.php?profile=$profile" . ($install_locale ? "&locale=$install_locale" : ''));
387 388 389
}

/**
390 391 392
 * Find all .profile files.
 */
function install_find_profiles() {
Dries's avatar
Dries committed
393
  return file_scan_directory('./profiles', '\.profile$', array('.', '..', 'CVS'), 0, TRUE, 'name', 0);
394 395 396 397
}

/**
 * Allow admin to select which profile to install.
398 399 400 401 402 403 404
 *
 * @return
 *   The selected profile.
 */
function install_select_profile() {
  include_once './includes/form.inc';

405
  $profiles = install_find_profiles();
406 407 408 409 410 411 412 413
  // Don't need to choose profile if only one available.
  if (sizeof($profiles) == 1) {
    $profile = array_pop($profiles);
    require_once $profile->filename;
    return $profile->name;
  }
  elseif (sizeof($profiles) > 1) {
    foreach ($profiles as $profile) {
414
      if ($_POST['profile'] == $profile->name) {
415 416 417
        return $profile->name;
      }
    }
418 419

    drupal_maintenance_theme();
420
    install_task_list('profile');
421

drumm's avatar
drumm committed
422
    drupal_set_title(st('Select an installation profile'));
423
    print theme('install_page', drupal_get_form('install_select_profile_form', $profiles));
424 425 426 427
    exit;
  }
}

428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
function install_select_profile_form($profiles) {
  foreach ($profiles as $profile) {
    include_once($profile->filename);
    // Load profile details.
    $function = $profile->name .'_profile_details';
    if (function_exists($function)) {
      $details = $function();
    }
    // If set, used defined name. Otherwise use file name.
    $name = isset($details['name']) ? $details['name'] : $profile->name;
    $form['profile'][$name] = array(
      '#type' => 'radio',
      '#value' => 'default',
      '#return_value' => $profile->name,
      '#title' => $name,
      '#description' => isset($details['description']) ? $details['description'] : '',
      '#parents' => array('profile'),
    );
  }
  $form['submit'] =  array(
    '#type' => 'submit',
drumm's avatar
drumm committed
449 450 451 452 453 454
    '#value' => st('Save configuration'),
  );
  return $form;
}

/**
455 456 457 458 459 460 461 462 463 464
 * 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.
drumm's avatar
drumm committed
465 466 467 468 469 470 471 472
 *
 * @return
 *   The selected language.
 */
function install_select_locale($profilename) {
  include_once './includes/file.inc';
  include_once './includes/form.inc';

473 474
  // Find all available locales.
  $locales = install_find_locales($profilename);
drumm's avatar
drumm committed
475 476 477 478

  // Don't need to choose locale if only one (English) is available.
  if (sizeof($locales) == 1) {
    return FALSE;
479 480
  }
  else {
drumm's avatar
drumm committed
481 482 483 484 485 486 487
    foreach ($locales as $locale) {
      if ($_POST['locale'] == $locale->name) {
        return $locale->name;
      }
    }

    drupal_maintenance_theme();
488
    install_task_list('locale');
drumm's avatar
drumm committed
489 490 491 492 493 494 495 496 497

    drupal_set_title(st('Choose your preferred language'));
    print theme('install_page', drupal_get_form('install_select_locale_form', $locales));
    exit;
  }
}

function install_select_locale_form($locales) {
  include_once './includes/locale.inc';
498
  $languages = _locale_get_predefined_list();
drumm's avatar
drumm committed
499 500 501 502
  foreach ($locales as $locale) {
    // Try to use verbose locale name
    $name = $locale->name;
    if (isset($languages[$name])) {
503
      $name = $languages[$name][0] . (isset($languages[$name][1]) ? ' '. st('(@language)', array('@language' => $languages[$name][1])) : '');
drumm's avatar
drumm committed
504 505 506 507 508
    }
    $form['locale'][$locale->name] = array(
      '#type' => 'radio',
      '#return_value' => $locale->name,
      '#default_value' => ($locale->name == 'en' ? TRUE : FALSE),
509
      '#title' => $name . ($locale->name == 'en' ? ' '. st('(built-in)') : ''),
drumm's avatar
drumm committed
510 511 512 513 514 515
      '#parents' => array('locale')
    );
  }
  $form['submit'] =  array(
    '#type' => 'submit',
    '#value' => st('Save configuration'),
516 517 518 519
  );
  return $form;
}

520 521 522 523 524
/**
 * Show an error page when there are no profiles available.
 */
function install_no_profile_error() {
  drupal_maintenance_theme();
525
  install_task_list('profile');
drumm's avatar
drumm committed
526
  drupal_set_title(st('No profiles available'));
527
  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>');
528 529 530 531 532 533 534 535
  exit;
}


/**
 * Show an error page when Drupal has already been installed.
 */
function install_already_done_error() {
536 537
  global $base_url;

538
  drupal_maintenance_theme();
drumm's avatar
drumm committed
539 540
  drupal_set_title(st('Drupal already installed'));
  print theme('install_page', st('<ul><li>To start over, you must empty your existing database.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To upgrade an existing installation, proceed to the <a href="@base-url/update.php">update script</a>.</li></ul>', array('@base-url' => $base_url)));
541 542 543
  exit;
}

544 545 546 547 548 549 550
/**
 * Show an error page when Drupal is missing required modules.
 */
function install_missing_modules_error($profile) {
  global $base_url;

  drupal_maintenance_theme();
551
  install_task_list('install');
552 553 554 555 556
  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;
}

557 558 559 560 561
/**
 * Page displayed when the installation is complete. Called from install.php.
 */
function install_complete($profile) {
  global $base_url;
562
  $output = '';
563 564
  // Store install profile for later use.
  variable_set('install_profile', $profile);
565 566 567 568 569 570 571 572

  // Bootstrap newly installed Drupal, while preserving existing messages.
  $messages = $_SESSION['messages'];
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  $_SESSION['messages'] = $messages;

  // Build final page.
  drupal_maintenance_theme();
573
  install_task_list();
574
  drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name())));
575
  $output .= '<p>'. st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) .'</p>';
576 577 578 579 580

  // Show profile finalization info.
  $function = $profile .'_profile_final';
  if (function_exists($function)) {
    // More steps required
581 582 583
    $profile_message = $function();
  }

584
  menu_rebuild();
585 586 587
  // If the profile returned a welcome message, use that instead of default.
  if (isset($profile_message)) {
    $output .= $profile_message;
588 589 590
  }
  else {
    // No more steps
591
    $output .= '<p>'. (drupal_set_message() ? st('Please review the messages above before continuing on to <a href="@url">your new site</a>.', array('@url' => url(''))) : st('You may now visit <a href="@url">your new site</a>.', array('@url' => url('')))) .'</p>';
592 593 594 595 596
  }
  // Output page.
  print theme('maintenance_page', $output);
}

597 598 599 600 601 602 603 604 605 606
/**
 * Page to check installation requirements and report any errors.
 */
function install_check_requirements($profile) {
  $requirements = drupal_check_profile($profile);
  $severity = drupal_requirements_severity($requirements);

  // If there are issues, report them.
  if ($severity == REQUIREMENT_ERROR) {
    drupal_maintenance_theme();
607
    install_task_list('requirements');
608 609 610 611 612 613 614

    foreach ($requirements as $requirement) {
      if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
        drupal_set_message($requirement['description'] .' ('. st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) .')', 'error');
      }
    }

615
    drupal_set_title(st('Incompatible environment'));
616 617 618 619 620
    print theme('install_page', '');
    exit;
  }
}

621 622 623 624 625 626 627 628 629 630 631 632
/**
 * 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'),
  );
Dries's avatar
Dries committed
633

634 635 636 637 638 639 640 641 642 643 644 645 646
  // 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));
}

647
install_main();