22 class WebInstallerOptions
extends WebInstallerPage {
28 if ( $this->getVar(
'_SkipOptional' ) ==
'skip' ) {
32 if ( $this->parent->request->wasPosted() ) {
33 if ( $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();
150 $extHtml = $this->getFieldsetStart(
'config-extensions' );
152 foreach ( $extensions
as $ext => $info ) {
153 $extHtml .= $this->parent->getCheckBox( [
159 $extHtml .= $this->parent->getHelpBox(
'config-extensions-help' ) .
160 $this->getFieldsetEnd();
161 $this->addHTML( $extHtml );
165 $this->setVar(
'wgDeletedDirectory',
167 '/', DIRECTORY_SEPARATOR,
168 $this->getVar(
'wgDeletedDirectory' )
172 $uploadwrapperStyle = $this->getVar(
'wgEnableUploads' ) ?
'' :
'display: none';
175 $this->getFieldsetStart(
'config-upload-settings' ) .
176 $this->parent->getCheckBox( [
177 'var' =>
'wgEnableUploads',
178 'label' =>
'config-upload-enable',
179 'attribs' => [
'class' =>
'showHideRadio',
'rel' =>
'uploadwrapper' ],
180 'help' => $this->parent->getHelpBox(
'config-upload-help' )
182 '<div id="uploadwrapper" style="' . $uploadwrapperStyle .
'">' .
183 $this->parent->getTextBox( [
184 'var' =>
'wgDeletedDirectory',
185 'label' =>
'config-upload-deleted',
186 'attribs' => [
'dir' =>
'ltr' ],
187 'help' => $this->parent->getHelpBox(
'config-upload-deleted-help' )
190 $this->parent->getTextBox( [
192 'label' =>
'config-logo',
193 'attribs' => [
'dir' =>
'ltr' ],
194 'help' => $this->parent->getHelpBox(
'config-logo-help' )
198 $this->parent->getCheckBox( [
199 'var' =>
'wgUseInstantCommons',
200 'label' =>
'config-instantcommons',
201 'help' => $this->parent->getHelpBox(
'config-instantcommons-help' )
203 $this->getFieldsetEnd()
206 $caches = [
'none' ];
207 $cachevalDefault =
'none';
209 if (
count( $this->getVar(
'_Caches' ) ) ) {
212 $cachevalDefault =
'accel';
214 $caches[] =
'memcached';
217 $cacheval = $this->getVar(
'_MainCacheType' );
222 $cacheval = $cachevalDefault;
224 $hidden = ( $cacheval ==
'memcached' ) ?
'' :
'display: none';
227 $this->getFieldsetStart(
'config-advanced-settings' ) .
232 $this->parent->getRadioSet( [
233 'var' =>
'_MainCacheType',
234 'label' =>
'config-cache-options',
235 'itemLabelPrefix' =>
'config-cache-',
237 'value' => $cacheval,
239 $this->parent->getHelpBox(
'config-cache-help' ) .
240 "<div id=\"config-memcachewrapper\" style=\"$hidden\">" .
241 $this->parent->getTextArea( [
242 'var' =>
'_MemCachedServers',
243 'label' =>
'config-memcached-servers',
244 'help' => $this->parent->getHelpBox(
'config-memcached-help' )
247 $this->getFieldsetEnd()
254 private function makeScreenshotsLink(
$name, $screenshots ) {
256 if (
count( $screenshots ) > 1 ) {
259 foreach ( $screenshots
as $shot ) {
263 $wgLang->formatNum( $counter++ )
266 return wfMessage(
'config-skins-screenshots' )
272 [
'href' => $screenshots[0] ],
282 public function getCCPartnerUrl() {
283 $server = $this->getVar(
'wgServer' );
284 $exitUrl = $server . $this->parent->getUrl( [
286 'SubmitCC' =>
'indeed',
287 'config__LicenseCode' =>
'cc',
288 'config_wgRightsUrl' =>
'[license_url]',
289 'config_wgRightsText' =>
'[license_name]',
290 'config_wgRightsIcon' =>
'[license_button]',
292 $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) .
293 '/mw-config/config-cc.css';
294 $iframeUrl =
'//creativecommons.org/license/?' .
296 'partner' =>
'MediaWiki',
297 'exit_url' => $exitUrl,
298 'lang' => $this->getVar(
'_UserLang' ),
299 'stylesheet' => $styleUrl,
308 public function getCCChooser() {
310 'class' =>
'config-cc-iframe',
311 'name' =>
'config-cc-iframe',
312 'id' =>
'config-cc-iframe',
317 if ( $this->getVar(
'_CCDone' ) ) {
318 $iframeAttribs[
'src'] = $this->parent->getUrl( [
'ShowCC' =>
'yes' ] );
320 $iframeAttribs[
'src'] = $this->getCCPartnerUrl();
322 $wrapperStyle = ( $this->getVar(
'_LicenseCode' ) ==
'cc-choose' ) ?
'' :
'display: none';
324 return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
332 public function getCCDoneBox() {
333 $js =
"parent.document.getElementById('config-cc-wrapper').style.height = '$1';";
335 $expandJs = str_replace(
'$1',
'54em', $js );
336 $reduceJs = str_replace(
'$1',
'70px', $js );
339 Html::element(
'img', [
'src' => $this->getVar(
'wgRightsIcon' ) ] ) .
341 htmlspecialchars( $this->getVar(
'wgRightsText' ) ) .
343 "<p style=\"text-align: center;\">" .
346 'href' => $this->getCCPartnerUrl(),
347 'onclick' => $expandJs,
353 # Reduce the wrapper div height
354 htmlspecialchars( $reduceJs ) .
359 public function submitCC() {
360 $newValues = $this->parent->setVarsFromRequest(
361 [
'wgRightsUrl',
'wgRightsText',
'wgRightsIcon' ] );
362 if (
count( $newValues ) != 3 ) {
363 $this->parent->showError(
'config-cc-error' );
367 $this->setVar(
'_CCDone',
true );
368 $this->addHTML( $this->getCCDoneBox() );
377 public function submitSkins() {
378 $skins = array_keys( $this->parent->findExtensions(
'skins' ) );
379 $this->parent->setVar(
'_Skins', $skins );
382 $skinNames = array_map(
'strtolower', $skins );
383 $this->parent->setVar(
'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
392 public function submit() {
393 $this->parent->setVarsFromRequest( [
'_RightsProfile',
'_LicenseCode',
394 'wgEnableEmail',
'wgPasswordSender',
'wgEnableUploads',
'wgLogo',
395 'wgEnableUserEmail',
'wgEnotifUserTalk',
'wgEnotifWatchlist',
396 'wgEmailAuthentication',
'_MainCacheType',
'_MemCachedServers',
397 'wgUseInstantCommons',
'wgDefaultSkin' ] );
401 if ( !array_key_exists( $this->getVar(
'_RightsProfile' ), $this->parent->rightsProfiles ) ) {
402 reset( $this->parent->rightsProfiles );
403 $this->setVar(
'_RightsProfile',
key( $this->parent->rightsProfiles ) );
406 $code = $this->getVar(
'_LicenseCode' );
407 if (
$code ==
'cc-choose' ) {
408 if ( !$this->getVar(
'_CCDone' ) ) {
409 $this->parent->showError(
'config-cc-not-chosen' );
412 } elseif ( array_key_exists(
$code, $this->parent->licenses ) ) {
417 $entry = $this->parent->licenses[
$code];
418 if ( isset( $entry[
'text'] ) ) {
419 $this->setVar(
'wgRightsText', $entry[
'text'] );
423 $this->setVar(
'wgRightsUrl', $entry[
'url'] );
424 $this->setVar(
'wgRightsIcon', $entry[
'icon'] );
426 $this->setVar(
'wgRightsText',
'' );
427 $this->setVar(
'wgRightsUrl',
'' );
428 $this->setVar(
'wgRightsIcon',
'' );
431 $skinsAvailable = array_keys( $this->parent->findExtensions(
'skins' ) );
432 $skinsToInstall = [];
433 foreach ( $skinsAvailable
as $skin ) {
434 $this->parent->setVarsFromRequest( [
"skin-$skin" ] );
435 if ( $this->getVar(
"skin-$skin" ) ) {
436 $skinsToInstall[] =
$skin;
439 $this->parent->setVar(
'_Skins', $skinsToInstall );
441 if ( !$skinsToInstall && $skinsAvailable ) {
442 $this->parent->showError(
'config-skins-must-enable-some' );
445 $defaultSkin = $this->getVar(
'wgDefaultSkin' );
446 $skinsToInstallLowercase = array_map(
'strtolower', $skinsToInstall );
447 if ( $skinsToInstall && array_search( $defaultSkin, $skinsToInstallLowercase ) ===
false ) {
448 $this->parent->showError(
'config-skins-must-enable-default' );
452 $extsAvailable = array_keys( $this->parent->findExtensions() );
454 foreach ( $extsAvailable
as $ext ) {
455 $this->parent->setVarsFromRequest( [
"ext-$ext" ] );
456 if ( $this->getVar(
"ext-$ext" ) ) {
457 $extsToInstall[] =
$ext;
460 $this->parent->setVar(
'_Extensions', $extsToInstall );
462 if ( $this->getVar(
'_MainCacheType' ) ==
'memcached' ) {
463 $memcServers = explode(
"\n", $this->getVar(
'_MemCachedServers' ) );
464 if ( !$memcServers ) {
465 $this->parent->showError(
'config-memcache-needservers' );
469 foreach ( $memcServers
as $server ) {
470 $memcParts = explode(
":", $server, 2 );
471 if ( !isset( $memcParts[0] )
473 && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) )
475 $this->parent->showError(
'config-memcache-badip', $memcParts[0] );
477 } elseif ( !isset( $memcParts[1] ) ) {
478 $this->parent->showError(
'config-memcache-noport', $memcParts[0] );
480 } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
481 $this->parent->showError(
'config-memcache-badport', 1, 65535 );