24 use Wikimedia\IPUtils;
32 if ( $this->
getVar(
'_SkipOptional' ) ==
'skip' ) {
36 if ( $this->parent->request->wasPosted() && $this->submit() ) {
41 $this->addModeOptions();
42 $this->addEmailOptions();
43 $this->addSkinOptions();
44 $this->addExtensionOptions();
45 $this->addFileOptions();
46 $this->addPersonalizationOptions();
47 $this->addAdvancedOptions();
53 private function addPersonalizationOptions() {
57 Html::rawElement(
'div', [
58 'class' =>
'config-drag-drop'
59 ],
wfMessage(
'config-logo-summary' )->parse() ) .
60 Html::openElement(
'div', [
61 'class' =>
'config-personalization-options'
63 Html::hidden(
'config_LogoSiteName', $this->
getVar(
'wgSitename' ) ) .
67 'value' =>
'$wgResourceBasePath/resources/assets/change-your-logo.svg',
68 'label' =>
'config-logo-icon',
69 'attribs' => [
'dir' =>
'ltr' ],
73 'var' =>
'_LogoWordmark',
74 'label' =>
'config-logo-wordmark',
75 'attribs' => [
'dir' =>
'ltr' ],
79 'var' =>
'_LogoTagline',
80 'label' =>
'config-logo-tagline',
81 'attribs' => [
'dir' =>
'ltr' ],
86 'label' =>
'config-logo-sidebar',
87 'attribs' => [
'dir' =>
'ltr' ],
90 Html::openElement(
'div', [
91 'class' =>
'logo-preview-area',
92 'data-main-page' =>
wfMessage(
'config-logo-preview-main' ),
93 'data-filedrop' =>
wfMessage(
'config-logo-filedrop' )
95 Html::closeElement(
'div' ) .
96 Html::closeElement(
'div' ) .
105 private function addModeOptions(): void {
111 $this->parent->getRadioSet( [
112 'var' =>
'_RightsProfile',
113 'label' =>
'config-profile',
114 'itemLabelPrefix' =>
'config-profile-',
115 'values' => array_keys( $this->parent->rightsProfiles ),
117 $this->parent->getInfoBox(
wfMessage(
'config-profile-help' )->plain() ) .
125 $this->parent->getRadioSet( [
126 'var' =>
'_LicenseCode',
127 'label' =>
'config-license',
128 'itemLabelPrefix' =>
'config-license-',
129 'values' => array_keys( $this->parent->licenses ),
130 'commonAttribs' => [
'class' =>
'licenseRadio' ],
133 $this->parent->getHelpBox(
'config-license-help' )
141 private function addEmailOptions(): void {
142 $emailwrapperStyle = $this->getVar(
'wgEnableEmail' ) ?
'' :
'display: none';
144 $this->getFieldsetStart(
'config-email-settings' ) .
145 $this->parent->getCheckBox( [
146 'var' =>
'wgEnableEmail',
147 'label' =>
'config-enable-email',
148 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'emailwrapper' ],
150 $this->parent->getHelpBox(
'config-enable-email-help' ) .
151 "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
152 $this->parent->getTextBox( [
153 'var' =>
'wgPasswordSender',
154 'label' =>
'config-email-sender'
156 $this->parent->getHelpBox(
'config-email-sender-help' ) .
157 $this->parent->getCheckBox( [
158 'var' =>
'wgEnableUserEmail',
159 'label' =>
'config-email-user',
161 $this->parent->getHelpBox(
'config-email-user-help' ) .
162 $this->parent->getCheckBox( [
163 'var' =>
'wgEnotifUserTalk',
164 'label' =>
'config-email-usertalk',
166 $this->parent->getHelpBox(
'config-email-usertalk-help' ) .
167 $this->parent->getCheckBox( [
168 'var' =>
'wgEnotifWatchlist',
169 'label' =>
'config-email-watchlist',
171 $this->parent->getHelpBox(
'config-email-watchlist-help' ) .
172 $this->parent->getCheckBox( [
173 'var' =>
'wgEmailAuthentication',
174 'label' =>
'config-email-auth',
176 $this->parent->getHelpBox(
'config-email-auth-help' ) .
178 $this->getFieldsetEnd()
186 private function addSkinOptions(): void {
187 $skins = $this->parent->findExtensions(
'skins' )->value;
188 '@phan-var array[] $skins';
189 $skinHtml = $this->getFieldsetStart(
'config-skins' );
191 $skinNames = array_map(
'strtolower', array_keys( $skins ) );
192 $chosenSkinName = $this->getVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
195 $radioButtons = $this->parent->getRadioElements( [
196 'var' =>
'wgDefaultSkin',
197 'itemLabels' => array_fill_keys( $skinNames,
'config-skins-use-as-default' ),
198 'values' => $skinNames,
199 'value' => $chosenSkinName,
202 foreach ( $skins as $skin => $info ) {
203 if ( isset( $info[
'screenshots'] ) ) {
204 $screenshotText = $this->makeScreenshotsLink( $skin, $info[
'screenshots'] );
206 $screenshotText = htmlspecialchars( $skin );
209 '<div class="config-skins-item">' .
210 $this->parent->getCheckBox( [
211 'var' =>
"skin-$skin",
212 'rawtext' => $screenshotText . $this->makeMoreInfoLink( $info ),
213 'value' => $this->getVar(
"skin-$skin",
true ),
215 '<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] .
'</div>' .
220 Html::warningBox(
wfMessage(
'config-skins-missing' )->plain(),
'config-warning-box' ) .
221 Html::hidden(
'config_wgDefaultSkin', $chosenSkinName );
224 $skinHtml .= $this->parent->getHelpBox(
'config-skins-help' ) .
225 $this->getFieldsetEnd();
226 $this->addHTML( $skinHtml );
233 private function addExtensionOptions(): void {
236 $extensions = $this->parent->findExtensions()->value;
237 '@phan-var array[] $extensions';
241 $extHtml = $this->getFieldsetStart(
'config-extensions' );
244 $types = SpecialVersion::getExtensionTypes();
246 foreach ( $extensions as
$ext => $info ) {
247 if ( !isset( $info[
'type'] ) || !isset( $types[$info[
'type']] ) ) {
251 $info[
'type'] =
'other';
253 $extByType[$info[
'type']][
$ext] = $info;
256 foreach ( $types as $type => $message ) {
257 if ( !isset( $extByType[$type] ) ) {
260 $extHtml .= Html::element(
'h2', [], $message );
261 foreach ( $extByType[$type] as
$ext => $info ) {
264 'class' =>
'config-ext-input'
267 if ( isset( $info[
'requires'][
'extensions'] ) ) {
268 $dependencyMap[
$ext][
'extensions'] = $info[
'requires'][
'extensions'];
269 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
271 if ( isset( $info[
'requires'][
'skins'] ) ) {
272 $dependencyMap[
$ext][
'skins'] = $info[
'requires'][
'skins'];
273 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
275 if ( isset( $dependencyMap[
$ext] ) ) {
279 if ( isset( $dependencyMap[
$ext][
'extensions'] ) ) {
280 foreach ( $dependencyMap[
$ext][
'extensions'] as $name ) {
281 $links[] = Html::element(
283 [
'href' =>
"#config_ext-$name" ],
288 if ( isset( $dependencyMap[
$ext][
'skins'] ) ) {
290 foreach ( $dependencyMap[
$ext][
'skins'] as $name ) {
291 $links[] = Html::element(
293 [
'href' =>
"#config_skin-$name" ],
299 $text =
wfMessage(
'config-extensions-requires' )
305 $extHtml .= $this->parent->getCheckBox( [
307 'rawtext' => $text . $this->makeMoreInfoLink( $info ),
308 'attribs' => $attribs,
309 'labelAttribs' => $labelAttribs,
314 $extHtml .= $this->parent->getHelpBox(
'config-extensions-help' ) .
315 $this->getFieldsetEnd();
316 $this->addHTML( $extHtml );
318 $this->addHTML( Html::inlineScript(
319 'var extDependencyMap = ' . Html::encodeJsVar( $dependencyMap )
328 private function addFileOptions(): void {
330 $this->setVar(
'wgDeletedDirectory',
332 '/', DIRECTORY_SEPARATOR,
333 $this->getVar(
'wgDeletedDirectory' )
337 $uploadwrapperStyle = $this->getVar(
'wgEnableUploads' ) ?
'' :
'display: none';
340 $this->getFieldsetStart(
'config-upload-settings' ) .
341 $this->parent->getCheckBox( [
342 'var' =>
'wgEnableUploads',
343 'label' =>
'config-upload-enable',
344 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'uploadwrapper' ],
345 'help' => $this->parent->getHelpBox(
'config-upload-help' )
347 '<div id="uploadwrapper" style="' . $uploadwrapperStyle .
'">' .
348 $this->parent->getTextBox( [
349 'var' =>
'wgDeletedDirectory',
350 'label' =>
'config-upload-deleted',
351 'attribs' => [
'dir' =>
'ltr' ],
352 'help' => $this->parent->getHelpBox(
'config-upload-deleted-help' )
357 $this->parent->getCheckBox( [
358 'var' =>
'wgUseInstantCommons',
359 'label' =>
'config-instantcommons',
360 'help' => $this->parent->getHelpBox(
'config-instantcommons-help' )
362 $this->getFieldsetEnd()
370 private function addAdvancedOptions(): void {
371 $caches = [
'none' ];
372 $cachevalDefault =
'none';
374 if ( count( $this->getVar(
'_Caches' ) ) ) {
377 $cachevalDefault =
'accel';
379 $caches[] =
'memcached';
382 $cacheval = $this->getVar(
'_MainCacheType' );
387 $cacheval = $cachevalDefault;
389 $hidden = ( $cacheval ==
'memcached' ) ?
'' :
'display: none';
392 $this->getFieldsetStart(
'config-advanced-settings' ) .
393 # Object cache settings
397 $this->parent->getRadioSet( [
398 'var' =>
'_MainCacheType',
399 'label' =>
'config-cache-options',
400 'itemLabelPrefix' =>
'config-cache-',
402 'value' => $cacheval,
404 $this->parent->getHelpBox(
'config-cache-help' ) .
405 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
406 $this->parent->getTextArea( [
407 'var' =>
'_MemCachedServers',
408 'label' =>
'config-memcached-servers',
409 'help' => $this->parent->getHelpBox(
'config-memcached-help' )
412 $this->getFieldsetEnd()
421 private function makeScreenshotsLink( $name, $screenshots ) {
423 if ( count( $screenshots ) > 1 ) {
427 foreach ( $screenshots as $shot ) {
428 $links[] = Html::element(
430 [
'href' => $shot,
'target' =>
'_blank' ],
431 $wgLang->formatNum( $counter++ )
434 return wfMessage(
'config-skins-screenshots' )
435 ->rawParams( $name,
$wgLang->commaList( $links ) )
438 $link = Html::element(
440 [
'href' => $screenshots[0],
'target' =>
'_blank' ],
443 return wfMessage(
'config-skins-screenshot', $name )->rawParams( $link )->escaped();
451 private function makeMoreInfoLink( $info ) {
452 if ( !isset( $info[
'url'] ) ) {
455 return ' ' .
wfMessage(
'parentheses' )->rawParams(
458 [
'href' => $info[
'url'] ],
459 wfMessage(
'config-ext-skins-more-info' )->text()
468 $server = $this->getVar(
'wgServer' );
469 $exitUrl = $server . $this->parent->getUrl( [
471 'SubmitCC' =>
'indeed',
472 'config__LicenseCode' =>
'cc',
473 'config_wgRightsUrl' =>
'[license_url]',
474 'config_wgRightsText' =>
'[license_name]',
475 'config_wgRightsIcon' =>
'[license_button]',
477 $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
478 '/mw-config/config-cc.css';
479 $iframeUrl =
'https://creativecommons.org/license/?' .
481 'partner' =>
'MediaWiki',
482 'exit_url' => $exitUrl,
483 'lang' => $this->getVar(
'_UserLang' ),
484 'stylesheet' => $styleUrl,
495 'class' =>
'config-cc-iframe',
496 'name' =>
'config-cc-iframe',
497 'id' =>
'config-cc-iframe',
502 if ( $this->getVar(
'_CCDone' ) ) {
503 $iframeAttribs[
'src'] = $this->parent->getUrl( [
'ShowCC' =>
'yes' ] );
505 $iframeAttribs[
'src'] = $this->getCCPartnerUrl();
507 $wrapperStyle = ( $this->getVar(
'_LicenseCode' ) ==
'cc-choose' ) ?
'' :
'display: none';
509 return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
510 Html::element(
'iframe', $iframeAttribs ) .
518 $js =
"parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
520 $expandJs = str_replace(
'$1',
'54em', $js );
521 $reduceJs = str_replace(
'$1',
'70px', $js );
524 Html::element(
'img', [
'src' => $this->getVar(
'wgRightsIcon' ) ] ) .
526 htmlspecialchars( $this->getVar(
'wgRightsText' ) ) .
528 "<p style=\"text-align: center;\">" .
531 'href' => $this->getCCPartnerUrl(),
532 'onclick' => $expandJs,
538 # Reduce the wrapper div height
539 htmlspecialchars( $reduceJs ) .
545 $newValues = $this->parent->setVarsFromRequest(
546 [
'wgRightsUrl',
'wgRightsText',
'wgRightsIcon' ] );
547 if ( count( $newValues ) != 3 ) {
548 $this->parent->showError(
'config-cc-error' );
552 $this->setVar(
'_CCDone',
true );
553 $this->addHTML( $this->getCCDoneBox() );
563 $skins = array_keys( $this->parent->findExtensions(
'skins' )->value );
564 $this->parent->setVar(
'_Skins', $skins );
567 $skinNames = array_map(
'strtolower', $skins );
568 $this->parent->setVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
578 $this->parent->setVarsFromRequest( [
'_RightsProfile',
'_LicenseCode',
579 'wgEnableEmail',
'wgPasswordSender',
'wgEnableUploads',
580 '_Logo1x',
'_LogoWordmark',
'_LogoTagline',
'_LogoIcon',
581 'wgEnableUserEmail',
'wgEnotifUserTalk',
'wgEnotifWatchlist',
582 'wgEmailAuthentication',
'_MainCacheType',
'_MemCachedServers',
583 'wgUseInstantCommons',
'wgDefaultSkin' ] );
587 if ( !array_key_exists( $this->getVar(
'_RightsProfile' ), $this->parent->rightsProfiles ) ) {
588 $this->setVar(
'_RightsProfile', array_key_first( $this->parent->rightsProfiles ) );
591 $code = $this->getVar(
'_LicenseCode' );
592 if ( $code ==
'cc-choose' ) {
593 if ( !$this->getVar(
'_CCDone' ) ) {
594 $this->parent->showError(
'config-cc-not-chosen' );
597 } elseif ( array_key_exists( $code, $this->parent->licenses ) ) {
602 $entry = $this->parent->licenses[$code];
603 $this->setVar(
'wgRightsText',
604 $entry[
'text'] ??
wfMessage(
'config-license-' . $code )->text() );
605 $this->setVar(
'wgRightsUrl', $entry[
'url'] );
606 $this->setVar(
'wgRightsIcon', $entry[
'icon'] );
608 $this->setVar(
'wgRightsText',
'' );
609 $this->setVar(
'wgRightsUrl',
'' );
610 $this->setVar(
'wgRightsIcon',
'' );
613 $skinsAvailable = array_keys( $this->parent->findExtensions(
'skins' )->value );
614 $skinsToInstall = [];
615 foreach ( $skinsAvailable as $skin ) {
616 $this->parent->setVarsFromRequest( [
"skin-$skin" ] );
617 if ( $this->getVar(
"skin-$skin" ) ) {
618 $skinsToInstall[] = $skin;
621 $this->parent->setVar(
'_Skins', $skinsToInstall );
623 if ( !$skinsToInstall && $skinsAvailable ) {
624 $this->parent->showError(
'config-skins-must-enable-some' );
627 $defaultSkin = $this->getVar(
'wgDefaultSkin' );
628 $skinsToInstallLowercase = array_map(
'strtolower', $skinsToInstall );
629 if ( $skinsToInstall && !in_array( $defaultSkin, $skinsToInstallLowercase ) ) {
630 $this->parent->showError(
'config-skins-must-enable-default' );
634 $extsAvailable = array_keys( $this->parent->findExtensions()->value );
636 foreach ( $extsAvailable as
$ext ) {
637 $this->parent->setVarsFromRequest( [
"ext-$ext" ] );
638 if ( $this->getVar(
"ext-$ext" ) ) {
639 $extsToInstall[] =
$ext;
642 $this->parent->setVar(
'_Extensions', $extsToInstall );
644 if ( $this->getVar(
'_MainCacheType' ) ==
'memcached' ) {
645 $memcServers = explode(
"\n", $this->getVar(
'_MemCachedServers' ) );
649 if ( !$memcServers ) {
650 $this->parent->showError(
'config-memcache-needservers' );
654 foreach ( $memcServers as $server ) {
655 $memcParts = explode(
":", $server, 2 );
656 if ( !isset( $memcParts[0] )
657 || ( !IPUtils::isValid( $memcParts[0] )
658 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
660 $this->parent->showError(
'config-memcache-badip', $memcParts[0] );
662 } elseif ( !isset( $memcParts[1] ) ) {
663 $this->parent->showError(
'config-memcache-noport', $memcParts[0] );
665 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
666 $this->parent->showError(
'config-memcache-badport', 1, 65535 );
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgLang
submitSkins()
If the user skips this installer page, we still need to set up the default skins, but ignore everythi...
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')
getVar( $var, $default=null)
getFieldsetStart( $legend)
Get the starting tags of a fieldset.
getTextBox( $params)
Get a labelled text box to configure a variable.
getHelpBox( $msg,... $args)
Get small text indented help for a preceding form field.
if(!is_readable( $file)) $ext