35 if ( $this->
getVar(
'_SkipOptional' ) ==
'skip' ) {
39 if ( $this->parent->request->wasPosted() && $this->submit() ) {
44 $this->addModeOptions();
45 $this->addEmailOptions();
46 $this->addSkinOptions();
47 $this->addExtensionOptions();
48 $this->addFileOptions();
49 $this->addPersonalizationOptions();
50 $this->addAdvancedOptions();
56 private function addPersonalizationOptions() {
60 Html::rawElement(
'div', [
61 'class' =>
'config-drag-drop'
62 ],
wfMessage(
'config-logo-summary' )->parse() ) .
63 Html::openElement(
'div', [
64 'class' =>
'config-personalization-options'
66 Html::hidden(
'config_LogoSiteName', $this->
getVar(
'wgSitename' ) ) .
70 'value' =>
'$wgResourceBasePath/resources/assets/change-your-logo.svg',
71 'label' =>
'config-logo-icon',
72 'attribs' => [
'dir' =>
'ltr' ],
76 'var' =>
'_LogoWordmark',
77 'label' =>
'config-logo-wordmark',
78 'attribs' => [
'dir' =>
'ltr' ],
82 'var' =>
'_LogoTagline',
83 'label' =>
'config-logo-tagline',
84 'attribs' => [
'dir' =>
'ltr' ],
89 'label' =>
'config-logo-sidebar',
90 'attribs' => [
'dir' =>
'ltr' ],
93 Html::openElement(
'div', [
94 'class' =>
'logo-preview-area',
95 'data-main-page' =>
wfMessage(
'config-logo-preview-main' ),
96 'data-filedrop' =>
wfMessage(
'config-logo-filedrop' )
98 Html::closeElement(
'div' ) .
99 Html::closeElement(
'div' ) .
107 private function addModeOptions(): void {
113 $this->parent->getRadioSet( [
114 'var' =>
'_RightsProfile',
115 'label' =>
'config-profile',
116 'itemLabelPrefix' =>
'config-profile-',
117 'values' => array_keys( $this->parent->rightsProfiles ),
119 $this->parent->getInfoBox(
wfMessage(
'config-profile-help' )->plain() ) .
127 $this->parent->getRadioSet( [
128 'var' =>
'_LicenseCode',
129 'label' =>
'config-license',
130 'itemLabelPrefix' =>
'config-license-',
131 'values' => array_keys( $this->parent->licenses ),
132 'commonAttribs' => [
'class' =>
'licenseRadio' ],
134 $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()
185 private function addSkinOptions(): void {
186 $skins = $this->parent->findExtensions(
'skins' )->value;
187 '@phan-var array[] $skins';
188 $skinHtml = $this->getFieldsetStart(
'config-skins' );
190 $skinNames = array_map(
'strtolower', array_keys( $skins ) );
191 $chosenSkinName = $this->getVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
194 $radioButtons = $this->parent->getRadioElements( [
195 'var' =>
'wgDefaultSkin',
196 'itemLabels' => array_fill_keys( $skinNames,
'config-skins-use-as-default' ),
197 'values' => $skinNames,
198 'value' => $chosenSkinName,
201 foreach ( $skins as $skin => $info ) {
202 if ( isset( $info[
'screenshots'] ) ) {
203 $screenshotText = $this->makeScreenshotsLink( $skin, $info[
'screenshots'] );
205 $screenshotText = htmlspecialchars( $skin );
208 '<div class="config-skins-item">' .
209 $this->parent->getCheckBox( [
210 'var' =>
"skin-$skin",
211 'rawtext' => $screenshotText . $this->makeMoreInfoLink( $info ),
212 'value' => $this->getVar(
"skin-$skin",
true ),
214 '<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] .
'</div>' .
219 Html::warningBox(
wfMessage(
'config-skins-missing' )->parse(),
'config-warning-box' ) .
220 Html::hidden(
'config_wgDefaultSkin', $chosenSkinName );
223 $skinHtml .= $this->parent->getHelpBox(
'config-skins-help' ) .
224 $this->getFieldsetEnd();
225 $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' );
242 $types = SpecialVersion::getExtensionTypes();
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] ) ) {
258 $extHtml .= Html::element(
'h2', [], $message );
259 foreach ( $extByType[$type] as $ext => $info ) {
262 'class' =>
'config-ext-input cdx-checkbox__input'
265 if ( isset( $info[
'requires'][
'extensions'] ) ) {
266 $dependencyMap[$ext][
'extensions'] = $info[
'requires'][
'extensions'];
267 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
269 if ( isset( $info[
'requires'][
'skins'] ) ) {
270 $dependencyMap[$ext][
'skins'] = $info[
'requires'][
'skins'];
271 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
273 if ( isset( $dependencyMap[$ext] ) ) {
277 if ( isset( $dependencyMap[$ext][
'extensions'] ) ) {
278 foreach ( $dependencyMap[$ext][
'extensions'] as $name ) {
279 $links[] = Html::element(
281 [
'href' =>
"#config_ext-$name" ],
286 if ( isset( $dependencyMap[$ext][
'skins'] ) ) {
288 foreach ( $dependencyMap[$ext][
'skins'] as $name ) {
289 $links[] = Html::element(
291 [
'href' =>
"#config_skin-$name" ],
297 $text =
wfMessage(
'config-extensions-requires' )
298 ->rawParams( $ext,
$wgLang->commaList( $links ) )
303 $extHtml .= $this->parent->getCheckBox( [
305 'rawtext' => $text . $this->makeMoreInfoLink( $info ),
306 'attribs' => $attribs,
307 'labelAttribs' => $labelAttribs,
312 $extHtml .= $this->parent->getHelpBox(
'config-extensions-help' ) .
313 $this->getFieldsetEnd();
314 $this->addHTML( $extHtml );
316 $this->addHTML( Html::inlineScript(
317 'var extDependencyMap = ' . Html::encodeJsVar( $dependencyMap )
325 private function addFileOptions(): void {
327 $this->setVar(
'wgDeletedDirectory',
329 '/', DIRECTORY_SEPARATOR,
330 $this->getVar(
'wgDeletedDirectory' )
334 $uploadwrapperStyle = $this->getVar(
'wgEnableUploads' ) ?
'' :
'display: none';
337 $this->getFieldsetStart(
'config-upload-settings' ) .
338 $this->parent->getCheckBox( [
339 'var' =>
'wgEnableUploads',
340 'label' =>
'config-upload-enable',
341 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'uploadwrapper' ],
342 'help' => $this->parent->getHelpBox(
'config-upload-help' )
344 '<div id="uploadwrapper" style="' . $uploadwrapperStyle .
'">' .
345 $this->parent->getTextBox( [
346 'var' =>
'wgDeletedDirectory',
347 'label' =>
'config-upload-deleted',
348 'attribs' => [
'dir' =>
'ltr' ],
349 'help' => $this->parent->getHelpBox(
'config-upload-deleted-help' )
354 $this->parent->getCheckBox( [
355 'var' =>
'wgUseInstantCommons',
356 'label' =>
'config-instantcommons',
357 'help' => $this->parent->getHelpBox(
'config-instantcommons-help' )
359 $this->getFieldsetEnd()
366 private function addAdvancedOptions(): void {
367 $caches = [
'none' ];
368 $cachevalDefault =
'none';
370 if ( count( $this->getVar(
'_Caches' ) ) ) {
373 $cachevalDefault =
'accel';
375 $caches[] =
'memcached';
378 $cacheval = $this->getVar(
'_MainCacheType' );
383 $cacheval = $cachevalDefault;
385 $hidden = ( $cacheval ==
'memcached' ) ?
'' :
'display: none';
388 $this->getFieldsetStart(
'config-advanced-settings' ) .
389 # Object cache settings
393 $this->parent->getRadioSet( [
394 'var' =>
'_MainCacheType',
395 'label' =>
'config-cache-options',
396 'itemLabelPrefix' =>
'config-cache-',
398 'value' => $cacheval,
400 $this->parent->getHelpBox(
'config-cache-help' ) .
401 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
402 $this->parent->getTextArea( [
403 'var' =>
'_MemCachedServers',
404 'label' =>
'config-memcached-servers',
405 'help' => $this->parent->getHelpBox(
'config-memcached-help' )
408 $this->getFieldsetEnd()
417 private function makeScreenshotsLink( $name, $screenshots ) {
419 if ( count( $screenshots ) > 1 ) {
423 foreach ( $screenshots as $shot ) {
424 $links[] = Html::element(
426 [
'href' => $shot,
'target' =>
'_blank' ],
427 $wgLang->formatNum( $counter++ )
430 return wfMessage(
'config-skins-screenshots' )
431 ->rawParams( $name,
$wgLang->commaList( $links ) )
434 $link = Html::element(
436 [
'href' => $screenshots[0],
'target' =>
'_blank' ],
439 return wfMessage(
'config-skins-screenshot', $name )->rawParams( $link )->escaped();
447 private function makeMoreInfoLink( $info ) {
448 if ( !isset( $info[
'url'] ) ) {
451 return ' ' .
wfMessage(
'parentheses' )->rawParams(
454 [
'href' => $info[
'url'] ],
455 wfMessage(
'config-ext-skins-more-info' )->text()
467 $skins = array_keys( $this->parent->findExtensions(
'skins' )->value );
468 $this->parent->setVar(
'_Skins', $skins );
471 $skinNames = array_map(
'strtolower', $skins );
472 $this->parent->setVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
482 $this->parent->setVarsFromRequest( [
'_RightsProfile',
'_LicenseCode',
483 'wgEnableEmail',
'wgPasswordSender',
'wgEnableUploads',
484 '_Logo1x',
'_LogoWordmark',
'_LogoTagline',
'_LogoIcon',
485 'wgEnableUserEmail',
'wgEnotifUserTalk',
'wgEnotifWatchlist',
486 'wgEmailAuthentication',
'_MainCacheType',
'_MemCachedServers',
487 'wgUseInstantCommons',
'wgDefaultSkin' ] );
491 if ( !array_key_exists( $this->getVar(
'_RightsProfile' ), $this->parent->rightsProfiles ) ) {
492 $this->setVar(
'_RightsProfile', array_key_first( $this->parent->rightsProfiles ) );
495 $code = $this->getVar(
'_LicenseCode' );
496 if ( array_key_exists( $code, $this->parent->licenses ) ) {
500 $entry = $this->parent->licenses[$code];
501 $this->setVar(
'wgRightsText',
502 $entry[
'text'] ??
wfMessage(
'config-license-' . $code )->text() );
503 $this->setVar(
'wgRightsUrl', $entry[
'url'] );
504 $this->setVar(
'wgRightsIcon', $entry[
'icon'] );
506 $this->setVar(
'wgRightsText',
'' );
507 $this->setVar(
'wgRightsUrl',
'' );
508 $this->setVar(
'wgRightsIcon',
'' );
511 $skinsAvailable = array_keys( $this->parent->findExtensions(
'skins' )->value );
512 $skinsToInstall = [];
513 foreach ( $skinsAvailable as $skin ) {
514 $this->parent->setVarsFromRequest( [
"skin-$skin" ] );
515 if ( $this->getVar(
"skin-$skin" ) ) {
516 $skinsToInstall[] = $skin;
519 $this->parent->setVar(
'_Skins', $skinsToInstall );
521 if ( !$skinsToInstall && $skinsAvailable ) {
522 $this->parent->showError(
'config-skins-must-enable-some' );
525 $defaultSkin = $this->getVar(
'wgDefaultSkin' );
526 $skinsToInstallLowercase = array_map(
'strtolower', $skinsToInstall );
527 if ( $skinsToInstall && !in_array( $defaultSkin, $skinsToInstallLowercase ) ) {
528 $this->parent->showError(
'config-skins-must-enable-default' );
532 $extsAvailable = array_keys( $this->parent->findExtensions()->value );
534 foreach ( $extsAvailable as $ext ) {
535 $this->parent->setVarsFromRequest( [
"ext-$ext" ] );
536 if ( $this->getVar(
"ext-$ext" ) ) {
537 $extsToInstall[] = $ext;
540 $this->parent->setVar(
'_Extensions', $extsToInstall );
542 if ( $this->getVar(
'_MainCacheType' ) ==
'memcached' ) {
543 $memcServers = explode(
"\n", $this->getVar(
'_MemCachedServers' ) );
547 if ( !$memcServers ) {
548 $this->parent->showError(
'config-memcache-needservers' );
552 foreach ( $memcServers as $server ) {
553 $memcParts = explode(
":", $server, 2 );
554 if ( !isset( $memcParts[0] )
555 || ( !IPUtils::isValid( $memcParts[0] )
556 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
558 $this->parent->showError(
'config-memcache-badip', $memcParts[0] );
560 } elseif ( !isset( $memcParts[1] ) ) {
561 $this->parent->showError(
'config-memcache-noport', $memcParts[0] );
563 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
564 $this->parent->showError(
'config-memcache-badport', 1, 65535 );