Slight improvements to FormSpecialPage behavior.
[lhc/web/wiklou.git] / includes / installer / WebInstallerPage.php
1 <?php
2 /**
3 * Base code for web installer pages.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Deployment
22 */
23
24 /**
25 * Abstract class to define pages for the web installer.
26 *
27 * @ingroup Deployment
28 * @since 1.17
29 */
30 abstract class WebInstallerPage {
31
32 /**
33 * The WebInstaller object this WebInstallerPage belongs to.
34 *
35 * @var WebInstaller
36 */
37 public $parent;
38
39 abstract public function execute();
40
41 /**
42 * Constructor.
43 *
44 * @param $parent WebInstaller
45 */
46 public function __construct( WebInstaller $parent ) {
47 $this->parent = $parent;
48 }
49
50 /**
51 * Is this a slow-running page in the installer? If so, WebInstaller will
52 * set_time_limit(0) before calling execute(). Right now this only applies
53 * to Install and Upgrade pages
54 * @return bool
55 */
56 public function isSlow() {
57 return false;
58 }
59
60 public function addHTML( $html ) {
61 $this->parent->output->addHTML( $html );
62 }
63
64 public function startForm() {
65 $this->addHTML(
66 "<div class=\"config-section\">\n" .
67 Html::openElement(
68 'form',
69 array(
70 'method' => 'post',
71 'action' => $this->parent->getUrl( array( 'page' => $this->getName() ) )
72 )
73 ) . "\n"
74 );
75 }
76
77 public function endForm( $continue = 'continue', $back = 'back' ) {
78 $s = "<div class=\"config-submit\">\n";
79 $id = $this->getId();
80
81 if ( $id === false ) {
82 $s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
83 }
84
85 if ( $continue ) {
86 // Fake submit button for enter keypress (bug 26267)
87 // Give grep a chance to find the usages: config-continue
88 $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(),
89 array( 'name' => "enter-$continue", 'style' =>
90 'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n";
91 }
92
93 if ( $back ) {
94 // Give grep a chance to find the usages: config-back
95 $s .= Xml::submitButton( wfMessage( "config-$back" )->text(),
96 array(
97 'name' => "submit-$back",
98 'tabindex' => $this->parent->nextTabIndex()
99 ) ) . "\n";
100 }
101
102 if ( $continue ) {
103 // Give grep a chance to find the usages: config-continue
104 $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(),
105 array(
106 'name' => "submit-$continue",
107 'tabindex' => $this->parent->nextTabIndex(),
108 ) ) . "\n";
109 }
110
111 $s .= "</div></form></div>\n";
112 $this->addHTML( $s );
113 }
114
115 public function getName() {
116 return str_replace( 'WebInstaller_', '', get_class( $this ) );
117 }
118
119 protected function getId() {
120 return array_search( $this->getName(), $this->parent->pageSequence );
121 }
122
123 public function getVar( $var ) {
124 return $this->parent->getVar( $var );
125 }
126
127 public function setVar( $name, $value ) {
128 $this->parent->setVar( $name, $value );
129 }
130
131 /**
132 * Get the starting tags of a fieldset.
133 *
134 * @param string $legend message name
135 *
136 * @return string
137 */
138 protected function getFieldsetStart( $legend ) {
139 return "\n<fieldset><legend>" . wfMessage( $legend )->escaped() . "</legend>\n";
140 }
141
142 /**
143 * Get the end tag of a fieldset.
144 *
145 * @return string
146 */
147 protected function getFieldsetEnd() {
148 return "</fieldset>\n";
149 }
150
151 /**
152 * Opens a textarea used to display the progress of a long operation
153 */
154 protected function startLiveBox() {
155 $this->addHTML(
156 '<div id="config-spinner" style="display:none;">' .
157 '<img src="../skins/common/images/ajax-loader.gif" /></div>' .
158 '<script>jQuery( "#config-spinner" ).show();</script>' .
159 '<div id="config-live-log">' .
160 '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
161 );
162 $this->parent->output->flush();
163 }
164
165 /**
166 * Opposite to startLiveBox()
167 */
168 protected function endLiveBox() {
169 $this->addHTML( '</textarea></div>
170 <script>jQuery( "#config-spinner" ).hide()</script>' );
171 $this->parent->output->flush();
172 }
173 }
174
175 class WebInstaller_Language extends WebInstallerPage {
176
177 public function execute() {
178 global $wgLang;
179 $r = $this->parent->request;
180 $userLang = $r->getVal( 'uselang' );
181 $contLang = $r->getVal( 'ContLang' );
182
183 $languages = Language::fetchLanguageNames();
184 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
185 if ( !$lifetime ) {
186 $lifetime = 1440; // PHP default
187 }
188
189 if ( $r->wasPosted() ) {
190 # Do session test
191 if ( $this->parent->getSession( 'test' ) === null ) {
192 $requestTime = $r->getVal( 'LanguageRequestTime' );
193 if ( !$requestTime ) {
194 // The most likely explanation is that the user was knocked back
195 // from another page on POST due to session expiry
196 $msg = 'config-session-expired';
197 } elseif ( time() - $requestTime > $lifetime ) {
198 $msg = 'config-session-expired';
199 } else {
200 $msg = 'config-no-session';
201 }
202 $this->parent->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
203 } else {
204 if ( isset( $languages[$userLang] ) ) {
205 $this->setVar( '_UserLang', $userLang );
206 }
207 if ( isset( $languages[$contLang] ) ) {
208 $this->setVar( 'wgLanguageCode', $contLang );
209 }
210 return 'continue';
211 }
212 } elseif ( $this->parent->showSessionWarning ) {
213 # The user was knocked back from another page to the start
214 # This probably indicates a session expiry
215 $this->parent->showError( 'config-session-expired',
216 $wgLang->formatTimePeriod( $lifetime ) );
217 }
218
219 $this->parent->setSession( 'test', true );
220
221 if ( !isset( $languages[$userLang] ) ) {
222 $userLang = $this->getVar( '_UserLang', 'en' );
223 }
224 if ( !isset( $languages[$contLang] ) ) {
225 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
226 }
227 $this->startForm();
228 $s = Html::hidden( 'LanguageRequestTime', time() ) .
229 $this->getLanguageSelector( 'uselang', 'config-your-language', $userLang,
230 $this->parent->getHelpBox( 'config-your-language-help' ) ) .
231 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang,
232 $this->parent->getHelpBox( 'config-wiki-language-help' ) );
233 $this->addHTML( $s );
234 $this->endForm( 'continue', false );
235 }
236
237 /**
238 * Get a "<select>" for selecting languages.
239 *
240 * @param $name
241 * @param $label
242 * @param $selectedCode
243 * @param $helpHtml string
244 * @return string
245 */
246 public function getLanguageSelector( $name, $label, $selectedCode, $helpHtml = '' ) {
247 global $wgDummyLanguageCodes;
248
249 $s = $helpHtml;
250
251 $s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name,
252 'tabindex' => $this->parent->nextTabIndex() ) ) . "\n";
253
254 $languages = Language::fetchLanguageNames();
255 ksort( $languages );
256 foreach ( $languages as $code => $lang ) {
257 if ( isset( $wgDummyLanguageCodes[$code] ) ) {
258 continue;
259 }
260 $s .= "\n" . Xml::option( "$code - $lang", $code, $code == $selectedCode );
261 }
262 $s .= "\n</select>\n";
263 return $this->parent->label( $label, $name, $s );
264 }
265
266 }
267
268 class WebInstaller_ExistingWiki extends WebInstallerPage {
269 public function execute() {
270 // If there is no LocalSettings.php, continue to the installer welcome page
271 $vars = Installer::getExistingLocalSettings();
272 if ( !$vars ) {
273 return 'skip';
274 }
275
276 // Check if the upgrade key supplied to the user has appeared in LocalSettings.php
277 if ( $vars['wgUpgradeKey'] !== false
278 && $this->getVar( '_UpgradeKeySupplied' )
279 && $this->getVar( 'wgUpgradeKey' ) === $vars['wgUpgradeKey'] )
280 {
281 // It's there, so the user is authorized
282 $status = $this->handleExistingUpgrade( $vars );
283 if ( $status->isOK() ) {
284 return 'skip';
285 } else {
286 $this->startForm();
287 $this->parent->showStatusBox( $status );
288 $this->endForm( 'continue' );
289 return 'output';
290 }
291 }
292
293 // If there is no $wgUpgradeKey, tell the user to add one to LocalSettings.php
294 if ( $vars['wgUpgradeKey'] === false ) {
295 if ( $this->getVar( 'wgUpgradeKey', false ) === false ) {
296 $secretKey = $this->getVar( 'wgSecretKey' ); // preserve $wgSecretKey
297 $this->parent->generateKeys();
298 $this->setVar( 'wgSecretKey', $secretKey );
299 $this->setVar( '_UpgradeKeySupplied', true );
300 }
301 $this->startForm();
302 $this->addHTML( $this->parent->getInfoBox(
303 wfMessage( 'config-upgrade-key-missing', "<pre dir=\"ltr\">\$wgUpgradeKey = '" .
304 $this->getVar( 'wgUpgradeKey' ) . "';</pre>" )->plain()
305 ) );
306 $this->endForm( 'continue' );
307 return 'output';
308 }
309
310 // If there is an upgrade key, but it wasn't supplied, prompt the user to enter it
311
312 $r = $this->parent->request;
313 if ( $r->wasPosted() ) {
314 $key = $r->getText( 'config_wgUpgradeKey' );
315 if ( !$key || $key !== $vars['wgUpgradeKey'] ) {
316 $this->parent->showError( 'config-localsettings-badkey' );
317 $this->showKeyForm();
318 return 'output';
319 }
320 // Key was OK
321 $status = $this->handleExistingUpgrade( $vars );
322 if ( $status->isOK() ) {
323 return 'continue';
324 } else {
325 $this->parent->showStatusBox( $status );
326 $this->showKeyForm();
327 return 'output';
328 }
329 } else {
330 $this->showKeyForm();
331 return 'output';
332 }
333 }
334
335 /**
336 * Show the "enter key" form
337 */
338 protected function showKeyForm() {
339 $this->startForm();
340 $this->addHTML(
341 $this->parent->getInfoBox( wfMessage( 'config-localsettings-upgrade' )->plain() ) .
342 '<br />' .
343 $this->parent->getTextBox( array(
344 'var' => 'wgUpgradeKey',
345 'label' => 'config-localsettings-key',
346 'attribs' => array( 'autocomplete' => 'off' ),
347 ) )
348 );
349 $this->endForm( 'continue' );
350 }
351
352 protected function importVariables( $names, $vars ) {
353 $status = Status::newGood();
354 foreach ( $names as $name ) {
355 if ( !isset( $vars[$name] ) ) {
356 $status->fatal( 'config-localsettings-incomplete', $name );
357 }
358 $this->setVar( $name, $vars[$name] );
359 }
360 return $status;
361 }
362
363 /**
364 * Initiate an upgrade of the existing database
365 * @param array $vars Variables from LocalSettings.php and AdminSettings.php
366 * @return Status
367 */
368 protected function handleExistingUpgrade( $vars ) {
369 // Check $wgDBtype
370 if ( !isset( $vars['wgDBtype'] ) ||
371 !in_array( $vars['wgDBtype'], Installer::getDBTypes() ) ) {
372 return Status::newFatal( 'config-localsettings-connection-error', '' );
373 }
374
375 // Set the relevant variables from LocalSettings.php
376 $requiredVars = array( 'wgDBtype' );
377 $status = $this->importVariables( $requiredVars, $vars );
378 $installer = $this->parent->getDBInstaller();
379 $status->merge( $this->importVariables( $installer->getGlobalNames(), $vars ) );
380 if ( !$status->isOK() ) {
381 return $status;
382 }
383
384 if ( isset( $vars['wgDBadminuser'] ) ) {
385 $this->setVar( '_InstallUser', $vars['wgDBadminuser'] );
386 } else {
387 $this->setVar( '_InstallUser', $vars['wgDBuser'] );
388 }
389 if ( isset( $vars['wgDBadminpassword'] ) ) {
390 $this->setVar( '_InstallPassword', $vars['wgDBadminpassword'] );
391 } else {
392 $this->setVar( '_InstallPassword', $vars['wgDBpassword'] );
393 }
394
395 // Test the database connection
396 $status = $installer->getConnection();
397 if ( !$status->isOK() ) {
398 // Adjust the error message to explain things correctly
399 $status->replaceMessage( 'config-connection-error',
400 'config-localsettings-connection-error' );
401 return $status;
402 }
403
404 // All good
405 $this->setVar( '_ExistingDBSettings', true );
406 return $status;
407 }
408 }
409
410 class WebInstaller_Welcome extends WebInstallerPage {
411
412 public function execute() {
413 if ( $this->parent->request->wasPosted() ) {
414 if ( $this->getVar( '_Environment' ) ) {
415 return 'continue';
416 }
417 }
418 $this->parent->output->addWikiText( wfMessage( 'config-welcome' )->plain() );
419 $status = $this->parent->doEnvironmentChecks();
420 if ( $status->isGood() ) {
421 $this->parent->output->addHTML( '<span class="success-message">' .
422 wfMessage( 'config-env-good' )->escaped() . '</span>' );
423 $this->parent->output->addWikiText( wfMessage( 'config-copyright',
424 SpecialVersion::getCopyrightAndAuthorList() )->plain() );
425 $this->startForm();
426 $this->endForm();
427 } else {
428 $this->parent->showStatusMessage( $status );
429 }
430 return '';
431 }
432
433 }
434
435 class WebInstaller_DBConnect extends WebInstallerPage {
436
437 public function execute() {
438 if ( $this->getVar( '_ExistingDBSettings' ) ) {
439 return 'skip';
440 }
441
442 $r = $this->parent->request;
443 if ( $r->wasPosted() ) {
444 $status = $this->submit();
445
446 if ( $status->isGood() ) {
447 $this->setVar( '_UpgradeDone', false );
448 return 'continue';
449 } else {
450 $this->parent->showStatusBox( $status );
451 }
452 }
453
454 $this->startForm();
455
456 $types = "<ul class=\"config-settings-block\">\n";
457 $settings = '';
458 $defaultType = $this->getVar( 'wgDBtype' );
459
460 // Give grep a chance to find the usages:
461 // config-support-mysql, config-support-postgres, config-support-oracle, config-support-sqlite
462 $dbSupport = '';
463 foreach ( $this->parent->getDBTypes() as $type ) {
464 $link = DatabaseBase::factory( $type )->getSoftwareLink();
465 $dbSupport .= wfMessage( "config-support-$type", $link )->plain() . "\n";
466 }
467 $this->addHTML( $this->parent->getInfoBox(
468 wfMessage( 'config-support-info', trim( $dbSupport ) )->text() ) );
469
470 foreach ( $this->parent->getVar( '_CompiledDBs' ) as $type ) {
471 $installer = $this->parent->getDBInstaller( $type );
472 $types .=
473 '<li>' .
474 Xml::radioLabel(
475 $installer->getReadableName(),
476 'DBType',
477 $type,
478 "DBType_$type",
479 $type == $defaultType,
480 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
481 ) .
482 "</li>\n";
483
484 // Give grep a chance to find the usages:
485 // config-header-mysql, config-header-postgres, config-header-oracle, config-header-sqlite
486 $settings .=
487 Html::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type,
488 'class' => 'dbWrapper' ) ) .
489 Html::element( 'h3', array(), wfMessage( 'config-header-' . $type )->text() ) .
490 $installer->getConnectForm() .
491 "</div>\n";
492 }
493 $types .= "</ul><br style=\"clear: left\"/>\n";
494
495 $this->addHTML(
496 $this->parent->label( 'config-db-type', false, $types ) .
497 $settings
498 );
499
500 $this->endForm();
501 }
502
503 public function submit() {
504 $r = $this->parent->request;
505 $type = $r->getVal( 'DBType' );
506 $this->setVar( 'wgDBtype', $type );
507 $installer = $this->parent->getDBInstaller( $type );
508 if ( !$installer ) {
509 return Status::newFatal( 'config-invalid-db-type' );
510 }
511 return $installer->submitConnectForm();
512 }
513
514 }
515
516 class WebInstaller_Upgrade extends WebInstallerPage {
517 public function isSlow() {
518 return true;
519 }
520
521 public function execute() {
522 if ( $this->getVar( '_UpgradeDone' ) ) {
523 // Allow regeneration of LocalSettings.php, unless we are working
524 // from a pre-existing LocalSettings.php file and we want to avoid
525 // leaking its contents
526 if ( $this->parent->request->wasPosted() && !$this->getVar( '_ExistingDBSettings' ) ) {
527 // Done message acknowledged
528 return 'continue';
529 } else {
530 // Back button click
531 // Show the done message again
532 // Make them click back again if they want to do the upgrade again
533 $this->showDoneMessage();
534 return 'output';
535 }
536 }
537
538 // wgDBtype is generally valid here because otherwise the previous page
539 // (connect) wouldn't have declared its happiness
540 $type = $this->getVar( 'wgDBtype' );
541 $installer = $this->parent->getDBInstaller( $type );
542
543 if ( !$installer->needsUpgrade() ) {
544 return 'skip';
545 }
546
547 if ( $this->parent->request->wasPosted() ) {
548 $installer->preUpgrade();
549
550 $this->startLiveBox();
551 $result = $installer->doUpgrade();
552 $this->endLiveBox();
553
554 if ( $result ) {
555 // If they're going to possibly regenerate LocalSettings, we
556 // need to create the upgrade/secret keys. Bug 26481
557 if ( !$this->getVar( '_ExistingDBSettings' ) ) {
558 $this->parent->generateKeys();
559 }
560 $this->setVar( '_UpgradeDone', true );
561 $this->showDoneMessage();
562 return 'output';
563 }
564 }
565
566 $this->startForm();
567 $this->addHTML( $this->parent->getInfoBox(
568 wfMessage( 'config-can-upgrade', $GLOBALS['wgVersion'] )->plain() ) );
569 $this->endForm();
570 }
571
572 public function showDoneMessage() {
573 $this->startForm();
574 $regenerate = !$this->getVar( '_ExistingDBSettings' );
575 if ( $regenerate ) {
576 $msg = 'config-upgrade-done';
577 } else {
578 $msg = 'config-upgrade-done-no-regenerate';
579 }
580 $this->parent->disableLinkPopups();
581 $this->addHTML(
582 $this->parent->getInfoBox(
583 wfMessage( $msg,
584 $this->getVar( 'wgServer' ) .
585 $this->getVar( 'wgScriptPath' ) . '/index' .
586 $this->getVar( 'wgScriptExtension' )
587 )->plain(), 'tick-32.png'
588 )
589 );
590 $this->parent->restoreLinkPopups();
591 $this->endForm( $regenerate ? 'regenerate' : false, false );
592 }
593
594 }
595
596 class WebInstaller_DBSettings extends WebInstallerPage {
597
598 public function execute() {
599 $installer = $this->parent->getDBInstaller( $this->getVar( 'wgDBtype' ) );
600
601 $r = $this->parent->request;
602 if ( $r->wasPosted() ) {
603 $status = $installer->submitSettingsForm();
604 if ( $status === false ) {
605 return 'skip';
606 } elseif ( $status->isGood() ) {
607 return 'continue';
608 } else {
609 $this->parent->showStatusBox( $status );
610 }
611 }
612
613 $form = $installer->getSettingsForm();
614 if ( $form === false ) {
615 return 'skip';
616 }
617
618 $this->startForm();
619 $this->addHTML( $form );
620 $this->endForm();
621 }
622
623 }
624
625 class WebInstaller_Name extends WebInstallerPage {
626
627 public function execute() {
628 $r = $this->parent->request;
629 if ( $r->wasPosted() ) {
630 if ( $this->submit() ) {
631 return 'continue';
632 }
633 }
634
635 $this->startForm();
636
637 // Encourage people to not name their site 'MediaWiki' by blanking the
638 // field. I think that was the intent with the original $GLOBALS['wgSitename']
639 // but these two always were the same so had the effect of making the
640 // installer forget $wgSitename when navigating back to this page.
641 if ( $this->getVar( 'wgSitename' ) == 'MediaWiki' ) {
642 $this->setVar( 'wgSitename', '' );
643 }
644
645 // Set wgMetaNamespace to something valid before we show the form.
646 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
647 $metaNS = $this->getVar( 'wgMetaNamespace' );
648 $this->setVar(
649 'wgMetaNamespace',
650 wfMessage( 'config-ns-other-default' )->inContentLanguage()->text()
651 );
652
653 $this->addHTML(
654 $this->parent->getTextBox( array(
655 'var' => 'wgSitename',
656 'label' => 'config-site-name',
657 'help' => $this->parent->getHelpBox( 'config-site-name-help' )
658 ) ) .
659 // getRadioSet() builds a set of labeled radio buttons.
660 // For grep: The following messages are used as the item labels:
661 // config-ns-site-name, config-ns-generic, config-ns-other
662 $this->parent->getRadioSet( array(
663 'var' => '_NamespaceType',
664 'label' => 'config-project-namespace',
665 'itemLabelPrefix' => 'config-ns-',
666 'values' => array( 'site-name', 'generic', 'other' ),
667 'commonAttribs' => array( 'class' => 'enableForOther',
668 'rel' => 'config_wgMetaNamespace' ),
669 'help' => $this->parent->getHelpBox( 'config-project-namespace-help' )
670 ) ) .
671 $this->parent->getTextBox( array(
672 'var' => 'wgMetaNamespace',
673 'label' => '', //TODO: Needs a label?
674 'attribs' => array( 'readonly' => 'readonly', 'class' => 'enabledByOther' ),
675
676 ) ) .
677 $this->getFieldSetStart( 'config-admin-box' ) .
678 $this->parent->getTextBox( array(
679 'var' => '_AdminName',
680 'label' => 'config-admin-name',
681 'help' => $this->parent->getHelpBox( 'config-admin-help' )
682 ) ) .
683 $this->parent->getPasswordBox( array(
684 'var' => '_AdminPassword',
685 'label' => 'config-admin-password',
686 ) ) .
687 $this->parent->getPasswordBox( array(
688 'var' => '_AdminPassword2',
689 'label' => 'config-admin-password-confirm'
690 ) ) .
691 $this->parent->getTextBox( array(
692 'var' => '_AdminEmail',
693 'label' => 'config-admin-email',
694 'help' => $this->parent->getHelpBox( 'config-admin-email-help' )
695 ) ) .
696 $this->parent->getCheckBox( array(
697 'var' => '_Subscribe',
698 'label' => 'config-subscribe',
699 'help' => $this->parent->getHelpBox( 'config-subscribe-help' )
700 ) ) .
701 $this->getFieldSetEnd() .
702 $this->parent->getInfoBox( wfMessage( 'config-almost-done' )->text() ) .
703 // getRadioSet() builds a set of labeled radio buttons.
704 // For grep: The following messages are used as the item labels:
705 // config-optional-continue, config-optional-skip
706 $this->parent->getRadioSet( array(
707 'var' => '_SkipOptional',
708 'itemLabelPrefix' => 'config-optional-',
709 'values' => array( 'continue', 'skip' )
710 ) )
711 );
712
713 // Restore the default value
714 $this->setVar( 'wgMetaNamespace', $metaNS );
715
716 $this->endForm();
717 return 'output';
718 }
719
720 public function submit() {
721 $retVal = true;
722 $this->parent->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
723 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
724 '_Subscribe', '_SkipOptional', 'wgMetaNamespace' ) );
725
726 // Validate site name
727 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
728 $this->parent->showError( 'config-site-name-blank' );
729 $retVal = false;
730 }
731
732 // Fetch namespace
733 $nsType = $this->getVar( '_NamespaceType' );
734 if ( $nsType == 'site-name' ) {
735 $name = $this->getVar( 'wgSitename' );
736 // Sanitize for namespace
737 // This algorithm should match the JS one in WebInstallerOutput.php
738 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
739 $name = str_replace( '&', '&amp;', $name );
740 $name = preg_replace( '/__+/', '_', $name );
741 $name = ucfirst( trim( $name, '_' ) );
742 } elseif ( $nsType == 'generic' ) {
743 $name = wfMessage( 'config-ns-generic' )->text();
744 } else { // other
745 $name = $this->getVar( 'wgMetaNamespace' );
746 }
747
748 // Validate namespace
749 if ( strpos( $name, ':' ) !== false ) {
750 $good = false;
751 } else {
752 // Title-style validation
753 $title = Title::newFromText( $name );
754 if ( !$title ) {
755 $good = $nsType == 'site-name';
756 } else {
757 $name = $title->getDBkey();
758 $good = true;
759 }
760 }
761 if ( !$good ) {
762 $this->parent->showError( 'config-ns-invalid', $name );
763 $retVal = false;
764 }
765
766 // Make sure it won't conflict with any existing namespaces
767 global $wgContLang;
768 $nsIndex = $wgContLang->getNsIndex( $name );
769 if ( $nsIndex !== false && $nsIndex !== NS_PROJECT ) {
770 $this->parent->showError( 'config-ns-conflict', $name );
771 $retVal = false;
772 }
773
774 $this->setVar( 'wgMetaNamespace', $name );
775
776 // Validate username for creation
777 $name = $this->getVar( '_AdminName' );
778 if ( strval( $name ) === '' ) {
779 $this->parent->showError( 'config-admin-name-blank' );
780 $cname = $name;
781 $retVal = false;
782 } else {
783 $cname = User::getCanonicalName( $name, 'creatable' );
784 if ( $cname === false ) {
785 $this->parent->showError( 'config-admin-name-invalid', $name );
786 $retVal = false;
787 } else {
788 $this->setVar( '_AdminName', $cname );
789 }
790 }
791
792 // Validate password
793 $msg = false;
794 $pwd = $this->getVar( '_AdminPassword' );
795 $user = User::newFromName( $cname );
796 $valid = $user && $user->getPasswordValidity( $pwd );
797 if ( strval( $pwd ) === '' ) {
798 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
799 # This message is more specific and helpful.
800 $msg = 'config-admin-password-blank';
801 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
802 $msg = 'config-admin-password-mismatch';
803 } elseif ( $valid !== true ) {
804 # As of writing this will only catch the username being e.g. 'FOO' and
805 # the password 'foo'
806 $msg = $valid;
807 }
808 if ( $msg !== false ) {
809 call_user_func_array( array( $this->parent, 'showError' ), (array)$msg );
810 $this->setVar( '_AdminPassword', '' );
811 $this->setVar( '_AdminPassword2', '' );
812 $retVal = false;
813 }
814
815 // Validate e-mail if provided
816 $email = $this->getVar( '_AdminEmail' );
817 if ( $email && !Sanitizer::validateEmail( $email ) ) {
818 $this->parent->showError( 'config-admin-error-bademail' );
819 $retVal = false;
820 }
821 // If they asked to subscribe to mediawiki-announce but didn't give
822 // an e-mail, show an error. Bug 29332
823 if ( !$email && $this->getVar( '_Subscribe' ) ) {
824 $this->parent->showError( 'config-subscribe-noemail' );
825 $retVal = false;
826 }
827
828 return $retVal;
829 }
830
831 }
832
833 class WebInstaller_Options extends WebInstallerPage {
834
835 public function execute() {
836 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
837 return 'skip';
838 }
839 if ( $this->parent->request->wasPosted() ) {
840 if ( $this->submit() ) {
841 return 'continue';
842 }
843 }
844
845 $emailwrapperStyle = $this->getVar( 'wgEnableEmail' ) ? '' : 'display: none';
846 $this->startForm();
847 $this->addHTML(
848 # User Rights
849 // getRadioSet() builds a set of labeled radio buttons.
850 // For grep: The following messages are used as the item labels:
851 // config-profile-wiki, config-profile-no-anon, config-profile-fishbowl, config-profile-private
852 $this->parent->getRadioSet( array(
853 'var' => '_RightsProfile',
854 'label' => 'config-profile',
855 'itemLabelPrefix' => 'config-profile-',
856 'values' => array_keys( $this->parent->rightsProfiles ),
857 ) ) .
858 $this->parent->getInfoBox( wfMessage( 'config-profile-help' )->plain() ) .
859
860 # Licensing
861 // getRadioSet() builds a set of labeled radio buttons.
862 // For grep: The following messages are used as the item labels:
863 // config-license-cc-by, config-license-cc-by-sa, config-license-cc-by-nc-sa,
864 // config-license-cc-0, config-license-pd, config-license-gfdl,
865 // config-license-none, config-license-cc-choose
866 $this->parent->getRadioSet( array(
867 'var' => '_LicenseCode',
868 'label' => 'config-license',
869 'itemLabelPrefix' => 'config-license-',
870 'values' => array_keys( $this->parent->licenses ),
871 'commonAttribs' => array( 'class' => 'licenseRadio' ),
872 ) ) .
873 $this->getCCChooser() .
874 $this->parent->getHelpBox( 'config-license-help' ) .
875
876 # E-mail
877 $this->getFieldSetStart( 'config-email-settings' ) .
878 $this->parent->getCheckBox( array(
879 'var' => 'wgEnableEmail',
880 'label' => 'config-enable-email',
881 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
882 ) ) .
883 $this->parent->getHelpBox( 'config-enable-email-help' ) .
884 "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
885 $this->parent->getTextBox( array(
886 'var' => 'wgPasswordSender',
887 'label' => 'config-email-sender'
888 ) ) .
889 $this->parent->getHelpBox( 'config-email-sender-help' ) .
890 $this->parent->getCheckBox( array(
891 'var' => 'wgEnableUserEmail',
892 'label' => 'config-email-user',
893 ) ) .
894 $this->parent->getHelpBox( 'config-email-user-help' ) .
895 $this->parent->getCheckBox( array(
896 'var' => 'wgEnotifUserTalk',
897 'label' => 'config-email-usertalk',
898 ) ) .
899 $this->parent->getHelpBox( 'config-email-usertalk-help' ) .
900 $this->parent->getCheckBox( array(
901 'var' => 'wgEnotifWatchlist',
902 'label' => 'config-email-watchlist',
903 ) ) .
904 $this->parent->getHelpBox( 'config-email-watchlist-help' ) .
905 $this->parent->getCheckBox( array(
906 'var' => 'wgEmailAuthentication',
907 'label' => 'config-email-auth',
908 ) ) .
909 $this->parent->getHelpBox( 'config-email-auth-help' ) .
910 "</div>" .
911 $this->getFieldSetEnd()
912 );
913
914 $extensions = $this->parent->findExtensions();
915
916 if ( $extensions ) {
917 $extHtml = $this->getFieldSetStart( 'config-extensions' );
918
919 foreach ( $extensions as $ext ) {
920 $extHtml .= $this->parent->getCheckBox( array(
921 'var' => "ext-$ext",
922 'rawtext' => $ext,
923 ) );
924 }
925
926 $extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) .
927 $this->getFieldSetEnd();
928 $this->addHTML( $extHtml );
929 }
930
931 // Having / in paths in Windows looks funny :)
932 $this->setVar( 'wgDeletedDirectory',
933 str_replace(
934 '/', DIRECTORY_SEPARATOR,
935 $this->getVar( 'wgDeletedDirectory' )
936 )
937 );
938 // If we're using the default, let the user set it relative to $wgScriptPath
939 $curLogo = $this->getVar( 'wgLogo' );
940 $logoString = ( $curLogo == "/wiki/skins/common/images/wiki.png" ) ?
941 '$wgStylePath/common/images/wiki.png' : $curLogo;
942
943 $uploadwrapperStyle = $this->getVar( 'wgEnableUploads' ) ? '' : 'display: none';
944 $this->addHTML(
945 # Uploading
946 $this->getFieldSetStart( 'config-upload-settings' ) .
947 $this->parent->getCheckBox( array(
948 'var' => 'wgEnableUploads',
949 'label' => 'config-upload-enable',
950 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
951 'help' => $this->parent->getHelpBox( 'config-upload-help' )
952 ) ) .
953 '<div id="uploadwrapper" style="' . $uploadwrapperStyle . '">' .
954 $this->parent->getTextBox( array(
955 'var' => 'wgDeletedDirectory',
956 'label' => 'config-upload-deleted',
957 'attribs' => array( 'dir' => 'ltr' ),
958 'help' => $this->parent->getHelpBox( 'config-upload-deleted-help' )
959 ) ) .
960 '</div>' .
961 $this->parent->getTextBox( array(
962 'var' => 'wgLogo',
963 'value' => $logoString,
964 'label' => 'config-logo',
965 'attribs' => array( 'dir' => 'ltr' ),
966 'help' => $this->parent->getHelpBox( 'config-logo-help' )
967 ) )
968 );
969 $this->addHTML(
970 $this->parent->getCheckBox( array(
971 'var' => 'wgUseInstantCommons',
972 'label' => 'config-instantcommons',
973 'help' => $this->parent->getHelpBox( 'config-instantcommons-help' )
974 ) ) .
975 $this->getFieldSetEnd()
976 );
977
978 $caches = array( 'none' );
979 if ( count( $this->getVar( '_Caches' ) ) ) {
980 $caches[] = 'accel';
981 }
982 $caches[] = 'memcached';
983
984 // We'll hide/show this on demand when the value changes, see config.js.
985 $cacheval = $this->getVar( 'wgMainCacheType' );
986 if ( !$cacheval ) {
987 // We need to set a default here; but don't hardcode it
988 // or we lose it every time we reload the page for validation
989 // or going back!
990 $cacheval = 'none';
991 }
992 $hidden = ( $cacheval == 'memcached' ) ? '' : 'display: none';
993 $this->addHTML(
994 # Advanced settings
995 $this->getFieldSetStart( 'config-advanced-settings' ) .
996 # Object cache settings
997 // getRadioSet() builds a set of labeled radio buttons.
998 // For grep: The following messages are used as the item labels:
999 // config-cache-none, config-cache-accel, config-cache-memcached
1000 $this->parent->getRadioSet( array(
1001 'var' => 'wgMainCacheType',
1002 'label' => 'config-cache-options',
1003 'itemLabelPrefix' => 'config-cache-',
1004 'values' => $caches,
1005 'value' => $cacheval,
1006 ) ) .
1007 $this->parent->getHelpBox( 'config-cache-help' ) .
1008 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
1009 $this->parent->getTextArea( array(
1010 'var' => '_MemCachedServers',
1011 'label' => 'config-memcached-servers',
1012 'help' => $this->parent->getHelpBox( 'config-memcached-help' )
1013 ) ) .
1014 '</div>' .
1015 $this->getFieldSetEnd()
1016 );
1017 $this->endForm();
1018 }
1019
1020 /**
1021 * @return string
1022 */
1023 public function getCCPartnerUrl() {
1024 $server = $this->getVar( 'wgServer' );
1025 $exitUrl = $server . $this->parent->getUrl( array(
1026 'page' => 'Options',
1027 'SubmitCC' => 'indeed',
1028 'config__LicenseCode' => 'cc',
1029 'config_wgRightsUrl' => '[license_url]',
1030 'config_wgRightsText' => '[license_name]',
1031 'config_wgRightsIcon' => '[license_button]',
1032 ) );
1033 $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
1034 '/skins/common/config-cc.css';
1035 $iframeUrl = 'http://creativecommons.org/license/?' .
1036 wfArrayToCgi( array(
1037 'partner' => 'MediaWiki',
1038 'exit_url' => $exitUrl,
1039 'lang' => $this->getVar( '_UserLang' ),
1040 'stylesheet' => $styleUrl,
1041 ) );
1042 return $iframeUrl;
1043 }
1044
1045 public function getCCChooser() {
1046 $iframeAttribs = array(
1047 'class' => 'config-cc-iframe',
1048 'name' => 'config-cc-iframe',
1049 'id' => 'config-cc-iframe',
1050 'frameborder' => 0,
1051 'width' => '100%',
1052 'height' => '100%',
1053 );
1054 if ( $this->getVar( '_CCDone' ) ) {
1055 $iframeAttribs['src'] = $this->parent->getUrl( array( 'ShowCC' => 'yes' ) );
1056 } else {
1057 $iframeAttribs['src'] = $this->getCCPartnerUrl();
1058 }
1059 $wrapperStyle = ( $this->getVar( '_LicenseCode' ) == 'cc-choose' ) ? '' : 'display: none';
1060
1061 return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
1062 Html::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
1063 "</div>\n";
1064 }
1065
1066 public function getCCDoneBox() {
1067 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1068 // If you change this height, also change it in config.css
1069 $expandJs = str_replace( '$1', '54em', $js );
1070 $reduceJs = str_replace( '$1', '70px', $js );
1071 return '<p>' .
1072 Html::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
1073 '&#160;&#160;' .
1074 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
1075 "</p>\n" .
1076 "<p style=\"text-align: center\">" .
1077 Html::element( 'a',
1078 array(
1079 'href' => $this->getCCPartnerUrl(),
1080 'onclick' => $expandJs,
1081 ),
1082 wfMessage( 'config-cc-again' )->text()
1083 ) .
1084 "</p>\n" .
1085 "<script type=\"text/javascript\">\n" .
1086 # Reduce the wrapper div height
1087 htmlspecialchars( $reduceJs ) .
1088 "\n" .
1089 "</script>\n";
1090 }
1091
1092 public function submitCC() {
1093 $newValues = $this->parent->setVarsFromRequest(
1094 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
1095 if ( count( $newValues ) != 3 ) {
1096 $this->parent->showError( 'config-cc-error' );
1097 return;
1098 }
1099 $this->setVar( '_CCDone', true );
1100 $this->addHTML( $this->getCCDoneBox() );
1101 }
1102
1103 public function submit() {
1104 $this->parent->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
1105 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
1106 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
1107 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
1108 'wgUseInstantCommons' ) );
1109
1110 if ( !in_array( $this->getVar( '_RightsProfile' ),
1111 array_keys( $this->parent->rightsProfiles ) ) )
1112 {
1113 reset( $this->parent->rightsProfiles );
1114 $this->setVar( '_RightsProfile', key( $this->parent->rightsProfiles ) );
1115 }
1116
1117 $code = $this->getVar( '_LicenseCode' );
1118 if ( $code == 'cc-choose' ) {
1119 if ( !$this->getVar( '_CCDone' ) ) {
1120 $this->parent->showError( 'config-cc-not-chosen' );
1121 return false;
1122 }
1123 } elseif ( in_array( $code, array_keys( $this->parent->licenses ) ) ) {
1124 // Give grep a chance to find the usages:
1125 // config-license-cc-by, config-license-cc-by-sa, config-license-cc-by-nc-sa,
1126 // config-license-cc-0, config-license-pd, config-license-gfdl,
1127 // config-license-none, config-license-cc-choose
1128 $entry = $this->parent->licenses[$code];
1129 if ( isset( $entry['text'] ) ) {
1130 $this->setVar( 'wgRightsText', $entry['text'] );
1131 } else {
1132 $this->setVar( 'wgRightsText', wfMessage( 'config-license-' . $code )->text() );
1133 }
1134 $this->setVar( 'wgRightsUrl', $entry['url'] );
1135 $this->setVar( 'wgRightsIcon', $entry['icon'] );
1136 } else {
1137 $this->setVar( 'wgRightsText', '' );
1138 $this->setVar( 'wgRightsUrl', '' );
1139 $this->setVar( 'wgRightsIcon', '' );
1140 }
1141
1142 $extsAvailable = $this->parent->findExtensions();
1143 $extsToInstall = array();
1144 foreach ( $extsAvailable as $ext ) {
1145 if ( $this->parent->request->getCheck( 'config_ext-' . $ext ) ) {
1146 $extsToInstall[] = $ext;
1147 }
1148 }
1149 $this->parent->setVar( '_Extensions', $extsToInstall );
1150
1151 if ( $this->getVar( 'wgMainCacheType' ) == 'memcached' ) {
1152 $memcServers = explode( "\n", $this->getVar( '_MemCachedServers' ) );
1153 if ( !$memcServers ) {
1154 $this->parent->showError( 'config-memcache-needservers' );
1155 return false;
1156 }
1157
1158 foreach ( $memcServers as $server ) {
1159 $memcParts = explode( ":", $server, 2 );
1160 if ( !isset( $memcParts[0] )
1161 || ( !IP::isValid( $memcParts[0] )
1162 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) ) ) {
1163 $this->parent->showError( 'config-memcache-badip', $memcParts[0] );
1164 return false;
1165 } elseif ( !isset( $memcParts[1] ) ) {
1166 $this->parent->showError( 'config-memcache-noport', $memcParts[0] );
1167 return false;
1168 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
1169 $this->parent->showError( 'config-memcache-badport', 1, 65535 );
1170 return false;
1171 }
1172 }
1173 }
1174 return true;
1175 }
1176
1177 }
1178
1179 class WebInstaller_Install extends WebInstallerPage {
1180 public function isSlow() {
1181 return true;
1182 }
1183
1184 public function execute() {
1185 if ( $this->getVar( '_UpgradeDone' ) ) {
1186 return 'skip';
1187 } elseif ( $this->getVar( '_InstallDone' ) ) {
1188 return 'continue';
1189 } elseif ( $this->parent->request->wasPosted() ) {
1190 $this->startForm();
1191 $this->addHTML( "<ul>" );
1192 $results = $this->parent->performInstallation(
1193 array( $this, 'startStage' ),
1194 array( $this, 'endStage' )
1195 );
1196 $this->addHTML( "</ul>" );
1197 // PerformInstallation bails on a fatal, so make sure the last item
1198 // completed before giving 'next.' Likewise, only provide back on failure
1199 $lastStep = end( $results );
1200 $continue = $lastStep->isOK() ? 'continue' : false;
1201 $back = $lastStep->isOK() ? false : 'back';
1202 $this->endForm( $continue, $back );
1203 } else {
1204 $this->startForm();
1205 $this->addHTML( $this->parent->getInfoBox( wfMessage( 'config-install-begin' )->plain() ) );
1206 $this->endForm();
1207 }
1208 return true;
1209 }
1210
1211 public function startStage( $step ) {
1212 $this->addHTML( "<li>" . wfMessage( "config-install-$step" )->escaped() . wfMessage( 'ellipsis' )->escaped() );
1213 if ( $step == 'extension-tables' ) {
1214 $this->startLiveBox();
1215 }
1216 }
1217
1218 /**
1219 * @param $step
1220 * @param $status Status
1221 */
1222 public function endStage( $step, $status ) {
1223 if ( $step == 'extension-tables' ) {
1224 $this->endLiveBox();
1225 }
1226 $msg = $status->isOk() ? 'config-install-step-done' : 'config-install-step-failed';
1227 $html = wfMessage( 'word-separator' )->escaped() . wfMessage( $msg )->escaped();
1228 if ( !$status->isOk() ) {
1229 $html = "<span class=\"error\">$html</span>";
1230 }
1231 $this->addHTML( $html . "</li>\n" );
1232 if ( !$status->isGood() ) {
1233 $this->parent->showStatusBox( $status );
1234 }
1235 }
1236
1237 }
1238
1239 class WebInstaller_Complete extends WebInstallerPage {
1240
1241 public function execute() {
1242 // Pop up a dialog box, to make it difficult for the user to forget
1243 // to download the file
1244 $lsUrl = $this->getVar( 'wgServer' ) . $this->parent->getURL( array( 'localsettings' => 1 ) );
1245 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
1246 strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) {
1247 // JS appears the only method that works consistently with IE7+
1248 $this->addHtml( "\n<script type=\"" . $GLOBALS['wgJsMimeType'] .
1249 '">jQuery( document ).ready( function() { document.location=' .
1250 Xml::encodeJsVar( $lsUrl ) . "; } );</script>\n" );
1251 } else {
1252 $this->parent->request->response()->header( "Refresh: 0;url=$lsUrl" );
1253 }
1254
1255 $this->startForm();
1256 $this->parent->disableLinkPopups();
1257 $this->addHTML(
1258 $this->parent->getInfoBox(
1259 wfMessage( 'config-install-done',
1260 $lsUrl,
1261 $this->getVar( 'wgServer' ) .
1262 $this->getVar( 'wgScriptPath' ) . '/index' .
1263 $this->getVar( 'wgScriptExtension' ),
1264 '<downloadlink/>'
1265 )->plain(), 'tick-32.png'
1266 )
1267 );
1268 $this->parent->restoreLinkPopups();
1269 $this->endForm( false, false );
1270 }
1271 }
1272
1273 class WebInstaller_Restart extends WebInstallerPage {
1274
1275 public function execute() {
1276 $r = $this->parent->request;
1277 if ( $r->wasPosted() ) {
1278 $really = $r->getVal( 'submit-restart' );
1279 if ( $really ) {
1280 $this->parent->reset();
1281 }
1282 return 'continue';
1283 }
1284
1285 $this->startForm();
1286 $s = $this->parent->getWarningBox( wfMessage( 'config-help-restart' )->plain() );
1287 $this->addHTML( $s );
1288 $this->endForm( 'restart' );
1289 }
1290
1291 }
1292
1293 abstract class WebInstaller_Document extends WebInstallerPage {
1294
1295 abstract protected function getFileName();
1296
1297 public function execute() {
1298 $text = $this->getFileContents();
1299 $text = InstallDocFormatter::format( $text );
1300 $this->parent->output->addWikiText( $text );
1301 $this->startForm();
1302 $this->endForm( false );
1303 }
1304
1305 public function getFileContents() {
1306 $file = __DIR__ . '/../../' . $this->getFileName();
1307 if ( ! file_exists( $file ) ) {
1308 return wfMessage( 'config-nofile', $file )->plain();
1309 }
1310 return file_get_contents( $file );
1311 }
1312
1313 }
1314
1315 class WebInstaller_Readme extends WebInstaller_Document {
1316 protected function getFileName() {
1317 return 'README';
1318 }
1319 }
1320
1321 class WebInstaller_ReleaseNotes extends WebInstaller_Document {
1322 protected function getFileName() {
1323 global $wgVersion;
1324
1325 if ( !preg_match( '/^(\d+)\.(\d+).*/i', $wgVersion, $result ) ) {
1326 throw new MWException( 'Variable $wgVersion has an invalid value.' );
1327 }
1328
1329 return 'RELEASE-NOTES-' . $result[1] . '.' . $result[2];
1330 }
1331 }
1332
1333 class WebInstaller_UpgradeDoc extends WebInstaller_Document {
1334 protected function getFileName() {
1335 return 'UPGRADE';
1336 }
1337 }
1338
1339 class WebInstaller_Copying extends WebInstaller_Document {
1340 protected function getFileName() {
1341 return 'COPYING';
1342 }
1343 }