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 Drupal supports.', array('@drupal-databases' => 'http://drupal.org/node/270#database')), ); } else { $form['basic_options'] = array( '#type' => 'fieldset', '#title' => st('Basic options'), '#description' => '
'. st('To set up your @drupal database, enter the following information.', array('@drupal' => drupal_install_profile_name())) .'
', ); if (count($db_types) > 1) { $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, '#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, '#required' => TRUE, ); // Database username $form['basic_options']['db_pass'] = array( '#type' => 'password', '#title' => st('Database password'), '#default_value' => $db_pass, '#size' => 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, // Hostnames can be 255 characters long. '#maxlength' => 255, '#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, // The maximum port number is 65536, 5 digits. '#maxlength' => 5, '#description' => st('If your database server is listening to a non-standard port, enter its number.'), ); // Table prefix $prefix = ($profile == 'default') ? 'drupal_' : $profile .'_'; $form['advanced_options']['db_prefix'] = array( '#type' => 'textfield', '#title' => st('Table prefix'), '#default_value' => $db_prefix, '#size' => 45, '#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_name(), '%prefix' => $prefix)), ); $form['save'] = array( '#type' => 'submit', '#value' => st('Save and continue'), ); $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'] = FALSE; } return $form; } /** * Form API validate for install_settings form. */ function install_settings_form_validate($form, &$form_state) { global $db_url; _install_settings_form_validate($form_state['values']['db_prefix'], $form_state['values']['db_type'], $form_state['values']['db_user'], $form_state['values']['db_pass'], $form_state['values']['db_host'], $form_state['values']['db_port'], $form_state['values']['db_path'], $form_state['values']['settings_file'], $form_state, $form); } /** * Helper function for install_settings_validate. */ function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, &$form_state, $form = NULL) { global $db_url; // Verify the table prefix 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, periods, or underscores.', array('%db_prefix' => $db_prefix)), 'error'); } if (!empty($db_port) && !is_numeric($db_port)) { form_set_error('db_port', st('Database port must be a number.')); } // Check database type if (!isset($form)) { $_db_url = is_array($db_url) ? $db_url['default'] : $db_url; $db_type = substr($_db_url, 0, strpos($_db_url, '://')); } $databases = drupal_detect_database_types(); if (!in_array($db_type, $databases)) { 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))); } else { // Verify $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); if (isset($form)) { form_set_value($form['_db_url'], $db_url, $form_state); } $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 continue 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 Installation and upgrading handbook. 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. */ function install_settings_form_submit($form, &$form_state) { global $profile, $install_locale; // Update global settings array and save $settings['db_url'] = array( 'value' => $form_state['values']['_db_url'], 'required' => TRUE, ); $settings['db_prefix'] = array( 'value' => $form_state['values']['db_prefix'], 'required' => TRUE, ); drupal_rewrite_settings($settings); // Continue to install profile step install_goto("install.php?profile=$profile". ($install_locale ? "&locale=$install_locale" : '')); } /** * 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 = install_find_profiles(); // 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) { if (!empty($_POST['profile']) && ($_POST['profile'] == $profile->name)) { return $profile->name; } } install_task_list('profile-select'); drupal_set_title(st('Select an installation profile')); print theme('install_page', drupal_get_form('install_select_profile_form', $profiles)); exit; } } /** * Form API array definition for the profile selection form. * * @param $form_state * Array of metadata about state of form processing. * @param $profile_files * Array of .profile files, as returned from file_scan_directory(). */ function install_select_profile_form(&$form_state, $profile_files) { $profiles = array(); $names = array(); foreach ($profile_files as $profile) { include_once($profile->filename); // Load profile details and store them for later retrieval. $function = $profile->name .'_profile_details'; if (function_exists($function)) { $details = $function(); } $profiles[$profile->name] = $details; // Determine the name of the profile; default to file name if defined name // is unspecified. $name = isset($details['name']) ? $details['name'] : $profile->name; $names[$profile->name] = $name; } // Display radio buttons alphabetically by human-readable name. natcasesort($names); foreach ($names as $profile => $name) { $form['profile'][$name] = array( '#type' => 'radio', '#value' => 'default', '#return_value' => $profile, '#title' => $name, '#description' => isset($profiles[$profile]['description']) ? $profiles[$profile]['description'] : '', '#parents' => array('profile'), ); } $form['submit'] = array( '#type' => 'submit', '#value' => st('Save and continue'), ); return $form; } /** * Find all .po files for the current profile. */ function install_find_locales($profilename) { $locales = file_scan_directory('./profiles/'. $profilename .'/translations', '\.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. */ function install_select_locale($profilename) { include_once './includes/file.inc'; include_once './includes/form.inc'; // Find all available locales. $locales = install_find_locales($profilename); // If only the built-in (English) language is available, // and we are using the default profile, inform the user // that the installer can be localized. Otherwise we assume // the user know what he is doing. if (count($locales) == 1) { if ($profilename == 'default') { install_task_list('locale-select'); drupal_set_title(st('Choose language')); if (!empty($_GET['localize'])) { $output = ''. st('With the addition of an appropriate translation package, this installer is capable of proceeding in another language of your choice. To install and use Drupal in a language other than English:') .'
'; $output .= ''. st('Alternatively, to install and use Drupal in English, or to defer the selection of an alternative language until after installation, select the first link below.') .'
'; $output .= ''. st('How should the installation continue?') .'
'; $output .= ''; } else { $output = ''; } print theme('install_page', $output); exit; } // One language, but not the default profile, assume // the user knows what he is doing. return FALSE; } else { // Allow profile to pre-select the language, skipping the selection. $function = $profilename .'_profile_details'; if (function_exists($function)) { $details = $function(); if (isset($details['language'])) { foreach ($locales as $locale) { if ($details['language'] == $locale->name) { return $locale->name; } } } } if (!empty($_POST['locale'])) { foreach ($locales as $locale) { if ($_POST['locale'] == $locale->name) { return $locale->name; } } } install_task_list('locale-select'); drupal_set_title(st('Choose language')); print theme('install_page', drupal_get_form('install_select_locale_form', $locales)); exit; } } /** * Form API array definition for language selection. */ function install_select_locale_form(&$form_state, $locales) { include_once './includes/locale.inc'; $languages = _locale_get_predefined_list(); foreach ($locales as $locale) { // Try to use verbose locale name $name = $locale->name; if (isset($languages[$name])) { $name = $languages[$name][0] . (isset($languages[$name][1]) ? ' '. st('(@language)', array('@language' => $languages[$name][1])) : ''); } $form['locale'][$locale->name] = array( '#type' => 'radio', '#return_value' => $locale->name, '#default_value' => ($locale->name == 'en' ? TRUE : FALSE), '#title' => $name . ($locale->name == 'en' ? ' '. st('(built-in)') : ''), '#parents' => array('locale') ); } $form['submit'] = array( '#type' => 'submit', '#value' => st('Select language'), ); return $form; } /** * Show an error page when there are no profiles available. */ function install_no_profile_error() { install_task_list('profile-select'); drupal_set_title(st('No profiles available')); print theme('install_page', ''. 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.') .'
'); exit; } /** * Show an error page when Drupal has already been installed. */ function install_already_done_error() { global $base_url; drupal_set_title(st('Drupal already installed')); print theme('install_page', st(''. st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) .'
'; $output .= ''. (isset($messages['error']) ? st('Please review the messages above before continuing on to your new site.', array('@url' => url(''))) : st('You may now visit your new site.', array('@url' => url('')))) .'
'; $task = 'done'; } // The end of the install process. Remember profile used. if ($task == 'done') { // Rebuild menu to get content type links registered by the profile, // and possibly any other menu items created through the tasks. menu_rebuild(); // Register actions declared by any modules. actions_synchronize(); // Randomize query-strings on css/js files, to hide the fact that // this is a new install, not upgraded yet. _drupal_flush_css_js(); variable_set('install_profile', $profile); } // Set task for user, and remember the task in the database. install_task_list($task); variable_set('install_task', $task); // Output page, if some output was required. Otherwise it is possible // that we are printing a JSON page and theme output should not be there. if (isset($output)) { print theme('maintenance_page', $output); } } /** * Batch callback for batch installation of modules. */ function _install_module_batch($module, $module_name, &$context) { _drupal_install_module($module); // We enable the installed module right away, so that the module will be // loaded by drupal_bootstrap in subsequent batch requests, and other // modules possibly depending on it can safely perform their installation // steps. module_enable(array($module)); $context['results'][] = $module; $context['message'] = st('Installed %module module.', array('%module' => $module_name)); } /** * Finished callback for the modules install batch. * * Advance installer task to language import. */ function _install_profile_batch_finished($success, $results) { variable_set('install_task', 'locale-initial-import'); } /** * Finished callback for the first locale import batch. * * Advance installer task to the configure screen. */ function _install_locale_initial_batch_finished($success, $results) { variable_set('install_task', 'configure'); } /** * Finished callback for the second locale import batch. * * Advance installer task to the finished screen. */ function _install_locale_remaining_batch_finished($success, $results) { variable_set('install_task', 'finished'); } /** * The list of reserved tasks to run in the installer. */ function install_reserved_tasks() { return array('configure', 'profile-install', 'profile-install-batch', 'locale-initial-import', 'locale-initial-batch', 'profile-finished', 'locale-remaining-batch', 'finished', 'done'); } /** * Check installation requirements and report any errors. */ function install_check_requirements($profile, $verify) { // If Drupal is not set up already, we need to create a settings file. if (!$verify) { $writable = FALSE; $conf_path = './'. conf_path(FALSE, TRUE); $settings_file = $conf_path .'/settings.php'; $file = $conf_path; $exists = FALSE; // Verify that the directory exists. if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) { // Check to make sure a settings.php already exists. $file = $settings_file; if (drupal_verify_install_file($settings_file, FILE_EXIST)) { $exists = TRUE; // If it does, make sure it is writable. $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE); } } if (!$exists) { drupal_set_message(st('The @drupal installer requires that you create a settings file as part of the installation process.'. st('The administrator account has complete access to the site; it will automatically be granted all permissions and can perform any administrative activity. This will be the only account that can perform certain activities, so keep its credentials safe.') .'
', '#weight' => -10, ); $form['admin_account']['account']['name'] = array('#type' => 'textfield', '#title' => st('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => st('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'), '#required' => TRUE, '#weight' => -10, ); $form['admin_account']['account']['mail'] = array('#type' => 'textfield', '#title' => st('E-mail address'), '#maxlength' => EMAIL_MAX_LENGTH, '#description' => st('All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), '#required' => TRUE, '#weight' => -5, ); $form['admin_account']['account']['pass'] = array( '#type' => 'password_confirm', '#required' => TRUE, '#size' => 25, '#weight' => 0, ); $form['server_settings'] = array( '#type' => 'fieldset', '#title' => st('Server settings'), '#collapsible' => FALSE, ); $form['server_settings']['date_default_timezone'] = array( '#type' => 'select', '#title' => st('Default time zone'), '#default_value' => 0, '#options' => _system_zonelist(), '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'), '#weight' => 5, ); $form['server_settings']['clean_url'] = array( '#type' => 'radios', '#title' => st('Clean URLs'), '#default_value' => 0, '#options' => array(0 => st('Disabled'), 1 => st('Enabled')), '#description' => st('This option makes Drupal emit "clean" URLs (i.e. without?q=
in the URL).'),
'#disabled' => TRUE,
'#prefix' => '