X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Finstaller%2FWebInstallerOptions.php;h=07378ab32e3cac965dabd26c91d56e5df9bece63;hp=fb8e35b5e2a828d352ce7abc77eb4d33133974d3;hb=e7720b8f8e09287384ddee271641d1b1721318bb;hpb=c9f533269658eff1919b371c6db3f4507f4587a1 diff --git a/includes/installer/WebInstallerOptions.php b/includes/installer/WebInstallerOptions.php index fb8e35b5e2..07378ab32e 100644 --- a/includes/installer/WebInstallerOptions.php +++ b/includes/installer/WebInstallerOptions.php @@ -42,12 +42,12 @@ class WebInstallerOptions extends WebInstallerPage { // getRadioSet() builds a set of labeled radio buttons. // For grep: The following messages are used as the item labels: // config-profile-wiki, config-profile-no-anon, config-profile-fishbowl, config-profile-private - $this->parent->getRadioSet( array( + $this->parent->getRadioSet( [ 'var' => '_RightsProfile', 'label' => 'config-profile', 'itemLabelPrefix' => 'config-profile-', 'values' => array_keys( $this->parent->rightsProfiles ), - ) ) . + ] ) . $this->parent->getInfoBox( wfMessage( 'config-profile-help' )->plain() ) . # Licensing @@ -56,76 +56,81 @@ class WebInstallerOptions extends WebInstallerPage { // config-license-cc-by, config-license-cc-by-sa, config-license-cc-by-nc-sa, // config-license-cc-0, config-license-pd, config-license-gfdl, // config-license-none, config-license-cc-choose - $this->parent->getRadioSet( array( + $this->parent->getRadioSet( [ 'var' => '_LicenseCode', 'label' => 'config-license', 'itemLabelPrefix' => 'config-license-', 'values' => array_keys( $this->parent->licenses ), - 'commonAttribs' => array( 'class' => 'licenseRadio' ), - ) ) . + 'commonAttribs' => [ 'class' => 'licenseRadio' ], + ] ) . $this->getCCChooser() . $this->parent->getHelpBox( 'config-license-help' ) . # E-mail - $this->getFieldSetStart( 'config-email-settings' ) . - $this->parent->getCheckBox( array( + $this->getFieldsetStart( 'config-email-settings' ) . + $this->parent->getCheckBox( [ 'var' => 'wgEnableEmail', 'label' => 'config-enable-email', - 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ), - ) ) . + 'attribs' => [ 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ], + ] ) . $this->parent->getHelpBox( 'config-enable-email-help' ) . "
" . - $this->parent->getTextBox( array( + $this->parent->getTextBox( [ 'var' => 'wgPasswordSender', 'label' => 'config-email-sender' - ) ) . + ] ) . $this->parent->getHelpBox( 'config-email-sender-help' ) . - $this->parent->getCheckBox( array( + $this->parent->getCheckBox( [ 'var' => 'wgEnableUserEmail', 'label' => 'config-email-user', - ) ) . + ] ) . $this->parent->getHelpBox( 'config-email-user-help' ) . - $this->parent->getCheckBox( array( + $this->parent->getCheckBox( [ 'var' => 'wgEnotifUserTalk', 'label' => 'config-email-usertalk', - ) ) . + ] ) . $this->parent->getHelpBox( 'config-email-usertalk-help' ) . - $this->parent->getCheckBox( array( + $this->parent->getCheckBox( [ 'var' => 'wgEnotifWatchlist', 'label' => 'config-email-watchlist', - ) ) . + ] ) . $this->parent->getHelpBox( 'config-email-watchlist-help' ) . - $this->parent->getCheckBox( array( + $this->parent->getCheckBox( [ 'var' => 'wgEmailAuthentication', 'label' => 'config-email-auth', - ) ) . + ] ) . $this->parent->getHelpBox( 'config-email-auth-help' ) . "
" . - $this->getFieldSetEnd() + $this->getFieldsetEnd() ); $skins = $this->parent->findExtensions( 'skins' ); - $skinHtml = $this->getFieldSetStart( 'config-skins' ); + $skinHtml = $this->getFieldsetStart( 'config-skins' ); - $skinNames = array_map( 'strtolower', $skins ); + $skinNames = array_map( 'strtolower', array_keys( $skins ) ); $chosenSkinName = $this->getVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) ); if ( $skins ) { - $radioButtons = $this->parent->getRadioElements( array( + $radioButtons = $this->parent->getRadioElements( [ 'var' => 'wgDefaultSkin', 'itemLabels' => array_fill_keys( $skinNames, 'config-skins-use-as-default' ), 'values' => $skinNames, 'value' => $chosenSkinName, - ) ); + ] ); - foreach ( $skins as $skin ) { + foreach ( $skins as $skin => $info ) { + if ( isset( $info['screenshots'] ) ) { + $screenshotText = $this->makeScreenshotsLink( $skin, $info['screenshots'] ); + } else { + $screenshotText = htmlspecialchars( $skin ); + } $skinHtml .= '
' . - $this->parent->getCheckBox( array( + $this->parent->getCheckBox( [ 'var' => "skin-$skin", - 'rawtext' => $skin, + 'rawtext' => $screenshotText, 'value' => $this->getVar( "skin-$skin", true ), // all found skins enabled by default - ) ) . + ] ) . '
' . $radioButtons[strtolower( $skin )] . '
' . '
'; } @@ -136,23 +141,23 @@ class WebInstallerOptions extends WebInstallerPage { } $skinHtml .= $this->parent->getHelpBox( 'config-skins-help' ) . - $this->getFieldSetEnd(); + $this->getFieldsetEnd(); $this->addHTML( $skinHtml ); $extensions = $this->parent->findExtensions(); if ( $extensions ) { - $extHtml = $this->getFieldSetStart( 'config-extensions' ); + $extHtml = $this->getFieldsetStart( 'config-extensions' ); - foreach ( $extensions as $ext ) { - $extHtml .= $this->parent->getCheckBox( array( + foreach ( $extensions as $ext => $info ) { + $extHtml .= $this->parent->getCheckBox( [ 'var' => "ext-$ext", 'rawtext' => $ext, - ) ); + ] ); } $extHtml .= $this->parent->getHelpBox( 'config-extensions-help' ) . - $this->getFieldSetEnd(); + $this->getFieldsetEnd(); $this->addHTML( $extHtml ); } @@ -167,38 +172,38 @@ class WebInstallerOptions extends WebInstallerPage { $uploadwrapperStyle = $this->getVar( 'wgEnableUploads' ) ? '' : 'display: none'; $this->addHTML( # Uploading - $this->getFieldSetStart( 'config-upload-settings' ) . - $this->parent->getCheckBox( array( + $this->getFieldsetStart( 'config-upload-settings' ) . + $this->parent->getCheckBox( [ 'var' => 'wgEnableUploads', 'label' => 'config-upload-enable', - 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ), + 'attribs' => [ 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ], 'help' => $this->parent->getHelpBox( 'config-upload-help' ) - ) ) . + ] ) . '
' . - $this->parent->getTextBox( array( + $this->parent->getTextBox( [ 'var' => 'wgDeletedDirectory', 'label' => 'config-upload-deleted', - 'attribs' => array( 'dir' => 'ltr' ), + 'attribs' => [ 'dir' => 'ltr' ], 'help' => $this->parent->getHelpBox( 'config-upload-deleted-help' ) - ) ) . + ] ) . '
' . - $this->parent->getTextBox( array( + $this->parent->getTextBox( [ 'var' => 'wgLogo', 'label' => 'config-logo', - 'attribs' => array( 'dir' => 'ltr' ), + 'attribs' => [ 'dir' => 'ltr' ], 'help' => $this->parent->getHelpBox( 'config-logo-help' ) - ) ) + ] ) ); $this->addHTML( - $this->parent->getCheckBox( array( + $this->parent->getCheckBox( [ 'var' => 'wgUseInstantCommons', 'label' => 'config-instantcommons', 'help' => $this->parent->getHelpBox( 'config-instantcommons-help' ) - ) ) . - $this->getFieldSetEnd() + ] ) . + $this->getFieldsetEnd() ); - $caches = array( 'none' ); + $caches = [ 'none' ]; $cachevalDefault = 'none'; if ( count( $this->getVar( '_Caches' ) ) ) { @@ -219,55 +224,80 @@ class WebInstallerOptions extends WebInstallerPage { $hidden = ( $cacheval == 'memcached' ) ? '' : 'display: none'; $this->addHTML( # Advanced settings - $this->getFieldSetStart( 'config-advanced-settings' ) . + $this->getFieldsetStart( 'config-advanced-settings' ) . # Object cache settings // getRadioSet() builds a set of labeled radio buttons. // For grep: The following messages are used as the item labels: // config-cache-none, config-cache-accel, config-cache-memcached - $this->parent->getRadioSet( array( + $this->parent->getRadioSet( [ 'var' => '_MainCacheType', 'label' => 'config-cache-options', 'itemLabelPrefix' => 'config-cache-', 'values' => $caches, 'value' => $cacheval, - ) ) . + ] ) . $this->parent->getHelpBox( 'config-cache-help' ) . "
" . - $this->parent->getTextArea( array( + $this->parent->getTextArea( [ 'var' => '_MemCachedServers', 'label' => 'config-memcached-servers', 'help' => $this->parent->getHelpBox( 'config-memcached-help' ) - ) ) . + ] ) . '
' . - $this->getFieldSetEnd() + $this->getFieldsetEnd() ); $this->endForm(); return null; } + private function makeScreenshotsLink( $name, $screenshots ) { + global $wgLang; + if ( count( $screenshots ) > 1 ) { + $links = []; + $counter = 1; + foreach ( $screenshots as $shot ) { + $links[] = Html::element( + 'a', + [ 'href' => $shot ], + $wgLang->formatNum( $counter++ ) + ); + } + return wfMessage( 'config-skins-screenshots' ) + ->rawParams( $name, $wgLang->commaList( $links ) ) + ->escaped(); + } else { + $link = Html::element( + 'a', + [ 'href' => $screenshots[0] ], + wfMessage( 'config-screenshot' )->text() + ); + return wfMessage( 'config-skins-screenshot', $name )->rawParams( $link )->escaped(); + } + } + /** * @return string */ public function getCCPartnerUrl() { $server = $this->getVar( 'wgServer' ); - $exitUrl = $server . $this->parent->getUrl( array( + $exitUrl = $server . $this->parent->getUrl( [ 'page' => 'Options', 'SubmitCC' => 'indeed', 'config__LicenseCode' => 'cc', 'config_wgRightsUrl' => '[license_url]', 'config_wgRightsText' => '[license_name]', 'config_wgRightsIcon' => '[license_button]', - ) ); + ] ); $styleUrl = $server . dirname( dirname( $this->parent->getUrl() ) ) . '/mw-config/config-cc.css'; $iframeUrl = '//creativecommons.org/license/?' . - wfArrayToCgi( array( + wfArrayToCgi( [ 'partner' => 'MediaWiki', 'exit_url' => $exitUrl, 'lang' => $this->getVar( '_UserLang' ), 'stylesheet' => $styleUrl, - ) ); + ] ); return $iframeUrl; } @@ -276,16 +306,16 @@ class WebInstallerOptions extends WebInstallerPage { * @return string */ public function getCCChooser() { - $iframeAttribs = array( + $iframeAttribs = [ 'class' => 'config-cc-iframe', 'name' => 'config-cc-iframe', 'id' => 'config-cc-iframe', 'frameborder' => 0, 'width' => '100%', 'height' => '100%', - ); + ]; if ( $this->getVar( '_CCDone' ) ) { - $iframeAttribs['src'] = $this->parent->getUrl( array( 'ShowCC' => 'yes' ) ); + $iframeAttribs['src'] = $this->parent->getUrl( [ 'ShowCC' => 'yes' ] ); } else { $iframeAttribs['src'] = $this->getCCPartnerUrl(); } @@ -306,16 +336,16 @@ class WebInstallerOptions extends WebInstallerPage { $reduceJs = str_replace( '$1', '70px', $js ); return '

' . - Html::element( 'img', array( 'src' => $this->getVar( 'wgRightsIcon' ) ) ) . + Html::element( 'img', [ 'src' => $this->getVar( 'wgRightsIcon' ) ] ) . '  ' . htmlspecialchars( $this->getVar( 'wgRightsText' ) ) . "

\n" . "

" . Html::element( 'a', - array( + [ 'href' => $this->getCCPartnerUrl(), 'onclick' => $expandJs, - ), + ], wfMessage( 'config-cc-again' )->text() ) . "

\n" . @@ -328,7 +358,7 @@ class WebInstallerOptions extends WebInstallerPage { public function submitCC() { $newValues = $this->parent->setVarsFromRequest( - array( 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ) ); + [ 'wgRightsUrl', 'wgRightsText', 'wgRightsIcon' ] ); if ( count( $newValues ) != 3 ) { $this->parent->showError( 'config-cc-error' ); @@ -345,7 +375,7 @@ class WebInstallerOptions extends WebInstallerPage { * @return bool */ public function submitSkins() { - $skins = $this->parent->findExtensions( 'skins' ); + $skins = array_keys( $this->parent->findExtensions( 'skins' ) ); $this->parent->setVar( '_Skins', $skins ); if ( $skins ) { @@ -360,11 +390,11 @@ class WebInstallerOptions extends WebInstallerPage { * @return bool */ public function submit() { - $this->parent->setVarsFromRequest( array( '_RightsProfile', '_LicenseCode', + $this->parent->setVarsFromRequest( [ '_RightsProfile', '_LicenseCode', 'wgEnableEmail', 'wgPasswordSender', 'wgEnableUploads', 'wgLogo', 'wgEnableUserEmail', 'wgEnotifUserTalk', 'wgEnotifWatchlist', 'wgEmailAuthentication', '_MainCacheType', '_MemCachedServers', - 'wgUseInstantCommons', 'wgDefaultSkin' ) ); + 'wgUseInstantCommons', 'wgDefaultSkin' ] ); $retVal = true; @@ -398,10 +428,10 @@ class WebInstallerOptions extends WebInstallerPage { $this->setVar( 'wgRightsIcon', '' ); } - $skinsAvailable = $this->parent->findExtensions( 'skins' ); - $skinsToInstall = array(); + $skinsAvailable = array_keys( $this->parent->findExtensions( 'skins' ) ); + $skinsToInstall = []; foreach ( $skinsAvailable as $skin ) { - $this->parent->setVarsFromRequest( array( "skin-$skin" ) ); + $this->parent->setVarsFromRequest( [ "skin-$skin" ] ); if ( $this->getVar( "skin-$skin" ) ) { $skinsToInstall[] = $skin; } @@ -419,10 +449,10 @@ class WebInstallerOptions extends WebInstallerPage { $retVal = false; } - $extsAvailable = $this->parent->findExtensions(); - $extsToInstall = array(); + $extsAvailable = array_keys( $this->parent->findExtensions() ); + $extsToInstall = []; foreach ( $extsAvailable as $ext ) { - $this->parent->setVarsFromRequest( array( "ext-$ext" ) ); + $this->parent->setVarsFromRequest( [ "ext-$ext" ] ); if ( $this->getVar( "ext-$ext" ) ) { $extsToInstall[] = $ext; }