30 abstract class WebInstallerPage {
42 abstract public function execute();
48 $this->parent = $parent;
58 public function isSlow() {
65 public function addHTML(
$html ) {
66 $this->parent->output->addHTML(
$html );
69 public function startForm() {
71 "<div class=\"config-section\">\n" .
76 'action' => $this->parent->getUrl(
array(
'page' => $this->getName() ) )
86 public function endForm( $continue =
'continue', $back =
'back' ) {
87 $s =
"<div class=\"config-submit\">\n";
90 if ( $id ===
false ) {
91 $s .=
Html::hidden(
'lastPage', $this->parent->request->getVal(
'lastPage' ) );
100 'name' =>
"enter-$continue",
101 'style' =>
'visibility:hidden;overflow:hidden;width:1px;margin:0'
111 'name' =>
"submit-$back",
112 'tabindex' => $this->parent->nextTabIndex()
122 'name' =>
"submit-$continue",
123 'tabindex' => $this->parent->nextTabIndex(),
128 $s .=
"</div></form></div>\n";
129 $this->addHTML(
$s );
135 public function getName() {
136 return str_replace(
'WebInstaller_',
'', get_class( $this ) );
142 protected function getId() {
143 return array_search( $this->getName(), $this->parent->pageSequence );
151 public function getVar( $var ) {
152 return $this->parent->getVar( $var );
170 protected function getFieldsetStart( $legend ) {
171 return "\n<fieldset><legend>" .
wfMessage( $legend )->escaped() .
"</legend>\n";
179 protected function getFieldsetEnd() {
180 return "</fieldset>\n";
186 protected function startLiveBox() {
188 '<div id="config-spinner" style="display:none;">' .
189 '<img src="../skins/common/images/ajax-loader.gif" /></div>' .
190 '<script>jQuery( "#config-spinner" ).show();</script>' .
191 '<div id="config-live-log">' .
192 '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
194 $this->parent->output->flush();
200 protected function endLiveBox() {
201 $this->addHTML(
'</textarea></div>
202 <script>jQuery( "#config-spinner" ).hide()</script>' );
203 $this->parent->output->flush();
208 class WebInstaller_Language
extends WebInstallerPage {
215 $r = $this->parent->request;
216 $userLang = $r->getVal(
'uselang' );
217 $contLang = $r->getVal(
'ContLang' );
220 $lifetime = intval( ini_get(
'session.gc_maxlifetime' ) );
225 if ( $r->wasPosted() ) {
227 if ( $this->parent->getSession(
'test' ) === null ) {
228 $requestTime = $r->getVal(
'LanguageRequestTime' );
229 if ( !$requestTime ) {
232 $msg =
'config-session-expired';
233 } elseif ( time() - $requestTime > $lifetime ) {
234 $msg =
'config-session-expired';
236 $msg =
'config-no-session';
238 $this->parent->showError( $msg,
$wgLang->formatTimePeriod( $lifetime ) );
241 $this->setVar(
'_UserLang', $userLang );
244 $this->setVar(
'wgLanguageCode', $contLang );
249 } elseif ( $this->parent->showSessionWarning ) {
250 # The user was knocked back from another page to the start
251 # This probably indicates a session expiry
252 $this->parent->showError(
'config-session-expired',
253 $wgLang->formatTimePeriod( $lifetime ) );
256 $this->parent->setSession(
'test',
true );
259 $userLang = $this->getVar(
'_UserLang',
'en' );
262 $contLang = $this->getVar(
'wgLanguageCode',
'en' );
266 $this->getLanguageSelector(
'uselang',
'config-your-language', $userLang,
267 $this->parent->getHelpBox(
'config-your-language-help' ) ) .
268 $this->getLanguageSelector(
'ContLang',
'config-wiki-language', $contLang,
269 $this->parent->getHelpBox(
'config-wiki-language-help' ) );
270 $this->addHTML(
$s );
271 $this->endForm(
'continue',
false );
286 public function getLanguageSelector(
$name, $label, $selectedCode, $helpHtml =
'' ) {
287 global $wgDummyLanguageCodes;
292 'tabindex' => $this->parent->nextTabIndex() ) ) .
"\n";
297 if ( isset( $wgDummyLanguageCodes[$code] ) ) {
300 $s .=
"\n" .
Xml::option(
"$code - $lang", $code, $code == $selectedCode );
302 $s .=
"\n</select>\n";
304 return $this->parent->label( $label,
$name,
$s );
309 class WebInstaller_ExistingWiki
extends WebInstallerPage {
322 if (
$vars[
'wgUpgradeKey'] !==
false
323 && $this->getVar(
'_UpgradeKeySupplied' )
324 && $this->getVar(
'wgUpgradeKey' ) ===
$vars[
'wgUpgradeKey']
327 $status = $this->handleExistingUpgrade(
$vars );
328 if ( $status->isOK() ) {
332 $this->parent->showStatusBox( $status );
333 $this->endForm(
'continue' );
340 if (
$vars[
'wgUpgradeKey'] ===
false ) {
341 if ( $this->getVar(
'wgUpgradeKey',
false ) ===
false ) {
342 $secretKey = $this->getVar(
'wgSecretKey' );
343 $this->parent->generateKeys();
344 $this->setVar(
'wgSecretKey', $secretKey );
345 $this->setVar(
'_UpgradeKeySupplied',
true );
348 $this->addHTML( $this->parent->getInfoBox(
349 wfMessage(
'config-upgrade-key-missing',
"<pre dir=\"ltr\">\$wgUpgradeKey = '" .
350 $this->getVar(
'wgUpgradeKey' ) .
"';</pre>" )->plain()
352 $this->endForm(
'continue' );
359 $r = $this->parent->request;
360 if ( $r->wasPosted() ) {
361 $key = $r->getText(
'config_wgUpgradeKey' );
362 if ( !$key || $key !==
$vars[
'wgUpgradeKey'] ) {
363 $this->parent->showError(
'config-localsettings-badkey' );
364 $this->showKeyForm();
369 $status = $this->handleExistingUpgrade(
$vars );
370 if ( $status->isOK() ) {
373 $this->parent->showStatusBox( $status );
374 $this->showKeyForm();
379 $this->showKeyForm();
388 protected function showKeyForm() {
391 $this->parent->getInfoBox(
wfMessage(
'config-localsettings-upgrade' )->plain() ) .
393 $this->parent->getTextBox(
array(
394 'var' =>
'wgUpgradeKey',
395 'label' =>
'config-localsettings-key',
396 'attribs' =>
array(
'autocomplete' =>
'off' ),
399 $this->endForm(
'continue' );
408 protected function importVariables( $names,
$vars ) {
412 $status->fatal(
'config-localsettings-incomplete',
$name );
427 protected function handleExistingUpgrade(
$vars ) {
429 if ( !isset(
$vars[
'wgDBtype'] ) ||
436 $requiredVars =
array(
'wgDBtype' );
437 $status = $this->importVariables( $requiredVars,
$vars );
438 $installer = $this->parent->getDBInstaller();
439 $status->merge( $this->importVariables( $installer->getGlobalNames(),
$vars ) );
440 if ( !$status->isOK() ) {
444 if ( isset(
$vars[
'wgDBadminuser'] ) ) {
445 $this->setVar(
'_InstallUser',
$vars[
'wgDBadminuser'] );
447 $this->setVar(
'_InstallUser',
$vars[
'wgDBuser'] );
449 if ( isset(
$vars[
'wgDBadminpassword'] ) ) {
450 $this->setVar(
'_InstallPassword',
$vars[
'wgDBadminpassword'] );
452 $this->setVar(
'_InstallPassword',
$vars[
'wgDBpassword'] );
456 $status = $installer->getConnection();
457 if ( !$status->isOK() ) {
459 $status->replaceMessage(
'config-connection-error',
460 'config-localsettings-connection-error' );
466 $this->setVar(
'_ExistingDBSettings',
true );
473 class WebInstaller_Welcome
extends WebInstallerPage {
479 if ( $this->parent->request->wasPosted() ) {
480 if ( $this->getVar(
'_Environment' ) ) {
484 $this->parent->output->addWikiText(
wfMessage(
'config-welcome' )->plain() );
485 $status = $this->parent->doEnvironmentChecks();
486 if ( $status->isGood() ) {
487 $this->parent->output->addHTML(
'<span class="success-message">' .
488 wfMessage(
'config-env-good' )->escaped() .
'</span>' );
489 $this->parent->output->addWikiText(
wfMessage(
'config-copyright',
494 $this->parent->showStatusMessage( $status );
502 class WebInstaller_DBConnect
extends WebInstallerPage {
508 if ( $this->getVar(
'_ExistingDBSettings' ) ) {
512 $r = $this->parent->request;
513 if ( $r->wasPosted() ) {
514 $status = $this->submit();
516 if ( $status->isGood() ) {
517 $this->setVar(
'_UpgradeDone',
false );
521 $this->parent->showStatusBox( $status );
527 $types =
"<ul class=\"config-settings-block\">\n";
529 $defaultType = $this->getVar(
'wgDBtype' );
535 $dbSupport .=
wfMessage(
"config-dbsupport-$type" )->plain() .
"\n";
537 $this->addHTML( $this->parent->getInfoBox(
538 wfMessage(
'config-support-info', trim( $dbSupport ) )->
text() ) );
542 $compiledDBs = $this->parent->getCompiledDBs();
543 if ( !in_array( $defaultType, $compiledDBs ) ) {
544 $defaultType = $compiledDBs[0];
547 foreach ( $compiledDBs
as $type ) {
548 $installer = $this->parent->getDBInstaller(
$type );
552 $installer->getReadableName(),
556 $type == $defaultType,
557 array(
'class' =>
'dbRadio',
'rel' =>
"DB_wrapper_$type" )
566 'id' =>
'DB_wrapper_' .
$type,
567 'class' =>
'dbWrapper'
571 $installer->getConnectForm() .
575 $types .=
"</ul><br style=\"clear: left\"/>\n";
577 $this->addHTML( $this->parent->label(
'config-db-type',
false, $types ) . $settings );
586 public function submit() {
587 $r = $this->parent->request;
588 $type = $r->getVal(
'DBType' );
592 $this->setVar(
'wgDBtype',
$type );
593 $installer = $this->parent->getDBInstaller(
$type );
598 return $installer->submitConnectForm();
603 class WebInstaller_Upgrade
extends WebInstallerPage {
608 public function isSlow() {
616 if ( $this->getVar(
'_UpgradeDone' ) ) {
620 if ( $this->parent->request->wasPosted() && !$this->getVar(
'_ExistingDBSettings' ) ) {
627 $this->showDoneMessage();
635 $type = $this->getVar(
'wgDBtype' );
636 $installer = $this->parent->getDBInstaller(
$type );
638 if ( !$installer->needsUpgrade() ) {
642 if ( $this->parent->request->wasPosted() ) {
643 $installer->preUpgrade();
645 $this->startLiveBox();
646 $result = $installer->doUpgrade();
652 if ( !$this->getVar(
'_ExistingDBSettings' ) ) {
653 $this->parent->generateKeys();
655 $this->setVar(
'_UpgradeDone',
true );
656 $this->showDoneMessage();
663 $this->addHTML( $this->parent->getInfoBox(
670 public function showDoneMessage() {
672 $regenerate = !$this->getVar(
'_ExistingDBSettings' );
674 $msg =
'config-upgrade-done';
676 $msg =
'config-upgrade-done-no-regenerate';
678 $this->parent->disableLinkPopups();
680 $this->parent->getInfoBox(
682 $this->getVar(
'wgServer' ) .
683 $this->getVar(
'wgScriptPath' ) .
'/index' .
684 $this->getVar(
'wgScriptExtension' )
685 )->plain(),
'tick-32.png'
688 $this->parent->restoreLinkPopups();
689 $this->endForm( $regenerate ?
'regenerate' :
false,
false );
694 class WebInstaller_DBSettings
extends WebInstallerPage {
700 $installer = $this->parent->getDBInstaller( $this->getVar(
'wgDBtype' ) );
702 $r = $this->parent->request;
703 if ( $r->wasPosted() ) {
704 $status = $installer->submitSettingsForm();
705 if ( $status ===
false ) {
707 } elseif ( $status->isGood() ) {
710 $this->parent->showStatusBox( $status );
714 $form = $installer->getSettingsForm();
715 if (
$form ===
false ) {
720 $this->addHTML(
$form );
728 class WebInstaller_Name
extends WebInstallerPage {
734 $r = $this->parent->request;
735 if ( $r->wasPosted() ) {
736 if ( $this->submit() ) {
747 if ( $this->getVar(
'wgSitename' ) ==
'MediaWiki' ) {
748 $this->setVar(
'wgSitename',
'' );
753 $metaNS = $this->getVar(
'wgMetaNamespace' );
756 wfMessage(
'config-ns-other-default' )->inContentLanguage()->
text()
760 $this->parent->getTextBox(
array(
761 'var' =>
'wgSitename',
762 'label' =>
'config-site-name',
763 'help' => $this->parent->getHelpBox(
'config-site-name-help' )
768 $this->parent->getRadioSet(
array(
769 'var' =>
'_NamespaceType',
770 'label' =>
'config-project-namespace',
771 'itemLabelPrefix' =>
'config-ns-',
772 'values' =>
array(
'site-name',
'generic',
'other' ),
773 'commonAttribs' =>
array(
'class' =>
'enableForOther',
774 'rel' =>
'config_wgMetaNamespace' ),
775 'help' => $this->parent->getHelpBox(
'config-project-namespace-help' )
777 $this->parent->getTextBox(
array(
778 'var' =>
'wgMetaNamespace',
780 'attribs' =>
array(
'readonly' =>
'readonly',
'class' =>
'enabledByOther' )
782 $this->getFieldSetStart(
'config-admin-box' ) .
783 $this->parent->getTextBox(
array(
784 'var' =>
'_AdminName',
785 'label' =>
'config-admin-name',
786 'help' => $this->parent->getHelpBox(
'config-admin-help' )
788 $this->parent->getPasswordBox(
array(
789 'var' =>
'_AdminPassword',
790 'label' =>
'config-admin-password',
792 $this->parent->getPasswordBox(
array(
793 'var' =>
'_AdminPassword2',
794 'label' =>
'config-admin-password-confirm'
796 $this->parent->getTextBox(
array(
797 'var' =>
'_AdminEmail',
798 'label' =>
'config-admin-email',
799 'help' => $this->parent->getHelpBox(
'config-admin-email-help' )
801 $this->parent->getCheckBox(
array(
802 'var' =>
'_Subscribe',
803 'label' =>
'config-subscribe',
804 'help' => $this->parent->getHelpBox(
'config-subscribe-help' )
806 $this->getFieldSetEnd() .
807 $this->parent->getInfoBox(
wfMessage(
'config-almost-done' )->
text() ) .
811 $this->parent->getRadioSet(
array(
812 'var' =>
'_SkipOptional',
813 'itemLabelPrefix' =>
'config-optional-',
814 'values' =>
array(
'continue',
'skip' )
819 $this->setVar(
'wgMetaNamespace', $metaNS );
829 public function submit() {
831 $this->parent->setVarsFromRequest(
array(
'wgSitename',
'_NamespaceType',
832 '_AdminName',
'_AdminPassword',
'_AdminPassword2',
'_AdminEmail',
833 '_Subscribe',
'_SkipOptional',
'wgMetaNamespace' ) );
836 if ( strval( $this->getVar(
'wgSitename' ) ) ===
'' ) {
837 $this->parent->showError(
'config-site-name-blank' );
842 $nsType = $this->getVar(
'_NamespaceType' );
843 if ( $nsType ==
'site-name' ) {
844 $name = $this->getVar(
'wgSitename' );
847 $name = preg_replace(
'/[\[\]\{\}|#<>%+? ]/',
'_',
$name );
851 } elseif ( $nsType ==
'generic' ) {
854 $name = $this->getVar(
'wgMetaNamespace' );
858 if ( strpos(
$name,
':' ) !==
false ) {
864 $good = $nsType ==
'site-name';
871 $this->parent->showError(
'config-ns-invalid',
$name );
878 if ( $nsIndex !==
false && $nsIndex !==
NS_PROJECT ) {
879 $this->parent->showError(
'config-ns-conflict',
$name );
883 $this->setVar(
'wgMetaNamespace',
$name );
886 $name = $this->getVar(
'_AdminName' );
887 if ( strval(
$name ) ===
'' ) {
888 $this->parent->showError(
'config-admin-name-blank' );
893 if ( $cname ===
false ) {
894 $this->parent->showError(
'config-admin-name-invalid',
$name );
897 $this->setVar(
'_AdminName', $cname );
903 $pwd = $this->getVar(
'_AdminPassword' );
906 $valid =
$user->getPasswordValidity( $pwd );
908 $valid =
'config-admin-name-invalid';
910 if ( strval( $pwd ) ===
'' ) {
911 # $user->getPasswordValidity just checks for $wgMinimalPasswordLength.
912 # This message is more specific and helpful.
913 $msg =
'config-admin-password-blank';
914 } elseif ( $pwd !== $this->getVar(
'_AdminPassword2' ) ) {
915 $msg =
'config-admin-password-mismatch';
916 } elseif ( $valid !==
true ) {
919 if ( $msg !==
false ) {
920 call_user_func_array(
array( $this->parent,
'showError' ), (
array)$msg );
921 $this->setVar(
'_AdminPassword',
'' );
922 $this->setVar(
'_AdminPassword2',
'' );
927 $email = $this->getVar(
'_AdminEmail' );
929 $this->parent->showError(
'config-admin-error-bademail' );
934 if ( !$email && $this->getVar(
'_Subscribe' ) ) {
935 $this->parent->showError(
'config-subscribe-noemail' );
944 class WebInstaller_Options
extends WebInstallerPage {
950 if ( $this->getVar(
'_SkipOptional' ) ==
'skip' ) {
953 if ( $this->parent->request->wasPosted() ) {
954 if ( $this->submit() ) {
959 $emailwrapperStyle = $this->getVar(
'wgEnableEmail' ) ?
'' :
'display: none';
966 $this->parent->getRadioSet(
array(
967 'var' =>
'_RightsProfile',
968 'label' =>
'config-profile',
969 'itemLabelPrefix' =>
'config-profile-',
970 'values' => array_keys( $this->parent->rightsProfiles ),
972 $this->parent->getInfoBox(
wfMessage(
'config-profile-help' )->plain() ) .
980 $this->parent->getRadioSet(
array(
981 'var' =>
'_LicenseCode',
982 'label' =>
'config-license',
983 'itemLabelPrefix' =>
'config-license-',
984 'values' => array_keys( $this->parent->licenses ),
985 'commonAttribs' =>
array(
'class' =>
'licenseRadio' ),
987 $this->getCCChooser() .
988 $this->parent->getHelpBox(
'config-license-help' ) .
991 $this->getFieldSetStart(
'config-email-settings' ) .
992 $this->parent->getCheckBox(
array(
993 'var' =>
'wgEnableEmail',
994 'label' =>
'config-enable-email',
995 'attribs' =>
array(
'class' =>
'showHideRadio',
'rel' =>
'emailwrapper' ),
997 $this->parent->getHelpBox(
'config-enable-email-help' ) .
998 "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
999 $this->parent->getTextBox(
array(
1000 'var' =>
'wgPasswordSender',
1001 'label' =>
'config-email-sender'
1003 $this->parent->getHelpBox(
'config-email-sender-help' ) .
1004 $this->parent->getCheckBox(
array(
1005 'var' =>
'wgEnableUserEmail',
1006 'label' =>
'config-email-user',
1008 $this->parent->getHelpBox(
'config-email-user-help' ) .
1009 $this->parent->getCheckBox(
array(
1010 'var' =>
'wgEnotifUserTalk',
1011 'label' =>
'config-email-usertalk',
1013 $this->parent->getHelpBox(
'config-email-usertalk-help' ) .
1014 $this->parent->getCheckBox(
array(
1015 'var' =>
'wgEnotifWatchlist',
1016 'label' =>
'config-email-watchlist',
1018 $this->parent->getHelpBox(
'config-email-watchlist-help' ) .
1019 $this->parent->getCheckBox(
array(
1020 'var' =>
'wgEmailAuthentication',
1021 'label' =>
'config-email-auth',
1023 $this->parent->getHelpBox(
'config-email-auth-help' ) .
1025 $this->getFieldSetEnd()
1031 $extHtml = $this->getFieldSetStart(
'config-extensions' );
1034 $extHtml .= $this->parent->getCheckBox(
array(
1035 'var' =>
"ext-$ext",
1040 $extHtml .= $this->parent->getHelpBox(
'config-extensions-help' ) .
1041 $this->getFieldSetEnd();
1042 $this->addHTML( $extHtml );
1046 $this->setVar(
'wgDeletedDirectory',
1048 '/', DIRECTORY_SEPARATOR,
1049 $this->getVar(
'wgDeletedDirectory' )
1053 $uploadwrapperStyle = $this->getVar(
'wgEnableUploads' ) ?
'' :
'display: none';
1056 $this->getFieldSetStart(
'config-upload-settings' ) .
1057 $this->parent->getCheckBox(
array(
1058 'var' =>
'wgEnableUploads',
1059 'label' =>
'config-upload-enable',
1060 'attribs' =>
array(
'class' =>
'showHideRadio',
'rel' =>
'uploadwrapper' ),
1061 'help' => $this->parent->getHelpBox(
'config-upload-help' )
1063 '<div id="uploadwrapper" style="' . $uploadwrapperStyle .
'">' .
1064 $this->parent->getTextBox(
array(
1065 'var' =>
'wgDeletedDirectory',
1066 'label' =>
'config-upload-deleted',
1067 'attribs' =>
array(
'dir' =>
'ltr' ),
1068 'help' => $this->parent->getHelpBox(
'config-upload-deleted-help' )
1071 $this->parent->getTextBox(
array(
1073 'label' =>
'config-logo',
1074 'attribs' =>
array(
'dir' =>
'ltr' ),
1075 'help' => $this->parent->getHelpBox(
'config-logo-help' )
1079 $this->parent->getCheckBox(
array(
1080 'var' =>
'wgUseInstantCommons',
1081 'label' =>
'config-instantcommons',
1082 'help' => $this->parent->getHelpBox(
'config-instantcommons-help' )
1084 $this->getFieldSetEnd()
1087 $caches =
array(
'none' );
1088 if ( count( $this->getVar(
'_Caches' ) ) ) {
1089 $caches[] =
'accel';
1091 $caches[] =
'memcached';
1094 $cacheval = $this->getVar(
'wgMainCacheType' );
1101 $hidden = ( $cacheval ==
'memcached' ) ?
'' :
'display: none';
1104 $this->getFieldSetStart(
'config-advanced-settings' ) .
1109 $this->parent->getRadioSet(
array(
1110 'var' =>
'wgMainCacheType',
1111 'label' =>
'config-cache-options',
1112 'itemLabelPrefix' =>
'config-cache-',
1113 'values' => $caches,
1114 'value' => $cacheval,
1116 $this->parent->getHelpBox(
'config-cache-help' ) .
1117 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
1118 $this->parent->getTextArea(
array(
1119 'var' =>
'_MemCachedServers',
1120 'label' =>
'config-memcached-servers',
1121 'help' => $this->parent->getHelpBox(
'config-memcached-help' )
1124 $this->getFieldSetEnd()
1134 public function getCCPartnerUrl() {
1135 $server = $this->getVar(
'wgServer' );
1136 $exitUrl = $server . $this->parent->getUrl(
array(
1137 'page' =>
'Options',
1138 'SubmitCC' =>
'indeed',
1139 'config__LicenseCode' =>
'cc',
1140 'config_wgRightsUrl' =>
'[license_url]',
1141 'config_wgRightsText' =>
'[license_name]',
1142 'config_wgRightsIcon' =>
'[license_button]',
1144 $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
1145 '/skins/common/config-cc.css';
1146 $iframeUrl =
'http://creativecommons.org/license/?' .
1148 'partner' =>
'MediaWiki',
1149 'exit_url' => $exitUrl,
1150 'lang' => $this->getVar(
'_UserLang' ),
1151 'stylesheet' => $styleUrl,
1160 public function getCCChooser() {
1161 $iframeAttribs =
array(
1162 'class' =>
'config-cc-iframe',
1163 'name' =>
'config-cc-iframe',
1164 'id' =>
'config-cc-iframe',
1169 if ( $this->getVar(
'_CCDone' ) ) {
1170 $iframeAttribs[
'src'] = $this->parent->getUrl(
array(
'ShowCC' =>
'yes' ) );
1172 $iframeAttribs[
'src'] = $this->getCCPartnerUrl();
1174 $wrapperStyle = ( $this->getVar(
'_LicenseCode' ) ==
'cc-choose' ) ?
'' :
'display: none';
1176 return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
1184 public function getCCDoneBox() {
1185 $js =
"parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
1187 $expandJs = str_replace(
'$1',
'54em', $js );
1188 $reduceJs = str_replace(
'$1',
'70px', $js );
1193 htmlspecialchars( $this->getVar(
'wgRightsText' ) ) .
1195 "<p style=\"text-align: center;\">" .
1198 'href' => $this->getCCPartnerUrl(),
1199 'onclick' => $expandJs,
1205 # Reduce the wrapper div height
1206 htmlspecialchars( $reduceJs ) .
1211 public function submitCC() {
1212 $newValues = $this->parent->setVarsFromRequest(
1213 array(
'wgRightsUrl',
'wgRightsText',
'wgRightsIcon' ) );
1214 if ( count( $newValues ) != 3 ) {
1215 $this->parent->showError(
'config-cc-error' );
1219 $this->setVar(
'_CCDone',
true );
1220 $this->addHTML( $this->getCCDoneBox() );
1226 public function submit() {
1227 $this->parent->setVarsFromRequest(
array(
'_RightsProfile',
'_LicenseCode',
1228 'wgEnableEmail',
'wgPasswordSender',
'wgEnableUploads',
'wgLogo',
1229 'wgEnableUserEmail',
'wgEnotifUserTalk',
'wgEnotifWatchlist',
1230 'wgEmailAuthentication',
'wgMainCacheType',
'_MemCachedServers',
1231 'wgUseInstantCommons' ) );
1233 if ( !array_key_exists( $this->getVar(
'_RightsProfile' ), $this->parent->rightsProfiles )
1235 reset( $this->parent->rightsProfiles );
1236 $this->setVar(
'_RightsProfile',
key( $this->parent->rightsProfiles ) );
1239 $code = $this->getVar(
'_LicenseCode' );
1240 if ( $code ==
'cc-choose' ) {
1241 if ( !$this->getVar(
'_CCDone' ) ) {
1242 $this->parent->showError(
'config-cc-not-chosen' );
1246 } elseif ( array_key_exists( $code, $this->parent->licenses ) ) {
1251 $entry = $this->parent->licenses[$code];
1252 if ( isset( $entry[
'text'] ) ) {
1253 $this->setVar(
'wgRightsText', $entry[
'text'] );
1255 $this->setVar(
'wgRightsText',
wfMessage(
'config-license-' . $code )->
text() );
1257 $this->setVar(
'wgRightsUrl', $entry[
'url'] );
1258 $this->setVar(
'wgRightsIcon', $entry[
'icon'] );
1260 $this->setVar(
'wgRightsText',
'' );
1261 $this->setVar(
'wgRightsUrl',
'' );
1262 $this->setVar(
'wgRightsIcon',
'' );
1265 $extsAvailable = $this->parent->findExtensions();
1266 $extsToInstall =
array();
1267 foreach ( $extsAvailable
as $ext ) {
1268 if ( $this->parent->request->getCheck(
'config_ext-' .
$ext ) ) {
1269 $extsToInstall[] =
$ext;
1272 $this->parent->setVar(
'_Extensions', $extsToInstall );
1274 if ( $this->getVar(
'wgMainCacheType' ) ==
'memcached' ) {
1275 $memcServers = explode(
"\n", $this->getVar(
'_MemCachedServers' ) );
1276 if ( !$memcServers ) {
1277 $this->parent->showError(
'config-memcache-needservers' );
1282 foreach ( $memcServers
as $server ) {
1283 $memcParts = explode(
":", $server, 2 );
1284 if ( !isset( $memcParts[0] )
1286 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
1288 $this->parent->showError(
'config-memcache-badip', $memcParts[0] );
1291 } elseif ( !isset( $memcParts[1] ) ) {
1292 $this->parent->showError(
'config-memcache-noport', $memcParts[0] );
1295 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
1296 $this->parent->showError(
'config-memcache-badport', 1, 65535 );
1308 class WebInstaller_Install
extends WebInstallerPage {
1313 public function isSlow() {
1321 if ( $this->getVar(
'_UpgradeDone' ) ) {
1323 } elseif ( $this->getVar(
'_InstallDone' ) ) {
1325 } elseif ( $this->parent->request->wasPosted() ) {
1327 $this->addHTML(
"<ul>" );
1328 $results = $this->parent->performInstallation(
1329 array( $this,
'startStage' ),
1330 array( $this,
'endStage' )
1332 $this->addHTML(
"</ul>" );
1335 $lastStep = end( $results );
1336 $continue = $lastStep->isOK() ?
'continue' :
false;
1337 $back = $lastStep->isOK() ?
false :
'back';
1338 $this->endForm( $continue, $back );
1341 $this->addHTML( $this->parent->getInfoBox(
wfMessage(
'config-install-begin' )->plain() ) );
1351 public function startStage( $step ) {
1354 $this->addHTML(
"<li>" .
wfMessage(
"config-install-$step" )->escaped() .
1357 if ( $step ==
'extension-tables' ) {
1358 $this->startLiveBox();
1366 public function endStage( $step, $status ) {
1367 if ( $step ==
'extension-tables' ) {
1368 $this->endLiveBox();
1370 $msg = $status->isOk() ?
'config-install-step-done' :
'config-install-step-failed';
1372 if ( !$status->isOk() ) {
1373 $html =
"<span class=\"error\">$html</span>";
1375 $this->addHTML(
$html .
"</li>\n" );
1376 if ( !$status->isGood() ) {
1377 $this->parent->showStatusBox( $status );
1383 class WebInstaller_Complete
extends WebInstallerPage {
1388 $lsUrl = $this->getVar(
'wgServer' ) . $this->parent->getURL(
array(
'localsettings' => 1 ) );
1389 if ( isset( $_SERVER[
'HTTP_USER_AGENT'] ) &&
1390 strpos( $_SERVER[
'HTTP_USER_AGENT'],
'MSIE' ) !==
false
1393 $this->addHtml(
"\n<script>jQuery( function () { document.location = " .
1396 $this->parent->request->response()->header(
"Refresh: 0;url=$lsUrl" );
1400 $this->parent->disableLinkPopups();
1402 $this->parent->getInfoBox(
1405 $this->getVar(
'wgServer' ) .
1406 $this->getVar(
'wgScriptPath' ) .
'/index' .
1407 $this->getVar(
'wgScriptExtension' ),
1409 )->plain(),
'tick-32.png'
1412 $this->addHTML( $this->parent->getInfoBox(
1415 $this->parent->restoreLinkPopups();
1416 $this->endForm(
false,
false );
1421 class WebInstaller_Restart
extends WebInstallerPage {
1427 $r = $this->parent->request;
1428 if ( $r->wasPosted() ) {
1429 $really = $r->getVal(
'submit-restart' );
1431 $this->parent->reset();
1438 $s = $this->parent->getWarningBox(
wfMessage(
'config-help-restart' )->plain() );
1439 $this->addHTML(
$s );
1440 $this->endForm(
'restart' );
1447 abstract class WebInstaller_Document
extends WebInstallerPage {
1452 abstract protected function getFileName();
1455 $text = $this->getFileContents();
1457 $this->parent->output->addWikiText( $text );
1459 $this->endForm(
false );
1465 public function getFileContents() {
1466 $file = __DIR__ .
'/../../' . $this->getFileName();
1467 if ( !file_exists(
$file ) ) {
1471 return file_get_contents(
$file );
1476 class WebInstaller_Readme
extends WebInstaller_Document {
1481 protected function getFileName() {
1487 class WebInstaller_ReleaseNotes
extends WebInstaller_Document {
1493 protected function getFileName() {
1496 if ( !preg_match(
'/^(\d+)\.(\d+).*/i', $wgVersion,
$result ) ) {
1497 throw new MWException(
'Variable $wgVersion has an invalid value.' );
1505 class WebInstaller_UpgradeDoc
extends WebInstaller_Document {
1510 protected function getFileName() {
1516 class WebInstaller_Copying
extends WebInstaller_Document {
1521 protected function getFileName() {