Esempio n. 1
0
/**
 * Add the installation task list to the current page.
 */
function install_task_list($active = NULL)
{
    // Default list of tasks.
    $tasks = array('profile-select' => st('Choose profile'), 'locale-select' => st('Choose language'), 'requirements' => st('Verify requirements'), 'database' => st('Set up database'), 'profile-install-batch' => st('Install profile'), 'locale-initial-batch' => st('Set up translations'), 'configure' => st('Configure site'));
    $profiles = install_find_profiles();
    $profile = isset($_GET['profile']) && isset($profiles[$_GET['profile']]) ? $_GET['profile'] : '.';
    $locales = install_find_locales($profile);
    // If we have only one profile, remove 'Choose profile'
    // and rename 'Install profile'.
    if (count($profiles) == 1) {
        unset($tasks['profile-select']);
        $tasks['profile-install-batch'] = st('Install site');
    }
    // Add tasks defined by the profile.
    if ($profile) {
        $function = $profile . '_profile_task_list';
        if (function_exists($function)) {
            $result = $function();
            if (is_array($result)) {
                $tasks += $result;
            }
        }
    }
    if (count($locales) < 2 || empty($_GET['locale']) || $_GET['locale'] == 'en') {
        // If not required, remove translation import from the task list.
        unset($tasks['locale-initial-batch']);
    } else {
        // If required, add remaining translations import task.
        $tasks += array('locale-remaining-batch' => st('Finish translations'));
    }
    // Add finished step as the last task.
    $tasks += array('finished' => st('Finished'));
    // Let the theming function know that 'finished' and 'done'
    // include everything, so every step is completed.
    if (in_array($active, array('finished', 'done'))) {
        $active = NULL;
    }
    drupal_set_content('left', theme_task_list($tasks, $active));
}
Esempio n. 2
0
/**
 * Installation task; select which profile to install.
 *
 * @param $install_state
 *   An array of information about the current installation state. The chosen
 *   profile will be added here, if it was not already selected previously, as
 *   will a list of all available profiles.
 * @return
 *   For interactive installations, a form allowing the profile to be selected,
 *   if the user has a choice that needs to be made. Otherwise, an exception is
 *   thrown if a profile cannot be chosen automatically.
 */
function install_select_profile(&$install_state)
{
    $install_state['profiles'] += install_find_profiles();
    if (empty($install_state['parameters']['profile'])) {
        // Try to find a profile.
        $profile = _install_select_profile($install_state['profiles']);
        if (empty($profile)) {
            // We still don't have a profile, so display a form for selecting one.
            // Only do this in the case of interactive installations, since this is
            // not a real form with submit handlers (the database isn't even set up
            // yet), rather just a convenience method for setting parameters in the
            // URL.
            if ($install_state['interactive']) {
                include_once DRUPAL_ROOT . '/includes/form.inc';
                drupal_set_title(st('Select an installation profile'));
                $form = drupal_get_form('install_select_profile_form', $install_state['profiles']);
                return drupal_render($form);
            } else {
                throw new Exception(install_no_profile_error());
            }
        } else {
            $install_state['parameters']['profile'] = $profile;
        }
    }
}