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' ) .
108 private function addModeOptions(): void {
114 $this->parent->getRadioSet( [
115 'var' =>
'_RightsProfile',
116 'label' =>
'config-profile',
117 'itemLabelPrefix' =>
'config-profile-',
118 'values' => array_keys( $this->parent->rightsProfiles ),
120 $this->parent->getInfoBox(
wfMessage(
'config-profile-help' )->plain() ) .
128 $this->parent->getRadioSet( [
129 'var' =>
'_LicenseCode',
130 'label' =>
'config-license',
131 'itemLabelPrefix' =>
'config-license-',
132 'values' => array_keys( $this->parent->licenses ),
133 'commonAttribs' => [
'class' =>
'licenseRadio' ],
135 $this->parent->getHelpBox(
'config-license-help' )
143 private function addEmailOptions(): void {
144 $emailwrapperStyle = $this->getVar(
'wgEnableEmail' ) ?
'' :
'display: none';
146 $this->getFieldsetStart(
'config-email-settings' ) .
147 $this->parent->getCheckBox( [
148 'var' =>
'wgEnableEmail',
149 'label' =>
'config-enable-email',
150 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'emailwrapper' ],
152 $this->parent->getHelpBox(
'config-enable-email-help' ) .
153 "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
154 $this->parent->getTextBox( [
155 'var' =>
'wgPasswordSender',
156 'label' =>
'config-email-sender'
158 $this->parent->getHelpBox(
'config-email-sender-help' ) .
159 $this->parent->getCheckBox( [
160 'var' =>
'wgEnableUserEmail',
161 'label' =>
'config-email-user',
163 $this->parent->getHelpBox(
'config-email-user-help' ) .
164 $this->parent->getCheckBox( [
165 'var' =>
'wgEnotifUserTalk',
166 'label' =>
'config-email-usertalk',
168 $this->parent->getHelpBox(
'config-email-usertalk-help' ) .
169 $this->parent->getCheckBox( [
170 'var' =>
'wgEnotifWatchlist',
171 'label' =>
'config-email-watchlist',
173 $this->parent->getHelpBox(
'config-email-watchlist-help' ) .
174 $this->parent->getCheckBox( [
175 'var' =>
'wgEmailAuthentication',
176 'label' =>
'config-email-auth',
178 $this->parent->getHelpBox(
'config-email-auth-help' ) .
180 $this->getFieldsetEnd()
188 private function addSkinOptions(): void {
189 $skins = $this->parent->findExtensions(
'skins' )->value;
190 '@phan-var array[] $skins';
191 $skinHtml = $this->getFieldsetStart(
'config-skins' );
193 $skinNames = array_map(
'strtolower', array_keys( $skins ) );
194 $chosenSkinName = $this->getVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
197 $radioButtons = $this->parent->getRadioElements( [
198 'var' =>
'wgDefaultSkin',
199 'itemLabels' => array_fill_keys( $skinNames,
'config-skins-use-as-default' ),
200 'values' => $skinNames,
201 'value' => $chosenSkinName,
204 foreach ( $skins as $skin => $info ) {
205 if ( isset( $info[
'screenshots'] ) ) {
206 $screenshotText = $this->makeScreenshotsLink( $skin, $info[
'screenshots'] );
208 $screenshotText = htmlspecialchars( $skin );
211 '<div class="config-skins-item">' .
212 $this->parent->getCheckBox( [
213 'var' =>
"skin-$skin",
214 'rawtext' => $screenshotText . $this->makeMoreInfoLink( $info ),
215 'value' => $this->getVar(
"skin-$skin",
true ),
217 '<div class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] .
'</div>' .
222 Html::warningBox(
wfMessage(
'config-skins-missing' )->parse(),
'config-warning-box' ) .
223 Html::hidden(
'config_wgDefaultSkin', $chosenSkinName );
226 $skinHtml .= $this->parent->getHelpBox(
'config-skins-help' ) .
227 $this->getFieldsetEnd();
228 $this->addHTML( $skinHtml );
235 private function addExtensionOptions(): void {
238 $extensions = $this->parent->findExtensions()->value;
239 '@phan-var array[] $extensions';
243 $extHtml = $this->getFieldsetStart(
'config-extensions' );
246 $types = SpecialVersion::getExtensionTypes();
248 foreach ( $extensions as $ext => $info ) {
249 if ( !isset( $info[
'type'] ) || !isset( $types[$info[
'type']] ) ) {
253 $info[
'type'] =
'other';
255 $extByType[$info[
'type']][$ext] = $info;
258 foreach ( $types as $type => $message ) {
259 if ( !isset( $extByType[$type] ) ) {
262 $extHtml .= Html::element(
'h2', [], $message );
263 foreach ( $extByType[$type] as $ext => $info ) {
266 'class' =>
'config-ext-input cdx-checkbox__input'
269 if ( isset( $info[
'requires'][
'extensions'] ) ) {
270 $dependencyMap[$ext][
'extensions'] = $info[
'requires'][
'extensions'];
271 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
273 if ( isset( $info[
'requires'][
'skins'] ) ) {
274 $dependencyMap[$ext][
'skins'] = $info[
'requires'][
'skins'];
275 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
277 if ( isset( $dependencyMap[$ext] ) ) {
281 if ( isset( $dependencyMap[$ext][
'extensions'] ) ) {
282 foreach ( $dependencyMap[$ext][
'extensions'] as $name ) {
283 $links[] = Html::element(
285 [
'href' =>
"#config_ext-$name" ],
290 if ( isset( $dependencyMap[$ext][
'skins'] ) ) {
292 foreach ( $dependencyMap[$ext][
'skins'] as $name ) {
293 $links[] = Html::element(
295 [
'href' =>
"#config_skin-$name" ],
301 $text =
wfMessage(
'config-extensions-requires' )
302 ->rawParams( $ext,
$wgLang->commaList( $links ) )
307 $extHtml .= $this->parent->getCheckBox( [
309 'rawtext' => $text . $this->makeMoreInfoLink( $info ),
310 'attribs' => $attribs,
311 'labelAttribs' => $labelAttribs,
316 $extHtml .= $this->parent->getHelpBox(
'config-extensions-help' ) .
317 $this->getFieldsetEnd();
318 $this->addHTML( $extHtml );
320 $this->addHTML( Html::inlineScript(
321 'var extDependencyMap = ' . Html::encodeJsVar( $dependencyMap )
330 private function addFileOptions(): void {
332 $this->setVar(
'wgDeletedDirectory',
334 '/', DIRECTORY_SEPARATOR,
335 $this->getVar(
'wgDeletedDirectory' )
339 $uploadwrapperStyle = $this->getVar(
'wgEnableUploads' ) ?
'' :
'display: none';
342 $this->getFieldsetStart(
'config-upload-settings' ) .
343 $this->parent->getCheckBox( [
344 'var' =>
'wgEnableUploads',
345 'label' =>
'config-upload-enable',
346 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'uploadwrapper' ],
347 'help' => $this->parent->getHelpBox(
'config-upload-help' )
349 '<div id="uploadwrapper" style="' . $uploadwrapperStyle .
'">' .
350 $this->parent->getTextBox( [
351 'var' =>
'wgDeletedDirectory',
352 'label' =>
'config-upload-deleted',
353 'attribs' => [
'dir' =>
'ltr' ],
354 'help' => $this->parent->getHelpBox(
'config-upload-deleted-help' )
359 $this->parent->getCheckBox( [
360 'var' =>
'wgUseInstantCommons',
361 'label' =>
'config-instantcommons',
362 'help' => $this->parent->getHelpBox(
'config-instantcommons-help' )
364 $this->getFieldsetEnd()
372 private function addAdvancedOptions(): void {
373 $caches = [
'none' ];
374 $cachevalDefault =
'none';
376 if ( count( $this->getVar(
'_Caches' ) ) ) {
379 $cachevalDefault =
'accel';
381 $caches[] =
'memcached';
384 $cacheval = $this->getVar(
'_MainCacheType' );
389 $cacheval = $cachevalDefault;
391 $hidden = ( $cacheval ==
'memcached' ) ?
'' :
'display: none';
394 $this->getFieldsetStart(
'config-advanced-settings' ) .
395 # Object cache settings
399 $this->parent->getRadioSet( [
400 'var' =>
'_MainCacheType',
401 'label' =>
'config-cache-options',
402 'itemLabelPrefix' =>
'config-cache-',
404 'value' => $cacheval,
406 $this->parent->getHelpBox(
'config-cache-help' ) .
407 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
408 $this->parent->getTextArea( [
409 'var' =>
'_MemCachedServers',
410 'label' =>
'config-memcached-servers',
411 'help' => $this->parent->getHelpBox(
'config-memcached-help' )
414 $this->getFieldsetEnd()
423 private function makeScreenshotsLink( $name, $screenshots ) {
425 if ( count( $screenshots ) > 1 ) {
429 foreach ( $screenshots as $shot ) {
430 $links[] = Html::element(
432 [
'href' => $shot,
'target' =>
'_blank' ],
433 $wgLang->formatNum( $counter++ )
436 return wfMessage(
'config-skins-screenshots' )
437 ->rawParams( $name,
$wgLang->commaList( $links ) )
440 $link = Html::element(
442 [
'href' => $screenshots[0],
'target' =>
'_blank' ],
445 return wfMessage(
'config-skins-screenshot', $name )->rawParams( $link )->escaped();
453 private function makeMoreInfoLink( $info ) {
454 if ( !isset( $info[
'url'] ) ) {
457 return ' ' .
wfMessage(
'parentheses' )->rawParams(
460 [
'href' => $info[
'url'] ],
461 wfMessage(
'config-ext-skins-more-info' )->text()
473 $skins = array_keys( $this->parent->findExtensions(
'skins' )->value );
474 $this->parent->setVar(
'_Skins', $skins );
477 $skinNames = array_map(
'strtolower', $skins );
478 $this->parent->setVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
488 $this->parent->setVarsFromRequest( [
'_RightsProfile',
'_LicenseCode',
489 'wgEnableEmail',
'wgPasswordSender',
'wgEnableUploads',
490 '_Logo1x',
'_LogoWordmark',
'_LogoTagline',
'_LogoIcon',
491 'wgEnableUserEmail',
'wgEnotifUserTalk',
'wgEnotifWatchlist',
492 'wgEmailAuthentication',
'_MainCacheType',
'_MemCachedServers',
493 'wgUseInstantCommons',
'wgDefaultSkin' ] );
497 if ( !array_key_exists( $this->getVar(
'_RightsProfile' ), $this->parent->rightsProfiles ) ) {
498 $this->setVar(
'_RightsProfile', array_key_first( $this->parent->rightsProfiles ) );
501 $code = $this->getVar(
'_LicenseCode' );
502 if ( array_key_exists( $code, $this->parent->licenses ) ) {
506 $entry = $this->parent->licenses[$code];
507 $this->setVar(
'wgRightsText',
508 $entry[
'text'] ??
wfMessage(
'config-license-' . $code )->text() );
509 $this->setVar(
'wgRightsUrl', $entry[
'url'] );
510 $this->setVar(
'wgRightsIcon', $entry[
'icon'] );
512 $this->setVar(
'wgRightsText',
'' );
513 $this->setVar(
'wgRightsUrl',
'' );
514 $this->setVar(
'wgRightsIcon',
'' );
517 $skinsAvailable = array_keys( $this->parent->findExtensions(
'skins' )->value );
518 $skinsToInstall = [];
519 foreach ( $skinsAvailable as $skin ) {
520 $this->parent->setVarsFromRequest( [
"skin-$skin" ] );
521 if ( $this->getVar(
"skin-$skin" ) ) {
522 $skinsToInstall[] = $skin;
525 $this->parent->setVar(
'_Skins', $skinsToInstall );
527 if ( !$skinsToInstall && $skinsAvailable ) {
528 $this->parent->showError(
'config-skins-must-enable-some' );
531 $defaultSkin = $this->getVar(
'wgDefaultSkin' );
532 $skinsToInstallLowercase = array_map(
'strtolower', $skinsToInstall );
533 if ( $skinsToInstall && !in_array( $defaultSkin, $skinsToInstallLowercase ) ) {
534 $this->parent->showError(
'config-skins-must-enable-default' );
538 $extsAvailable = array_keys( $this->parent->findExtensions()->value );
540 foreach ( $extsAvailable as $ext ) {
541 $this->parent->setVarsFromRequest( [
"ext-$ext" ] );
542 if ( $this->getVar(
"ext-$ext" ) ) {
543 $extsToInstall[] = $ext;
546 $this->parent->setVar(
'_Extensions', $extsToInstall );
548 if ( $this->getVar(
'_MainCacheType' ) ==
'memcached' ) {
549 $memcServers = explode(
"\n", $this->getVar(
'_MemCachedServers' ) );
553 if ( !$memcServers ) {
554 $this->parent->showError(
'config-memcache-needservers' );
558 foreach ( $memcServers as $server ) {
559 $memcParts = explode(
":", $server, 2 );
560 if ( !isset( $memcParts[0] )
561 || ( !IPUtils::isValid( $memcParts[0] )
562 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
564 $this->parent->showError(
'config-memcache-badip', $memcParts[0] );
566 } elseif ( !isset( $memcParts[1] ) ) {
567 $this->parent->showError(
'config-memcache-noport', $memcParts[0] );
569 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
570 $this->parent->showError(
'config-memcache-badport', 1, 65535 );