jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/371080 )

Change subject: installer: Link to skin screenshots
......................................................................


installer: Link to skin screenshots

Skins can now place *.png files in a "screenshots/" directory and the
installer will link to them. It assumes that the skin directory is in a
web accessible directory.

Bug: T70331
Co-Authored-By: Isarra <zhoris...@gmail.com>
Change-Id: I30a4374619ac2cb6afe6d8c0d9181dd6b14aae79
---
M includes/installer/CliInstaller.php
M includes/installer/Installer.php
M includes/installer/WebInstallerOptions.php
M includes/installer/i18n/en.json
M includes/installer/i18n/qqq.json
5 files changed, 54 insertions(+), 10 deletions(-)

Approvals:
  Brian Wolff: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/installer/CliInstaller.php 
b/includes/installer/CliInstaller.php
index 6ac78c4..32d2634 100644
--- a/includes/installer/CliInstaller.php
+++ b/includes/installer/CliInstaller.php
@@ -108,7 +108,7 @@
                }
 
                // Set up the default skins
-               $skins = $this->findExtensions( 'skins' );
+               $skins = array_keys( $this->findExtensions( 'skins' ) );
                $this->setVar( '_Skins', $skins );
 
                if ( $skins ) {
diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php
index 573a92d..a29d987 100644
--- a/includes/installer/Installer.php
+++ b/includes/installer/Installer.php
@@ -1340,7 +1340,7 @@
         * Reasonable values for $directory include 'extensions' (the default) 
and 'skins'.
         *
         * @param string $directory Directory to search in
-        * @return array
+        * @return array [ $extName => [ 'screenshots' => [ '...' ] ]
         */
        public function findExtensions( $directory = 'extensions' ) {
                if ( $this->getVar( 'IP' ) === null ) {
@@ -1362,7 +1362,15 @@
                                continue;
                        }
                        if ( file_exists( "$extDir/$file/$jsonFile" ) || 
file_exists( "$extDir/$file/$file.php" ) ) {
-                               $exts[] = $file;
+                               // Extension exists. Now see if there are 
screenshots
+                               $exts[$file] = [];
+                               if ( is_dir( "$extDir/$file/screenshots" ) ) {
+                                       $paths = glob( 
"$extDir/$file/screenshots/*.png" );
+                                       foreach ( $paths as $path ) {
+                                               $exts[$file]['screenshots'][] = 
str_replace( $extDir, "../$directory", $path );
+                                       }
+
+                               }
                        }
                }
                closedir( $dh );
diff --git a/includes/installer/WebInstallerOptions.php 
b/includes/installer/WebInstallerOptions.php
index 0c01b64..07378ab 100644
--- a/includes/installer/WebInstallerOptions.php
+++ b/includes/installer/WebInstallerOptions.php
@@ -107,7 +107,7 @@
                $skins = $this->parent->findExtensions( '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 ) {
@@ -118,12 +118,17 @@
                                '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 .=
                                        '<div class="config-skins-item">' .
                                        $this->parent->getCheckBox( [
                                                'var' => "skin-$skin",
-                                               'rawtext' => $skin,
+                                               'rawtext' => $screenshotText,
                                                'value' => $this->getVar( 
"skin-$skin", true ), // all found skins enabled by default
                                        ] ) .
                                        '<div 
class="config-skins-use-as-default">' . $radioButtons[strtolower( $skin )] . 
'</div>' .
@@ -144,7 +149,7 @@
                if ( $extensions ) {
                        $extHtml = $this->getFieldsetStart( 'config-extensions' 
);
 
-                       foreach ( $extensions as $ext ) {
+                       foreach ( $extensions as $ext => $info ) {
                                $extHtml .= $this->parent->getCheckBox( [
                                        'var' => "ext-$ext",
                                        'rawtext' => $ext,
@@ -246,6 +251,31 @@
                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
         */
@@ -345,7 +375,7 @@
         * @return bool
         */
        public function submitSkins() {
-               $skins = $this->parent->findExtensions( 'skins' );
+               $skins = array_keys( $this->parent->findExtensions( 'skins' ) );
                $this->parent->setVar( '_Skins', $skins );
 
                if ( $skins ) {
@@ -398,7 +428,7 @@
                        $this->setVar( 'wgRightsIcon', '' );
                }
 
-               $skinsAvailable = $this->parent->findExtensions( 'skins' );
+               $skinsAvailable = array_keys( $this->parent->findExtensions( 
'skins' ) );
                $skinsToInstall = [];
                foreach ( $skinsAvailable as $skin ) {
                        $this->parent->setVarsFromRequest( [ "skin-$skin" ] );
@@ -419,7 +449,7 @@
                        $retVal = false;
                }
 
-               $extsAvailable = $this->parent->findExtensions();
+               $extsAvailable = array_keys( $this->parent->findExtensions() );
                $extsToInstall = [];
                foreach ( $extsAvailable as $ext ) {
                        $this->parent->setVarsFromRequest( [ "ext-$ext" ] );
diff --git a/includes/installer/i18n/en.json b/includes/installer/i18n/en.json
index db92652..bb245f5 100644
--- a/includes/installer/i18n/en.json
+++ b/includes/installer/i18n/en.json
@@ -308,6 +308,9 @@
        "config-help-tooltip": "click to expand",
        "config-nofile": "File \"$1\" could not be found. Has it been deleted?",
        "config-extension-link": "Did you know that your wiki supports 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Extensions 
extensions]?\n\nYou can browse 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Category:Extensions_by_category
 extensions by category] or the 
[https://www.mediawiki.org/wiki/Extension_Matrix Extension Matrix] to see the 
full list of extensions.",
+       "config-skins-screenshots": "$1 (screenshots: $2)",
+       "config-skins-screenshot": "$1 ($2)",
+       "config-screenshot": "screenshot",
        "mainpagetext": "<strong>MediaWiki has been installed.</strong>",
        "mainpagedocfooter": "Consult the 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide] 
for information on using the wiki software.\n\n== Getting started ==\n* 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings
 Configuration settings list]\n* 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]\n* 
[https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki 
release mailing list]\n* 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources
 Localise MediaWiki for your language]\n* 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam Learn 
how to combat spam on your wiki]"
 }
diff --git a/includes/installer/i18n/qqq.json b/includes/installer/i18n/qqq.json
index 8d10b51..b82c03d 100644
--- a/includes/installer/i18n/qqq.json
+++ b/includes/installer/i18n/qqq.json
@@ -327,6 +327,9 @@
        "config-help-tooltip": "Tooltip for the 'help' links 
({{msg-mw|config-help}}), to make it clear they'll expand in place rather than 
open a new page",
        "config-nofile": "Used as failure message. Parameters:\n* $1 - 
filename",
        "config-extension-link": "Shown on last page of installation to inform 
about possible extensions.\n{{Identical|Did you know}}",
+       "config-skins-screenshots": "Radio button text, $1 is the skin name, 
and $2 is a list of links to screenshots of that skin",
+       "config-skins-screenshot": "Radio button text, $1 is the skin name, and 
$2 is a link to a screenshot of that skin, where the link text is 
{{mw-msg|config-screenshot}}.",
+       "config-screenshot": "Link text for the link in 
{{mw-msg|config-skins-screenshot}}",
        "mainpagetext": "Along with {{msg-mw|mainpagedocfooter}}, the text you 
will see on the Main Page when your wiki is installed.",
        "mainpagedocfooter": "Along with {{msg-mw|mainpagetext}}, the text you 
will see on the Main Page when your wiki is installed.\nThis might be a good 
place to put information about <nowiki>{{GRAMMAR:}}</nowiki>. See 
[[{{NAMESPACE}}:{{BASEPAGENAME}}/fi]] for an example. For languages having 
grammatical distinctions and not having an appropriate 
<nowiki>{{GRAMMAR:}}</nowiki> software available, a suggestion to check and 
possibly amend the messages having <nowiki>{{SITENAME}}</nowiki> may be 
valuable. See [[{{NAMESPACE}}:{{BASEPAGENAME}}/ksh]] for an example."
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/371080
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I30a4374619ac2cb6afe6d8c0d9181dd6b14aae79
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Isarra <zhoris...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to