public function batchInstall(array $params, $createHtaccess = FALSE)
{
restore_error_handler();
restore_exception_handler();
$defaults = array('dbhost' => 'localhost', 'dbprefix' => 'elgg_', 'language' => 'en', 'siteaccess' => ACCESS_PUBLIC, 'site_guid' => 1);
$params = array_merge($defaults, $params);
$requiredParams = array('dbuser', 'dbpassword', 'dbname', 'sitename', 'wwwroot', 'dataroot', 'displayname', 'email', 'username', 'password');
foreach ($requiredParams as $key) {
if (empty($params[$key])) {
$msg = _elgg_services()->translator->translate('install:error:requiredfield', array($key));
throw new InstallationException($msg);
}
}
// password is passed in once
$params['password1'] = $params['password2'] = $params['password'];
if ($createHtaccess) {
$rewriteTester = new ElggRewriteTester();
if (!$rewriteTester->createHtaccess($params['wwwroot'], Directory\Local::root()->getPath())) {
throw new InstallationException(_elgg_services()->translator->translate('install:error:htaccess'));
}
}
$this->setInstallStatus();
if (!$this->status['config']) {
if (!$this->createSettingsFile($params)) {
throw new InstallationException(_elgg_services()->translator->translate('install:error:settings'));
}
}
if (!$this->connectToDatabase()) {
throw new InstallationException(_elgg_services()->translator->translate('install:error:databasesettings'));
}
if (!$this->status['database']) {
if (!$this->installDatabase()) {
throw new InstallationException(_elgg_services()->translator->translate('install:error:cannotloadtables'));
}
}
// load remaining core libraries
$this->finishBootstraping('settings');
if (!$this->saveSiteSettings($params)) {
throw new InstallationException(_elgg_services()->translator->translate('install:error:savesitesettings'));
}
if (!$this->createAdminAccount($params)) {
throw new InstallationException(_elgg_services()->translator->translate('install:admin:cannot_create'));
}
}