You are here

function install_settings_form in Drupal 5

Same name and namespace in other branches
  1. 6 install.php \install_settings_form()
  2. 7 includes/install.core.inc \install_settings_form()

Form API array definition for install_settings.

1 string reference to 'install_settings_form'
install_change_settings in ./install.php
Configure and rewrite settings.php.

File

./install.php, line 184

Code

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) {
  $db_types = drupal_detect_database_types();
  if (count($db_types) == 0) {
    $form['no_db_types'] = array(
      '#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',
      )),
    );
  }
  else {
    $form['basic_options'] = array(
      '#type' => 'fieldset',
      '#title' => st('Basic options'),
      '#description' => '<p>' . st('To set up your @drupal database, enter the following information.', array(
        '@drupal' => drupal_install_profile_name(),
      )) . '</p>',
    );
    if (count($db_types) > 1) {

      // Database type
      $db_types = drupal_detect_database_types();
      $form['basic_options']['db_type'] = array(
        '#type' => 'radios',
        '#title' => st('Database type'),
        '#required' => TRUE,
        '#options' => $db_types,
        '#default_value' => $db_type ? $db_type : current($db_types),
        '#description' => st('The type of database your @drupal data will be stored in.', array(
          '@drupal' => drupal_install_profile_name(),
        )),
      );
      $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(),
      ));
    }
    else {
      if (count($db_types) == 1) {
        $db_types = array_values($db_types);
        $form['basic_options']['db_type'] = array(
          '#type' => 'hidden',
          '#value' => $db_types[0],
        );
        $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(),
        ));
      }
    }

    // Database name
    $form['basic_options']['db_path'] = array(
      '#type' => 'textfield',
      '#title' => st('Database name'),
      '#default_value' => $db_path,
      '#size' => 45,
      '#maxlength' => 45,
      '#required' => TRUE,
      '#description' => $db_path_description,
    );

    // Database username
    $form['basic_options']['db_user'] = array(
      '#type' => 'textfield',
      '#title' => st('Database username'),
      '#default_value' => $db_user,
      '#size' => 45,
      '#maxlength' => 45,
      '#required' => TRUE,
    );

    // Database username
    $form['basic_options']['db_pass'] = array(
      '#type' => 'password',
      '#title' => st('Database password'),
      '#default_value' => $db_pass,
      '#size' => 45,
      '#maxlength' => 45,
    );
    $form['advanced_options'] = array(
      '#type' => 'fieldset',
      '#title' => st('Advanced options'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#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."),
    );

    // Database host
    $form['advanced_options']['db_host'] = array(
      '#type' => 'textfield',
      '#title' => st('Database host'),
      '#default_value' => $db_host,
      '#size' => 45,
      '#maxlength' => 45,
      '#required' => TRUE,
      '#description' => st('If your database is located on a different server, change this.'),
    );

    // 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.'),
    );

    // Table prefix
    $form['advanced_options']['db_prefix'] = array(
      '#type' => 'textfield',
      '#title' => st('Table prefix'),
      '#default_value' => $db_prefix,
      '#size' => 45,
      '#maxlength' => 45,
      '#description' => st('If more than one @drupal web site will be sharing this database, enter a table prefix for your @drupal site here.', array(
        '@drupal' => drupal_install_profile_name(),
      )),
    );
    $form['save'] = array(
      '#type' => 'submit',
      '#value' => st('Save configuration'),
    );
    $form['errors'] = array();
    $form['settings_file'] = array(
      '#type' => 'value',
      '#value' => $settings_file,
    );
    $form['_db_url'] = array(
      '#type' => 'value',
    );
    $form['#action'] = "install.php?profile={$profile}" . ($install_locale ? "&locale={$install_locale}" : '');
    $form['#redirect'] = NULL;
  }
  return $form;
}