17 import(
'classes.install.Install');
18 import(
'lib.pkp.classes.install.form.MaintenanceForm');
45 parent::__construct($request,
'install/install.tpl');
49 $this->localesComplete = array();
50 foreach ($this->supportedLocales as $key => $name) {
54 $this->supportedClientCharsets = array (
55 'utf-8' =>
'Unicode (UTF-8)',
56 'iso-8859-1' =>
'Western (ISO-8859-1)'
59 $this->supportedConnectionCharsets = array (
60 '' => __(
'common.notApplicable'),
61 'utf8' =>
'Unicode (UTF-8)'
64 $this->supportedDatabaseCharsets = array (
65 '' => __(
'common.notApplicable'),
66 'utf8' =>
'Unicode (UTF-8)'
69 $this->supportedDatabaseDrivers = array (
71 'mysql' => array(
'mysql',
'MySQL'),
72 'mysqli' => array(
'mysqli',
'MySQLi'),
73 'postgres9' => array(
'pgsql',
'PostgreSQL'),
74 'oracle' => array(
'oci8',
'Oracle'),
75 'mssql' => array(
'mssql',
'MS SQL Server'),
76 'fbsql' => array(
'fbsql',
'FrontBase'),
77 'ibase' => array(
'ibase',
'Interbase'),
78 'firebird' => array(
'ibase',
'Firebird'),
79 'informix' => array(
'ifx',
'Informix'),
80 'sybase' => array(
'sybase',
'Sybase'),
81 'odbc' => array(
'odbc',
'ODBC'),
86 $this->
addCheck(
new FormValidatorInSet($this,
'locale',
'required',
'installer.form.localeRequired', array_keys($this->supportedLocales)));
87 $this->
addCheck(
new FormValidatorCustom($this,
'locale',
'required',
'installer.form.localeRequired', array(
'AppLocale',
'isLocaleValid')));
88 $this->
addCheck(
new FormValidatorInSet($this,
'clientCharset',
'required',
'installer.form.clientCharsetRequired', array_keys($this->supportedClientCharsets)));
90 $this->
addCheck(
new FormValidator($this,
'adminUsername',
'required',
'installer.form.usernameRequired'));
92 $this->
addCheck(
new FormValidator($this,
'adminPassword',
'required',
'installer.form.passwordRequired'));
93 $this->
addCheck(
new FormValidatorCustom($this,
'adminPassword',
'required',
'installer.form.passwordsDoNotMatch',
function($password) use ($form) {
94 return $password == $form->getData(
'adminPassword2');
97 $this->
addCheck(
new FormValidatorInSet($this,
'databaseDriver',
'required',
'installer.form.databaseDriverRequired', array_keys($this->supportedDatabaseDrivers)));
98 $this->
addCheck(
new FormValidator($this,
'databaseName',
'required',
'installer.form.databaseNameRequired'));
104 function display($request =
null, $template =
null) {
105 import(
'lib.pkp.classes.xslt.XSLTransformer');
107 $templateMgr->assign(array(
108 'localeOptions' => $this->supportedLocales,
109 'localesComplete' => $this->localesComplete,
110 'clientCharsetOptions' => $this->supportedClientCharsets,
111 'connectionCharsetOptions' => $this->supportedConnectionCharsets,
112 'allowFileUploads' => get_cfg_var(
'file_uploads') ? __(
'common.yes') : __(
'common.no'),
113 'maxFileUploadSize' => get_cfg_var(
'upload_max_filesize'),
116 'phpIsSupportedVersion' => version_compare(PHP_REQUIRED_VERSION, PHP_VERSION) != 1,
118 'xslRequired' => REQUIRES_XSL,
119 'phpRequiredVersion' => PHP_REQUIRED_VERSION,
120 'phpVersion' => PHP_VERSION,
123 parent::display($request, $template);
130 $docRoot = dirname($_SERVER[
'DOCUMENT_ROOT']);
133 $docRoot = str_replace(
'\\',
'/', $docRoot);
137 if ($docRoot !==
'/') $docRoot .=
'/';
139 $this->_data = array(
141 'additionalLocales' => array(),
142 'clientCharset' =>
'utf-8',
143 'connectionCharset' =>
'utf8',
144 'filesDir' => $docRoot .
'files',
145 'databaseDriver' =>
'mysql',
146 'databaseHost' =>
'localhost',
148 'databasePassword' =>
'',
150 'createDatabase' => 1,
152 'enableBeacon' =>
true,
180 if ($this->
getData(
'additionalLocales') ==
null || !is_array($this->
getData(
'additionalLocales'))) {
181 $this->
setData(
'additionalLocales', array());
190 function execute(...$functionArgs) {
191 parent::execute(...$functionArgs);
194 $installer =
new Install($this->_data);
196 if ($installer->execute()) {
197 if (!$installer->wroteConfig()) {
199 $templateMgr->assign(array(
'writeConfigFailed' =>
true,
'configFileContents' => $installer->getConfigContents()));
202 $templateMgr->display(
'install/installComplete.tpl');
205 switch ($installer->getErrorType()) {
206 case INSTALLER_ERROR_DB:
215 $installer->destroy();
224 $dbDrivers = array();
225 foreach ($this->supportedDatabaseDrivers as $driver => $info) {
226 list($module, $name) = $info;
227 if (!extension_loaded($module)) {
228 $name =
'[ ' . $name .
' ]';
230 $dbDrivers[$driver] = $name;