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', wfMsg( 'config-authors' ) ) );
208 class WebInstaller_DBConnect
extends WebInstallerPage
{
210 public function execute() {
211 $r = $this->parent
->request
;
212 if ( $r->wasPosted() ) {
213 $status = $this->submit();
214 if ( $status->isGood() ) {
215 $this->setVar( '_UpgradeDone', false );
218 $this->parent
->showStatusBox( $status );
224 $types = "<ul class=\"config-settings-block\">\n";
226 $defaultType = $this->getVar( 'wgDBtype' );
229 foreach( $this->parent
->getDBTypes() as $type ) {
230 $db = 'Database' . ucfirst( $type );
231 $dbSupport .= wfMsgNoTrans( "config-support-$type", $db::getSoftwareLink() ) . "\n";
233 $this->addHTML( $this->parent
->getInfoBox(
234 wfMsg( 'config-support-info', $dbSupport ) ) );
236 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
237 $installer = $this->parent
->getDBInstaller( $type );
241 $installer->getReadableName(),
245 $type == $defaultType,
246 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
251 Xml
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
252 Xml
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
253 $installer->getConnectForm() .
256 $types .= "</ul><br clear=\"left\"/>\n";
259 $this->parent
->label( 'config-db-type', false, $types ) .
266 public function submit() {
267 $r = $this->parent
->request
;
268 $type = $r->getVal( 'DBType' );
269 $this->setVar( 'wgDBtype', $type );
270 $installer = $this->parent
->getDBInstaller( $type );
272 return Status
::newFatal( 'config-invalid-db-type' );
274 return $installer->submitConnectForm();
279 class WebInstaller_Upgrade
extends WebInstallerPage
{
281 public function execute() {
282 if ( $this->getVar( '_UpgradeDone' ) ) {
283 if ( $this->parent
->request
->wasPosted() ) {
284 // Done message acknowledged
288 // Show the done message again
289 // Make them click back again if they want to do the upgrade again
290 $this->showDoneMessage();
295 // wgDBtype is generally valid here because otherwise the previous page
296 // (connect) wouldn't have declared its happiness
297 $type = $this->getVar( 'wgDBtype' );
298 $installer = $this->parent
->getDBInstaller( $type );
300 if ( !$installer->needsUpgrade() ) {
304 if ( $this->parent
->request
->wasPosted() ) {
305 $installer->preUpgrade();
307 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
308 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
309 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
311 $this->parent
->output
->flush();
312 $result = $installer->doUpgrade();
313 $this->addHTML( '</textarea>
314 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
315 $this->parent
->output
->flush();
317 $this->setVar( '_UpgradeDone', true );
318 $this->showDoneMessage();
324 $this->addHTML( $this->parent
->getInfoBox(
325 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
329 public function showDoneMessage() {
332 $this->parent
->getInfoBox(
333 wfMsgNoTrans( 'config-upgrade-done',
334 $GLOBALS['wgServer'] .
335 $this->getVar( 'wgScriptPath' ) . '/index' .
336 $this->getVar( 'wgScriptExtension' )
340 $this->endForm( 'regenerate' );
345 class WebInstaller_DBSettings
extends WebInstallerPage
{
347 public function execute() {
348 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
350 $r = $this->parent
->request
;
351 if ( $r->wasPosted() ) {
352 $status = $installer->submitSettingsForm();
353 if ( $status === false ) {
355 } elseif ( $status->isGood() ) {
358 $this->parent
->showStatusBox( $status );
362 $form = $installer->getSettingsForm();
363 if ( $form === false ) {
368 $this->addHTML( $form );
374 class WebInstaller_Name
extends WebInstallerPage
{
376 public function execute() {
377 $r = $this->parent
->request
;
378 if ( $r->wasPosted() ) {
379 if ( $this->submit() ) {
386 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
387 $this->setVar( 'wgSitename', '' );
390 // Set wgMetaNamespace to something valid before we show the form.
391 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
392 $metaNS = $this->getVar( 'wgMetaNamespace' );
393 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
396 $this->parent
->getTextBox( array(
397 'var' => 'wgSitename',
398 'label' => 'config-site-name',
400 $this->parent
->getHelpBox( 'config-site-name-help' ) .
401 $this->parent
->getRadioSet( array(
402 'var' => '_NamespaceType',
403 'label' => 'config-project-namespace',
404 'itemLabelPrefix' => 'config-ns-',
405 'values' => array( 'site-name', 'generic', 'other' ),
406 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
408 $this->parent
->getTextBox( array(
409 'var' => 'wgMetaNamespace',
411 'attribs' => array( 'disabled' => '' ),
413 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
414 $this->parent
->getFieldsetStart( 'config-admin-box' ) .
415 $this->parent
->getTextBox( array(
416 'var' => '_AdminName',
417 'label' => 'config-admin-name'
419 $this->parent
->getPasswordBox( array(
420 'var' => '_AdminPassword',
421 'label' => 'config-admin-password',
423 $this->parent
->getPasswordBox( array(
424 'var' => '_AdminPassword2',
425 'label' => 'config-admin-password-confirm'
427 $this->parent
->getHelpBox( 'config-admin-help' ) .
428 $this->parent
->getTextBox( array(
429 'var' => '_AdminEmail',
430 'label' => 'config-admin-email'
432 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
433 $this->parent
->getCheckBox( array(
434 'var' => '_Subscribe',
435 'label' => 'config-subscribe'
437 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
438 $this->parent
->getFieldsetEnd() .
439 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
440 $this->parent
->getRadioSet( array(
441 'var' => '_SkipOptional',
442 'itemLabelPrefix' => 'config-optional-',
443 'values' => array( 'continue', 'skip' )
447 // Restore the default value
448 $this->setVar( 'wgMetaNamespace', $metaNS );
454 public function submit() {
456 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
457 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
458 '_Subscribe', '_SkipOptional' ) );
460 // Validate site name
461 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
462 $this->parent
->showError( 'config-site-name-blank' );
467 $nsType = $this->getVar( '_NamespaceType' );
468 if ( $nsType == 'site-name' ) {
469 $name = $this->getVar( 'wgSitename' );
470 // Sanitize for namespace
471 // This algorithm should match the JS one in WebInstallerOutput.php
472 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
473 $name = str_replace( '&', '&', $name );
474 $name = preg_replace( '/__+/', '_', $name );
475 $name = ucfirst( trim( $name, '_' ) );
476 } elseif ( $nsType == 'generic' ) {
477 $name = wfMsg( 'config-ns-generic' );
479 $name = $this->getVar( 'wgMetaNamespace' );
482 // Validate namespace
483 if ( strpos( $name, ':' ) !== false ) {
486 // Title-style validation
487 $title = Title
::newFromText( $name );
489 $good = $nsType == 'site-name' ?
true : false;
491 $name = $title->getDBkey();
496 $this->parent
->showError( 'config-ns-invalid', $name );
499 $this->setVar( 'wgMetaNamespace', $name );
501 // Validate username for creation
502 $name = $this->getVar( '_AdminName' );
503 if ( strval( $name ) === '' ) {
504 $this->parent
->showError( 'config-admin-name-blank' );
508 $cname = User
::getCanonicalName( $name, 'creatable' );
509 if ( $cname === false ) {
510 $this->parent
->showError( 'config-admin-name-invalid', $name );
513 $this->setVar( '_AdminName', $cname );
519 $pwd = $this->getVar( '_AdminPassword' );
520 $user = User
::newFromName( $cname );
521 $valid = $user->getPasswordValidity( $pwd );
522 if ( strval( $pwd ) === '' ) {
523 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
524 # This message is more specific and helpful.
525 $msg = 'config-admin-password-blank';
526 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
527 $msg = 'config-admin-password-mismatch';
528 } elseif ( $valid !== true ) {
529 # As of writing this will only catch the username being e.g. 'FOO' and
533 if ( $msg !== false ) {
534 $this->parent
->showError( $msg );
535 $this->setVar( '_AdminPassword', '' );
536 $this->setVar( '_AdminPassword2', '' );
544 class WebInstaller_Options
extends WebInstallerPage
{
546 public function execute() {
547 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
550 if ( $this->parent
->request
->wasPosted() ) {
551 if ( $this->submit() ) {
559 $this->parent
->getRadioSet( array(
560 'var' => '_RightsProfile',
561 'label' => 'config-profile',
562 'itemLabelPrefix' => 'config-profile-',
563 'values' => array_keys( $this->parent
->rightsProfiles
),
565 $this->parent
->getHelpBox( 'config-profile-help' ) .
568 $this->parent
->getRadioSet( array(
569 'var' => '_LicenseCode',
570 'label' => 'config-license',
571 'itemLabelPrefix' => 'config-license-',
572 'values' => array_keys( $this->parent
->licenses
),
573 'commonAttribs' => array( 'class' => 'licenseRadio' ),
575 $this->getCCChooser() .
576 $this->parent
->getHelpBox( 'config-license-help' ) .
579 $this->parent
->getFieldsetStart( 'config-email-settings' ) .
580 $this->parent
->getCheckBox( array(
581 'var' => 'wgEnableEmail',
582 'label' => 'config-enable-email',
583 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
585 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
586 "<div id=\"emailwrapper\">" .
587 $this->parent
->getTextBox( array(
588 'var' => 'wgPasswordSender',
589 'label' => 'config-email-sender'
591 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
592 $this->parent
->getCheckBox( array(
593 'var' => 'wgEnableUserEmail',
594 'label' => 'config-email-user',
596 $this->parent
->getHelpBox( 'config-email-user-help' ) .
597 $this->parent
->getCheckBox( array(
598 'var' => 'wgEnotifUserTalk',
599 'label' => 'config-email-usertalk',
601 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
602 $this->parent
->getCheckBox( array(
603 'var' => 'wgEnotifWatchlist',
604 'label' => 'config-email-watchlist',
606 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
607 $this->parent
->getCheckBox( array(
608 'var' => 'wgEmailAuthentication',
609 'label' => 'config-email-auth',
611 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
613 $this->parent
->getFieldsetEnd()
616 $extensions = $this->parent
->findExtensions();
619 $extHtml = $this->parent
->getFieldsetStart( 'config-extensions' );
621 foreach( $extensions as $ext ) {
622 $extHtml .= $this->parent
->getCheckBox( array(
628 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
629 $this->parent
->getFieldsetEnd();
630 $this->addHTML( $extHtml );
635 $this->parent
->getFieldsetStart( 'config-upload-settings' ) .
636 $this->parent
->getCheckBox( array(
637 'var' => 'wgEnableUploads',
638 'label' => 'config-upload-enable',
639 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
641 $this->parent
->getHelpBox( 'config-upload-help' ) .
642 '<div id="uploadwrapper" style="display: none;">' .
643 $this->parent
->getTextBox( array(
644 'var' => 'wgDeletedDirectory',
645 'label' => 'config-upload-deleted',
647 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
649 $this->parent
->getTextBox( array(
651 'label' => 'config-logo'
653 $this->parent
->getHelpBox( 'config-logo-help' )
655 $canUse = $this->getVar( '_ExternalHTTP' ) ?
656 'config-instantcommons-good' : 'config-instantcommons-bad';
658 $this->parent
->getCheckBox( array(
659 'var' => 'wgUseInstantCommons',
660 'label' => 'config-instantcommons',
662 $this->parent
->getHelpBox( 'config-instantcommons-help', wfMsgNoTrans( $canUse ) ) .
663 $this->parent
->getFieldsetEnd()
666 $caches = array( 'none' );
667 if( count( $this->getVar( '_Caches' ) ) ) {
670 $caches[] = 'memcached';
674 $this->parent
->getFieldsetStart( 'config-advanced-settings' ) .
675 # Object cache settings
676 $this->parent
->getRadioSet( array(
677 'var' => 'wgMainCacheType',
678 'label' => 'config-cache-options',
679 'itemLabelPrefix' => 'config-cache-',
683 $this->parent
->getHelpBox( 'config-cache-help' ) .
684 '<div id="config-memcachewrapper">' .
685 $this->parent
->getTextBox( array(
686 'var' => '_MemCachedServers',
687 'label' => 'config-memcached-servers',
689 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
690 $this->parent
->getFieldsetEnd()
695 public function getCCPartnerUrl() {
697 $exitUrl = $wgServer . $this->parent
->getUrl( array(
699 'SubmitCC' => 'indeed',
700 'config__LicenseCode' => 'cc',
701 'config_wgRightsUrl' => '[license_url]',
702 'config_wgRightsText' => '[license_name]',
703 'config_wgRightsIcon' => '[license_button]',
705 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
706 '/skins/common/config-cc.css';
707 $iframeUrl = 'http://creativecommons.org/license/?' .
709 'partner' => 'MediaWiki',
710 'exit_url' => $exitUrl,
711 'lang' => $this->getVar( '_UserLang' ),
712 'stylesheet' => $styleUrl,
717 public function getCCChooser() {
718 $iframeAttribs = array(
719 'class' => 'config-cc-iframe',
720 'name' => 'config-cc-iframe',
721 'id' => 'config-cc-iframe',
726 if ( $this->getVar( '_CCDone' ) ) {
727 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
729 $iframeAttribs['src'] = $this->getCCPartnerUrl();
733 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
734 Xml
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
738 public function getCCDoneBox() {
739 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
740 // If you change this height, also change it in config.css
741 $expandJs = str_replace( '$1', '54em', $js );
742 $reduceJs = str_replace( '$1', '70px', $js );
745 Xml
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
747 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
749 "<p style=\"text-align: center\">" .
752 'href' => $this->getCCPartnerUrl(),
753 'onclick' => $expandJs,
755 wfMsg( 'config-cc-again' )
758 "<script type=\"text/javascript\">\n" .
759 # Reduce the wrapper div height
760 htmlspecialchars( $reduceJs ) .
765 public function submitCC() {
766 $newValues = $this->parent
->setVarsFromRequest(
767 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
768 if ( count( $newValues ) != 3 ) {
769 $this->parent
->showError( 'config-cc-error' );
772 $this->setVar( '_CCDone', true );
773 $this->addHTML( $this->getCCDoneBox() );
776 public function submit() {
777 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
778 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
779 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
780 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
781 'wgUseInstantCommons' ) );
783 if ( !in_array( $this->getVar( '_RightsProfile' ),
784 array_keys( $this->parent
->rightsProfiles
) ) )
786 reset( $this->parent
->rightsProfiles
);
787 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
790 $code = $this->getVar( '_LicenseCode' );
791 if ( $code == 'cc-choose' ) {
792 if ( !$this->getVar( '_CCDone' ) ) {
793 $this->parent
->showError( 'config-cc-not-chosen' );
796 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
797 $entry = $this->parent
->licenses
[$code];
798 if ( isset( $entry['text'] ) ) {
799 $this->setVar( 'wgRightsText', $entry['text'] );
801 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
803 $this->setVar( 'wgRightsUrl', $entry['url'] );
804 $this->setVar( 'wgRightsIcon', $entry['icon'] );
806 $this->setVar( 'wgRightsText', '' );
807 $this->setVar( 'wgRightsUrl', '' );
808 $this->setVar( 'wgRightsIcon', '' );
811 $extsAvailable = $this->parent
->findExtensions();
812 $extsToInstall = array();
813 foreach( $extsAvailable as $ext ) {
814 if( $this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
815 $extsToInstall[] = $ext;
818 $this->parent
->setVar( '_Extensions', $extsToInstall );
824 class WebInstaller_Install
extends WebInstallerPage
{
826 public function execute() {
827 if( $this->parent
->request
->wasPosted() ) {
829 } elseif( $this->getVar( '_InstallDone' ) ) {
831 $status = new Status();
832 $status->warning( 'config-install-alreadydone' );
833 $this->parent
->showStatusBox( $status );
834 } elseif( $this->getVar( '_UpgradeDone' ) ) {
838 $this->addHTML("<ul>");
839 $this->parent
->performInstallation(
840 array( $this, 'startStage'),
841 array( $this, 'endStage' )
843 $this->addHTML("</ul>");
849 public function startStage( $step ) {
850 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
853 public function endStage( $step, $status ) {
854 $msg = $status->isOk() ?
'config-install-step-done' : 'config-install-step-failed';
855 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
856 if ( !$status->isOk() ) {
857 $html = "<span class=\"error\">$html</span>";
859 $this->addHTML( $html . "</li>\n" );
860 if( !$status->isGood() ) {
861 $this->parent
->showStatusBox( $status );
867 class WebInstaller_Complete
extends WebInstallerPage
{
869 public function execute() {
872 $this->parent
->getInfoBox(
873 wfMsgNoTrans( 'config-install-done',
874 $GLOBALS['wgServer'] . $this->parent
->getURL( array( 'localsettings' => 1 ) ),
875 $GLOBALS['wgServer'] .
876 $this->getVar( 'wgScriptPath' ) . '/index' .
877 $this->getVar( 'wgScriptExtension' )
881 $this->endForm( false );
885 class WebInstaller_Restart
extends WebInstallerPage
{
887 public function execute() {
888 $r = $this->parent
->request
;
889 if ( $r->wasPosted() ) {
890 $really = $r->getVal( 'submit-restart' );
892 $this->parent
->session
= array();
893 $this->parent
->happyPages
= array();
894 $this->parent
->settings
= array();
900 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
901 $this->addHTML( $s );
902 $this->endForm( 'restart' );
907 abstract class WebInstaller_Document
extends WebInstallerPage
{
909 protected abstract function getFileName();
911 public function execute() {
912 $text = $this->getFileContents();
913 $this->parent
->output
->addWikiText( $text );
915 $this->endForm( false );
918 public function getFileContents() {
919 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
922 protected function formatTextFile( $text ) {
923 $text = str_replace( array( '<', '{{', '[[' ),
924 array( '<', '{{', '[[' ), $text );
925 // replace numbering with [1], [2], etc with MW-style numbering
926 $text = preg_replace( "/\r?\n(\r?\n)?\\[\\d+\\]/m", "\\1#", $text );
927 // join word-wrapped lines into one
930 $text = preg_replace( "/\n([\\*#])([^\r\n]*?)\r?\n([^\r\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
931 } while ( $text != $prev );
932 // turn (bug nnnn) into links
933 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
934 // add links to manual to every global variable mentioned
935 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
936 // special case for <pre> - formatted links
939 $text = preg_replace( '/^([^\\s].*?)\r?\n[\\s]+(https?:\/\/)/m', "\\1\n:\\2", $text );
940 } while ( $text != $prev );
944 private function replaceBugLinks( $matches ) {
945 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
946 $matches[1] . ' bug ' . $matches[1] . ']</span>';
949 private function replaceConfigLinks( $matches ) {
950 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
951 $matches[1] . ' ' . $matches[1] . ']</span>';
956 class WebInstaller_Readme
extends WebInstaller_Document
{
958 protected function getFileName() { return 'README'; }
960 public function getFileContents() {
961 return $this->formatTextFile( parent
::getFileContents() );
966 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
968 protected function getFileName() { return 'RELEASE-NOTES'; }
970 public function getFileContents() {
971 return $this->formatTextFile( parent
::getFileContents() );
976 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
978 protected function getFileName() { return 'UPGRADE'; }
980 public function getFileContents() {
981 return $this->formatTextFile( parent
::getFileContents() );
986 class WebInstaller_Copying
extends WebInstaller_Document
{
988 protected function getFileName() { return 'COPYING'; }
990 public function getFileContents() {
991 $text = parent
::getFileContents();
992 $text = str_replace( "\x0C", '', $text );
993 $text = preg_replace_callback( '/\n[ \t]+/m', array( 'WebInstaller_Copying', 'replaceLeadingSpaces' ), $text );
994 $text = '<tt>' . nl2br( $text ) . '</tt>';
998 private static function replaceLeadingSpaces( $matches ) {
999 return "\n" . str_repeat( ' ', strlen( $matches[0] ) );