22 class WebInstallerOptions
extends WebInstallerPage {
30 if ( $this->getVar(
'_SkipOptional' ) ==
'skip' ) {
34 if ( $this->parent->request->wasPosted() && $this->submit() ) {
38 $emailwrapperStyle = $this->getVar(
'wgEnableEmail' ) ?
'' :
'display: none';
45 $this->parent->getRadioSet( [
46 'var' =>
'_RightsProfile',
47 'label' =>
'config-profile',
48 'itemLabelPrefix' =>
'config-profile-',
49 'values' => array_keys( $this->parent->rightsProfiles ),
51 $this->parent->getInfoBox(
wfMessage(
'config-profile-help' )->
plain() ) .
59 $this->parent->getRadioSet( [
60 'var' =>
'_LicenseCode',
61 'label' =>
'config-license',
62 'itemLabelPrefix' =>
'config-license-',
63 'values' => array_keys( $this->parent->licenses ),
64 'commonAttribs' => [
'class' =>
'licenseRadio' ],
66 $this->getCCChooser() .
67 $this->parent->getHelpBox(
'config-license-help' ) .
70 $this->getFieldsetStart(
'config-email-settings' ) .
71 $this->parent->getCheckBox( [
72 'var' =>
'wgEnableEmail',
73 'label' =>
'config-enable-email',
74 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'emailwrapper' ],
76 $this->parent->getHelpBox(
'config-enable-email-help' ) .
77 "<div id=\"emailwrapper\" style=\"$emailwrapperStyle\">" .
78 $this->parent->getTextBox( [
79 'var' =>
'wgPasswordSender',
80 'label' =>
'config-email-sender'
82 $this->parent->getHelpBox(
'config-email-sender-help' ) .
83 $this->parent->getCheckBox( [
84 'var' =>
'wgEnableUserEmail',
85 'label' =>
'config-email-user',
87 $this->parent->getHelpBox(
'config-email-user-help' ) .
88 $this->parent->getCheckBox( [
89 'var' =>
'wgEnotifUserTalk',
90 'label' =>
'config-email-usertalk',
92 $this->parent->getHelpBox(
'config-email-usertalk-help' ) .
93 $this->parent->getCheckBox( [
94 'var' =>
'wgEnotifWatchlist',
95 'label' =>
'config-email-watchlist',
97 $this->parent->getHelpBox(
'config-email-watchlist-help' ) .
98 $this->parent->getCheckBox( [
99 'var' =>
'wgEmailAuthentication',
100 'label' =>
'config-email-auth',
102 $this->parent->getHelpBox(
'config-email-auth-help' ) .
104 $this->getFieldsetEnd()
107 $skins = $this->parent->findExtensions(
'skins' );
108 $skinHtml = $this->getFieldsetStart(
'config-skins' );
110 $skinNames = array_map(
'strtolower', array_keys( $skins ) );
111 $chosenSkinName = $this->getVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
114 $radioButtons = $this->parent->getRadioElements( [
115 'var' =>
'wgDefaultSkin',
116 'itemLabels' => array_fill_keys( $skinNames,
'config-skins-use-as-default' ),
117 'values' => $skinNames,
118 'value' => $chosenSkinName,
121 foreach ( $skins
as $skin => $info ) {
122 if ( isset( $info[
'screenshots'] ) ) {
123 $screenshotText = $this->makeScreenshotsLink(
$skin, $info[
'screenshots'] );
125 $screenshotText = htmlspecialchars(
$skin );
128 '<div class="config-skins-item">' .
129 $this->parent->getCheckBox( [
130 'var' =>
"skin-$skin",
131 'rawtext' => $screenshotText,
132 'value' => $this->getVar(
"skin-$skin",
true ),
134 '<div class="config-skins-use-as-default">' . $radioButtons[strtolower(
$skin )] .
'</div>' .
139 $this->parent->getWarningBox(
wfMessage(
'config-skins-missing' )->
plain() ) .
140 Html::hidden(
'config_wgDefaultSkin', $chosenSkinName );
143 $skinHtml .= $this->parent->getHelpBox(
'config-skins-help' ) .
144 $this->getFieldsetEnd();
145 $this->addHTML( $skinHtml );
147 $extensions = $this->parent->findExtensions();
151 $extHtml = $this->getFieldsetStart(
'config-extensions' );
156 foreach ( $extensions
as $ext => $info ) {
157 if ( !isset( $info[
'type'] ) || !isset( $types[$info[
'type']] ) ) {
161 $info[
'type'] =
'other';
163 $extByType[$info[
'type']][
$ext] = $info;
166 foreach ( $types
as $type => $message ) {
167 if ( !isset( $extByType[
$type] ) ) {
170 $extHtml .= Html::element(
'h2', [], $message );
173 if ( isset( $info[
'url'] ) ) {
174 $urlText =
' ' . Html::element(
'a', [
'href' => $info[
'url'] ],
'(more information)' );
178 'class' =>
'config-ext-input'
182 if ( isset( $info[
'requires'][
'extensions'] ) ) {
183 $dependencyMap[
$ext][
'extensions'] = $info[
'requires'][
'extensions'];
184 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
186 if ( isset( $info[
'requires'][
'skins'] ) ) {
187 $dependencyMap[
$ext][
'skins'] = $info[
'requires'][
'skins'];
188 $labelAttribs[
'class'] =
'mw-ext-with-dependencies';
190 if ( isset( $dependencyMap[
$ext] ) ) {
194 if ( isset( $dependencyMap[
$ext][
'extensions'] ) ) {
195 foreach ( $dependencyMap[
$ext][
'extensions']
as $name ) {
196 $links[] = Html::element(
198 [
'href' =>
"#config_ext-$name" ],
203 if ( isset( $dependencyMap[
$ext][
'skins'] ) ) {
204 foreach ( $dependencyMap[
$ext][
'skins']
as $name ) {
205 $links[] = Html::element(
207 [
'href' =>
"#config_skin-$name" ],
213 $text =
wfMessage(
'config-extensions-requires' )
219 $extHtml .= $this->parent->getCheckBox( [
223 'labelAttribs' => $labelAttribs,
228 $extHtml .= $this->parent->getHelpBox(
'config-extensions-help' ) .
229 $this->getFieldsetEnd();
230 $this->addHTML( $extHtml );
232 $this->addHTML( Html::inlineScript(
238 $this->setVar(
'wgDeletedDirectory',
240 '/', DIRECTORY_SEPARATOR,
241 $this->getVar(
'wgDeletedDirectory' )
245 $uploadwrapperStyle = $this->getVar(
'wgEnableUploads' ) ?
'' :
'display: none';
248 $this->getFieldsetStart(
'config-upload-settings' ) .
249 $this->parent->getCheckBox( [
250 'var' =>
'wgEnableUploads',
251 'label' =>
'config-upload-enable',
252 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'uploadwrapper' ],
253 'help' => $this->parent->getHelpBox(
'config-upload-help' )
255 '<div id="uploadwrapper" style="' . $uploadwrapperStyle .
'">' .
256 $this->parent->getTextBox( [
257 'var' =>
'wgDeletedDirectory',
258 'label' =>
'config-upload-deleted',
259 'attribs' => [
'dir' =>
'ltr' ],
260 'help' => $this->parent->getHelpBox(
'config-upload-deleted-help' )
263 $this->parent->getTextBox( [
265 'label' =>
'config-logo',
266 'attribs' => [
'dir' =>
'ltr' ],
267 'help' => $this->parent->getHelpBox(
'config-logo-help' )
271 $this->parent->getCheckBox( [
272 'var' =>
'wgUseInstantCommons',
273 'label' =>
'config-instantcommons',
274 'help' => $this->parent->getHelpBox(
'config-instantcommons-help' )
276 $this->getFieldsetEnd()
279 $caches = [
'none' ];
280 $cachevalDefault =
'none';
282 if (
count( $this->getVar(
'_Caches' ) ) ) {
285 $cachevalDefault =
'accel';
287 $caches[] =
'memcached';
290 $cacheval = $this->getVar(
'_MainCacheType' );
295 $cacheval = $cachevalDefault;
297 $hidden = ( $cacheval ==
'memcached' ) ?
'' :
'display: none';
300 $this->getFieldsetStart(
'config-advanced-settings' ) .
305 $this->parent->getRadioSet( [
306 'var' =>
'_MainCacheType',
307 'label' =>
'config-cache-options',
308 'itemLabelPrefix' =>
'config-cache-',
310 'value' => $cacheval,
312 $this->parent->getHelpBox(
'config-cache-help' ) .
313 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
314 $this->parent->getTextArea( [
315 'var' =>
'_MemCachedServers',
316 'label' =>
'config-memcached-servers',
317 'help' => $this->parent->getHelpBox(
'config-memcached-help' )
320 $this->getFieldsetEnd()
327 private function makeScreenshotsLink(
$name, $screenshots ) {
329 if (
count( $screenshots ) > 1 ) {
332 foreach ( $screenshots
as $shot ) {
333 $links[] = Html::element(
335 [
'href' => $shot,
'target' =>
'_blank' ],
336 $wgLang->formatNum( $counter++ )
339 return wfMessage(
'config-skins-screenshots' )
343 $link = Html::element(
345 [
'href' => $screenshots[0],
'target' =>
'_blank' ],
355 public function getCCPartnerUrl() {
356 $server = $this->getVar(
'wgServer' );
357 $exitUrl = $server . $this->parent->getUrl( [
359 'SubmitCC' =>
'indeed',
360 'config__LicenseCode' =>
'cc',
361 'config_wgRightsUrl' =>
'[license_url]',
362 'config_wgRightsText' =>
'[license_name]',
363 'config_wgRightsIcon' =>
'[license_button]',
365 $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
366 '/mw-config/config-cc.css';
367 $iframeUrl =
'//creativecommons.org/license/?' .
369 'partner' =>
'MediaWiki',
370 'exit_url' => $exitUrl,
371 'lang' => $this->getVar(
'_UserLang' ),
372 'stylesheet' => $styleUrl,
381 public function getCCChooser() {
383 'class' =>
'config-cc-iframe',
384 'name' =>
'config-cc-iframe',
385 'id' =>
'config-cc-iframe',
390 if ( $this->getVar(
'_CCDone' ) ) {
391 $iframeAttribs[
'src'] = $this->parent->getUrl( [
'ShowCC' =>
'yes' ] );
393 $iframeAttribs[
'src'] = $this->getCCPartnerUrl();
395 $wrapperStyle = ( $this->getVar(
'_LicenseCode' ) ==
'cc-choose' ) ?
'' :
'display: none';
397 return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
398 Html::element(
'iframe', $iframeAttribs ) .
405 public function getCCDoneBox() {
406 $js =
"parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
408 $expandJs = str_replace(
'$1',
'54em', $js );
409 $reduceJs = str_replace(
'$1',
'70px', $js );
412 Html::element(
'img', [
'src' => $this->getVar(
'wgRightsIcon' ) ] ) .
414 htmlspecialchars( $this->getVar(
'wgRightsText' ) ) .
416 "<p style=\"text-align: center;\">" .
419 'href' => $this->getCCPartnerUrl(),
420 'onclick' => $expandJs,
426 # Reduce the wrapper
div height
427 htmlspecialchars( $reduceJs ) .
432 public function submitCC() {
433 $newValues = $this->parent->setVarsFromRequest(
434 [
'wgRightsUrl',
'wgRightsText',
'wgRightsIcon' ] );
435 if (
count( $newValues ) != 3 ) {
436 $this->parent->showError(
'config-cc-error' );
440 $this->setVar(
'_CCDone',
true );
441 $this->addHTML( $this->getCCDoneBox() );
450 public function submitSkins() {
451 $skins = array_keys( $this->parent->findExtensions(
'skins' ) );
452 $this->parent->setVar(
'_Skins', $skins );
455 $skinNames = array_map(
'strtolower', $skins );
456 $this->parent->setVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
465 public function submit() {
466 $this->parent->setVarsFromRequest( [
'_RightsProfile',
'_LicenseCode',
467 'wgEnableEmail',
'wgPasswordSender',
'wgEnableUploads',
'wgLogo',
468 'wgEnableUserEmail',
'wgEnotifUserTalk',
'wgEnotifWatchlist',
469 'wgEmailAuthentication',
'_MainCacheType',
'_MemCachedServers',
470 'wgUseInstantCommons',
'wgDefaultSkin' ] );
474 if ( !array_key_exists( $this->getVar(
'_RightsProfile' ), $this->parent->rightsProfiles ) ) {
475 reset( $this->parent->rightsProfiles );
476 $this->setVar(
'_RightsProfile',
key( $this->parent->rightsProfiles ) );
479 $code = $this->getVar(
'_LicenseCode' );
480 if (
$code ==
'cc-choose' ) {
481 if ( !$this->getVar(
'_CCDone' ) ) {
482 $this->parent->showError(
'config-cc-not-chosen' );
485 } elseif ( array_key_exists(
$code, $this->parent->licenses ) ) {
490 $entry = $this->parent->licenses[
$code];
491 $this->setVar(
'wgRightsText',
493 $this->setVar(
'wgRightsUrl', $entry[
'url'] );
494 $this->setVar(
'wgRightsIcon', $entry[
'icon'] );
496 $this->setVar(
'wgRightsText',
'' );
497 $this->setVar(
'wgRightsUrl',
'' );
498 $this->setVar(
'wgRightsIcon',
'' );
501 $skinsAvailable = array_keys( $this->parent->findExtensions(
'skins' ) );
502 $skinsToInstall = [];
503 foreach ( $skinsAvailable
as $skin ) {
504 $this->parent->setVarsFromRequest( [
"skin-$skin" ] );
505 if ( $this->getVar(
"skin-$skin" ) ) {
506 $skinsToInstall[] =
$skin;
509 $this->parent->setVar(
'_Skins', $skinsToInstall );
511 if ( !$skinsToInstall && $skinsAvailable ) {
512 $this->parent->showError(
'config-skins-must-enable-some' );
515 $defaultSkin = $this->getVar(
'wgDefaultSkin' );
516 $skinsToInstallLowercase = array_map(
'strtolower', $skinsToInstall );
517 if ( $skinsToInstall && array_search( $defaultSkin, $skinsToInstallLowercase ) ===
false ) {
518 $this->parent->showError(
'config-skins-must-enable-default' );
522 $extsAvailable = array_keys( $this->parent->findExtensions() );
524 foreach ( $extsAvailable
as $ext ) {
525 $this->parent->setVarsFromRequest( [
"ext-$ext" ] );
526 if ( $this->getVar(
"ext-$ext" ) ) {
527 $extsToInstall[] =
$ext;
530 $this->parent->setVar(
'_Extensions', $extsToInstall );
532 if ( $this->getVar(
'_MainCacheType' ) ==
'memcached' ) {
533 $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] )
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 );