本文整理汇总了PHP中drupal_verify_profile函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_verify_profile函数的具体用法?PHP drupal_verify_profile怎么用?PHP drupal_verify_profile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drupal_verify_profile函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetUpWithMissingDependencies
/**
* Verifies that the exception message in the profile step is correct.
*/
public function testSetUpWithMissingDependencies() {
// Prime the drupal_get_filename() static cache with the location of the
// testing profile as it is not the currently active profile and we don't
// yet have any cached way to retrieve its location.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', 'testing_missing_dependencies', 'core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml');
$info = drupal_verify_profile([
'parameters' => ['profile' => 'testing_missing_dependencies'],
'profile_info' => install_profile_info('testing_missing_dependencies'),
]);
$message = $info['required_modules']['description']->render();
$this->assertContains('Missing_module1', $message);
$this->assertContains('Missing_module2', $message);
}
示例2: install_main
/**
* 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()
{
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
// The user agent header is used to pass a database prefix in the request when
// running tests. However, for security reasons, it is imperative that no
// installation be permitted using such a prefix.
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], "simpletest") !== FALSE) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
}
// This must go after drupal_bootstrap(), which unsets globals!
global $profile, $install_locale, $conf;
require_once './modules/system/system.install';
require_once './includes/file.inc';
// Ensure correct page headers are sent (e.g. caching)
drupal_page_header();
// Set up $language, so t() caller functions will still work.
drupal_init_language();
// 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');
// Install profile chosen, set the global immediately.
// This needs to be done before the theme cache gets
// initialized in drupal_maintenance_theme().
if (!empty($_GET['profile'])) {
$profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
}
// Set up theme system for the maintenance page.
drupal_maintenance_theme();
// Check existing settings.php.
$verify = install_verify_settings();
if ($verify) {
// Since we have a database connection, we use the normal cache system.
// This is important, as the installer calls into the Drupal system for
// the clean URL checks, so we should maintain the cache properly.
require_once './includes/cache.inc';
$conf['cache_inc'] = './includes/cache.inc';
// Establish a connection to the database.
require_once './includes/database.inc';
db_set_active();
// Check if Drupal is installed.
$task = install_verify_drupal();
if ($task == 'done') {
install_already_done_error();
}
} else {
// Since no persistent storage is available yet, and functions that check
// for cached data will fail, we temporarily replace the normal cache
// system with a stubbed-out version that short-circuits the actual
// caching process and avoids any errors.
require_once './includes/cache-install.inc';
$conf['cache_inc'] = './includes/cache-install.inc';
$task = NULL;
}
// No profile was passed in GET, ask the user.
if (empty($_GET['profile'])) {
if ($profile = install_select_profile()) {
install_goto("install.php?profile={$profile}");
} else {
install_no_profile_error();
}
}
// Load the profile.
require_once "./profiles/{$profile}/{$profile}.profile";
// 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}");
}
// Tasks come after the database is set up
if (!$task) {
global $db_url;
if (!$verify && !empty($db_url)) {
// Do not install over a configured settings.php.
install_already_done_error();
}
// Check the installation requirements for Drupal and this profile.
install_check_requirements($profile, $verify);
// Verify existence of all required modules.
$modules = drupal_verify_profile($profile, $install_locale);
// If any error messages are set now, it means a requirement problem.
$messages = drupal_set_message();
if (!empty($messages['error'])) {
//.........这里部分代码省略.........
示例3: setUp
/**
* Installs Atrium instead of Drupal
*
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
protected function setUp()
{
global $db_prefix, $user, $language, $profile, $install_locale;
// $language (Drupal 6).
// Store necessary current values before switching to prefixed database.
$this->originalPrefix = $db_prefix;
$this->originalLanguage = clone $language;
$clean_url_original = variable_get('clean_url', 0);
// Must reset locale here, since schema calls t(). (Drupal 6)
if (module_exists('locale')) {
$language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
locale(NULL, NULL, TRUE);
}
// Generate temporary prefixed database to ensure that tests have a clean starting point.
// $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
$install_locale = $this->install_locale;
$profile = $this->install_profile;
// include_once DRUPAL_ROOT . '/includes/install.inc';
include_once './includes/install.inc';
drupal_install_system();
// $this->preloadRegistry();
// Set up theme system for the maintenance page.
// Otherwise we have trouble: https://ds.openatrium.com/dsi/node/18426#comment-38118
// @todo simpletest module patch
drupal_maintenance_theme();
// Add the specified modules to the list of modules in the default profile.
$args = func_get_args();
// $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
$modules = array_unique(array_merge(drupal_verify_profile($this->install_profile, $this->install_locale), $args));
// drupal_install_modules($modules, TRUE);
drupal_install_modules($modules);
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
// stale data for the previous run's database prefix and all
// calls to it will fail.
drupal_get_schema(NULL, TRUE);
if ($this->install_profile == 'openatrium') {
// Download and import translation if needed
if ($this->install_locale != 'en') {
$this->installLanguage($this->install_locale);
}
// Install more modules
$modules = _openatrium_atrium_modules();
drupal_install_modules($modules);
// Configure intranet
// $profile_tasks = $this->install_profile . '_profile_tasks';
_openatrium_intranet_configure();
_openatrium_intranet_configure_check();
variable_set('atrium_install', 1);
// Clear views cache before rebuilding menu tree. Requires patch
// [patch_here] to Views, as new modules have been included and
// default views need to be re-detected.
module_exists('views') ? views_get_all_views(TRUE) : TRUE;
menu_rebuild();
}
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
user_access(NULL, NULL, TRUE);
// Drupal 6.
// Log in with a clean $user.
$this->originalUser = $user;
// drupal_save_session(FALSE);
// $user = user_load(1);
session_save_session(FALSE);
$user = user_load(array('uid' => 1));
// Restore necessary variables.
variable_set('install_profile', $this->install_profile);
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', 'simpletest@example.com');
// Use temporary files directory with the same prefix as database.
$this->originalFileDirectory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
$directory = file_directory_path();
// Create the files directory.
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
set_time_limit($this->timeLimit);
}
示例4: install_main
/**
* 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()
{
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
// This must go after drupal_bootstrap(), which unsets globals!
global $profile, $install_locale;
require_once './modules/system/system.install';
require_once './includes/file.inc';
// Ensure correct page headers are sent (e.g. caching)
drupal_page_header();
// 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()) {
install_goto("install.php?profile={$profile}");
} else {
install_no_profile_error();
}
// 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}");
}
// Load the profile.
require_once "./profiles/{$profile}/{$profile}.profile";
// Check the installation requirements for Drupal and this profile.
install_check_requirements($profile);
// Change the settings.php information if verification failed earlier.
// Note: will trigger a redirect if database credentials change.
if (!$verify) {
install_change_settings($profile, $install_locale);
}
// Verify existence of all required modules.
$modules = drupal_verify_profile($profile, $install_locale);
if (!$modules) {
install_missing_modules_error($profile);
}
// Perform actual installation defined in the profile.
drupal_install_profile($profile, $modules);
// 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');
} 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)));
}
// Show end page.
install_complete($profile);
}
示例5: setUp
/**
* Generates a random database prefix and runs the install scripts on the prefixed database.
* After installation many caches are flushed and the internal browser is setup so that the page
* requests will run on the new prefix. A temporary files directory is created with the same name
* as the database prefix.
*
* @param ... List modules to enable.
*/
function setUp()
{
global $db_prefix, $simpletest_ua_key;
if ($simpletest_ua_key) {
$this->db_prefix_original = $db_prefix;
$clean_url_original = variable_get('clean_url', 0);
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
include_once './includes/install.inc';
drupal_install_system();
$modules = array_unique(array_merge(func_get_args(), drupal_verify_profile('default', 'en')));
drupal_install_modules($modules);
$this->_modules = drupal_map_assoc($modules);
$this->_modules['system'] = 'system';
$task = 'profile';
default_profile_tasks($task, '');
menu_rebuild();
actions_synchronize();
_drupal_flush_css_js();
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
// Use temporary files directory with the same prefix as database.
$this->original_file_directory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
file_check_directory(file_directory_path(), TRUE);
// Create the files directory.
}
parent::setUp();
}
示例6: install_verify_requirements
/**
* Installation task; verify the requirements for installing Drupal.
*
* @param $install_state
* An array of information about the current installation state.
* @return
* A themed status report, or an exception if there are requirement errors.
* Otherwise, no output is returned, so that the next task can be run
* in the same page request.
*/
function install_verify_requirements(&$install_state)
{
// Check the installation requirements for Drupal and this profile.
$requirements = install_check_requirements($install_state);
// Verify existence of all required modules.
$requirements += drupal_verify_profile($install_state);
// Check the severity of the requirements reported.
$severity = drupal_requirements_severity($requirements);
if ($severity == REQUIREMENT_ERROR) {
if ($install_state['interactive']) {
drupal_set_title(st('Requirements problem'));
$status_report = theme('status_report', array('requirements' => $requirements));
$status_report .= st('Check the error messages and <a href="!url">proceed with the installation</a>.', array('!url' => request_uri()));
return $status_report;
} else {
// Throw an exception showing all unmet requirements.
$failures = array();
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description'];
}
}
throw new Exception(implode("\n\n", $failures));
}
}
}
示例7: setUp
/**
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
protected function setUp()
{
global $db_prefix, $user, $language;
// Store necessary current values before switching to prefixed database.
$this->originalLanguage = $language;
// $this->originalLanguageDefault = variable_get('language_default');
$this->originalPrefix = $db_prefix;
$this->originalFileDirectory = file_directory_path();
// $this->originalProfile = drupal_get_profile();
$clean_url_original = variable_get('clean_url', 0);
// Must reset locale here, since schema calls t(). (Drupal 6)
if (module_exists('locale')) {
$language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
locale(NULL, NULL, TRUE);
}
// Generate temporary prefixed database to ensure that tests have a clean starting point.
// $db_prefix_new = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
$db_prefix_new = $db_prefix . 'simpletest' . mt_rand(1000, 1000000);
// Workaround to insure we init the theme layer before going into prefixed
// environment. (Drupal 6)
$this->pass(t('Starting run with db_prefix %prefix', array('%prefix' => $db_prefix_new)), 'System');
// db_update('simpletest_test_id')
// ->fields(array('last_prefix' => $db_prefix_new))
// ->condition('test_id', $this->testId)
// ->execute();
db_query("UPDATE {simpletest_test_id}\n SET last_prefix = '%s'\n WHERE test_id = %d", $db_prefix_new, $this->testId);
$db_prefix = $db_prefix_new;
// Create test directory ahead of installation so fatal errors and debug
// information can be logged during installation process.
$directory = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10);
// file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
// Log fatal errors.
ini_set('log_errors', 1);
ini_set('error_log', $directory . '/error.log');
// include_once DRUPAL_ROOT . '/includes/install.inc';
include_once './includes/install.inc';
drupal_install_system();
// $this->preloadRegistry();
// // Include the default profile
// variable_set('install_profile', 'default');
// $profile_details = install_profile_info('default', 'en');
// Add the specified modules to the list of modules in the default profile.
// Install the modules specified by the default profile.
// drupal_install_modules($profile_details['dependencies'], TRUE);
drupal_install_modules(drupal_verify_profile('default', 'en'));
// node_type_clear();
// Install additional modules one at a time in order to make sure that the
// list of modules is updated between each module's installation.
$modules = func_get_args();
foreach ($modules as $module) {
// drupal_install_modules(array($module), TRUE);
drupal_install_modules(array($module));
}
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
// stale data for the previous run's database prefix and all
// calls to it will fail.
drupal_get_schema(NULL, TRUE);
// Run default profile tasks.
// $install_state = array();
// drupal_install_modules(array('default'), TRUE);
$task = 'profile';
default_profile_tasks($task, '');
// Rebuild caches.
// node_types_rebuild();
actions_synchronize();
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
user_access(NULL, NULL, TRUE);
// Drupal 6.
// Log in with a clean $user.
$this->originalUser = $user;
// drupal_save_session(FALSE);
// $user = user_load(1);
session_save_session(FALSE);
$user = user_load(array('uid' => 1));
// Restore necessary variables.
variable_set('install_profile', 'default');
// variable_set('install_task', 'done');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', 'simpletest@example.com');
// // Set up English language.
// unset($GLOBALS['conf']['language_default']);
// $language = language_default();
// Use the test mail class instead of the default mail handler class.
// variable_set('mail_sending_system', array('default-system' => 'TestingMailSystem'));
variable_set('smtp_library', drupal_get_path('module', 'simpletest') . '/simpletest.mail.inc');
//.........这里部分代码省略.........
示例8: setUp
/**
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
protected function setUp()
{
global $db_prefix, $user, $language;
// $language (Drupal 6).
// Store necessary current values before switching to prefixed database.
$this->originalPrefix = $db_prefix;
$clean_url_original = variable_get('clean_url', 0);
// Must reset locale here, since schema calls t(). (Drupal 6)
if (module_exists('locale')) {
$language = (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '');
locale(NULL, NULL, TRUE);
}
// Generate temporary prefixed database to ensure that tests have a clean starting point.
// $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
// include_once DRUPAL_ROOT . '/includes/install.inc';
include_once './includes/install.inc';
drupal_install_system();
// $this->preloadRegistry();
// Add the specified modules to the list of modules in the default profile.
$args = func_get_args();
// $modules = array_unique(array_merge(drupal_get_profile_modules('default', 'en'), $args));
$modules = array_unique(array_merge(drupal_verify_profile('default', 'en'), $args));
// drupal_install_modules($modules, TRUE);
drupal_install_modules($modules);
// Because the schema is static cached, we need to flush
// it between each run. If we don't, then it will contain
// stale data for the previous run's database prefix and all
// calls to it will fail.
drupal_get_schema(NULL, TRUE);
// Run default profile tasks.
$task = 'profile';
default_profile_tasks($task, '');
// Rebuild caches.
actions_synchronize();
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
user_access(NULL, NULL, TRUE);
// Drupal 6.
// Log in with a clean $user.
$this->originalUser = $user;
// drupal_save_session(FALSE);
// $user = user_load(1);
session_save_session(FALSE);
$user = user_load(array('uid' => 1));
// Restore necessary variables.
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', 'simpletest@example.com');
// Use temporary files directory with the same prefix as database.
$this->originalFileDirectory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
$directory = file_directory_path();
// Create the files directory.
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
set_time_limit($this->timeLimit);
}
示例9: setUp
/**
* Generates a random database prefix, runs the install scripts on the
* prefixed database and enable the specified modules. After installation
* many caches are flushed and the internal browser is setup so that the
* page requests will run on the new prefix. A temporary files directory
* is created with the same name as the database prefix.
*
* @param ...
* List of modules to enable for the duration of the test.
*/
function setUp()
{
global $db_prefix, $user, $language;
// $language (Drupal 6).
global $install_locale;
// Store necessary current values before switching to prefixed database.
$this->db_prefix_original = $db_prefix;
$clean_url_original = variable_get('clean_url', 0);
// Generate temporary prefixed database to ensure that tests have a clean starting point.
$db_prefix = 'simpletest' . mt_rand(1000, 1000000);
include_once './includes/install.inc';
drupal_install_system();
// Add the specified modules to the list of modules in the default profile.
$args = func_get_args();
// Add language and basic i18n modules
$install_locale = $this->install_locale;
$i18n_modules = array('locale', 'translation', 'i18n', 'i18n_test');
$modules = array_unique(array_merge(drupal_verify_profile('default', $this->install_locale), $args, $i18n_modules));
drupal_install_modules($modules);
// Install locale
if ($this->install_locale != 'en') {
$this->addLanguage($this->install_locale, TRUE);
}
// Run default profile tasks.
$task = 'profile';
default_profile_tasks($task, '');
// Rebuild caches.
actions_synchronize();
_drupal_flush_css_js();
$this->refreshVariables();
$this->checkPermissions(array(), TRUE);
user_access(NULL, NULL, TRUE);
// Drupal 6.
// Log in with a clean $user.
$this->originalUser = $user;
// drupal_save_session(FALSE);
// $user = user_load(1);
session_save_session(FALSE);
$user = user_load(1);
// Restore necessary variables.
variable_set('install_profile', 'default');
variable_set('install_task', 'profile-finished');
variable_set('clean_url', $clean_url_original);
variable_set('site_mail', 'simpletest@example.com');
// Use temporary files directory with the same prefix as database.
$this->originalFileDirectory = file_directory_path();
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
$directory = file_directory_path();
// Create the files directory.
file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
drupal_set_time_limit($this->timeLimit);
// Some more includes
require_once 'includes/language.inc';
// Refresh theme
$this->initTheme();
// Set path languages so we can retrieve pages in different languages
variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
}
示例10: install_main
/**
* 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()
{
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
// The user agent header is used to pass a database prefix in the request when
// running tests. However, for security reasons, it is imperative that no
// installation be permitted using such a prefix.
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], "simpletest") !== FALSE) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
}
// This must go after drupal_bootstrap(), which unsets globals!
global $profile, $install_locale, $conf;
require_once DRUPAL_ROOT . '/modules/system/system.install';
require_once DRUPAL_ROOT . '/includes/file.inc';
// Ensure correct page headers are sent (e.g. caching)
drupal_page_header();
// Set up $language, so t() caller functions will still work.
drupal_init_language();
// Load module basics (needed for hook invokes).
include_once DRUPAL_ROOT . '/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');
// Load the cache infrastructure using a "fake" cache implementation that
// does not attempt to write to the database. We need this during the initial
// part of the installer because the database is not available yet. We
// continue to use it even when the database does become available, in order
// to preserve consistency between interactive and command-line installations
// (the latter complete in one page request and therefore are forced to
// continue using the cache implementation they started with) and also
// because any data put in the cache during the installer is inherently
// suspect, due to the fact that Drupal is not fully set up yet.
require_once DRUPAL_ROOT . '/includes/cache-install.inc';
$conf['cache_inc'] = './includes/cache-install.inc';
// Install profile chosen, set the global immediately.
// This needs to be done before the theme cache gets
// initialized in drupal_maintenance_theme().
if (!empty($_GET['profile'])) {
$profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
}
// Set up theme system for the maintenance page.
drupal_maintenance_theme();
// Check existing settings.php.
$verify = install_verify_settings();
if ($verify) {
// Establish a connection to the database.
require_once DRUPAL_ROOT . '/includes/database.inc';
db_set_active();
// Check if Drupal is installed.
$task = install_verify_drupal();
if ($task == 'done') {
install_already_done_error();
}
} else {
$task = NULL;
}
// No profile was passed in GET, ask the user.
if (empty($_GET['profile'])) {
if ($profile = install_select_profile()) {
install_goto("install.php?profile={$profile}");
} else {
install_no_profile_error();
}
}
// Load the profile.
require_once DRUPAL_ROOT . "/profiles/{$profile}/{$profile}.profile";
// 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}");
}
// Tasks come after the database is set up
if (!$task) {
global $db_url;
if (!$verify && !empty($db_url)) {
// Do not install over a configured settings.php.
install_already_done_error();
}
// Check the installation requirements for Drupal and this profile.
install_check_requirements($profile, $verify);
// Verify existence of all required modules.
$modules = drupal_verify_profile($profile, $install_locale);
// If any error messages are set now, it means a requirement problem.
$messages = drupal_set_message();
if (!empty($messages['error'])) {
//.........这里部分代码省略.........