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