4 * Abstract class to define pages for the web installer.
6 abstract class WebInstallerPage
{
9 * The WebInstaller object this WebInstallerPage belongs to.
15 public abstract function execute();
20 * @param WebInstaller $parent
22 public function __construct( WebInstaller
$parent ) {
23 $this->parent
= $parent;
26 public function addHTML( $html ) {
27 $this->parent
->output
->addHTML( $html );
30 public function startForm() {
32 "<div class=\"config-section\">\n" .
37 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
43 public function endForm( $continue = 'continue' ) {
44 $this->parent
->output
->outputWarnings();
45 $s = "<div class=\"config-submit\">\n";
48 if ( $id === false ) {
49 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
53 // Fake submit button for enter keypress
54 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
55 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
59 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
61 'name' => 'submit-back',
62 'tabindex' => $this->parent
->nextTabIndex()
67 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
69 'name' => "submit-$continue",
70 'tabindex' => $this->parent
->nextTabIndex(),
74 $s .= "</div></form></div>\n";
78 public function getName() {
79 return str_replace( 'WebInstaller_', '', get_class( $this ) );
82 public function getId() {
83 return array_search( $this->getName(), $this->parent
->pageSequence
);
86 public function getVar( $var ) {
87 return $this->parent
->getVar( $var );
90 public function setVar( $name, $value ) {
91 $this->parent
->setVar( $name, $value );
96 class WebInstaller_Language
extends WebInstallerPage
{
98 public function execute() {
100 $r = $this->parent
->request
;
101 $userLang = $r->getVal( 'UserLang' );
102 $contLang = $r->getVal( 'ContLang' );
104 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
106 $lifetime = 1440; // PHP default
109 if ( $r->wasPosted() ) {
111 if ( $this->parent
->getSession( 'test' ) === null ) {
112 $requestTime = $r->getVal( 'LanguageRequestTime' );
113 if ( !$requestTime ) {
114 // The most likely explanation is that the user was knocked back
115 // from another page on POST due to session expiry
116 $msg = 'config-session-expired';
117 } elseif ( time() - $requestTime > $lifetime ) {
118 $msg = 'config-session-expired';
120 $msg = 'config-no-session';
122 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
124 $languages = Language
::getLanguageNames();
125 if ( isset( $languages[$userLang] ) ) {
126 $this->setVar( '_UserLang', $userLang );
128 if ( isset( $languages[$contLang] ) ) {
129 $this->setVar( 'wgLanguageCode', $contLang );
133 } elseif ( $this->parent
->showSessionWarning
) {
134 # The user was knocked back from another page to the start
135 # This probably indicates a session expiry
136 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
139 $this->parent
->setSession( 'test', true );
141 if ( !isset( $languages[$userLang] ) ) {
142 $userLang = $this->getVar( '_UserLang', 'en' );
144 if ( !isset( $languages[$contLang] ) ) {
145 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
149 Xml
::hidden( 'LanguageRequestTime', time() ) .
150 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
151 $this->parent
->getHelpBox( 'config-your-language-help' ) .
152 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
153 $this->parent
->getHelpBox( 'config-wiki-language-help' );
156 $this->addHTML( $s );
161 * Get a <select> for selecting languages.
163 public function getLanguageSelector( $name, $label, $selectedCode ) {
164 global $wgDummyLanguageCodes;
165 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
167 $languages = Language
::getLanguageNames();
169 $dummies = array_flip( $wgDummyLanguageCodes );
170 foreach ( $languages as $code => $lang ) {
171 if ( isset( $dummies[$code] ) ) continue;
172 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
174 $s .= "\n</select>\n";
175 return $this->parent
->label( $label, $name, $s );
180 class WebInstaller_Welcome
extends WebInstallerPage
{
182 public function execute() {
183 if ( $this->parent
->request
->wasPosted() ) {
184 if ( $this->getVar( '_Environment' ) ) {
188 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
189 $status = $this->parent
->doEnvironmentChecks();
191 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright', wfMsg( 'config-authors' ) ) );
199 class WebInstaller_DBConnect
extends WebInstallerPage
{
201 public function execute() {
202 $r = $this->parent
->request
;
203 if ( $r->wasPosted() ) {
204 $status = $this->submit();
205 if ( $status->isGood() ) {
206 $this->setVar( '_UpgradeDone', false );
209 $this->parent
->showStatusBox( $status );
215 $types = "<ul class=\"config-settings-block\">\n";
217 $defaultType = $this->getVar( 'wgDBtype' );
218 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
219 $installer = $this->parent
->getDBInstaller( $type );
223 $installer->getReadableName(),
227 $type == $defaultType,
228 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
233 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
234 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
235 $installer->getConnectForm() .
238 $types .= "</ul><br clear=\"left\"/>\n";
241 $this->parent
->label( 'config-db-type', false, $types ) .
248 public function submit() {
249 $r = $this->parent
->request
;
250 $type = $r->getVal( 'DBType' );
251 $this->setVar( 'wgDBtype', $type );
252 $installer = $this->parent
->getDBInstaller( $type );
254 return Status
::newFatal( 'config-invalid-db-type' );
256 return $installer->submitConnectForm();
261 class WebInstaller_Upgrade
extends WebInstallerPage
{
263 public function execute() {
264 if ( $this->getVar( '_UpgradeDone' ) ) {
265 if ( $this->parent
->request
->wasPosted() ) {
266 // Done message acknowledged
270 // Show the done message again
271 // Make them click back again if they want to do the upgrade again
272 $this->showDoneMessage();
277 // wgDBtype is generally valid here because otherwise the previous page
278 // (connect) wouldn't have declared its happiness
279 $type = $this->getVar( 'wgDBtype' );
280 $installer = $this->parent
->getDBInstaller( $type );
282 if ( !$installer->needsUpgrade() ) {
286 if ( $this->parent
->request
->wasPosted() ) {
288 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
289 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
290 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
292 $this->parent
->output
->flush();
293 $result = $installer->doUpgrade();
294 $this->addHTML( '</textarea>
295 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
296 $this->parent
->output
->flush();
298 $this->setVar( '_UpgradeDone', true );
299 $this->showDoneMessage();
305 $this->addHTML( $this->parent
->getInfoBox(
306 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
310 public function showDoneMessage() {
313 $this->parent
->getInfoBox(
314 wfMsgNoTrans( 'config-upgrade-done',
315 $GLOBALS['wgServer'] .
316 $this->getVar( 'wgScriptPath' ) . '/index' .
317 $this->getVar( 'wgScriptExtension' )
321 $this->endForm( 'regenerate' );
326 class WebInstaller_DBSettings
extends WebInstallerPage
{
328 public function execute() {
329 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
331 $r = $this->parent
->request
;
332 if ( $r->wasPosted() ) {
333 $status = $installer->submitSettingsForm();
334 if ( $status === false ) {
336 } elseif ( $status->isGood() ) {
339 $this->parent
->showStatusBox( $status );
343 $form = $installer->getSettingsForm();
344 if ( $form === false ) {
349 $this->addHTML( $form );
355 class WebInstaller_Name
extends WebInstallerPage
{
357 public function execute() {
358 $r = $this->parent
->request
;
359 if ( $r->wasPosted() ) {
360 if ( $this->submit() ) {
367 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
368 $this->setVar( 'wgSitename', '' );
371 // Set wgMetaNamespace to something valid before we show the form.
372 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
373 $metaNS = $this->getVar( 'wgMetaNamespace' );
374 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
377 $this->parent
->getTextBox( array(
378 'var' => 'wgSitename',
379 'label' => 'config-site-name',
381 $this->parent
->getHelpBox( 'config-site-name-help' ) .
382 $this->parent
->getRadioSet( array(
383 'var' => '_NamespaceType',
384 'label' => 'config-project-namespace',
385 'itemLabelPrefix' => 'config-ns-',
386 'values' => array( 'site-name', 'generic', 'other' ),
387 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
389 $this->parent
->getTextBox( array(
390 'var' => 'wgMetaNamespace',
392 'attribs' => array( 'disabled' => '' ),
394 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
395 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
396 $this->parent
->getTextBox( array(
397 'var' => '_AdminName',
398 'label' => 'config-admin-name'
400 $this->parent
->getPasswordBox( array(
401 'var' => '_AdminPassword',
402 'label' => 'config-admin-password',
404 $this->parent
->getPasswordBox( array(
405 'var' => '_AdminPassword2',
406 'label' => 'config-admin-password-confirm'
408 $this->parent
->getHelpBox( 'config-admin-help' ) .
409 $this->parent
->getTextBox( array(
410 'var' => '_AdminEmail',
411 'label' => 'config-admin-email'
413 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
414 $this->parent
->getCheckBox( array(
415 'var' => '_Subscribe',
416 'label' => 'config-subscribe'
418 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
419 $this->parent
->getFieldsetEnd() .
420 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
421 $this->parent
->getRadioSet( array(
422 'var' => '_SkipOptional',
423 'itemLabelPrefix' => 'config-optional-',
424 'values' => array( 'continue', 'skip' )
428 // Restore the default value
429 $this->setVar( 'wgMetaNamespace', $metaNS );
435 public function submit() {
437 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
438 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
439 '_Subscribe', '_SkipOptional' ) );
441 // Validate site name
442 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
443 $this->parent
->showError( 'config-site-name-blank' );
448 $nsType = $this->getVar( '_NamespaceType' );
449 if ( $nsType == 'site-name' ) {
450 $name = $this->getVar( 'wgSitename' );
451 // Sanitize for namespace
452 // This algorithm should match the JS one in WebInstallerOutput.php
453 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
454 $name = str_replace( '&', '&', $name );
455 $name = preg_replace( '/__+/', '_', $name );
456 $name = ucfirst( trim( $name, '_' ) );
457 } elseif ( $nsType == 'generic' ) {
458 $name = wfMsg( 'config-ns-generic' );
460 $name = $this->getVar( 'wgMetaNamespace' );
463 // Validate namespace
464 if ( strpos( $name, ':' ) !== false ) {
467 // Title-style validation
468 $title = Title
::newFromText( $name );
470 $good = $nsType == 'site-name' ?
true : false;
472 $name = $title->getDBkey();
477 $this->parent
->showError( 'config-ns-invalid', $name );
480 $this->setVar( 'wgMetaNamespace', $name );
482 // Validate username for creation
483 $name = $this->getVar( '_AdminName' );
484 if ( strval( $name ) === '' ) {
485 $this->parent
->showError( 'config-admin-name-blank' );
489 $cname = User
::getCanonicalName( $name, 'creatable' );
490 if ( $cname === false ) {
491 $this->parent
->showError( 'config-admin-name-invalid', $name );
494 $this->setVar( '_AdminName', $cname );
500 $pwd = $this->getVar( '_AdminPassword' );
501 $user = User
::newFromName( $cname );
502 $valid = $user->getPasswordValidity( $pwd );
503 if ( strval( $pwd ) === '' ) {
504 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
505 # This message is more specific and helpful.
506 $msg = 'config-admin-password-blank';
507 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
508 $msg = 'config-admin-password-mismatch';
509 } elseif ( $valid !== true ) {
510 # As of writing this will only catch the username being e.g. 'FOO' and
514 if ( $msg !== false ) {
515 $this->parent
->showError( $msg );
516 $this->setVar( '_AdminPassword', '' );
517 $this->setVar( '_AdminPassword2', '' );
525 class WebInstaller_Options
extends WebInstallerPage
{
527 public function execute() {
528 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
531 if ( $this->parent
->request
->wasPosted() ) {
532 if ( $this->submit() ) {
540 $this->parent
->getRadioSet( array(
541 'var' => '_RightsProfile',
542 'label' => 'config-profile',
543 'itemLabelPrefix' => 'config-profile-',
544 'values' => array_keys( $this->parent
->rightsProfiles
),
546 $this->parent
->getHelpBox( 'config-profile-help' ) .
549 $this->parent
->getRadioSet( array(
550 'var' => '_LicenseCode',
551 'label' => 'config-license',
552 'itemLabelPrefix' => 'config-license-',
553 'values' => array_keys( $this->parent
->licenses
),
554 'commonAttribs' => array( 'class' => 'licenseRadio' ),
556 $this->getCCChooser() .
557 $this->parent
->getHelpBox( 'config-license-help' ) .
560 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
561 $this->parent
->getCheckBox( array(
562 'var' => 'wgEnableEmail',
563 'label' => 'config-enable-email',
564 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
566 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
567 "<div id=\"emailwrapper\">" .
568 $this->parent
->getTextBox( array(
569 'var' => 'wgPasswordSender',
570 'label' => 'config-email-sender'
572 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
573 $this->parent
->getCheckBox( array(
574 'var' => 'wgEnableUserEmail',
575 'label' => 'config-email-user',
577 $this->parent
->getHelpBox( 'config-email-user-help' ) .
578 $this->parent
->getCheckBox( array(
579 'var' => 'wgEnotifUserTalk',
580 'label' => 'config-email-usertalk',
582 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
583 $this->parent
->getCheckBox( array(
584 'var' => 'wgEnotifWatchlist',
585 'label' => 'config-email-watchlist',
587 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
588 $this->parent
->getCheckBox( array(
589 'var' => 'wgEmailAuthentication',
590 'label' => 'config-email-auth',
592 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
594 $this->parent
->getFieldsetEnd()
597 $extensions = $this->parent
->findExtensions();
599 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
600 foreach( array_keys($extensions) as $ext ) {
601 $extHtml .= $this->parent
->getCheckBox( array(
606 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
607 $this->parent
->getFieldsetEnd();
608 $this->addHTML( $extHtml );
613 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
614 $this->parent
->getCheckBox( array(
615 'var' => 'wgEnableUploads',
616 'label' => 'config-upload-enable',
617 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
619 $this->parent
->getHelpBox( 'config-upload-help' ) .
620 '<div id="uploadwrapper" style="display: none;">' .
621 $this->parent
->getTextBox( array(
622 'var' => 'wgDeletedDirectory',
623 'label' => 'config-upload-deleted',
625 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
627 $this->parent
->getTextBox( array(
629 'label' => 'config-logo'
631 $this->parent
->getHelpBox( 'config-logo-help' )
633 $canUse = $this->getVar( '_ExternalHTTP' ) ?
634 'config-instantcommons-good' : 'config-instantcommons-bad';
636 $this->parent
->getCheckBox( array(
637 'var' => 'wgUseInstantCommons',
638 'label' => 'config-instantcommons',
640 $this->parent
->getHelpBox( 'config-instantcommons-help', wfMsgNoTrans( $canUse ) ) .
641 $this->parent
->getFieldsetEnd()
644 $caches = array( 'none' );
645 if( count( $this->getVar( '_Caches' ) ) ) {
648 $caches[] = 'memcached';
652 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
653 # Object cache settings
654 $this->parent
->getRadioSet( array(
655 'var' => 'wgMainCacheType',
656 'label' => 'config-cache-options',
657 'itemLabelPrefix' => 'config-cache-',
661 $this->parent
->getHelpBox( 'config-cache-help' ) .
662 '<div id="config-memcachewrapper">' .
663 $this->parent
->getTextBox( array(
664 'var' => '_MemCachedServers',
665 'label' => 'config-memcached-servers',
667 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
668 $this->parent
->getFieldsetEnd()
673 public function getCCPartnerUrl() {
675 $exitUrl = $wgServer . $this->parent
->getUrl( array(
677 'SubmitCC' => 'indeed',
678 'config__LicenseCode' => 'cc',
679 'config_wgRightsUrl' => '[license_url]',
680 'config_wgRightsText' => '[license_name]',
681 'config_wgRightsIcon' => '[license_button]',
683 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
684 '/skins/common/config-cc.css';
685 $iframeUrl = 'http://creativecommons.org/license/?' .
687 'partner' => 'MediaWiki',
688 'exit_url' => $exitUrl,
689 'lang' => $this->getVar( '_UserLang' ),
690 'stylesheet' => $styleUrl,
695 public function getCCChooser() {
696 $iframeAttribs = array(
697 'class' => 'config-cc-iframe',
698 'name' => 'config-cc-iframe',
699 'id' => 'config-cc-iframe',
704 if ( $this->getVar( '_CCDone' ) ) {
705 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
707 $iframeAttribs['src'] = $this->getCCPartnerUrl();
711 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
712 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
716 public function getCCDoneBox() {
717 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
718 // If you change this height, also change it in config.css
719 $expandJs = str_replace( '$1', '54em', $js );
720 $reduceJs = str_replace( '$1', '70px', $js );
723 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
725 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
727 "<p style=\"text-align: center\">" .
730 'href' => $this->getCCPartnerUrl(),
731 'onclick' => $expandJs,
733 wfMsg( 'config-cc-again' )
736 "<script type=\"text/javascript\">\n" .
737 # Reduce the wrapper div height
738 htmlspecialchars( $reduceJs ) .
743 public function submitCC() {
744 $newValues = $this->parent
->setVarsFromRequest(
745 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
746 if ( count( $newValues ) != 3 ) {
747 $this->parent
->showError( 'config-cc-error' );
750 $this->setVar( '_CCDone', true );
751 $this->addHTML( $this->getCCDoneBox() );
754 public function submit() {
755 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
756 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUpload', 'wgLogo',
757 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
758 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
759 'wgUseInstantCommons' ) );
761 if ( !in_array( $this->getVar( '_RightsProfile' ),
762 array_keys( $this->parent
->rightsProfiles
) ) )
764 reset( $this->parent
->rightsProfiles
);
765 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
768 $code = $this->getVar( '_LicenseCode' );
769 if ( $code == 'cc-choose' ) {
770 if ( !$this->getVar( '_CCDone' ) ) {
771 $this->parent
->showError( 'config-cc-not-chosen' );
774 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
775 $entry = $this->parent
->licenses
[$code];
776 if ( isset( $entry['text'] ) ) {
777 $this->setVar( 'wgRightsText', $entry['text'] );
779 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
781 $this->setVar( 'wgRightsUrl', $entry['url'] );
782 $this->setVar( 'wgRightsIcon', $entry['icon'] );
784 $this->setVar( 'wgRightsText', '' );
785 $this->setVar( 'wgRightsUrl', '' );
786 $this->setVar( 'wgRightsIcon', '' );
789 $exts = $this->parent
->getVar( '_Extensions' );
790 foreach( $exts as $key => $ext ) {
791 if( !$this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
792 unset( $exts[$key] );
795 $this->parent
->setVar( '_Extensions', $exts );
801 class WebInstaller_Install
extends WebInstallerPage
{
803 public function execute() {
804 if( $this->parent
->request
->wasPosted() ) {
806 } elseif( $this->getVar( '_InstallDone' ) ) {
808 $status = new Status();
809 $status->warning( 'config-install-alreadydone' );
810 $this->parent
->showStatusBox( $status );
813 $this->addHTML("<ul>");
814 $this->parent
->performInstallation(
815 array( $this, 'startStage'),
816 array( $this, 'endStage' )
818 $this->addHTML("</ul>");
824 public function startStage( $step ) {
825 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
828 public function endStage( $step, $status ) {
829 $success = $status->isGood();
830 $msg = $success ?
'config-install-step-done' : 'config-install-step-failed';
831 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
833 $html = "<span class=\"error\">$html</span>";
835 $this->addHTML( $html . "</li>\n" );
837 $this->parent
->showStatusBox( $status );
843 class WebInstaller_Complete
extends WebInstallerPage
{
845 public function execute() {
849 $this->parent
->getInfoBox(
850 wfMsgNoTrans( 'config-install-done',
851 $GLOBALS['wgServer'] . $this->parent
->getURL( array( 'localsettings' => 1 ) ),
852 $GLOBALS['wgServer'] .
853 $this->getVar( 'wgScriptPath' ) . '/index' .
854 $this->getVar( 'wgScriptExtension' )
858 $this->endForm( false );
862 class WebInstaller_Restart
extends WebInstallerPage
{
864 public function execute() {
865 $r = $this->parent
->request
;
866 if ( $r->wasPosted() ) {
867 $really = $r->getVal( 'submit-restart' );
869 $this->parent
->session
= array();
870 $this->parent
->happyPages
= array();
871 $this->parent
->settings
= array();
877 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
878 $this->addHTML( $s );
879 $this->endForm( 'restart' );
884 abstract class WebInstaller_Document
extends WebInstallerPage
{
886 protected abstract function getFileName();
888 public function execute() {
889 $text = $this->getFileContents();
890 $this->parent
->output
->addWikiText( $text );
892 $this->endForm( false );
895 public function getFileContents() {
896 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
899 protected function formatTextFile( $text ) {
900 $text = str_replace( array( '<', '{{', '[[' ),
901 array( '<', '{{', '[[' ), $text );
902 // replace numbering with [1], [2], etc with MW-style numbering
903 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
904 // join word-wrapped lines into one
907 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
908 } while ( $text != $prev );
909 // turn (bug nnnn) into links
910 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
911 // add links to manual to every global variable mentioned
912 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
913 // special case for <pre> - formatted links
916 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
917 } while ( $text != $prev );
921 private function replaceBugLinks( $matches ) {
922 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
923 $matches[1] . ' bug ' . $matches[1] . ']</span>';
926 private function replaceConfigLinks( $matches ) {
927 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
928 $matches[1] . ' ' . $matches[1] . ']</span>';
933 class WebInstaller_Readme
extends WebInstaller_Document
{
935 protected function getFileName() { return 'README'; }
937 public function getFileContents() {
938 return $this->formatTextFile( parent
::getFileContents() );
943 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
945 protected function getFileName() { return 'RELEASE-NOTES'; }
947 public function getFileContents() {
948 return $this->formatTextFile( parent
::getFileContents() );
953 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
955 protected function getFileName() { return 'UPGRADE'; }
957 public function getFileContents() {
958 return $this->formatTextFile( parent
::getFileContents() );
963 class WebInstaller_Copying
extends WebInstaller_Document
{
965 protected function getFileName() { return 'COPYING'; }
967 public function getFileContents() {
968 $text = parent
::getFileContents();
969 $text = str_replace( "\x0C", '', $text );
970 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
971 $text = '<tt>' . nl2br( $text ) . '</tt>';
975 private static function replaceLeadingSpaces( $matches ) {
976 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );