3 * Base code for web installer pages.
10 * Abstract class to define pages for the web installer.
15 abstract class WebInstallerPage
{
18 * The WebInstaller object this WebInstallerPage belongs to.
24 public abstract function execute();
29 * @param $parent WebInstaller
31 public function __construct( WebInstaller
$parent ) {
32 $this->parent
= $parent;
35 public function addHTML( $html ) {
36 $this->parent
->output
->addHTML( $html );
39 public function startForm() {
41 "<div class=\"config-section\">\n" .
46 'action' => $this->parent
->getUrl( array( 'page' => $this->getName() ) )
52 public function endForm( $continue = 'continue' ) {
53 $this->parent
->output
->outputWarnings();
54 $s = "<div class=\"config-submit\">\n";
57 if ( $id === false ) {
58 $s .= Xml
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
62 // Fake submit button for enter keypress
63 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
64 array( 'name' => "enter-$continue", 'style' => 'display:none' ) ) . "\n";
68 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
70 'name' => 'submit-back',
71 'tabindex' => $this->parent
->nextTabIndex()
76 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
78 'name' => "submit-$continue",
79 'tabindex' => $this->parent
->nextTabIndex(),
83 $s .= "</div></form></div>\n";
87 public function getName() {
88 return str_replace( 'WebInstaller_', '', get_class( $this ) );
91 public function getId() {
92 return array_search( $this->getName(), $this->parent
->pageSequence
);
95 public function getVar( $var ) {
96 return $this->parent
->getVar( $var );
99 public function setVar( $name, $value ) {
100 $this->parent
->setVar( $name, $value );
105 class WebInstaller_Language
extends WebInstallerPage
{
107 public function execute() {
109 $r = $this->parent
->request
;
110 $userLang = $r->getVal( 'UserLang' );
111 $contLang = $r->getVal( 'ContLang' );
113 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
115 $lifetime = 1440; // PHP default
118 if ( $r->wasPosted() ) {
120 if ( $this->parent
->getSession( 'test' ) === null ) {
121 $requestTime = $r->getVal( 'LanguageRequestTime' );
122 if ( !$requestTime ) {
123 // The most likely explanation is that the user was knocked back
124 // from another page on POST due to session expiry
125 $msg = 'config-session-expired';
126 } elseif ( time() - $requestTime > $lifetime ) {
127 $msg = 'config-session-expired';
129 $msg = 'config-no-session';
131 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
133 $languages = Language
::getLanguageNames();
134 if ( isset( $languages[$userLang] ) ) {
135 $this->setVar( '_UserLang', $userLang );
137 if ( isset( $languages[$contLang] ) ) {
138 $this->setVar( 'wgLanguageCode', $contLang );
142 } elseif ( $this->parent
->showSessionWarning
) {
143 # The user was knocked back from another page to the start
144 # This probably indicates a session expiry
145 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
148 $this->parent
->setSession( 'test', true );
150 if ( !isset( $languages[$userLang] ) ) {
151 $userLang = $this->getVar( '_UserLang', 'en' );
153 if ( !isset( $languages[$contLang] ) ) {
154 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
158 Xml
::hidden( 'LanguageRequestTime', time() ) .
159 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
160 $this->parent
->getHelpBox( 'config-your-language-help' ) .
161 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
162 $this->parent
->getHelpBox( 'config-wiki-language-help' );
165 $this->addHTML( $s );
170 * Get a <select> for selecting languages.
172 public function getLanguageSelector( $name, $label, $selectedCode ) {
173 global $wgDummyLanguageCodes;
174 $s = Xml
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
176 $languages = Language
::getLanguageNames();
178 $dummies = array_flip( $wgDummyLanguageCodes );
179 foreach ( $languages as $code => $lang ) {
180 if ( isset( $dummies[$code] ) ) continue;
181 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
183 $s .= "\n</select>\n";
184 return $this->parent
->label( $label, $name, $s );
189 class WebInstaller_Welcome
extends WebInstallerPage
{
191 public function execute() {
192 if ( $this->parent
->request
->wasPosted() ) {
193 if ( $this->getVar( '_Environment' ) ) {
197 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
198 $status = $this->parent
->doEnvironmentChecks();
200 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright',
201 SpecialVersion
::getCopyrightAndAuthorList() ) );
209 class WebInstaller_DBConnect
extends WebInstallerPage
{
211 public function execute() {
212 $r = $this->parent
->request
;
213 if ( $r->wasPosted() ) {
214 $status = $this->submit();
215 if ( $status->isGood() ) {
216 $this->setVar( '_UpgradeDone', false );
219 $this->parent
->showStatusBox( $status );
225 $types = "<ul class=\"config-settings-block\">\n";
227 $defaultType = $this->getVar( 'wgDBtype' );
230 foreach( $this->parent
->getDBTypes() as $type ) {
231 $db = 'Database' . ucfirst( $type );
232 $dbSupport .= wfMsgNoTrans( "config-support-$type",
233 call_user_func( array( $db, 'getSoftwareLink' ) ) ) . "\n";
235 $this->addHTML( $this->parent
->getInfoBox(
236 wfMsg( 'config-support-info', $dbSupport ) ) );
238 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
239 $installer = $this->parent
->getDBInstaller( $type );
243 $installer->getReadableName(),
247 $type == $defaultType,
248 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
253 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
254 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
255 $installer->getConnectForm() .
258 $types .= "</ul><br clear=\"left\"/>\n";
261 $this->parent
->label( 'config-db-type', false, $types ) .
268 public function submit() {
269 $r = $this->parent
->request
;
270 $type = $r->getVal( 'DBType' );
271 $this->setVar( 'wgDBtype', $type );
272 $installer = $this->parent
->getDBInstaller( $type );
274 return Status
::newFatal( 'config-invalid-db-type' );
276 return $installer->submitConnectForm();
281 class WebInstaller_Upgrade
extends WebInstallerPage
{
283 public function execute() {
284 if ( $this->getVar( '_UpgradeDone' ) ) {
285 if ( $this->parent
->request
->wasPosted() ) {
286 // Done message acknowledged
290 // Show the done message again
291 // Make them click back again if they want to do the upgrade again
292 $this->showDoneMessage();
297 // wgDBtype is generally valid here because otherwise the previous page
298 // (connect) wouldn't have declared its happiness
299 $type = $this->getVar( 'wgDBtype' );
300 $installer = $this->parent
->getDBInstaller( $type );
302 if ( !$installer->needsUpgrade() ) {
306 if ( $this->parent
->request
->wasPosted() ) {
307 $installer->preUpgrade();
309 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
310 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
311 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
313 $this->parent
->output
->flush();
314 $result = $installer->doUpgrade();
315 $this->addHTML( '</textarea>
316 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
317 $this->parent
->output
->flush();
319 $this->setVar( '_UpgradeDone', true );
320 $this->showDoneMessage();
326 $this->addHTML( $this->parent
->getInfoBox(
327 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
331 public function showDoneMessage() {
334 $this->parent
->getInfoBox(
335 wfMsgNoTrans( 'config-upgrade-done',
336 $GLOBALS['wgServer'] .
337 $this->getVar( 'wgScriptPath' ) . '/index' .
338 $this->getVar( 'wgScriptExtension' )
342 $this->endForm( 'regenerate' );
347 class WebInstaller_DBSettings
extends WebInstallerPage
{
349 public function execute() {
350 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
352 $r = $this->parent
->request
;
353 if ( $r->wasPosted() ) {
354 $status = $installer->submitSettingsForm();
355 if ( $status === false ) {
357 } elseif ( $status->isGood() ) {
360 $this->parent
->showStatusBox( $status );
364 $form = $installer->getSettingsForm();
365 if ( $form === false ) {
370 $this->addHTML( $form );
376 class WebInstaller_Name
extends WebInstallerPage
{
378 public function execute() {
379 $r = $this->parent
->request
;
380 if ( $r->wasPosted() ) {
381 if ( $this->submit() ) {
388 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
389 $this->setVar( 'wgSitename', '' );
392 // Set wgMetaNamespace to something valid before we show the form.
393 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
394 $metaNS = $this->getVar( 'wgMetaNamespace' );
395 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
398 $this->parent
->getTextBox( array(
399 'var' => 'wgSitename',
400 'label' => 'config-site-name',
402 $this->parent
->getHelpBox( 'config-site-name-help' ) .
403 $this->parent
->getRadioSet( array(
404 'var' => '_NamespaceType',
405 'label' => 'config-project-namespace',
406 'itemLabelPrefix' => 'config-ns-',
407 'values' => array( 'site-name', 'generic', 'other' ),
408 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
410 $this->parent
->getTextBox( array(
411 'var' => 'wgMetaNamespace',
413 'attribs' => array( 'disabled' => '' ),
415 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
416 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
417 $this->parent
->getTextBox( array(
418 'var' => '_AdminName',
419 'label' => 'config-admin-name'
421 $this->parent
->getPasswordBox( array(
422 'var' => '_AdminPassword',
423 'label' => 'config-admin-password',
425 $this->parent
->getPasswordBox( array(
426 'var' => '_AdminPassword2',
427 'label' => 'config-admin-password-confirm'
429 $this->parent
->getHelpBox( 'config-admin-help' ) .
430 $this->parent
->getTextBox( array(
431 'var' => '_AdminEmail',
432 'label' => 'config-admin-email'
434 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
435 $this->parent
->getCheckBox( array(
436 'var' => '_Subscribe',
437 'label' => 'config-subscribe'
439 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
440 $this->parent
->getFieldsetEnd() .
441 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
442 $this->parent
->getRadioSet( array(
443 'var' => '_SkipOptional',
444 'itemLabelPrefix' => 'config-optional-',
445 'values' => array( 'continue', 'skip' )
449 // Restore the default value
450 $this->setVar( 'wgMetaNamespace', $metaNS );
456 public function submit() {
458 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
459 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
460 '_Subscribe', '_SkipOptional' ) );
462 // Validate site name
463 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
464 $this->parent
->showError( 'config-site-name-blank' );
469 $nsType = $this->getVar( '_NamespaceType' );
470 if ( $nsType == 'site-name' ) {
471 $name = $this->getVar( 'wgSitename' );
472 // Sanitize for namespace
473 // This algorithm should match the JS one in WebInstallerOutput.php
474 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
475 $name = str_replace( '&', '&', $name );
476 $name = preg_replace( '/__+/', '_', $name );
477 $name = ucfirst( trim( $name, '_' ) );
478 } elseif ( $nsType == 'generic' ) {
479 $name = wfMsg( 'config-ns-generic' );
481 $name = $this->getVar( 'wgMetaNamespace' );
484 // Validate namespace
485 if ( strpos( $name, ':' ) !== false ) {
488 // Title-style validation
489 $title = Title
::newFromText( $name );
491 $good = $nsType == 'site-name';
493 $name = $title->getDBkey();
498 $this->parent
->showError( 'config-ns-invalid', $name );
501 $this->setVar( 'wgMetaNamespace', $name );
503 // Validate username for creation
504 $name = $this->getVar( '_AdminName' );
505 if ( strval( $name ) === '' ) {
506 $this->parent
->showError( 'config-admin-name-blank' );
510 $cname = User
::getCanonicalName( $name, 'creatable' );
511 if ( $cname === false ) {
512 $this->parent
->showError( 'config-admin-name-invalid', $name );
515 $this->setVar( '_AdminName', $cname );
521 $pwd = $this->getVar( '_AdminPassword' );
522 $user = User
::newFromName( $cname );
523 $valid = $user->getPasswordValidity( $pwd );
524 if ( strval( $pwd ) === '' ) {
525 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
526 # This message is more specific and helpful.
527 $msg = 'config-admin-password-blank';
528 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
529 $msg = 'config-admin-password-mismatch';
530 } elseif ( $valid !== true ) {
531 # As of writing this will only catch the username being e.g. 'FOO' and
535 if ( $msg !== false ) {
536 $this->parent
->showError( $msg );
537 $this->setVar( '_AdminPassword', '' );
538 $this->setVar( '_AdminPassword2', '' );
546 class WebInstaller_Options
extends WebInstallerPage
{
548 public function execute() {
549 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
552 if ( $this->parent
->request
->wasPosted() ) {
553 if ( $this->submit() ) {
561 $this->parent
->getRadioSet( array(
562 'var' => '_RightsProfile',
563 'label' => 'config-profile',
564 'itemLabelPrefix' => 'config-profile-',
565 'values' => array_keys( $this->parent
->rightsProfiles
),
567 $this->parent
->getHelpBox( 'config-profile-help' ) .
570 $this->parent
->getRadioSet( array(
571 'var' => '_LicenseCode',
572 'label' => 'config-license',
573 'itemLabelPrefix' => 'config-license-',
574 'values' => array_keys( $this->parent
->licenses
),
575 'commonAttribs' => array( 'class' => 'licenseRadio' ),
577 $this->getCCChooser() .
578 $this->parent
->getHelpBox( 'config-license-help' ) .
581 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
582 $this->parent
->getCheckBox( array(
583 'var' => 'wgEnableEmail',
584 'label' => 'config-enable-email',
585 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
587 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
588 "<div id=\"emailwrapper\">" .
589 $this->parent
->getTextBox( array(
590 'var' => 'wgPasswordSender',
591 'label' => 'config-email-sender'
593 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
594 $this->parent
->getCheckBox( array(
595 'var' => 'wgEnableUserEmail',
596 'label' => 'config-email-user',
598 $this->parent
->getHelpBox( 'config-email-user-help' ) .
599 $this->parent
->getCheckBox( array(
600 'var' => 'wgEnotifUserTalk',
601 'label' => 'config-email-usertalk',
603 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
604 $this->parent
->getCheckBox( array(
605 'var' => 'wgEnotifWatchlist',
606 'label' => 'config-email-watchlist',
608 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
609 $this->parent
->getCheckBox( array(
610 'var' => 'wgEmailAuthentication',
611 'label' => 'config-email-auth',
613 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
615 $this->parent
->getFieldsetEnd()
618 $extensions = $this->parent
->findExtensions();
621 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
623 foreach( $extensions as $ext ) {
624 $extHtml .= $this->parent
->getCheckBox( array(
630 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
631 $this->parent
->getFieldsetEnd();
632 $this->addHTML( $extHtml );
637 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
638 $this->parent
->getCheckBox( array(
639 'var' => 'wgEnableUploads',
640 'label' => 'config-upload-enable',
641 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
643 $this->parent
->getHelpBox( 'config-upload-help' ) .
644 '<div id="uploadwrapper" style="display: none;">' .
645 $this->parent
->getTextBox( array(
646 'var' => 'wgDeletedDirectory',
647 'label' => 'config-upload-deleted',
649 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
651 $this->parent
->getTextBox( array(
653 'label' => 'config-logo'
655 $this->parent
->getHelpBox( 'config-logo-help' )
657 $canUse = $this->getVar( '_ExternalHTTP' ) ?
658 'config-instantcommons-good' : 'config-instantcommons-bad';
660 $this->parent
->getCheckBox( array(
661 'var' => 'wgUseInstantCommons',
662 'label' => 'config-instantcommons',
664 $this->parent
->getHelpBox( 'config-instantcommons-help', wfMsgNoTrans( $canUse ) ) .
665 $this->parent
->getFieldsetEnd()
668 $caches = array( 'none' );
669 if( count( $this->getVar( '_Caches' ) ) ) {
672 $caches[] = 'memcached';
676 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
677 # Object cache settings
678 $this->parent
->getRadioSet( array(
679 'var' => 'wgMainCacheType',
680 'label' => 'config-cache-options',
681 'itemLabelPrefix' => 'config-cache-',
685 $this->parent
->getHelpBox( 'config-cache-help' ) .
686 '<div id="config-memcachewrapper">' .
687 $this->parent
->getTextBox( array(
688 'var' => '_MemCachedServers',
689 'label' => 'config-memcached-servers',
691 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
692 $this->parent
->getFieldsetEnd()
697 public function getCCPartnerUrl() {
699 $exitUrl = $wgServer . $this->parent
->getUrl( array(
701 'SubmitCC' => 'indeed',
702 'config__LicenseCode' => 'cc',
703 'config_wgRightsUrl' => '[license_url]',
704 'config_wgRightsText' => '[license_name]',
705 'config_wgRightsIcon' => '[license_button]',
707 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
708 '/skins/common/config-cc.css';
709 $iframeUrl = 'http://creativecommons.org/license/?' .
711 'partner' => 'MediaWiki',
712 'exit_url' => $exitUrl,
713 'lang' => $this->getVar( '_UserLang' ),
714 'stylesheet' => $styleUrl,
719 public function getCCChooser() {
720 $iframeAttribs = array(
721 'class' => 'config-cc-iframe',
722 'name' => 'config-cc-iframe',
723 'id' => 'config-cc-iframe',
728 if ( $this->getVar( '_CCDone' ) ) {
729 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
731 $iframeAttribs['src'] = $this->getCCPartnerUrl();
735 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
736 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
740 public function getCCDoneBox() {
741 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
742 // If you change this height, also change it in config.css
743 $expandJs = str_replace( '$1', '54em', $js );
744 $reduceJs = str_replace( '$1', '70px', $js );
747 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
749 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
751 "<p style=\"text-align: center\">" .
754 'href' => $this->getCCPartnerUrl(),
755 'onclick' => $expandJs,
757 wfMsg( 'config-cc-again' )
760 "<script type=\"text/javascript\">\n" .
761 # Reduce the wrapper div height
762 htmlspecialchars( $reduceJs ) .
767 public function submitCC() {
768 $newValues = $this->parent
->setVarsFromRequest(
769 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
770 if ( count( $newValues ) != 3 ) {
771 $this->parent
->showError( 'config-cc-error' );
774 $this->setVar( '_CCDone', true );
775 $this->addHTML( $this->getCCDoneBox() );
778 public function submit() {
779 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
780 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
781 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
782 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
783 'wgUseInstantCommons' ) );
785 if ( !in_array( $this->getVar( '_RightsProfile' ),
786 array_keys( $this->parent
->rightsProfiles
) ) )
788 reset( $this->parent
->rightsProfiles
);
789 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
792 $code = $this->getVar( '_LicenseCode' );
793 if ( $code == 'cc-choose' ) {
794 if ( !$this->getVar( '_CCDone' ) ) {
795 $this->parent
->showError( 'config-cc-not-chosen' );
798 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
799 $entry = $this->parent
->licenses
[$code];
800 if ( isset( $entry['text'] ) ) {
801 $this->setVar( 'wgRightsText', $entry['text'] );
803 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
805 $this->setVar( 'wgRightsUrl', $entry['url'] );
806 $this->setVar( 'wgRightsIcon', $entry['icon'] );
808 $this->setVar( 'wgRightsText', '' );
809 $this->setVar( 'wgRightsUrl', '' );
810 $this->setVar( 'wgRightsIcon', '' );
813 $extsAvailable = $this->parent
->findExtensions();
814 $extsToInstall = array();
815 foreach( $extsAvailable as $ext ) {
816 if( $this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
817 $extsToInstall[] = $ext;
820 $this->parent
->setVar( '_Extensions', $extsToInstall );
826 class WebInstaller_Install
extends WebInstallerPage
{
828 public function execute() {
829 if( $this->parent
->request
->wasPosted() ) {
831 } elseif( $this->getVar( '_InstallDone' ) ) {
833 $status = new Status();
834 $status->warning( 'config-install-alreadydone' );
835 $this->parent
->showStatusBox( $status );
836 } elseif( $this->getVar( '_UpgradeDone' ) ) {
840 $this->addHTML("<ul>");
841 $this->parent
->performInstallation(
842 array( $this, 'startStage'),
843 array( $this, 'endStage' )
845 $this->addHTML("</ul>");
851 public function startStage( $step ) {
852 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
855 public function endStage( $step, $status ) {
856 $msg = $status->isOk() ?
'config-install-step-done' : 'config-install-step-failed';
857 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
858 if ( !$status->isOk() ) {
859 $html = "<span class=\"error\">$html</span>";
861 $this->addHTML( $html . "</li>\n" );
862 if( !$status->isGood() ) {
863 $this->parent
->showStatusBox( $status );
869 class WebInstaller_Complete
extends WebInstallerPage
{
871 public function execute() {
874 $this->parent
->getInfoBox(
875 wfMsgNoTrans( 'config-install-done',
876 $GLOBALS['wgServer'] . $this->parent
->getURL( array( 'localsettings' => 1 ) ),
877 $GLOBALS['wgServer'] .
878 $this->getVar( 'wgScriptPath' ) . '/index' .
879 $this->getVar( 'wgScriptExtension' )
883 $this->endForm( false );
887 class WebInstaller_Restart
extends WebInstallerPage
{
889 public function execute() {
890 $r = $this->parent
->request
;
891 if ( $r->wasPosted() ) {
892 $really = $r->getVal( 'submit-restart' );
894 $this->parent
->session
= array();
895 $this->parent
->happyPages
= array();
896 $this->parent
->settings
= array();
902 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
903 $this->addHTML( $s );
904 $this->endForm( 'restart' );
909 abstract class WebInstaller_Document
extends WebInstallerPage
{
911 protected abstract function getFileName();
913 public function execute() {
914 $text = $this->getFileContents();
915 $this->parent
->output
->addWikiText( $text );
917 $this->endForm( false );
920 public function getFileContents() {
921 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
924 protected function formatTextFile( $text ) {
925 $text = str_replace( array( '<', '{{', '[[' ),
926 array( '<', '{{', '[[' ), $text );
927 // replace numbering with [1], [2], etc with MW-style numbering
928 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
929 // join word-wrapped lines into one
932 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
933 } while ( $text != $prev );
934 // turn (bug nnnn) into links
935 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
936 // add links to manual to every global variable mentioned
937 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
938 // special case for <pre> - formatted links
941 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
942 } while ( $text != $prev );
946 private function replaceBugLinks( $matches ) {
947 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
948 $matches[1] . ' bug ' . $matches[1] . ']</span>';
951 private function replaceConfigLinks( $matches ) {
952 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
953 $matches[1] . ' ' . $matches[1] . ']</span>';
958 class WebInstaller_Readme
extends WebInstaller_Document
{
960 protected function getFileName() { return 'README'; }
962 public function getFileContents() {
963 return $this->formatTextFile( parent
::getFileContents() );
968 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
970 protected function getFileName() { return 'RELEASE-NOTES'; }
972 public function getFileContents() {
973 return $this->formatTextFile( parent
::getFileContents() );
978 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
980 protected function getFileName() { return 'UPGRADE'; }
982 public function getFileContents() {
983 return $this->formatTextFile( parent
::getFileContents() );
988 class WebInstaller_Copying
extends WebInstaller_Document
{
990 protected function getFileName() { return 'COPYING'; }
992 public function getFileContents() {
993 $text = parent
::getFileContents();
994 $text = str_replace( "\x0C", '', $text );
995 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
996 $text = '<tt>' . nl2br( $text ) . '</tt>';
1000 private static function replaceLeadingSpaces( $matches ) {
1001 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );