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 );
206 } elseif ( $this->parent
->showSessionWarning
) {
207 # The user was knocked back from another page to the start
208 # This probably indicates a session expiry
209 $this->parent
->showError( 'config-session-expired', $wgLang->formatTimePeriod( $lifetime ) );
212 $this->parent
->setSession( 'test', true );
214 if ( !isset( $languages[$userLang] ) ) {
215 $userLang = $this->getVar( '_UserLang', 'en' );
217 if ( !isset( $languages[$contLang] ) ) {
218 $contLang = $this->getVar( 'wgLanguageCode', 'en' );
221 $s = Html
::hidden( 'LanguageRequestTime', time() ) .
222 $this->getLanguageSelector( 'UserLang', 'config-your-language', $userLang, $this->parent
->getHelpBox( 'config-your-language-help' ) ) .
223 $this->getLanguageSelector( 'ContLang', 'config-wiki-language', $contLang, $this->parent
->getHelpBox( 'config-wiki-language-help' ) );
224 $this->addHTML( $s );
229 * Get a <select> for selecting languages.
231 public function getLanguageSelector( $name, $label, $selectedCode ) {
232 global $wgDummyLanguageCodes;
233 $s = Html
::openElement( 'select', array( 'id' => $name, 'name' => $name ) ) . "\n";
235 $languages = Language
::getLanguageNames();
237 $dummies = array_flip( $wgDummyLanguageCodes );
238 foreach ( $languages as $code => $lang ) {
239 if ( isset( $dummies[$code] ) ) continue;
240 $s .= "\n" . Xml
::option( "$code - $lang", $code, $code == $selectedCode );
242 $s .= "\n</select>\n";
243 return $this->parent
->label( $label, $name, $s );
248 class WebInstaller_Welcome
extends WebInstallerPage
{
250 public function execute() {
251 if ( $this->parent
->request
->wasPosted() ) {
252 if ( $this->getVar( '_Environment' ) ) {
256 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-welcome' ) );
257 $status = $this->parent
->doEnvironmentChecks();
259 $this->parent
->output
->addWikiText( wfMsgNoTrans( 'config-copyright',
260 SpecialVersion
::getCopyrightAndAuthorList() ) );
268 class WebInstaller_DBConnect
extends WebInstallerPage
{
270 public function execute() {
271 $r = $this->parent
->request
;
272 if ( $r->wasPosted() ) {
273 $status = $this->submit();
274 if ( $status->isGood() ) {
275 $this->setVar( '_UpgradeDone', false );
278 $this->parent
->showStatusBox( $status );
284 $types = "<ul class=\"config-settings-block\">\n";
286 $defaultType = $this->getVar( 'wgDBtype' );
289 foreach( $this->parent
->getDBTypes() as $type ) {
290 $db = 'Database' . ucfirst( $type );
291 $dbSupport .= wfMsgNoTrans( "config-support-$type",
292 call_user_func( array( $db, 'getSoftwareLink' ) ) ) . "\n";
294 $this->addHTML( $this->parent
->getInfoBox(
295 wfMsg( 'config-support-info', $dbSupport ) ) );
297 foreach ( $this->parent
->getVar( '_CompiledDBs' ) as $type ) {
298 $installer = $this->parent
->getDBInstaller( $type );
302 $installer->getReadableName(),
306 $type == $defaultType,
307 array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" )
312 Html
::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) .
313 Html
::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) .
314 $installer->getConnectForm() .
317 $types .= "</ul><br clear=\"left\"/>\n";
320 $this->parent
->label( 'config-db-type', false, $types ) .
327 public function submit() {
328 $r = $this->parent
->request
;
329 $type = $r->getVal( 'DBType' );
330 $this->setVar( 'wgDBtype', $type );
331 $installer = $this->parent
->getDBInstaller( $type );
333 return Status
::newFatal( 'config-invalid-db-type' );
335 return $installer->submitConnectForm();
340 class WebInstaller_Upgrade
extends WebInstallerPage
{
342 public function execute() {
343 if ( $this->getVar( '_UpgradeDone' ) ) {
344 if ( $this->parent
->request
->wasPosted() ) {
345 // Done message acknowledged
349 // Show the done message again
350 // Make them click back again if they want to do the upgrade again
351 $this->showDoneMessage();
356 // wgDBtype is generally valid here because otherwise the previous page
357 // (connect) wouldn't have declared its happiness
358 $type = $this->getVar( 'wgDBtype' );
359 $installer = $this->parent
->getDBInstaller( $type );
361 if ( !$installer->needsUpgrade() ) {
365 if ( $this->parent
->request
->wasPosted() ) {
366 $installer->preUpgrade();
368 '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' .
369 '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' .
370 '<textarea id="config-update-log" name="UpdateLog" rows="10" readonly="readonly">'
372 $this->parent
->output
->flush();
373 $result = $installer->doUpgrade();
374 $this->addHTML( '</textarea>
375 <script>jQuery( "#config-spinner" )[0].style.display = "none";</script>' );
376 $this->parent
->output
->flush();
378 $this->setVar( '_UpgradeDone', true );
379 $this->showDoneMessage();
385 $this->addHTML( $this->parent
->getInfoBox(
386 wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) );
390 public function showDoneMessage() {
393 $this->parent
->getInfoBox(
394 wfMsgNoTrans( 'config-upgrade-done',
395 $GLOBALS['wgServer'] .
396 $this->getVar( 'wgScriptPath' ) . '/index' .
397 $this->getVar( 'wgScriptExtension' )
401 $this->endForm( 'regenerate' );
406 class WebInstaller_DBSettings
extends WebInstallerPage
{
408 public function execute() {
409 $installer = $this->parent
->getDBInstaller( $this->getVar( 'wgDBtype' ) );
411 $r = $this->parent
->request
;
412 if ( $r->wasPosted() ) {
413 $status = $installer->submitSettingsForm();
414 if ( $status === false ) {
416 } elseif ( $status->isGood() ) {
419 $this->parent
->showStatusBox( $status );
423 $form = $installer->getSettingsForm();
424 if ( $form === false ) {
429 $this->addHTML( $form );
435 class WebInstaller_Name
extends WebInstallerPage
{
437 public function execute() {
438 $r = $this->parent
->request
;
439 if ( $r->wasPosted() ) {
440 if ( $this->submit() ) {
447 if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) {
448 $this->setVar( 'wgSitename', '' );
451 // Set wgMetaNamespace to something valid before we show the form.
452 // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
453 $metaNS = $this->getVar( 'wgMetaNamespace' );
454 $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) );
457 $this->parent
->getTextBox( array(
458 'var' => 'wgSitename',
459 'label' => 'config-site-name',
460 'help' => $this->parent
->getHelpBox( 'config-site-name-help' )
462 $this->parent
->getRadioSet( array(
463 'var' => '_NamespaceType',
464 'label' => 'config-project-namespace',
465 'itemLabelPrefix' => 'config-ns-',
466 'values' => array( 'site-name', 'generic', 'other' ),
467 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ),
468 'help' => $this->parent
->getHelpBox( 'config-project-namespace-help' )
470 $this->parent
->getTextBox( array(
471 'var' => 'wgMetaNamespace',
472 'label' => '', //TODO: Needs a label?
473 'attribs' => array( 'readonly' => 'readonly', 'class' => 'enabledByOther' ),
476 $this->getFieldSetStart( 'config-admin-box' ) .
477 $this->parent
->getTextBox( array(
478 'var' => '_AdminName',
479 'label' => 'config-admin-name',
480 'help' => $this->parent
->getHelpBox( 'config-admin-help' )
482 $this->parent
->getPasswordBox( array(
483 'var' => '_AdminPassword',
484 'label' => 'config-admin-password',
486 $this->parent
->getPasswordBox( array(
487 'var' => '_AdminPassword2',
488 'label' => 'config-admin-password-confirm'
490 $this->parent
->getTextBox( array(
491 'var' => '_AdminEmail',
492 'label' => 'config-admin-email',
493 'help' => $this->parent
->getHelpBox( 'config-admin-email-help' )
495 $this->parent
->getCheckBox( array(
496 'var' => '_Subscribe',
497 'label' => 'config-subscribe',
498 'help' => $this->parent
->getHelpBox( 'config-subscribe-help' )
500 $this->getFieldSetEnd() .
501 $this->parent
->getInfoBox( wfMsg( 'config-almost-done' ) ) .
502 $this->parent
->getRadioSet( array(
503 'var' => '_SkipOptional',
504 'itemLabelPrefix' => 'config-optional-',
505 'values' => array( 'continue', 'skip' )
509 // Restore the default value
510 $this->setVar( 'wgMetaNamespace', $metaNS );
516 public function submit() {
518 $this->parent
->setVarsFromRequest( array( 'wgSitename', '_NamespaceType',
519 '_AdminName', '_AdminPassword', '_AdminPassword2', '_AdminEmail',
520 '_Subscribe', '_SkipOptional' ) );
522 // Validate site name
523 if ( strval( $this->getVar( 'wgSitename' ) ) === '' ) {
524 $this->parent
->showError( 'config-site-name-blank' );
529 $nsType = $this->getVar( '_NamespaceType' );
530 if ( $nsType == 'site-name' ) {
531 $name = $this->getVar( 'wgSitename' );
532 // Sanitize for namespace
533 // This algorithm should match the JS one in WebInstallerOutput.php
534 $name = preg_replace( '/[\[\]\{\}|#<>%+? ]/', '_', $name );
535 $name = str_replace( '&', '&', $name );
536 $name = preg_replace( '/__+/', '_', $name );
537 $name = ucfirst( trim( $name, '_' ) );
538 } elseif ( $nsType == 'generic' ) {
539 $name = wfMsg( 'config-ns-generic' );
541 $name = $this->getVar( 'wgMetaNamespace' );
544 // Validate namespace
545 if ( strpos( $name, ':' ) !== false ) {
548 // Title-style validation
549 $title = Title
::newFromText( $name );
551 $good = $nsType == 'site-name';
553 $name = $title->getDBkey();
558 $this->parent
->showError( 'config-ns-invalid', $name );
561 $this->setVar( 'wgMetaNamespace', $name );
563 // Validate username for creation
564 $name = $this->getVar( '_AdminName' );
565 if ( strval( $name ) === '' ) {
566 $this->parent
->showError( 'config-admin-name-blank' );
570 $cname = User
::getCanonicalName( $name, 'creatable' );
571 if ( $cname === false ) {
572 $this->parent
->showError( 'config-admin-name-invalid', $name );
575 $this->setVar( '_AdminName', $cname );
582 $pwd = $this->getVar( '_AdminPassword' );
583 $user = User
::newFromName( $cname );
584 $valid = $user && $user->getPasswordValidity( $pwd );
585 if ( strval( $pwd ) === '' ) {
586 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
587 # This message is more specific and helpful.
588 $msg = 'config-admin-password-blank';
589 } elseif ( $pwd !== $this->getVar( '_AdminPassword2' ) ) {
590 $msg = 'config-admin-password-mismatch';
591 } elseif ( $valid !== true ) {
592 # As of writing this will only catch the username being e.g. 'FOO' and
596 if ( $msg !== false ) {
597 $this->parent
->showError( $msg );
598 $this->setVar( '_AdminPassword', '' );
599 $this->setVar( '_AdminPassword2', '' );
607 class WebInstaller_Options
extends WebInstallerPage
{
609 public function execute() {
610 if ( $this->getVar( '_SkipOptional' ) == 'skip' ) {
613 if ( $this->parent
->request
->wasPosted() ) {
614 if ( $this->submit() ) {
622 $this->parent
->getRadioSet( array(
623 'var' => '_RightsProfile',
624 'label' => 'config-profile',
625 'itemLabelPrefix' => 'config-profile-',
626 'values' => array_keys( $this->parent
->rightsProfiles
),
628 $this->parent
->getHelpBox( 'config-profile-help' ) .
631 $this->parent
->getRadioSet( array(
632 'var' => '_LicenseCode',
633 'label' => 'config-license',
634 'itemLabelPrefix' => 'config-license-',
635 'values' => array_keys( $this->parent
->licenses
),
636 'commonAttribs' => array( 'class' => 'licenseRadio' ),
638 $this->getCCChooser() .
639 $this->parent
->getHelpBox( 'config-license-help' ) .
642 $this->getFieldSetStart( 'config-email-settings' ) .
643 $this->parent
->getCheckBox( array(
644 'var' => 'wgEnableEmail',
645 'label' => 'config-enable-email',
646 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ),
648 $this->parent
->getHelpBox( 'config-enable-email-help' ) .
649 "<div id=\"emailwrapper\">" .
650 $this->parent
->getTextBox( array(
651 'var' => 'wgPasswordSender',
652 'label' => 'config-email-sender'
654 $this->parent
->getHelpBox( 'config-email-sender-help' ) .
655 $this->parent
->getCheckBox( array(
656 'var' => 'wgEnableUserEmail',
657 'label' => 'config-email-user',
659 $this->parent
->getHelpBox( 'config-email-user-help' ) .
660 $this->parent
->getCheckBox( array(
661 'var' => 'wgEnotifUserTalk',
662 'label' => 'config-email-usertalk',
664 $this->parent
->getHelpBox( 'config-email-usertalk-help' ) .
665 $this->parent
->getCheckBox( array(
666 'var' => 'wgEnotifWatchlist',
667 'label' => 'config-email-watchlist',
669 $this->parent
->getHelpBox( 'config-email-watchlist-help' ) .
670 $this->parent
->getCheckBox( array(
671 'var' => 'wgEmailAuthentication',
672 'label' => 'config-email-auth',
674 $this->parent
->getHelpBox( 'config-email-auth-help' ) .
676 $this->getFieldSetEnd()
679 $extensions = $this->parent
->findExtensions();
682 $extHtml = $this->getFieldSetStart( 'config-extensions' );
684 foreach( $extensions as $ext ) {
685 $extHtml .= $this->parent
->getCheckBox( array(
691 $extHtml .= $this->parent
->getHelpBox( 'config-extensions-help' ) .
692 $this->getFieldSetEnd();
693 $this->addHTML( $extHtml );
698 $this->getFieldSetStart( 'config-upload-settings' ) .
699 $this->parent
->getCheckBox( array(
700 'var' => 'wgEnableUploads',
701 'label' => 'config-upload-enable',
702 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ),
703 'help' => $this->parent
->getHelpBox( 'config-upload-help' )
705 '<div id="uploadwrapper" style="display: none;">' .
706 $this->parent
->getTextBox( array(
707 'var' => 'wgDeletedDirectory',
708 'label' => 'config-upload-deleted',
709 'help' => $this->parent
->getHelpBox( 'config-upload-deleted-help' )
712 $this->parent
->getTextBox( array(
714 'label' => 'config-logo',
715 'help' => $this->parent
->getHelpBox( 'config-logo-help' )
719 $this->parent
->getCheckBox( array(
720 'var' => 'wgUseInstantCommons',
721 'label' => 'config-instantcommons',
722 'help' => $this->parent
->getHelpBox( 'config-instantcommons-help' )
724 $this->getFieldSetEnd()
727 $caches = array( 'none' );
728 if( count( $this->getVar( '_Caches' ) ) ) {
731 $caches[] = 'memcached';
735 $this->getFieldSetStart( 'config-advanced-settings' ) .
736 # Object cache settings
737 $this->parent
->getRadioSet( array(
738 'var' => 'wgMainCacheType',
739 'label' => 'config-cache-options',
740 'itemLabelPrefix' => 'config-cache-',
744 $this->parent
->getHelpBox( 'config-cache-help' ) .
745 '<div id="config-memcachewrapper">' .
746 $this->parent
->getTextBox( array(
747 'var' => '_MemCachedServers',
748 'label' => 'config-memcached-servers',
749 'help' => $this->parent
->getHelpBox( 'config-memcached-help' )
752 $this->getFieldSetEnd()
757 public function getCCPartnerUrl() {
759 $exitUrl = $wgServer . $this->parent
->getUrl( array(
761 'SubmitCC' => 'indeed',
762 'config__LicenseCode' => 'cc',
763 'config_wgRightsUrl' => '[license_url]',
764 'config_wgRightsText' => '[license_name]',
765 'config_wgRightsIcon' => '[license_button]',
767 $styleUrl = $wgServer . dirname( dirname( $this->parent
->getUrl() ) ) .
768 '/skins/common/config-cc.css';
769 $iframeUrl = 'http://creativecommons.org/license/?' .
771 'partner' => 'MediaWiki',
772 'exit_url' => $exitUrl,
773 'lang' => $this->getVar( '_UserLang' ),
774 'stylesheet' => $styleUrl,
779 public function getCCChooser() {
780 $iframeAttribs = array(
781 'class' => 'config-cc-iframe',
782 'name' => 'config-cc-iframe',
783 'id' => 'config-cc-iframe',
788 if ( $this->getVar( '_CCDone' ) ) {
789 $iframeAttribs['src'] = $this->parent
->getUrl( array( 'ShowCC' => 'yes' ) );
791 $iframeAttribs['src'] = $this->getCCPartnerUrl();
795 "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" .
796 Html
::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
800 public function getCCDoneBox() {
801 $js = "parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
802 // If you change this height, also change it in config.css
803 $expandJs = str_replace( '$1', '54em', $js );
804 $reduceJs = str_replace( '$1', '70px', $js );
807 Html
::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) .
809 htmlspecialchars( $this->getVar( 'wgRightsText' ) ) .
811 "<p style=\"text-align: center\">" .
814 'href' => $this->getCCPartnerUrl(),
815 'onclick' => $expandJs,
817 wfMsg( 'config-cc-again' )
820 "<script type=\"text/javascript\">\n" .
821 # Reduce the wrapper div height
822 htmlspecialchars( $reduceJs ) .
827 public function submitCC() {
828 $newValues = $this->parent
->setVarsFromRequest(
829 array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) );
830 if ( count( $newValues ) != 3 ) {
831 $this->parent
->showError( 'config-cc-error' );
834 $this->setVar( '_CCDone', true );
835 $this->addHTML( $this->getCCDoneBox() );
838 public function submit() {
839 $this->parent
->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode',
840 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo',
841 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist',
842 'wgEmailAuthentication', 'wgMainCacheType', '_MemCachedServers',
843 'wgUseInstantCommons' ) );
845 if ( !in_array( $this->getVar( '_RightsProfile' ),
846 array_keys( $this->parent
->rightsProfiles
) ) )
848 reset( $this->parent
->rightsProfiles
);
849 $this->setVar( '_RightsProfile', key( $this->parent
->rightsProfiles
) );
852 $code = $this->getVar( '_LicenseCode' );
853 if ( $code == 'cc-choose' ) {
854 if ( !$this->getVar( '_CCDone' ) ) {
855 $this->parent
->showError( 'config-cc-not-chosen' );
858 } elseif ( in_array( $code, array_keys( $this->parent
->licenses
) ) ) {
859 $entry = $this->parent
->licenses
[$code];
860 if ( isset( $entry['text'] ) ) {
861 $this->setVar( 'wgRightsText', $entry['text'] );
863 $this->setVar( 'wgRightsText', wfMsg( 'config-license-' . $code ) );
865 $this->setVar( 'wgRightsUrl', $entry['url'] );
866 $this->setVar( 'wgRightsIcon', $entry['icon'] );
868 $this->setVar( 'wgRightsText', '' );
869 $this->setVar( 'wgRightsUrl', '' );
870 $this->setVar( 'wgRightsIcon', '' );
873 $extsAvailable = $this->parent
->findExtensions();
874 $extsToInstall = array();
875 foreach( $extsAvailable as $ext ) {
876 if( $this->parent
->request
->getCheck( 'config_ext-' . $ext ) ) {
877 $extsToInstall[] = $ext;
880 $this->parent
->setVar( '_Extensions', $extsToInstall );
886 class WebInstaller_Install
extends WebInstallerPage
{
888 public function execute() {
889 if( $this->parent
->request
->wasPosted() ) {
891 } elseif( $this->getVar( '_InstallDone' ) ) {
893 $status = new Status();
894 $status->warning( 'config-install-alreadydone' );
895 $this->parent
->showStatusBox( $status );
896 } elseif( $this->getVar( '_UpgradeDone' ) ) {
900 $this->addHTML("<ul>");
901 $this->parent
->performInstallation(
902 array( $this, 'startStage'),
903 array( $this, 'endStage' )
905 $this->addHTML("</ul>");
911 public function startStage( $step ) {
912 $this->addHTML( "<li>" . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') );
915 public function endStage( $step, $status ) {
916 $msg = $status->isOk() ?
'config-install-step-done' : 'config-install-step-failed';
917 $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg );
918 if ( !$status->isOk() ) {
919 $html = "<span class=\"error\">$html</span>";
921 $this->addHTML( $html . "</li>\n" );
922 if( !$status->isGood() ) {
923 $this->parent
->showStatusBox( $status );
929 class WebInstaller_Complete
extends WebInstallerPage
{
931 public function execute() {
932 // Pop up a dialog box, to make it difficult for the user to forget
933 // to download the file
934 $lsUrl = $GLOBALS['wgServer'] . $this->parent
->getURL( array( 'localsettings' => 1 ) );
935 $this->parent
->request
->response()->header( "Refresh: 0;$lsUrl" );
939 $this->parent
->getInfoBox(
940 wfMsgNoTrans( 'config-install-done',
942 $GLOBALS['wgServer'] .
943 $this->getVar( 'wgScriptPath' ) . '/index' .
944 $this->getVar( 'wgScriptExtension' )
948 $this->endForm( false );
952 class WebInstaller_Restart
extends WebInstallerPage
{
954 public function execute() {
955 $r = $this->parent
->request
;
956 if ( $r->wasPosted() ) {
957 $really = $r->getVal( 'submit-restart' );
959 $this->parent
->session
= array();
960 $this->parent
->happyPages
= array();
961 $this->parent
->settings
= array();
967 $s = $this->parent
->getWarningBox( wfMsgNoTrans( 'config-help-restart' ) );
968 $this->addHTML( $s );
969 $this->endForm( 'restart' );
974 abstract class WebInstaller_Document
extends WebInstallerPage
{
976 protected abstract function getFileName();
978 public function execute() {
979 $text = $this->getFileContents();
980 $text = $this->formatTextFile( $text );
981 $this->parent
->output
->addWikiText( $text );
983 $this->endForm( false );
986 public function getFileContents() {
987 return file_get_contents( dirname( __FILE__
) . '/../../' . $this->getFileName() );
990 protected function formatTextFile( $text ) {
991 // Use Unix line endings, escape some wikitext stuff
992 $text = str_replace( array( '<', '{{', '[[', "\r" ),
993 array( '<', '{{', '[[', '' ), $text );
994 // join word-wrapped lines into one
997 $text = preg_replace( "/\n([\\*#\t])([^\n]*?)\n([^\n#\\*:]+)/", "\n\\1\\2 \\3", $text );
998 } while ( $text != $prev );
999 // Replace tab indents with colons
1000 $text = preg_replace( '/^\t\t/m', '::', $text );
1001 $text = preg_replace( '/^\t/m', ':', $text );
1002 // turn (bug nnnn) into links
1003 $text = preg_replace_callback('/bug (\d+)/', array( $this, 'replaceBugLinks' ), $text );
1004 // add links to manual to every global variable mentioned
1005 $text = preg_replace_callback('/(\$wg[a-z0-9_]+)/i', array( $this, 'replaceConfigLinks' ), $text );
1009 private function replaceBugLinks( $matches ) {
1010 return '<span class="config-plainlink">[https://bugzilla.wikimedia.org/' .
1011 $matches[1] . ' bug ' . $matches[1] . ']</span>';
1014 private function replaceConfigLinks( $matches ) {
1015 return '<span class="config-plainlink">[http://www.mediawiki.org/wiki/Manual:' .
1016 $matches[1] . ' ' . $matches[1] . ']</span>';
1021 class WebInstaller_Readme
extends WebInstaller_Document
{
1022 protected function getFileName() { return 'README'; }
1025 class WebInstaller_ReleaseNotes
extends WebInstaller_Document
{
1026 protected function getFileName() { return 'RELEASE-NOTES'; }
1029 class WebInstaller_UpgradeDoc
extends WebInstaller_Document
{
1030 protected function getFileName() { return 'UPGRADE'; }
1033 class WebInstaller_Copying
extends WebInstaller_Document
{
1034 protected function getFileName() { return 'COPYING'; }