30 if ( $this->
getVar(
'_SkipOptional' ) ==
'skip' ) {
34 if ( $this->parent->request->wasPosted() && $this->submit() ) {
39 $this->addModeOptions();
40 $this->addEmailOptions();
41 $this->addSkinOptions();
42 $this->addExtensionOptions();
43 $this->addFileOptions();
44 $this->addPersonalizationOptions();
45 $this->addAdvancedOptions();
51 private function addPersonalizationOptions() {
55 Html::rawElement(
'div', [
56 'class' =>
'config-drag-drop'
57 ],
wfMessage(
'config-logo-summary' )->parse() ) .
58 Html::openElement(
'div', [
59 'class' =>
'config-personalization-options'
61 Html::hidden(
'config_LogoSiteName', $this->
getVar(
'wgSitename' ) ) .
65 'value' =>
'$wgResourceBasePath/resources/assets/change-your-logo.svg',
66 'label' =>
'config-logo-icon',
67 'attribs' => [
'dir' =>
'ltr' ],
71 'var' =>
'_LogoWordmark',
72 'label' =>
'config-logo-wordmark',
73 'attribs' => [
'dir' =>
'ltr' ],
77 'var' =>
'_LogoTagline',
78 'label' =>
'config-logo-tagline',
79 'attribs' => [
'dir' =>
'ltr' ],
84 'label' =>
'config-logo-sidebar',
85 'attribs' => [
'dir' =>
'ltr' ],
88 Html::openElement(
'div', [
89 'class' =>
'logo-preview-area',
90 'data-main-page' =>
wfMessage(
'config-logo-preview-main' ),
91 'data-filedrop' =>
wfMessage(
'config-logo-filedrop' )
93 Html::closeElement(
'div' ) .
94 Html::closeElement(
'div' ) .
103 private function addModeOptions(): void {
109 $this->parent->getRadioSet( [
110 'var' =>
'_RightsProfile',
111 'label' =>
'config-profile',
112 'itemLabelPrefix' =>
'config-profile-',
113 'values' => array_keys( $this->parent->rightsProfiles ),
115 $this->parent->getInfoBox(
wfMessage(
'config-profile-help' )->plain() ) .
123 $this->parent->getRadioSet( [
124 'var' =>
'_LicenseCode',
125 'label' =>
'config-license',
126 'itemLabelPrefix' =>
'config-license-',
127 'values' => array_keys( $this->parent->licenses ),
128 'commonAttribs' => [
'class' =>
'licenseRadio' ],
131 $this->parent->getHelpBox(
'config-license-help' )
139 private function addEmailOptions(): void {
140 $emailwrapperStyle = $this->getVar(
'wgEnableEmail' ) ?
'' :
'display: none';
142 $this->getFieldsetStart(
'config-email-settings' ) .
143 $this->parent->getCheckBox( [
144 'var' =>
'wgEnableEmail',
145 'label' =>
'config-enable-email',
146 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'emailwrapper' ],
148 $this->parent->getHelpBox(
'config-enable-email-help' ) .
149 "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
150 $this->parent->getTextBox( [
151 'var' =>
'wgPasswordSender',
152 'label' =>
'config-email-sender'
154 $this->parent->getHelpBox(
'config-email-sender-help' ) .
155 $this->parent->getCheckBox( [
156 'var' =>
'wgEnableUserEmail',
157 'label' =>
'config-email-user',
159 $this->parent->getHelpBox(
'config-email-user-help' ) .
160 $this->parent->getCheckBox( [
161 'var' =>
'wgEnotifUserTalk',
162 'label' =>
'config-email-usertalk',
164 $this->parent->getHelpBox(
'config-email-usertalk-help' ) .
165 $this->parent->getCheckBox( [
166 'var' =>
'wgEnotifWatchlist',
167 'label' =>
'config-email-watchlist',
169 $this->parent->getHelpBox(
'config-email-watchlist-help' ) .
170 $this->parent->getCheckBox( [
171 'var' =>
'wgEmailAuthentication',
172 'label' =>
'config-email-auth',
174 $this->parent->getHelpBox(
'config-email-auth-help' ) .
176 $this->getFieldsetEnd()
184 private function addSkinOptions(): void {
185 $skins = $this->parent->findExtensions(
'skins' )->value;
186 '@phan-var array[] $skins';
187 $skinHtml = $this->getFieldsetStart(
'config-skins' );
189 $skinNames = array_map(
'strtolower', array_keys( $skins ) );
190 $chosenSkinName = $this->getVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
193 $radioButtons = $this->parent->getRadioElements( [
194 'var' =>
'wgDefaultSkin',
195 'itemLabels' => array_fill_keys( $skinNames,
'config-skins-use-as-default' ),
196 'values' => $skinNames,
197 'value' => $chosenSkinName,
200 foreach ( $skins as $skin => $info ) {
201 if ( isset( $info[
'screenshots'] ) ) {
202 $screenshotText = $this->makeScreenshotsLink( $skin, $info[
'screenshots'] );
204 $screenshotText = htmlspecialchars( $skin );
207 '<div class="config-skins-item">' .
208 $this->parent->getCheckBox( [
209 'var' =>
"skin-$skin",
210 'rawtext' => $screenshotText,
211 'value' => $this->getVar(
"skin-$skin",
true ),
213 '<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] .
'</div>' .
219 Html::hidden(
'config_wgDefaultSkin', $chosenSkinName );
222 $skinHtml .= $this->parent->getHelpBox(
'config-skins-help' ) .
223 $this->getFieldsetEnd();
224 $this->addHTML( $skinHtml );
231 private function addExtensionOptions(): void {
234 $extensions = $this->parent->findExtensions()->value;
235 '@phan-var array[] $extensions';
239 $extHtml = $this->getFieldsetStart(
'config-extensions' );
244 foreach ( $extensions as
$ext => $info ) {
245 if ( !isset( $info[
'type'] ) || !isset( $types[$info[
'type']] ) ) {
249 $info[
'type'] =
'other';
251 $extByType[$info[
'type']][
$ext] = $info;
254 foreach ( $types as
$type => $message ) {
255 if ( !isset( $extByType[
$type] ) ) {
259 foreach ( $extByType[
$type] as
$ext => $info ) {
261 if ( isset( $info[
'url'] ) ) {
262 $urlText =
' ' .
Html::element(
'a', [
'href' => $info[
'url'] ],
'(more information)' );
266 'class' =>
'config-ext-input'
270 if ( isset( $info[
'requires'][
'extensions'] ) ) {
271 $dependencyMap[
$ext][
'extensions'] = $info[
'requires'][
'extensions'];
272 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
274 if ( isset( $info[
'requires'][
'skins'] ) ) {
275 $dependencyMap[
$ext][
'skins'] = $info[
'requires'][
'skins'];
276 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
278 if ( isset( $dependencyMap[
$ext] ) ) {
282 if ( isset( $dependencyMap[
$ext][
'extensions'] ) ) {
283 foreach ( $dependencyMap[
$ext][
'extensions'] as $name ) {
286 [
'href' =>
"#config_ext-$name" ],
291 if ( isset( $dependencyMap[
$ext][
'skins'] ) ) {
293 foreach ( $dependencyMap[
$ext][
'skins'] as $name ) {
296 [
'href' =>
"#config_skin-$name" ],
302 $text =
wfMessage(
'config-extensions-requires' )
308 $extHtml .= $this->parent->getCheckBox( [
311 'attribs' => $attribs,
312 'labelAttribs' => $labelAttribs,
317 $extHtml .= $this->parent->getHelpBox(
'config-extensions-help' ) .
318 $this->getFieldsetEnd();
319 $this->addHTML( $extHtml );
321 $this->addHTML( Html::inlineScript(
322 'var extDependencyMap = ' . Xml::encodeJsVar( $dependencyMap )
331 private function addFileOptions(): void {
333 $this->setVar(
'wgDeletedDirectory',
335 '/', DIRECTORY_SEPARATOR,
336 $this->getVar(
'wgDeletedDirectory' )
340 $uploadwrapperStyle = $this->getVar(
'wgEnableUploads' ) ?
'' :
'display: none';
343 $this->getFieldsetStart(
'config-upload-settings' ) .
344 $this->parent->getCheckBox( [
345 'var' =>
'wgEnableUploads',
346 'label' =>
'config-upload-enable',
347 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'uploadwrapper' ],
348 'help' => $this->parent->getHelpBox(
'config-upload-help' )
350 '<div id="uploadwrapper" style="' . $uploadwrapperStyle .
'">' .
351 $this->parent->getTextBox( [
352 'var' =>
'wgDeletedDirectory',
353 'label' =>
'config-upload-deleted',
354 'attribs' => [
'dir' =>
'ltr' ],
355 'help' => $this->parent->getHelpBox(
'config-upload-deleted-help' )
360 $this->parent->getCheckBox( [
361 'var' =>
'wgUseInstantCommons',
362 'label' =>
'config-instantcommons',
363 'help' => $this->parent->getHelpBox(
'config-instantcommons-help' )
365 $this->getFieldsetEnd()
373 private function addAdvancedOptions(): void {
374 $caches = [
'none' ];
375 $cachevalDefault =
'none';
377 if ( count( $this->getVar(
'_Caches' ) ) ) {
380 $cachevalDefault =
'accel';
382 $caches[] =
'memcached';
385 $cacheval = $this->getVar(
'_MainCacheType' );
390 $cacheval = $cachevalDefault;
392 $hidden = ( $cacheval ==
'memcached' ) ?
'' :
'display: none';
395 $this->getFieldsetStart(
'config-advanced-settings' ) .
396 # Object cache settings
400 $this->parent->getRadioSet( [
401 'var' =>
'_MainCacheType',
402 'label' =>
'config-cache-options',
403 'itemLabelPrefix' =>
'config-cache-',
405 'value' => $cacheval,
407 $this->parent->getHelpBox(
'config-cache-help' ) .
408 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
409 $this->parent->getTextArea( [
410 'var' =>
'_MemCachedServers',
411 'label' =>
'config-memcached-servers',
412 'help' => $this->parent->getHelpBox(
'config-memcached-help' )
415 $this->getFieldsetEnd()
424 private function makeScreenshotsLink( $name, $screenshots ) {
426 if ( count( $screenshots ) > 1 ) {
430 foreach ( $screenshots as $shot ) {
433 [
'href' => $shot,
'target' =>
'_blank' ],
434 $wgLang->formatNum( $counter++ )
437 return wfMessage(
'config-skins-screenshots' )
438 ->rawParams( $name,
$wgLang->commaList( $links ) )
443 [
'href' => $screenshots[0],
'target' =>
'_blank' ],
446 return wfMessage(
'config-skins-screenshot', $name )->rawParams( $link )->escaped();
454 $server = $this->getVar(
'wgServer' );
455 $exitUrl = $server . $this->parent->getUrl( [
457 'SubmitCC' =>
'indeed',
458 'config__LicenseCode' =>
'cc',
459 'config_wgRightsUrl' =>
'[license_url]',
460 'config_wgRightsText' =>
'[license_name]',
461 'config_wgRightsIcon' =>
'[license_button]',
463 $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
464 '/mw-config/config-cc.css';
465 $iframeUrl =
'https://creativecommons.org/license/?' .
467 'partner' =>
'MediaWiki',
468 'exit_url' => $exitUrl,
469 'lang' => $this->getVar(
'_UserLang' ),
470 'stylesheet' => $styleUrl,
481 'class' =>
'config-cc-iframe',
482 'name' =>
'config-cc-iframe',
483 'id' =>
'config-cc-iframe',
488 if ( $this->getVar(
'_CCDone' ) ) {
489 $iframeAttribs[
'src'] = $this->parent->getUrl( [
'ShowCC' =>
'yes' ] );
491 $iframeAttribs[
'src'] = $this->getCCPartnerUrl();
493 $wrapperStyle = ( $this->getVar(
'_LicenseCode' ) ==
'cc-choose' ) ?
'' :
'display: none';
495 return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
496 Html::element(
'iframe', $iframeAttribs ) .
504 $js =
"parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
506 $expandJs = str_replace(
'$1',
'54em', $js );
507 $reduceJs = str_replace(
'$1',
'70px', $js );
510 Html::element(
'img', [
'src' => $this->getVar(
'wgRightsIcon' ) ] ) .
512 htmlspecialchars( $this->getVar(
'wgRightsText' ) ) .
514 "<p style=\"text-align: center;\">" .
517 'href' => $this->getCCPartnerUrl(),
518 'onclick' => $expandJs,
524 # Reduce the wrapper div height
525 htmlspecialchars( $reduceJs ) .
531 $newValues = $this->parent->setVarsFromRequest(
532 [
'wgRightsUrl',
'wgRightsText',
'wgRightsIcon' ] );
533 if ( count( $newValues ) != 3 ) {
534 $this->parent->showError(
'config-cc-error' );
538 $this->setVar(
'_CCDone',
true );
539 $this->addHTML( $this->getCCDoneBox() );
549 $skins = array_keys( $this->parent->findExtensions(
'skins' )->value );
550 $this->parent->setVar(
'_Skins', $skins );
553 $skinNames = array_map(
'strtolower', $skins );
554 $this->parent->setVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
564 $this->parent->setVarsFromRequest( [
'_RightsProfile',
'_LicenseCode',
565 'wgEnableEmail',
'wgPasswordSender',
'wgEnableUploads',
566 '_Logo1x',
'_LogoWordmark',
'_LogoTagline',
'_LogoIcon',
567 'wgEnableUserEmail',
'wgEnotifUserTalk',
'wgEnotifWatchlist',
568 'wgEmailAuthentication',
'_MainCacheType',
'_MemCachedServers',
569 'wgUseInstantCommons',
'wgDefaultSkin' ] );
573 if ( !array_key_exists( $this->getVar(
'_RightsProfile' ), $this->parent->rightsProfiles ) ) {
574 reset( $this->parent->rightsProfiles );
575 $this->setVar(
'_RightsProfile', key( $this->parent->rightsProfiles ) );
578 $code = $this->getVar(
'_LicenseCode' );
579 if ( $code ==
'cc-choose' ) {
580 if ( !$this->getVar(
'_CCDone' ) ) {
581 $this->parent->showError(
'config-cc-not-chosen' );
584 } elseif ( array_key_exists( $code, $this->parent->licenses ) ) {
589 $entry = $this->parent->licenses[$code];
590 $this->setVar(
'wgRightsText',
591 $entry[
'text'] ??
wfMessage(
'config-license-' . $code )->text() );
592 $this->setVar(
'wgRightsUrl', $entry[
'url'] );
593 $this->setVar(
'wgRightsIcon', $entry[
'icon'] );
595 $this->setVar(
'wgRightsText',
'' );
596 $this->setVar(
'wgRightsUrl',
'' );
597 $this->setVar(
'wgRightsIcon',
'' );
600 $skinsAvailable = array_keys( $this->parent->findExtensions(
'skins' )->value );
601 $skinsToInstall = [];
602 foreach ( $skinsAvailable as $skin ) {
603 $this->parent->setVarsFromRequest( [
"skin-$skin" ] );
604 if ( $this->getVar(
"skin-$skin" ) ) {
605 $skinsToInstall[] = $skin;
608 $this->parent->setVar(
'_Skins', $skinsToInstall );
610 if ( !$skinsToInstall && $skinsAvailable ) {
611 $this->parent->showError(
'config-skins-must-enable-some' );
614 $defaultSkin = $this->getVar(
'wgDefaultSkin' );
615 $skinsToInstallLowercase = array_map(
'strtolower', $skinsToInstall );
616 if ( $skinsToInstall && !in_array( $defaultSkin, $skinsToInstallLowercase ) ) {
617 $this->parent->showError(
'config-skins-must-enable-default' );
621 $extsAvailable = array_keys( $this->parent->findExtensions()->value );
623 foreach ( $extsAvailable as
$ext ) {
624 $this->parent->setVarsFromRequest( [
"ext-$ext" ] );
625 if ( $this->getVar(
"ext-$ext" ) ) {
626 $extsToInstall[] =
$ext;
629 $this->parent->setVar(
'_Extensions', $extsToInstall );
631 if ( $this->getVar(
'_MainCacheType' ) ==
'memcached' ) {
632 $memcServers = explode(
"\n", $this->getVar(
'_MemCachedServers' ) );
636 if ( !$memcServers ) {
637 $this->parent->showError(
'config-memcache-needservers' );
641 foreach ( $memcServers as $server ) {
642 $memcParts = explode(
":", $server, 2 );
643 if ( !isset( $memcParts[0] )
644 || ( !IPUtils::isValid( $memcParts[0] )
645 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
647 $this->parent->showError(
'config-memcache-badip', $memcParts[0] );
649 } elseif ( !isset( $memcParts[1] ) ) {
650 $this->parent->showError(
'config-memcache-noport', $memcParts[0] );
652 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
653 $this->parent->showError(
'config-memcache-badport', 1, 65535 );
Abstract class to define pages for the web installer.
WebInstaller $parent
The WebInstaller object this WebInstallerPage belongs to.
getFieldsetEnd()
Get the end tag of a fieldset.
endForm( $continue='continue', $back='back')
getFieldsetStart( $legend)
Get the starting tags of a fieldset.