- Patch #524728 by David_Rothstein, JoshuaRogers, JacobSingh et al: refactor install.php to allow Drupal to be installed from the command line.
parent
1115fba064
commit
aab51b9319
|
|
@ -126,6 +126,9 @@ Drupal 7.0, xxxx-xx-xx (development version)
|
|||
and allow custom data fields to be attached to itself.
|
||||
* Provides a subset of the features of the Content Construction
|
||||
Kit (CCK) module.
|
||||
- Installer:
|
||||
* Refactored the installer into an API that allows Drupal to be installed
|
||||
via a command line script.
|
||||
- Page organization
|
||||
* Made the help text area a full featured region with blocks.
|
||||
* Site mission is replaced with the highlighted content block region and
|
||||
|
|
|
|||
|
|
@ -390,6 +390,66 @@ function conf_path($require_settings = TRUE, $reset = FALSE) {
|
|||
return $conf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set appropriate server variables needed for command line scripts to work.
|
||||
*
|
||||
* This function can be called by command line scripts before bootstrapping
|
||||
* Drupal, to ensure that the page loads with the desired server parameters.
|
||||
* This is because many parts of Drupal assume that they are running in a web
|
||||
* browser and therefore use information from the global PHP $_SERVER variable
|
||||
* that does not get set when Drupal is run from the command line.
|
||||
*
|
||||
* In many cases, the default way in which this function populates the $_SERVER
|
||||
* variable is sufficient, and it can therefore be called without passing in
|
||||
* any input. However, command line scripts running on a multisite installation
|
||||
* (or on any installation that has settings.php stored somewhere other than
|
||||
* the sites/default folder) need to pass in the URL of the site to allow
|
||||
* Drupal to detect the correct location of the settings.php file. Passing in
|
||||
* the 'url' parameter is also required for functions like request_uri() to
|
||||
* return the expected values.
|
||||
*
|
||||
* Most other parameters do not need to be passed in, but may be necessary in
|
||||
* some cases; for example, if Drupal's ip_address() function needs to return
|
||||
* anything but the standard localhost value ('127.0.0.1'), the command line
|
||||
* script should pass in the desired value via the 'REMOTE_ADDR' key.
|
||||
*
|
||||
* @param $variables
|
||||
* (optional) An associative array of variables within $_SERVER that should
|
||||
* be replaced. If the special element 'url' is provided in this array, it
|
||||
* will be used to populate some of the server defaults; it should be set to
|
||||
* the URL of the current page request, excluding any $_GET request but
|
||||
* including the script name (e.g., http://www.example.com/mysite/index.php).
|
||||
*
|
||||
* @see conf_path()
|
||||
* @see request_uri()
|
||||
* @see ip_address()
|
||||
*/
|
||||
function drupal_override_server_variables($variables = array()) {
|
||||
// Set defaults based on the provided URL.
|
||||
if (isset($variables['url'])) {
|
||||
$url = parse_url($variables['url']);
|
||||
unset($variables['url']);
|
||||
}
|
||||
else {
|
||||
$url = array();
|
||||
}
|
||||
$url += array(
|
||||
'path' => '',
|
||||
'host' => 'localhost',
|
||||
);
|
||||
$defaults = array(
|
||||
'HTTP_HOST' => $url['host'],
|
||||
'SCRIPT_NAME' => $url['path'],
|
||||
'REMOTE_ADDR' => '127.0.0.1',
|
||||
'REQUEST_METHOD' => 'GET',
|
||||
'SERVER_NAME' => NULL,
|
||||
'SERVER_SOFTWARE' => 'PHP CLI',
|
||||
'HTTP_USER_AGENT' => NULL,
|
||||
);
|
||||
// Replace elements of the $_SERVER array, as appropriate.
|
||||
$_SERVER = $variables + $_SERVER + $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize PHP environment.
|
||||
*/
|
||||
|
|
@ -1487,6 +1547,13 @@ function drupal_maintenance_theme() {
|
|||
_drupal_maintenance_theme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return TRUE if a Drupal installation is currently being attempted.
|
||||
*/
|
||||
function drupal_installation_attempted() {
|
||||
return defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the localization function. Use in code that needs to
|
||||
* run both during installation and normal operation.
|
||||
|
|
@ -1496,7 +1563,7 @@ function get_t() {
|
|||
// This is not converted to drupal_static because there is no point in
|
||||
// resetting this as it can not change in the course of a request.
|
||||
if (!isset($t)) {
|
||||
$t = function_exists('install_main') ? 'st' : 't';
|
||||
$t = drupal_installation_attempted() ? 'st' : 't';
|
||||
}
|
||||
return $t;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ function cache_get($key, $table = 'cache') {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
function cache_get_multiple(array &$cids, $bin = 'cache') {
|
||||
return array();
|
||||
}
|
||||
|
||||
function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3607,15 +3607,18 @@ function drupal_cron_cleanup() {
|
|||
* An array of file objects of the specified type.
|
||||
*/
|
||||
function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
|
||||
global $profile;
|
||||
global $install_state;
|
||||
$config = conf_path();
|
||||
|
||||
// When this function is called during Drupal's initial installation process,
|
||||
// the name of the profile that's about to be installed is stored in the global
|
||||
// $profile variable. At all other times, the standard Drupal systems variable
|
||||
// installation state. At all other times, the standard Drupal systems variable
|
||||
// table contains the name of the current profile, and we can call variable_get()
|
||||
// to determine what one is active.
|
||||
if (!isset($profile)) {
|
||||
if (isset($install_state['parameters']['profile'])) {
|
||||
$profile = $install_state['parameters']['profile'];
|
||||
}
|
||||
else {
|
||||
$profile = variable_get('install_profile', 'default');
|
||||
}
|
||||
$searchdir = array($directory);
|
||||
|
|
|
|||
|
|
@ -2509,7 +2509,7 @@ function db_result(DatabaseStatementInterface $statement) {
|
|||
*/
|
||||
function _db_check_install_needed() {
|
||||
global $databases;
|
||||
if (empty($databases) && !function_exists('install_main')) {
|
||||
if (empty($databases) && !drupal_installation_attempted()) {
|
||||
include_once DRUPAL_ROOT . '/includes/install.inc';
|
||||
install_goto('install.php');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -705,7 +705,11 @@ function drupal_redirect_form($form, $redirect = NULL) {
|
|||
call_user_func_array('drupal_goto', $goto);
|
||||
}
|
||||
else {
|
||||
drupal_goto($goto);
|
||||
// This function can be called from the installer, which guarantees
|
||||
// that $redirect will always be a string, so catch that case here
|
||||
// and use the appropriate redirect function.
|
||||
$function = drupal_installation_attempted() ? 'install_goto' : 'drupal_goto';
|
||||
$function($goto);
|
||||
}
|
||||
}
|
||||
drupal_goto($_GET['q']);
|
||||
|
|
|
|||
|
|
@ -165,7 +165,8 @@ function drupal_set_installed_schema_version($module, $version) {
|
|||
* The name defined in the profile's _profile_details() hook.
|
||||
*/
|
||||
function drupal_install_profile_name() {
|
||||
global $profile;
|
||||
global $install_state;
|
||||
$profile = $install_state['parameters']['profile'];
|
||||
static $name = NULL;
|
||||
|
||||
if (!isset($name)) {
|
||||
|
|
@ -190,7 +191,6 @@ function drupal_install_profile_name() {
|
|||
* The auto-detected $base_url that should be configured in settings.php
|
||||
*/
|
||||
function drupal_detect_baseurl($file = 'install.php') {
|
||||
global $profile;
|
||||
$proto = $_SERVER['HTTPS'] ? 'https://' : 'http://';
|
||||
$host = $_SERVER['SERVER_NAME'];
|
||||
$port = ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']);
|
||||
|
|
@ -214,7 +214,7 @@ function drupal_detect_database_types() {
|
|||
// without modifying the installer.
|
||||
// Because we have no registry yet, we need to also include the install.inc
|
||||
// file for the driver explicitly.
|
||||
|
||||
require_once DRUPAL_ROOT . '/includes/database/database.inc';
|
||||
foreach (file_scan_directory(DRUPAL_ROOT . '/includes/database', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) {
|
||||
include_once "{$file->filepath}/install.inc";
|
||||
include_once "{$file->filepath}/database.inc";
|
||||
|
|
@ -346,7 +346,7 @@ abstract class DatabaseTasks {
|
|||
}
|
||||
}
|
||||
else {
|
||||
drupal_set_message(st('Failed to run all tasks against the database server. The task %task wasn\'t found.', array('%task' => $task['function'])), 'error');
|
||||
throw new DatabaseTaskException(st("Failed to run all tasks against the database server. The task %task wasn\'t found.", array('%task' => $task['function'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -471,11 +471,11 @@ function drupal_rewrite_settings($settings = array(), $prefix = '') {
|
|||
|
||||
$fp = fopen(DRUPAL_ROOT . '/' . $settings_file, 'w');
|
||||
if ($fp && fwrite($fp, $buffer) === FALSE) {
|
||||
drupal_set_message(st('Failed to modify %settings, please verify the file permissions.', array('%settings' => $settings_file)), 'error');
|
||||
throw new Exception(st('Failed to modify %settings, please verify the file permissions.', array('%settings' => $settings_file)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
drupal_set_message(st('Failed to open %settings, please verify the file permissions.', array('%settings' => $default_settings)), 'error');
|
||||
throw new Exception(st('Failed to open %settings, please verify the file permissions.', array('%settings' => $default_settings)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -497,24 +497,24 @@ function drupal_get_install_files($module_list = array()) {
|
|||
/**
|
||||
* Verify an install profile for installation.
|
||||
*
|
||||
* @param $profile
|
||||
* Name of install profile to verify.
|
||||
* @param $locale
|
||||
* Name of locale used (if any).
|
||||
* @param $install_state
|
||||
* An array of information about the current installation state.
|
||||
* @return
|
||||
* The list of modules to install.
|
||||
*/
|
||||
function drupal_verify_profile($profile, $locale) {
|
||||
function drupal_verify_profile($install_state) {
|
||||
$profile = $install_state['parameters']['profile'];
|
||||
$locale = $install_state['parameters']['locale'];
|
||||
|
||||
include_once DRUPAL_ROOT . '/includes/file.inc';
|
||||
include_once DRUPAL_ROOT . '/includes/common.inc';
|
||||
|
||||
$profile_file = DRUPAL_ROOT . "/profiles/$profile/$profile.profile";
|
||||
|
||||
if (!isset($profile) || !file_exists($profile_file)) {
|
||||
install_no_profile_error();
|
||||
throw new Exception(install_no_profile_error());
|
||||
}
|
||||
$info = install_profile_info($profile);
|
||||
|
||||
$info = $install_state['profile_info'];
|
||||
|
||||
// Get a list of modules that exist in Drupal's assorted subdirectories.
|
||||
$present_modules = array();
|
||||
|
|
@ -927,11 +927,12 @@ function install_goto($path) {
|
|||
*/
|
||||
function st($string, $args = array()) {
|
||||
static $locale_strings = NULL;
|
||||
global $profile, $install_locale;
|
||||
global $install_state;
|
||||
|
||||
if (!isset($locale_strings)) {
|
||||
$locale_strings = array();
|
||||
$filename = 'profiles/' . $profile . '/translations/' . $install_locale . '.po';
|
||||
if (isset($install_state['parameters']['profile']) && isset($install_state['parameters']['locale'])) {
|
||||
$filename = 'profiles/' . $install_state['parameters']['profile'] . '/translations/' . $install_state['parameters']['locale'] . '.po';
|
||||
if (file_exists(DRUPAL_ROOT . '/' . $filename)) {
|
||||
require_once DRUPAL_ROOT . '/includes/locale.inc';
|
||||
$file = (object) array('filepath' => $filename);
|
||||
|
|
@ -939,6 +940,7 @@ function st($string, $args = array()) {
|
|||
$locale_strings = _locale_import_one_string('mem-report');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require_once DRUPAL_ROOT . '/includes/theme.inc';
|
||||
// Transform arguments before inserting them
|
||||
|
|
@ -974,7 +976,7 @@ function drupal_check_profile($profile) {
|
|||
$profile_file = DRUPAL_ROOT . "/profiles/$profile/$profile.profile";
|
||||
|
||||
if (!isset($profile) || !file_exists($profile_file)) {
|
||||
install_no_profile_error();
|
||||
throw new Exception(install_no_profile_error());
|
||||
}
|
||||
|
||||
$info = install_profile_info($profile);
|
||||
|
|
@ -1053,8 +1055,6 @@ function drupal_check_module($module) {
|
|||
* - name: The real name of the install profile for display purposes.
|
||||
* - description: A brief description of the profile.
|
||||
* - dependencies: An array of shortnames of other modules this install profile requires.
|
||||
* - tasks: An associative array of tasks and the page title of each task that need to be
|
||||
* completed for installation.
|
||||
*
|
||||
* Example of .info file:
|
||||
* @verbatim
|
||||
|
|
@ -1078,7 +1078,6 @@ function install_profile_info($profile, $locale = 'en') {
|
|||
// Set defaults for module info.
|
||||
$defaults = array(
|
||||
'dependencies' => array(),
|
||||
'tasks' => array(),
|
||||
'description' => '',
|
||||
'version' => NULL,
|
||||
'php' => DRUPAL_MINIMUM_PHP,
|
||||
|
|
|
|||
1259
install.php
1259
install.php
File diff suppressed because it is too large
Load Diff
|
|
@ -1056,8 +1056,8 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
drupal_get_schema(NULL, TRUE);
|
||||
|
||||
// Run default profile tasks.
|
||||
$task = 'profile';
|
||||
default_profile_tasks($task, '');
|
||||
$install_state = array();
|
||||
default_profile_site_setup($install_state);
|
||||
|
||||
// Rebuild caches.
|
||||
node_types_rebuild();
|
||||
|
|
@ -1073,7 +1073,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
|
||||
// Restore necessary variables.
|
||||
variable_set('install_profile', 'default');
|
||||
variable_set('install_task', 'profile-finished');
|
||||
variable_set('install_task', 'done');
|
||||
variable_set('clean_url', $clean_url_original);
|
||||
variable_set('site_mail', 'simpletest@example.com');
|
||||
// Set up English language.
|
||||
|
|
|
|||
|
|
@ -1877,125 +1877,170 @@ function hook_registry_files_alter(&$files, $module_cache) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Perform any final installation tasks for an installation profile.
|
||||
* Return an array of tasks to be performed by an installation profile.
|
||||
*
|
||||
* The installer goes through the profile-select -> locale-select
|
||||
* -> requirements -> database -> profile-install-batch
|
||||
* -> locale-initial-batch -> configure -> locale-remaining-batch
|
||||
* -> finished -> done tasks, in this order, if you don't implement
|
||||
* this function in your profile.
|
||||
* Any tasks you define here will be run, in order, after the installer has
|
||||
* finished the site configuration step but before it has moved on to the
|
||||
* final import of languages and the end of the installation. You can have any
|
||||
* number of custom tasks to perform during this phase.
|
||||
*
|
||||
* If this function is implemented, you can have any number of
|
||||
* custom tasks to perform after 'configure', implementing a state
|
||||
* machine here to walk the user through those tasks. First time,
|
||||
* this function gets called with $task set to 'profile', and you
|
||||
* can advance to further tasks by setting $task to your tasks'
|
||||
* identifiers, used as array keys in the tasks property of the
|
||||
* profilename.info file.
|
||||
* Each task you define here corresponds to a callback function which you must
|
||||
* separately define and which is called when your task is run. This function
|
||||
* will receive the global installation state variable, $install_state, as
|
||||
* input, and has the opportunity to access or modify any of its settings. See
|
||||
* the install_state_defaults() function in the installer for the list of
|
||||
* $install_state settings used by Drupal core.
|
||||
*
|
||||
* You must avoid the reserved tasks listed in install_reserved_tasks().
|
||||
* If you implement your custom tasks, this function will get called in
|
||||
* every HTTP request (for form processing, printing your information
|
||||
* screens and so on) until you advance to the 'profile-finished' task,
|
||||
* with which you hand control back to the installer. Each custom page
|
||||
* you return needs to provide a way to continue, such as a form
|
||||
* submission or a link. You should also set custom page titles.
|
||||
* At the end of your task function, you can indicate that you want the
|
||||
* installer to pause and display a page to the user by returning any themed
|
||||
* output that should be displayed on that page (but see below for tasks that
|
||||
* use the form API or batch API; the return values of these task functions are
|
||||
* handled differently). You should also use drupal_set_title() within the task
|
||||
* callback function to set a custom page title. For some tasks, however, you
|
||||
* may want to simply do some processing and pass control to the next task
|
||||
* without ending the page request; to indicate this, simply do not send back
|
||||
* a return value from your task function at all. This can be used, for
|
||||
* example, by installation profiles that need to configure certain site
|
||||
* settings in the database without obtaining any input from the user.
|
||||
*
|
||||
* You should define the list of custom tasks you implement by
|
||||
* specifying an array of tasks in your profilename.info file, as these
|
||||
* show up in the list of tasks on the installer user interface.
|
||||
* The task function is treated specially if it defines a form or requires
|
||||
* batch processing; in that case, you should return either the form API
|
||||
* definition or batch API array, as appropriate. See below for more
|
||||
* information on the 'type' key that you must define in the task definition
|
||||
* to inform the installer that your task falls into one of those two
|
||||
* categories. It is important to use these APIs directly, since the installer
|
||||
* may be run non-interactively (for example, via a command line script), all
|
||||
* in one page request; in that case, the installer will automatically take
|
||||
* care of submitting forms and processing batches correctly for both types of
|
||||
* installations. You can inspect the $install_state['interactive'] boolean to
|
||||
* see whether or not the current installation is interactive, if you need
|
||||
* access to this information.
|
||||
*
|
||||
* Example :
|
||||
* task[custom_task] = My first custom task
|
||||
* task[custom_task_2] = My second custom task
|
||||
*
|
||||
* Remember that the user will be able to reload the pages multiple
|
||||
* times, so you might want to use variable_set() and variable_get()
|
||||
* to remember your data and control further processing, if $task
|
||||
* is insufficient. Should a profile want to display a form here,
|
||||
* it can; the form should set '#redirect' to FALSE, and rely on
|
||||
* an action in the submit handler, such as variable_set(), to
|
||||
* detect submission and proceed to further tasks. See the configuration
|
||||
* form handling code in install_tasks() for an example.
|
||||
*
|
||||
* Important: Any temporary variables should be removed using
|
||||
* variable_del() before advancing to the 'profile-finished' phase.
|
||||
*
|
||||
* @param $task
|
||||
* The current $task of the install system. When hook_profile_tasks()
|
||||
* is first called, this is 'profile'.
|
||||
* @param $url
|
||||
* Complete URL to be used for a link or form action on a custom page,
|
||||
* if providing any, to allow the user to proceed with the installation.
|
||||
* Remember that a user installing Drupal interactively will be able to reload
|
||||
* an installation page multiple times, so you should use variable_set() and
|
||||
* variable_get() if you are collecting any data that you need to store and
|
||||
* inspect later. It is important to remove any temporary variables using
|
||||
* variable_del() before your last task has completed and control is handed
|
||||
* back to the installer.
|
||||
*
|
||||
* @return
|
||||
* An optional HTML string to display to the user. Only used if you
|
||||
* modify the $task, otherwise discarded.
|
||||
* A keyed array of tasks the profile will perform during the final stage of
|
||||
* the installation. Each key represents the name of a function (usually a
|
||||
* function defined by this profile, although that is not strictly required)
|
||||
* that is called when that task is run. The values are associative arrays
|
||||
* containing the following key-value pairs (all of which are optional):
|
||||
* - 'display_name'
|
||||
* The human-readable name of the task. This will be displayed to the
|
||||
* user while the installer is running, along with a list of other tasks
|
||||
* that are being run. Leave this unset to prevent the task from
|
||||
* appearing in the list.
|
||||
* - 'display'
|
||||
* This is a boolean which can be used to provide finer-grained control
|
||||
* over whether or not the task will display. This is mostly useful for
|
||||
* tasks that are intended to display only under certain conditions; for
|
||||
* these tasks, you can set 'display_name' to the name that you want to
|
||||
* display, but then use this boolean to hide the task only when certain
|
||||
* conditions apply.
|
||||
* - 'type'
|
||||
* A string representing the type of task. This parameter has three
|
||||
* possible values:
|
||||
* - 'normal': This indicates that the task will be treated as a regular
|
||||
* callback function, which does its processing and optionally returns
|
||||
* HTML output. This is the default behavior which is used when 'type' is
|
||||
* not set.
|
||||
* - 'batch': This indicates that the task function will return a batch
|
||||
* API definition suitable for batch_set(). The installer will then take
|
||||
* care of automatically running the task via batch processing.
|
||||
* - 'form': This indicates that the task function will return a standard
|
||||
* form API definition (and separately define validation and submit
|
||||
* handlers, as appropriate). The installer will then take care of
|
||||
* automatically directing the user through the form submission process.
|
||||
* - 'run'
|
||||
* A constant representing the manner in which the task will be run. This
|
||||
* parameter has three possible values:
|
||||
* - INSTALL_TASK_RUN_IF_NOT_COMPLETED: This indicates that the task will
|
||||
* run once during the installation of the profile. This is the default
|
||||
* behavior which is used when 'run' is not set.
|
||||
* - INSTALL_TASK_SKIP: This indicates that the task will not run during
|
||||
* the current installation page request. It can be used to skip running
|
||||
* an installation task when certain conditions are met, even though the
|
||||
* task may still show on the list of installation tasks presented to the
|
||||
* user.
|
||||
* - INSTALL_TASK_RUN_IF_REACHED: This indicates that the task will run
|
||||
* on each installation page request that reaches it. This is rarely
|
||||
* necessary for an installation profile to use; it is primarily used by
|
||||
* the Drupal installer for bootstrap-related tasks.
|
||||
* - 'function'
|
||||
* Normally this does not need to be set, but it can be used to force the
|
||||
* installer to call a different function when the task is run (rather
|
||||
* than the function whose name is given by the array key). This could be
|
||||
* used, for example, to allow the same function to be called by two
|
||||
* different tasks.
|
||||
*
|
||||
* @see install_state_defaults()
|
||||
* @see batch_set()
|
||||
*/
|
||||
function hook_profile_tasks(&$task, $url) {
|
||||
|
||||
// Enable some standard blocks.
|
||||
$values = array(
|
||||
array(
|
||||
'module' => 'system',
|
||||
'delta' => 'main',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'content',
|
||||
'pages' => '',
|
||||
'cache' => -1,
|
||||
function hook_profile_tasks() {
|
||||
// Here, we define a variable to allow tasks to indicate that a particular,
|
||||
// processor-intensive batch process needs to be triggered later on in the
|
||||
// installation.
|
||||
$myprofile_needs_batch_processing = variable_get('myprofile_needs_batch_processing', FALSE);
|
||||
$tasks = array(
|
||||
// This is an example of a task that defines a form which the user who is
|
||||
// installing the site will be asked to fill out. To implement this task,
|
||||
// your profile would define a function named myprofile_data_import_form()
|
||||
// as a normal form API callback function, with associated validation and
|
||||
// submit handlers. In the submit handler, in addition to saving whatever
|
||||
// other data you have collected from the user, you might also call
|
||||
// variable_set('myprofile_needs_batch_processing', TRUE) if the user has
|
||||
// entered data which requires that batch processing will need to occur
|
||||
// later on.
|
||||
'myprofile_data_import_form' => array(
|
||||
'display_name' => st('Data import options'),
|
||||
'type' => 'form',
|
||||
),
|
||||
array(
|
||||
'module' => 'user',
|
||||
'delta' => 'login',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'left',
|
||||
'pages' => '',
|
||||
'cache' => -1,
|
||||
// Similarly, to implement this task, your profile would define a function
|
||||
// named myprofile_settings_form() with associated validation and submit
|
||||
// handlers. This form might be used to collect and save additional
|
||||
// information from the user that your profile needs. There are no extra
|
||||
// steps required for your profile to act as an "installation wizard"; you
|
||||
// can simply define as many tasks of type 'form' as you wish to execute,
|
||||
// and the forms will be presented to the user, one after another.
|
||||
'myprofile_settings_form' => array(
|
||||
'display_name' => st('Additional options'),
|
||||
'type' => 'form',
|
||||
),
|
||||
array(
|
||||
'module' => 'system',
|
||||
'delta' => 'navigation',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'left',
|
||||
'pages' => '',
|
||||
'cache' => -1,
|
||||
// This is an example of a task that performs batch operations. To
|
||||
// implement this task, your profile would define a function named
|
||||
// myprofile_batch_processing() which returns a batch API array definition
|
||||
// that the installer will use to execute your batch operations. Due to the
|
||||
// 'myprofile_needs_batch_processing' variable used here, this task will be
|
||||
// hidden and skipped unless your profile set it to TRUE in one of the
|
||||
// previous tasks.
|
||||
'myprofile_batch_processing' => array(
|
||||
'display_name' => st('Import additional data'),
|
||||
'display' => $myprofile_needs_batch_processing,
|
||||
'type' => 'batch',
|
||||
'run' => $myprofile_needs_batch_processing ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
|
||||
),
|
||||
array(
|
||||
'module' => 'system',
|
||||
'delta' => 'management',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 1,
|
||||
'region' => 'left',
|
||||
'pages' => '',
|
||||
'cache' => -1,
|
||||
),
|
||||
array(
|
||||
'module' => 'system',
|
||||
'delta' => 'help',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'help',
|
||||
'pages' => '',
|
||||
'cache' => -1,
|
||||
// This is an example of a task that will not be displayed in the list that
|
||||
// the user sees. To implement this task, your profile would define a
|
||||
// function named myprofile_final_site_setup(), in which additional,
|
||||
// automated site setup operations would be performed. Since this is the
|
||||
// last task defined by your profile, you should also use this function to
|
||||
// call variable_del('myprofile_needs_batch_processing') and clean up the
|
||||
// variable that was used above. If you want the user to pass to the final
|
||||
// Drupal installation tasks uninterrupted, return no output from this
|
||||
// function. Otherwise, return themed output that the user will see (for
|
||||
// example, a confirmation page explaining that your profile's tasks are
|
||||
// complete, with a link to reload the current page and therefore pass on
|
||||
// to the final Drupal installation tasks when the user is ready to do so).
|
||||
'myprofile_final_site_setup' => array(
|
||||
),
|
||||
);
|
||||
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
|
||||
foreach ($values as $record) {
|
||||
$query->values($record);
|
||||
return $tasks;
|
||||
}
|
||||
$query->execute();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup hooks".
|
||||
|
|
|
|||
|
|
@ -4,7 +4,24 @@
|
|||
/**
|
||||
* Implement hook_profile_tasks().
|
||||
*/
|
||||
function default_profile_tasks(&$task, $url) {
|
||||
function default_profile_tasks() {
|
||||
$tasks = array(
|
||||
'default_profile_site_setup' => array(),
|
||||
);
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installation task; perform actions to set up the site for this profile.
|
||||
*
|
||||
* This task does not return any output, meaning that control will be passed
|
||||
* along to the next task without ending the page request.
|
||||
*
|
||||
* @param $install_state
|
||||
* An array of information about the current installation state.
|
||||
*/
|
||||
function default_profile_site_setup(&$install_state) {
|
||||
|
||||
// Enable some standard blocks.
|
||||
$values = array(
|
||||
array(
|
||||
|
|
|
|||
|
|
@ -4,7 +4,23 @@
|
|||
/**
|
||||
* Implement hook_profile_tasks().
|
||||
*/
|
||||
function expert_profile_tasks(&$task, $url) {
|
||||
function expert_profile_tasks() {
|
||||
$tasks = array(
|
||||
'expert_profile_site_setup' => array(),
|
||||
);
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installation task; perform actions to set up the site for this profile.
|
||||
*
|
||||
* This task does not return any output, meaning that control will be passed
|
||||
* along to the next task without ending the page request.
|
||||
*
|
||||
* @param $install_state
|
||||
* An array of information about the current installation state.
|
||||
*/
|
||||
function expert_profile_site_setup(&$install_state) {
|
||||
|
||||
// Enable some standard blocks.
|
||||
$values = array(
|
||||
|
|
|
|||
Loading…
Reference in New Issue