17 import(
'classes.install.Install');
18 import(
'lib.pkp.classes.install.form.InstallForm');
19 import(
'lib.pkp.classes.site.Version');
20 import(
'lib.pkp.classes.site.VersionCheck');
32 parent::__construct(
$argv);
40 .
"Usage: {$this->scriptName}\n";
56 $installer =
new Install($this->params);
57 $installer->setLogger($this);
59 if ($installer->execute()) {
60 if (count($installer->getNotes()) > 0) {
61 printf(
"\nRelease Notes\n");
62 printf(
"----------------------------------------\n");
63 foreach ($installer->getNotes() as $note) {
64 printf(
"%s\n\n", $note);
68 if (!$installer->wroteConfig()) {
69 printf(
"\nNew config.inc.php:\n");
70 printf(
"----------------------------------------\n");
71 echo $installer->getConfigContents();
72 printf(
"----------------------------------------\n");
75 $newVersion = $installer->getNewVersion();
76 printf(
"Successfully installed version %s\n", $newVersion->getVersionString(
false));
79 printf(
"ERROR: Installation failed: %s\n", $installer->getErrorString());
93 $this->
readParamOptions(
'locale',
'locale.primary', $installForm->supportedLocales,
'en_US');
94 $this->
readParamOptions(
'additionalLocales',
'installer.additionalLocales', $installForm->supportedLocales,
'',
true);
95 $this->
readParamOptions(
'clientCharset',
'installer.clientCharset', $installForm->supportedClientCharsets,
'utf-8');
96 $this->
readParamOptions(
'connectionCharset',
'installer.connectionCharset', $installForm->supportedConnectionCharsets,
'');
100 $this->
readParam(
'filesDir',
'installer.filesDir');
103 $this->
printTitle(
'installer.administratorAccount');
104 $this->
readParam(
'adminUsername',
'user.username');
107 $this->
readParam(
'adminPassword',
'user.password');
109 $this->
readParam(
'adminPassword2',
'user.repeatPassword');
111 }
while ($this->params[
'adminPassword'] != $this->params[
'adminPassword2']);
113 $this->
readParam(
'adminEmail',
'user.email');
116 $this->
printTitle(
'installer.databaseSettings');
117 $this->
readParamOptions(
'databaseDriver',
'installer.databaseDriver', $installForm->checkDBDrivers());
118 $this->
readParam(
'databaseHost',
'installer.databaseHost',
'');
119 $this->
readParam(
'databaseUsername',
'installer.databaseUsername',
'');
120 $this->
readParam(
'databasePassword',
'installer.databasePassword',
'');
121 $this->
readParam(
'databaseName',
'installer.databaseName');
126 $this->
readParam(
'oaiRepositoryId',
'installer.oaiRepositoryId');
138 printf(
"\n%s\n%s\n%s\n", str_repeat(
'-', 80), __($title), str_repeat(
'-', 80));
146 $value = trim(fgets(STDIN));
147 if ($value ===
false || feof(STDIN)) {
160 function readParam($name, $prompt, $defaultValue =
null) {
162 if (isset($defaultValue)) {
163 printf(
"%s (%s): ", __($prompt), $defaultValue !==
'' ? $defaultValue : __(
'common.none'));
165 printf(
"%s: ", __($prompt));
170 if ($value ===
'' && isset($defaultValue)) {
171 $value = $defaultValue;
173 }
while ($value ===
'' && $defaultValue !==
'');
174 $this->params[$name] = $value;
184 if ($default ==
'N') {
185 printf(
"%s [y/N] ", __($prompt));
187 $this->params[$name] = (int)(strtolower(substr(trim($value), 0, 1)) ==
'y');
189 printf(
"%s [Y/n] ", __($prompt));
191 $this->params[$name] = (int)(strtolower(substr(trim($value), 0, 1)) !=
'n');
202 function readParamOptions($name, $prompt, $options, $defaultValue =
null, $allowMultiple =
false) {
204 printf(
"%s\n", __($prompt));
205 foreach ($options as $k => $v) {
206 printf(
" %-10s %s\n",
'[' . $k .
']', $v);
208 if ($allowMultiple) {
209 printf(
" (%s)\n", __(
'installer.form.separateMultiple'));
211 if (isset($defaultValue)) {
212 printf(
"%s (%s): ", __(
'common.select'), $defaultValue !==
'' ? $defaultValue : __(
'common.none'));
214 printf(
"%s: ", __(
'common.select'));
219 if ($value ===
'' && isset($defaultValue)) {
220 $value = $defaultValue;
225 if ($allowMultiple) {
226 $values = ($value ===
'' ? array() : preg_split(
'/\s*,\s*/', $value));
228 $values = array($value);
230 foreach ($values as $k) {
231 if (!isset($options[$k])) {
237 }
while ($value ===
'' && $defaultValue !==
'');
239 if ($allowMultiple) {
240 $this->params[$name] = $values;
242 $this->params[$name] = $value;
250 function log($message) {
251 printf(
"[%s]\n", $message);