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 $s = "<div class=\"config-submit\">\n";
56 if ( $id === false ) {
57 $s .= Html
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
61 // Fake submit button for enter keypress (bug 26267)
62 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
63 array( 'name' => "enter-$continue", 'style' => 'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n";
67 $s .= Xml
::submitButton( wfMsg( 'config-back' ),
69 'name' => 'submit-back',
70 'tabindex' => $this->parent
->nextTabIndex()
75 $s .= Xml
::submitButton( wfMsg( "config-$continue" ),
77 'name' => "submit-$continue",
78 'tabindex' => $this->parent
->nextTabIndex(),
82 $s .= "</div></form></div>\n";
86 public function getName() {
87 return str_replace( 'WebInstaller_', '', get_class( $this ) );
90 protected function getId() {
91 return array_search( $this->getName(), $this->parent
->pageSequence
);
94 public function getVar( $var ) {
95 return $this->parent
->getVar( $var );
98 public function setVar( $name, $value ) {
99 $this->parent
->setVar( $name, $value );
103 * Get the starting tags of a fieldset.
105 * @param $legend String: message name
107 protected function getFieldsetStart( $legend ) {
108 return "\n<fieldset><legend>" . wfMsgHtml( $legend ) . "</legend>\n";
112 * Get the end tag of a fieldset.
114 protected function getFieldsetEnd() {
115 return "</fieldset>\n";
119 class WebInstaller_Locked
extends WebInstallerPage
{
120 // The status of Installer::getLocalSettingsStatus()
123 public function setLocalSettingsStatus( Status
$s ) {
127 protected function getId() {
131 public function execute() {
132 $r = $this->parent
->request
;
133 if( !$r->wasPosted() ||
!$this->status
->isOK() ) {
137 $key = $r->getText( 'config_wpUpgradeKey' );
138 if( !$key ||
$key !== $this->getVar( '_UpgradeKey' ) ) {
139 $this->parent
->showError( 'config-localsettings-badkey' );
143 $this->setVar( '_LocalSettingsLocked', false );
150 * Display stuff to the end user
152 private function display() {
154 $this->parent
->showStatusBox( $this->status
);
156 if( $this->status
->isOK() && !$this->status
->isGood() ) {
157 $this->addHTML( "<br />" .
158 $this->parent
->getTextBox( array(
159 'var' => 'wpUpgradeKey',
160 'label' => 'config-localsettings-key',
163 $continue = 'continue';
165 $this->endForm( $continue );
169 class WebInstaller_Language
extends WebInstallerPage
{
171 public function execute() {
173 $r = $this->parent
->request
;
174 $userLang = $r->getVal( 'UserLang' );
175 $contLang = $r->getVal( 'ContLang' );
177 $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) );
179 $lifetime = 1440; // PHP default
182 if ( $r->wasPosted() ) {
184 if ( $this->parent
->getSession( 'test' ) === null ) {
185 $requestTime = $r->getVal( 'LanguageRequestTime' );
186 if ( !$requestTime ) {
187 // The most likely explanation is that the user was knocked back
188 // from another page on POST due to session expiry
189 $msg = 'config-session-expired';
190 } elseif ( time() - $requestTime > $lifetime ) {
191 $msg = 'config-session-expired';
193 $msg = 'config-no-session';
195 $this->parent
->showError( $msg, $wgLang->formatTimePeriod( $lifetime ) );
197 $languages = Language
::getLanguageNames();
198 if ( isset( $languages[$userLang] ) ) {
199 $this->setVar( '_UserLang', $userLang );
201 if ( isset( $languages[$contLang] ) ) {
202 $this->setVar( 'wgLanguageCode', $contLang );
204 $this->setVar( '_ExternalHTTP', $r->getBool( 'config__ExternalHTTP' ) );
207 } elseif ( $this->parent
->showSessionWarning
) {
208 # The user was knocked back from another page to the start
209 # This probably indicates a session expiry
210 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
213 $this->parent
->setSession( 'test', true );
215 if ( !isset( $languages[$userLang] ) ) {
216 $userLang = $this->getVar( '_UserLang', 'en' );
218 if ( !isset( $languages[$contLang] ) ) {
219 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
222 $s = Html
::hidden( 'LanguageRequestTime', time() ) .
223 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang ) .
224 $this->parent
->getHelpBox( 'config-your-language-help' ) .
225 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang ) .
226 $this->parent
->getHelpBox( 'config-wiki-language-help' ) .
227 $this->parent
->getCheckBox(
228 array( 'var' => '_ExternalHTTP', 'label' => 'config-allow-requests' )
229 ) . $this->parent
->getHelpBox( 'config-allow-requests-help' );
231 $this->addHTML( $s );
236 * Get a <select> for selecting languages.
238 public function getLanguageSelector( $name, $label, $selectedCode ) {
239 global $wgDummyLanguageCodes;
240 $s = Html
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
242 $languages = Language
::getLanguageNames();
244 $dummies = array_flip( $wgDummyLanguageCodes );
245 foreach ( $languages as $code => $lang ) {
246 if ( isset( $dummies[$code] ) ) continue;
247 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
249 $s .= "\n</select>\n";
250 return $this->parent
->label( $label, $name, $s );
255 class WebInstaller_Welcome
extends WebInstallerPage
{
257 public function execute() {
258 if ( $this->parent
->request
->wasPosted() ) {
259 if ( $this->getVar( '_Environment' ) ) {
263 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
264 $status = $this->parent
->doEnvironmentChecks();
266 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright',
267 SpecialVersion
::getCopyrightAndAuthorList() ) );
275 class WebInstaller_DBConnect
extends WebInstallerPage
{
277 public function execute() {
278 $r = $this->parent
->request
;
279 if ( $r->wasPosted() ) {
280 $status = $this->submit();
281 if ( $status->isGood() ) {
282 $this->setVar( '_UpgradeDone', false );
285 $this->parent
->showStatusBox( $status );
291 $types = "<ul class=\"config-settings-block\">\n";
293 $defaultType = $this->getVar( 'wgDBtype' );
296 foreach( $this->parent
->getDBTypes() as $type ) {
297 $db = 'Database' . ucfirst( $type );
298 $dbSupport .= wfMsgNoTrans( "config-support-$type",
299 call_user_func( array( $db, 'getSoftwareLink' ) ) ) . "\n";
301 $this->addHTML( $this->parent
->getInfoBox(
302 wfMsg( 'config-support-info', $dbSupport ) ) );
304 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
305 $installer = $this->parent
->getDBInstaller( $type );
309 $installer->getReadableName(),
313 $type == $defaultType,
314 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
319 Html
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
320 Html
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
321 $installer->getConnectForm() .
324 $types .= "</ul><br clear=\"left\"/>\n";
327 $this->parent
->label( 'config-db-type', false, $types ) .
334 public function submit() {
335 $r = $this->parent
->request
;
336 $type = $r->getVal( 'DBType' );
337 $this->setVar( 'wgDBtype', $type );
338 $installer = $this->parent
->getDBInstaller( $type );
340 return Status
::newFatal( 'config-invalid-db-type' );
342 return $installer->submitConnectForm();
347 class WebInstaller_Upgrade
extends WebInstallerPage
{
349 public function execute() {
350 if ( $this->getVar( '_UpgradeDone' ) ) {
351 if ( $this->parent
->request
->wasPosted() ) {
352 // Done message acknowledged
356 // Show the done message again
357 // Make them click back again if they want to do the upgrade again
358 $this->showDoneMessage();
363 // wgDBtype is generally valid here because otherwise the previous page
364 // (connect) wouldn't have declared its happiness
365 $type = $this->getVar( 'wgDBtype' );
366 $installer = $this->parent
->getDBInstaller( $type );
368 if ( !$installer->needsUpgrade() ) {
372 if ( $this->parent
->request
->wasPosted() ) {
373 $installer->preUpgrade();
375 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
376 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
377 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
379 $this->parent
->output
->flush();
380 $result = $installer->doUpgrade();
381 $this->addHTML( '</textarea>
382 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
383 $this->parent
->output
->flush();
385 $this->setVar( '_UpgradeDone', true );
386 $this->showDoneMessage();
392 $this->addHTML( $this->parent
->getInfoBox(
393 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
397 public function showDoneMessage() {
400 $this->parent
->getInfoBox(
401 wfMsgNoTrans( 'config-upgrade-done',
402 $GLOBALS['wgServer'] .
403 $this->getVar( 'wgScriptPath' ) . '/index' .
404 $this->getVar( 'wgScriptExtension' )
408 $this->endForm( 'regenerate' );
413 class WebInstaller_DBSettings
extends WebInstallerPage
{
415 public function execute() {
416 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
418 $r = $this->parent
->request
;
419 if ( $r->wasPosted() ) {
420 $status = $installer->submitSettingsForm();
421 if ( $status === false ) {
423 } elseif ( $status->isGood() ) {
426 $this->parent
->showStatusBox( $status );
430 $form = $installer->getSettingsForm();
431 if ( $form === false ) {
436 $this->addHTML( $form );
442 class WebInstaller_Name
extends WebInstallerPage
{
444 public function execute() {
445 $r = $this->parent
->request
;
446 if ( $r->wasPosted() ) {
447 if ( $this->submit() ) {
454 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
455 $this->setVar( 'wgSitename', '' );
458 // Set wgMetaNamespace to something valid before we show the form.
459 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
460 $metaNS = $this->getVar( 'wgMetaNamespace' );
461 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
464 $this->parent
->getTextBox( array(
465 'var' => 'wgSitename',
466 'label' => 'config-site-name',
468 $this->parent
->getHelpBox( 'config-site-name-help' ) .
469 $this->parent
->getRadioSet( array(
470 'var' => '_NamespaceType',
471 'label' => 'config-project-namespace',
472 'itemLabelPrefix' => 'config-ns-',
473 'values' => array( 'site-name', 'generic', 'other' ),
474 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
476 $this->parent
->getTextBox( array(
477 'var' => 'wgMetaNamespace',
478 'label' => '', //TODO: Needs a label?
479 'attribs' => array( 'readonly' => 'readonly', 'class' => 'enabledByOther' ),
481 $this->parent
->getHelpBox( 'config-project-namespace-help' ) .
482 $this->getFieldSetStart( 'config-admin-box' ) .
483 $this->parent
->getTextBox( array(
484 'var' => '_AdminName',
485 'label' => 'config-admin-name',
486 'help' => $this->parent
->getHelpBox( 'config-admin-help' )
488 $this->parent
->getPasswordBox( array(
489 'var' => '_AdminPassword',
490 'label' => 'config-admin-password',
492 $this->parent
->getPasswordBox( array(
493 'var' => '_AdminPassword2',
494 'label' => 'config-admin-password-confirm'
496 $this->parent
->getHelpBox( 'config-admin-help' ) .
497 $this->parent
->getTextBox( array(
498 'var' => '_AdminEmail',
499 'label' => 'config-admin-email'
501 $this->parent
->getHelpBox( 'config-admin-email-help' ) .
502 $this->parent
->getCheckBox( array(
503 'var' => '_Subscribe',
504 'label' => 'config-subscribe'
506 $this->parent
->getHelpBox( 'config-subscribe-help' ) .
507 $this->getFieldSetEnd() .
508 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
509 $this->parent
->getRadioSet( array(
510 'var' => '_SkipOptional',
511 'itemLabelPrefix' => 'config-optional-',
512 'values' => array( 'continue', 'skip' )
516 // Restore the default value
517 $this->setVar( 'wgMetaNamespace', $metaNS );
523 public function submit() {
525 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
526 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
527 '_Subscribe', '_SkipOptional' ) );
529 // Validate site name
530 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
531 $this->parent
->showError( 'config-site-name-blank' );
536 $nsType = $this->getVar( '_NamespaceType' );
537 if ( $nsType == 'site-name' ) {
538 $name = $this->getVar( 'wgSitename' );
539 // Sanitize for namespace
540 // This algorithm should match the JS one in WebInstallerOutput.php
541 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
542 $name = str_replace( '&', '&', $name );
543 $name = preg_replace( '/__+/', '_', $name );
544 $name = ucfirst( trim( $name, '_' ) );
545 } elseif ( $nsType == 'generic' ) {
546 $name = wfMsg( 'config-ns-generic' );
548 $name = $this->getVar( 'wgMetaNamespace' );
551 // Validate namespace
552 if ( strpos( $name, ':' ) !== false ) {
555 // Title-style validation
556 $title = Title
::newFromText( $name );
558 $good = $nsType == 'site-name';
560 $name = $title->getDBkey();
565 $this->parent
->showError( 'config-ns-invalid', $name );
568 $this->setVar( 'wgMetaNamespace', $name );
570 // Validate username for creation
571 $name = $this->getVar( '_AdminName' );
572 if ( strval( $name ) === '' ) {
573 $this->parent
->showError( 'config-admin-name-blank' );
577 $cname = User
::getCanonicalName( $name, 'creatable' );
578 if ( $cname === false ) {
579 $this->parent
->showError( 'config-admin-name-invalid', $name );
582 $this->setVar( '_AdminName', $cname );
588 $pwd = $this->getVar( '_AdminPassword' );
589 $user = User
::newFromName( $cname );
590 $valid = $user->getPasswordValidity( $pwd );
591 if ( strval( $pwd ) === '' ) {
592 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
593 # This message is more specific and helpful.
594 $msg = 'config-admin-password-blank';
595 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
596 $msg = 'config-admin-password-mismatch';
597 } elseif ( $valid !== true ) {
598 # As of writing this will only catch the username being e.g. 'FOO' and
602 if ( $msg !== false ) {
603 $this->parent
->showError( $msg );
604 $this->setVar( '_AdminPassword', '' );
605 $this->setVar( '_AdminPassword2', '' );
613 class WebInstaller_Options
extends WebInstallerPage
{
615 public function execute() {
616 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
619 if ( $this->parent
->request
->wasPosted() ) {
620 if ( $this->submit() ) {
628 $this->parent
->getRadioSet( array(
629 'var' => '_RightsProfile',
630 'label' => 'config-profile',
631 'itemLabelPrefix' => 'config-profile-',
632 'values' => array_keys( $this->parent
->rightsProfiles
),
634 $this->parent
->getHelpBox( 'config-profile-help' ) .
637 $this->parent
->getRadioSet( array(
638 'var' => '_LicenseCode',
639 'label' => 'config-license',
640 'itemLabelPrefix' => 'config-license-',
641 'values' => array_keys( $this->parent
->licenses
),
642 'commonAttribs' => array( 'class' => 'licenseRadio' ),
644 $this->getCCChooser() .
645 $this->parent
->getHelpBox( 'config-license-help' ) .
648 $this->getFieldSetStart( 'config-email-settings' ) .
649 $this->parent
->getCheckBox( array(
650 'var' => 'wgEnableEmail',
651 'label' => 'config-enable-email',
652 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
654 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
655 "<div id=\"emailwrapper\">" .
656 $this->parent
->getTextBox( array(
657 'var' => 'wgPasswordSender',
658 'label' => 'config-email-sender'
660 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
661 $this->parent
->getCheckBox( array(
662 'var' => 'wgEnableUserEmail',
663 'label' => 'config-email-user',
665 $this->parent
->getHelpBox( 'config-email-user-help' ) .
666 $this->parent
->getCheckBox( array(
667 'var' => 'wgEnotifUserTalk',
668 'label' => 'config-email-usertalk',
670 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
671 $this->parent
->getCheckBox( array(
672 'var' => 'wgEnotifWatchlist',
673 'label' => 'config-email-watchlist',
675 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
676 $this->parent
->getCheckBox( array(
677 'var' => 'wgEmailAuthentication',
678 'label' => 'config-email-auth',
680 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
682 $this->getFieldSetEnd()
685 $extensions = $this->parent
->findExtensions();
688 $extHtml = $this->getFieldSetStart( 'config-extensions' );
690 foreach( $extensions as $ext ) {
691 $extHtml .= $this->parent
->getCheckBox( array(
697 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
698 $this->getFieldSetEnd();
699 $this->addHTML( $extHtml );
704 $this->getFieldSetStart( 'config-upload-settings' ) .
705 $this->parent
->getCheckBox( array(
706 'var' => 'wgEnableUploads',
707 'label' => 'config-upload-enable',
708 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
710 $this->parent
->getHelpBox( 'config-upload-help' ) .
711 '<div id="uploadwrapper" style="display: none;">' .
712 $this->parent
->getTextBox( array(
713 'var' => 'wgDeletedDirectory',
714 'label' => 'config-upload-deleted',
716 $this->parent
->getHelpBox( 'config-upload-deleted-help' ) .
718 $this->parent
->getTextBox( array(
720 'label' => 'config-logo'
722 $this->parent
->getHelpBox( 'config-logo-help' )
724 $canUse = $this->getVar( '_ExternalHTTP' ) ?
725 'config-instantcommons-good' : 'config-instantcommons-bad';
727 $this->parent
->getCheckBox( array(
728 'var' => 'wgUseInstantCommons',
729 'label' => 'config-instantcommons',
731 $this->parent
->getHelpBox( 'config-instantcommons-help', wfMsgNoTrans( $canUse ) ) .
732 $this->getFieldSetEnd()
735 $caches = array( 'none' );
736 if( count( $this->getVar( '_Caches' ) ) ) {
739 $caches[] = 'memcached';
743 $this->getFieldSetStart( 'config-advanced-settings' ) .
744 # Object cache settings
745 $this->parent
->getRadioSet( array(
746 'var' => 'wgMainCacheType',
747 'label' => 'config-cache-options',
748 'itemLabelPrefix' => 'config-cache-',
752 $this->parent
->getHelpBox( 'config-cache-help' ) .
753 '<div id="config-memcachewrapper">' .
754 $this->parent
->getTextBox( array(
755 'var' => '_MemCachedServers',
756 'label' => 'config-memcached-servers',
758 $this->parent
->getHelpBox( 'config-memcached-help' ) . '</div>' .
759 $this->getFieldSetEnd()
764 public function getCCPartnerUrl() {
766 $exitUrl = $wgServer . $this->parent
->getUrl( array(
768 'SubmitCC' => 'indeed',
769 'config__LicenseCode' => 'cc',
770 'config_wgRightsUrl' => '[license_url]',
771 'config_wgRightsText' => '[license_name]',
772 'config_wgRightsIcon' => '[license_button]',
774 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
775 '/skins/common/config-cc.css';
776 $iframeUrl = 'http://creativecommons.org/license/?' .
778 'partner' => 'MediaWiki',
779 'exit_url' => $exitUrl,
780 'lang' => $this->getVar( '_UserLang' ),
781 'stylesheet' => $styleUrl,
786 public function getCCChooser() {
787 $iframeAttribs = array(
788 'class' => 'config-cc-iframe',
789 'name' => 'config-cc-iframe',
790 'id' => 'config-cc-iframe',
795 if ( $this->getVar( '_CCDone' ) ) {
796 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
798 $iframeAttribs['src'] = $this->getCCPartnerUrl();
802 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
803 Html
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
807 public function getCCDoneBox() {
808 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
809 // If you change this height, also change it in config.css
810 $expandJs = str_replace( '$1', '54em', $js );
811 $reduceJs = str_replace( '$1', '70px', $js );
814 Html
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
816 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
818 "<p style=\"text-align: center\">" .
821 'href' => $this->getCCPartnerUrl(),
822 'onclick' => $expandJs,
824 wfMsg( 'config-cc-again' )
827 "<script type=\"text/javascript\">\n" .
828 # Reduce the wrapper div height
829 htmlspecialchars( $reduceJs ) .
834 public function submitCC() {
835 $newValues = $this->parent
->setVarsFromRequest(
836 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
837 if ( count( $newValues ) != 3 ) {
838 $this->parent
->showError( 'config-cc-error' );
841 $this->setVar( '_CCDone', true );
842 $this->addHTML( $this->getCCDoneBox() );
845 public function submit() {
846 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
847 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
848 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
849 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
850 'wgUseInstantCommons' ) );
852 if ( !in_array( $this->getVar( '_RightsProfile' ),
853 array_keys( $this->parent
->rightsProfiles
) ) )
855 reset( $this->parent
->rightsProfiles
);
856 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
859 $code = $this->getVar( '_LicenseCode' );
860 if ( $code == 'cc-choose' ) {
861 if ( !$this->getVar( '_CCDone' ) ) {
862 $this->parent
->showError( 'config-cc-not-chosen' );
865 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
866 $entry = $this->parent
->licenses
[$code];
867 if ( isset( $entry['text'] ) ) {
868 $this->setVar( 'wgRightsText', $entry['text'] );
870 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
872 $this->setVar( 'wgRightsUrl', $entry['url'] );
873 $this->setVar( 'wgRightsIcon', $entry['icon'] );
875 $this->setVar( 'wgRightsText', '' );
876 $this->setVar( 'wgRightsUrl', '' );
877 $this->setVar( 'wgRightsIcon', '' );
880 $extsAvailable = $this->parent
->findExtensions();
881 $extsToInstall = array();
882 foreach( $extsAvailable as $ext ) {
883 if( $this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
884 $extsToInstall[] = $ext;
887 $this->parent
->setVar( '_Extensions', $extsToInstall );
893 class WebInstaller_Install
extends WebInstallerPage
{
895 public function execute() {
896 if( $this->parent
->request
->wasPosted() ) {
898 } elseif( $this->getVar( '_InstallDone' ) ) {
900 $status = new Status();
901 $status->warning( 'config-install-alreadydone' );
902 $this->parent
->showStatusBox( $status );
903 } elseif( $this->getVar( '_UpgradeDone' ) ) {
907 $this->addHTML("<ul>");
908 $this->parent
->performInstallation(
909 array( $this, 'startStage'),
910 array( $this, 'endStage' )
912 $this->addHTML("</ul>");
918 public function startStage( $step ) {
919 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
922 public function endStage( $step, $status ) {
923 $msg = $status->isOk() ?
'config-install-step-done' : 'config-install-step-failed';
924 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
925 if ( !$status->isOk() ) {
926 $html = "<span class=\"error\">$html</span>";
928 $this->addHTML( $html . "</li>\n" );
929 if( !$status->isGood() ) {
930 $this->parent
->showStatusBox( $status );
936 class WebInstaller_Complete
extends WebInstallerPage
{
938 public function execute() {
941 $this->parent
->getInfoBox(
942 wfMsgNoTrans( 'config-install-done',
943 $GLOBALS['wgServer'] . $this->parent
->getURL( array( 'localsettings' => 1 ) ),
944 $GLOBALS['wgServer'] .
945 $this->getVar( 'wgScriptPath' ) . '/index' .
946 $this->getVar( 'wgScriptExtension' )
950 $this->endForm( false );
954 class WebInstaller_Restart
extends WebInstallerPage
{
956 public function execute() {
957 $r = $this->parent
->request
;
958 if ( $r->wasPosted() ) {
959 $really = $r->getVal( 'submit-restart' );
961 $this->parent
->session
= array();
962 $this->parent
->happyPages
= array();
963 $this->parent
->settings
= array();
969 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
970 $this->addHTML( $s );
971 $this->endForm( 'restart' );
976 abstract class WebInstaller_Document
extends WebInstallerPage
{
978 protected abstract function getFileName();
980 public function execute() {
981 $text = $this->getFileContents();
982 $text = $this->formatTextFile( $text );
983 $this->parent
->output
->addWikiText( $text );
985 $this->endForm( false );
988 public function getFileContents() {
989 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
992 protected function formatTextFile( $text ) {
993 // Use Unix line endings, escape some wikitext stuff
994 $text = str_replace( array( '<', '{{', '[[', "\r" ),
995 array( '<', '{{', '[[', '' ), $text );
996 // join word-wrapped lines into one
999 $text = preg_replace( "/\n([\\*#\t])([^\n]*?)\n([^\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
1000 } while ( $text != $prev );
1001 // Replace tab indents with colons
1002 $text = preg_replace( '/^\t\t/m', '::', $text );
1003 $text = preg_replace( '/^\t/m', ':', $text );
1004 // turn (bug nnnn) into links
1005 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1006 // add links to manual to every global variable mentioned
1007 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1011 private function replaceBugLinks( $matches ) {
1012 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1013 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1016 private function replaceConfigLinks( $matches ) {
1017 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1018 $matches[1] . ' ' . $matches[1] . ']</span>';
1023 class WebInstaller_Readme
extends WebInstaller_Document
{
1024 protected function getFileName() { return 'README'; }
1027 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1028 protected function getFileName() { return 'RELEASE-NOTES'; }
1031 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1032 protected function getFileName() { return 'UPGRADE'; }
1035 class WebInstaller_Copying
extends WebInstaller_Document
{
1036 protected function getFileName() { return 'COPYING'; }