22 if ( $this->
getVar(
'_SkipOptional' ) ==
'skip' ) {
26 if ( $this->parent->request->wasPosted() && $this->submit() ) {
31 $this->addModeOptions();
32 $this->addEmailOptions();
33 $this->addSkinOptions();
34 $this->addExtensionOptions();
35 $this->addFileOptions();
36 $this->addPersonalizationOptions();
37 $this->addAdvancedOptions();
43 private function addPersonalizationOptions() {
47 Html::rawElement(
'div', [
48 'class' =>
'config-drag-drop'
49 ],
wfMessage(
'config-logo-summary' )->parse() ) .
50 Html::openElement(
'div', [
51 'class' =>
'config-personalization-options'
53 Html::hidden(
'config_LogoSiteName', $this->
getVar(
'wgSitename' ) ) .
57 'value' =>
'$wgResourceBasePath/resources/assets/change-your-logo.svg',
58 'label' =>
'config-logo-icon',
59 'attribs' => [
'dir' =>
'ltr' ],
63 'var' =>
'_LogoWordmark',
64 'label' =>
'config-logo-wordmark',
65 'attribs' => [
'dir' =>
'ltr' ],
69 'var' =>
'_LogoTagline',
70 'label' =>
'config-logo-tagline',
71 'attribs' => [
'dir' =>
'ltr' ],
76 'label' =>
'config-logo-sidebar',
77 'attribs' => [
'dir' =>
'ltr' ],
80 Html::openElement(
'div', [
81 'class' =>
'logo-preview-area',
82 'data-main-page' =>
wfMessage(
'config-logo-preview-main' ),
83 'data-filedrop' =>
wfMessage(
'config-logo-filedrop' )
85 Html::closeElement(
'div' ) .
86 Html::closeElement(
'div' ) .
94 private function addModeOptions(): void {
100 $this->parent->getRadioSet( [
101 'var' =>
'_RightsProfile',
102 'label' =>
'config-profile',
103 'itemLabelPrefix' =>
'config-profile-',
104 'values' => array_keys( $this->parent->rightsProfiles ),
106 $this->parent->getInfoBox(
wfMessage(
'config-profile-help' )->plain() ) .
114 $this->parent->getRadioSet( [
115 'var' =>
'_LicenseCode',
116 'label' =>
'config-license',
117 'itemLabelPrefix' =>
'config-license-',
118 'values' => array_keys( $this->parent->licenses ),
119 'commonAttribs' => [
'class' =>
'licenseRadio' ],
121 $this->parent->getHelpBox(
'config-license-help' )
128 private function addEmailOptions(): void {
129 $emailwrapperStyle = $this->getVar(
'wgEnableEmail' ) ?
'' :
'display: none';
131 $this->getFieldsetStart(
'config-email-settings' ) .
132 $this->parent->getCheckBox( [
133 'var' =>
'wgEnableEmail',
134 'label' =>
'config-enable-email',
135 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'emailwrapper' ],
137 $this->parent->getHelpBox(
'config-enable-email-help' ) .
138 "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
139 $this->parent->getTextBox( [
140 'var' =>
'wgPasswordSender',
141 'label' =>
'config-email-sender'
143 $this->parent->getHelpBox(
'config-email-sender-help' ) .
144 $this->parent->getCheckBox( [
145 'var' =>
'wgEnableUserEmail',
146 'label' =>
'config-email-user',
148 $this->parent->getHelpBox(
'config-email-user-help' ) .
149 $this->parent->getCheckBox( [
150 'var' =>
'wgEnotifUserTalk',
151 'label' =>
'config-email-usertalk',
153 $this->parent->getHelpBox(
'config-email-usertalk-help' ) .
154 $this->parent->getCheckBox( [
155 'var' =>
'wgEnotifWatchlist',
156 'label' =>
'config-email-watchlist',
158 $this->parent->getHelpBox(
'config-email-watchlist-help' ) .
159 $this->parent->getCheckBox( [
160 'var' =>
'wgEmailAuthentication',
161 'label' =>
'config-email-auth',
163 $this->parent->getHelpBox(
'config-email-auth-help' ) .
165 $this->getFieldsetEnd()
172 private function addSkinOptions(): void {
173 $skins = $this->parent->findExtensions(
'skins' )->value;
174 '@phan-var array[] $skins';
175 $skinHtml = $this->getFieldsetStart(
'config-skins' );
177 $skinNames = array_map( strtolower( ... ), array_keys( $skins ) );
178 $chosenSkinName = $this->getVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
181 $radioButtons = $this->parent->getRadioElements( [
182 'var' =>
'wgDefaultSkin',
183 'itemLabels' => array_fill_keys( $skinNames,
'config-skins-use-as-default' ),
184 'values' => $skinNames,
185 'value' => $chosenSkinName,
188 foreach ( $skins as $skin => $info ) {
189 if ( isset( $info[
'screenshots'] ) ) {
190 $screenshotText = $this->makeScreenshotsLink( $skin, $info[
'screenshots'] );
192 $screenshotText = htmlspecialchars( $skin );
195 '<div class="config-skins-item">' .
196 $this->parent->getCheckBox( [
197 'var' =>
"skin-$skin",
198 'rawtext' => $screenshotText . $this->makeMoreInfoLink( $info ),
199 'value' => $this->getVar(
"skin-$skin",
true ),
201 '<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] .
'</div>' .
206 Html::warningBox(
wfMessage(
'config-skins-missing' )->parse(),
'config-warning-box' ) .
207 Html::hidden(
'config_wgDefaultSkin', $chosenSkinName );
210 $skinHtml .= $this->parent->getHelpBox(
'config-skins-help' ) .
211 $this->getFieldsetEnd();
212 $this->addHTML( $skinHtml );
218 private function addExtensionOptions(): void {
221 $extensions = $this->parent->findExtensions()->value;
222 '@phan-var array[] $extensions';
226 $extHtml = $this->getFieldsetStart(
'config-extensions' );
229 $types = SpecialVersion::getExtensionTypes();
231 foreach ( $extensions as $ext => $info ) {
232 if ( !isset( $info[
'type'] ) || !isset( $types[$info[
'type']] ) ) {
236 $info[
'type'] =
'other';
238 $extByType[$info[
'type']][$ext] = $info;
241 foreach ( $types as $type => $message ) {
242 if ( !isset( $extByType[$type] ) ) {
245 $extHtml .= Html::element(
'h2', [], $message );
246 foreach ( $extByType[$type] as $ext => $info ) {
249 'class' =>
'config-ext-input cdx-checkbox__input'
252 if ( isset( $info[
'requires'][
'extensions'] ) ) {
253 $dependencyMap[$ext][
'extensions'] = $info[
'requires'][
'extensions'];
254 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
256 if ( isset( $info[
'requires'][
'skins'] ) ) {
257 $dependencyMap[$ext][
'skins'] = $info[
'requires'][
'skins'];
258 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
260 if ( isset( $dependencyMap[$ext] ) ) {
264 if ( isset( $dependencyMap[$ext][
'extensions'] ) ) {
265 foreach ( $dependencyMap[$ext][
'extensions'] as $name ) {
266 $links[] = Html::element(
268 [
'href' =>
"#config_ext-$name" ],
273 if ( isset( $dependencyMap[$ext][
'skins'] ) ) {
275 foreach ( $dependencyMap[$ext][
'skins'] as $name ) {
276 $links[] = Html::element(
278 [
'href' =>
"#config_skin-$name" ],
284 $text =
wfMessage(
'config-extensions-requires', $ext )
285 ->rawParams( $lang->commaList( $links ) )
288 $text = htmlspecialchars( $ext );
290 $extHtml .= $this->parent->getCheckBox( [
292 'rawtext' => $text . $this->makeMoreInfoLink( $info ),
293 'attribs' => $attribs,
294 'labelAttribs' => $labelAttribs,
299 $extHtml .= $this->parent->getHelpBox(
'config-extensions-help' ) .
300 $this->getFieldsetEnd();
301 $this->addHTML( $extHtml );
303 $this->addHTML( $this->inlineScript(
304 'var extDependencyMap = ' . Html::encodeJsVar( $dependencyMap )
312 private function addFileOptions(): void {
314 $this->setVar(
'wgDeletedDirectory',
316 '/', DIRECTORY_SEPARATOR,
317 $this->getVar(
'wgDeletedDirectory' )
321 $uploadwrapperStyle = $this->getVar(
'wgEnableUploads' ) ?
'' :
'display: none';
324 $this->getFieldsetStart(
'config-upload-settings' ) .
325 $this->parent->getCheckBox( [
326 'var' =>
'wgEnableUploads',
327 'label' =>
'config-upload-enable',
328 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'uploadwrapper' ],
329 'help' => $this->parent->getHelpBox(
'config-upload-help' )
331 '<div id="uploadwrapper" style="' . $uploadwrapperStyle .
'">' .
332 $this->parent->getTextBox( [
333 'var' =>
'wgDeletedDirectory',
334 'label' =>
'config-upload-deleted',
335 'attribs' => [
'dir' =>
'ltr' ],
336 'help' => $this->parent->getHelpBox(
'config-upload-deleted-help' )
341 $this->parent->getCheckBox( [
342 'var' =>
'wgUseInstantCommons',
343 'label' =>
'config-instantcommons',
344 'help' => $this->parent->getHelpBox(
'config-instantcommons-help' )
346 $this->getFieldsetEnd()
353 private function addAdvancedOptions(): void {
354 $caches = [
'none' ];
355 $cachevalDefault =
'none';
357 if ( count( $this->getVar(
'_Caches' ) ) ) {
360 $cachevalDefault =
'accel';
362 $caches[] =
'memcached';
365 $cacheval = $this->getVar(
'_MainCacheType' );
370 $cacheval = $cachevalDefault;
372 $hidden = ( $cacheval ==
'memcached' ) ?
'' :
'display: none';
375 $this->getFieldsetStart(
'config-advanced-settings' ) .
376 # Object cache settings
380 $this->parent->getRadioSet( [
381 'var' =>
'_MainCacheType',
382 'label' =>
'config-cache-options',
383 'itemLabelPrefix' =>
'config-cache-',
385 'value' => $cacheval,
387 $this->parent->getHelpBox(
'config-cache-help' ) .
388 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
389 $this->parent->getTextArea( [
390 'var' =>
'_MemCachedServers',
391 'label' =>
'config-memcached-servers',
392 'help' => $this->parent->getHelpBox(
'config-memcached-help' )
395 $this->getFieldsetEnd()
404 private function makeScreenshotsLink( $name, $screenshots ) {
405 $lang = RequestContext::getMain()->getLanguage();
406 if ( count( $screenshots ) > 1 ) {
410 foreach ( $screenshots as $shot ) {
411 $links[] = Html::element(
413 [
'href' => $shot,
'target' =>
'_blank' ],
414 $lang->formatNum( $counter++ )
417 return wfMessage(
'config-skins-screenshots', $name )
418 ->rawParams( $lang->commaList( $links ) )
421 $link = Html::element(
423 [
'href' => $screenshots[0],
'target' =>
'_blank' ],
426 return wfMessage(
'config-skins-screenshot', $name )->rawParams( $link )->escaped();
434 private function makeMoreInfoLink( $info ) {
435 if ( !isset( $info[
'url'] ) ) {
438 return ' ' .
wfMessage(
'parentheses' )->rawParams(
441 [
'href' => $info[
'url'] ],
442 wfMessage(
'config-ext-skins-more-info' )->text()
454 $skins = array_keys( $this->parent->findExtensions(
'skins' )->value );
455 $this->parent->setVar(
'_Skins', $skins );
458 $skinNames = array_map( strtolower( ... ), $skins );
459 $this->parent->setVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
469 $this->parent->setVarsFromRequest( [
'_RightsProfile',
'_LicenseCode',
470 'wgEnableEmail',
'wgPasswordSender',
'wgEnableUploads',
471 '_Logo1x',
'_LogoWordmark',
'_LogoTagline',
'_LogoIcon',
472 'wgEnableUserEmail',
'wgEnotifUserTalk',
'wgEnotifWatchlist',
473 'wgEmailAuthentication',
'_MainCacheType',
'_MemCachedServers',
474 'wgUseInstantCommons',
'wgDefaultSkin' ] );
478 if ( !array_key_exists( $this->
getVar(
'_RightsProfile' ), $this->parent->rightsProfiles ) ) {
479 $this->
setVar(
'_RightsProfile', array_key_first( $this->parent->rightsProfiles ) );
482 $code = $this->
getVar(
'_LicenseCode' );
483 if ( array_key_exists( $code, $this->parent->licenses ) ) {
487 $entry = $this->parent->licenses[$code];
488 $this->
setVar(
'wgRightsText',
489 $entry[
'text'] ??
wfMessage(
'config-license-' . $code )->text() );
490 $this->
setVar(
'wgRightsUrl', $entry[
'url'] );
491 $this->
setVar(
'wgRightsIcon', $entry[
'icon'] );
493 $this->
setVar(
'wgRightsText',
'' );
494 $this->
setVar(
'wgRightsUrl',
'' );
495 $this->
setVar(
'wgRightsIcon',
'' );
498 $skinsAvailable = array_keys( $this->parent->findExtensions(
'skins' )->value );
499 $skinsToInstall = [];
500 foreach ( $skinsAvailable as $skin ) {
501 $this->parent->setVarsFromRequest( [
"skin-$skin" ] );
502 if ( $this->
getVar(
"skin-$skin" ) ) {
503 $skinsToInstall[] = $skin;
506 $this->parent->setVar(
'_Skins', $skinsToInstall );
508 if ( !$skinsToInstall && $skinsAvailable ) {
509 $this->parent->showError(
'config-skins-must-enable-some' );
512 $defaultSkin = $this->
getVar(
'wgDefaultSkin' );
513 $skinsToInstallLowercase = array_map( strtolower( ... ), $skinsToInstall );
514 if ( $skinsToInstall && !in_array( $defaultSkin, $skinsToInstallLowercase ) ) {
515 $this->parent->showError(
'config-skins-must-enable-default' );
519 $extsAvailable = array_keys( $this->parent->findExtensions()->value );
521 foreach ( $extsAvailable as $ext ) {
522 $this->parent->setVarsFromRequest( [
"ext-$ext" ] );
523 if ( $this->
getVar(
"ext-$ext" ) ) {
524 $extsToInstall[] = $ext;
527 $this->parent->setVar(
'_Extensions', $extsToInstall );
529 if ( $this->
getVar(
'_MainCacheType' ) ==
'memcached' ) {
530 $memcServers = explode(
"\n", $this->
getVar(
'_MemCachedServers' ) );
534 if ( !$memcServers ) {
535 $this->parent->showError(
'config-memcache-needservers' );
539 foreach ( $memcServers as $server ) {
540 $memcParts = explode(
":", $server, 2 );
541 if ( !isset( $memcParts[0] )
542 || ( !IPUtils::isValid( $memcParts[0] )
543 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
545 $this->parent->showError(
'config-memcache-badip', $memcParts[0] );
547 } elseif ( !isset( $memcParts[1] ) ) {
548 $this->parent->showError(
'config-memcache-noport', $memcParts[0] );
550 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
551 $this->parent->showError(
'config-memcache-badport', 1, 65535 );