Ebe123 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/156048

Change subject: Add option to hide and unhide file thumbnails in file history
......................................................................

Add option to hide and unhide file thumbnails in file history

This change adds a show/hide option to the thumbnails of files in
the file history, that defaults to hiding the thumbnails. The message
used is 'filehist-showhidethumb' and also messages suffixed with "-show"
and "-hide" for the options. The global 'wgShowArchiveThumbnails'
has been removed, being replaced by the new user option.

Bug: 69053
Change-Id: Ie993204e8c2a3e52713479f7f2451fc3e7c65580
---
M RELEASE-NOTES-1.24
M includes/DefaultSettings.php
M includes/page/ImagePage.php
M languages/i18n/en.json
M languages/i18n/qqq.json
5 files changed, 66 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/48/156048/1

diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index 32ce12b..bccf721 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -63,6 +63,7 @@
 * The default thumb size ($wgDefaultUserOptions['thumbsize']) is now 300px, up 
from
   180px. If you have altered the number of entries in $wgThumbLimits for your 
wiki, you
   may need to adjust your default user settings to compensate for the index 
change.
+* $wgShowArchiveThumbnails has been removed.
 
 === New features in 1.24 ===
 * Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
@@ -169,6 +170,7 @@
 * (bug 35045) Redirects to sections will now update the URL in browser's 
address
   bar using the HTML5 History API. When [[Dog]] redirects to [[Animals#Dog]],
   the user will now see "Animals#Dog" in their browser instead of "Dog#Dog".
+* (bug 69053) File thumbnails can be shown or hidden in the file history.
 
 === Bug fixes in 1.24 ===
 * (bug 50572) MediaWiki:Blockip should support gender
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 14799c6..af589d3 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -1062,11 +1062,6 @@
 $wgGenerateThumbnailOnParse = true;
 
 /**
- * Show thumbnails for old images on the image description page
- */
-$wgShowArchiveThumbnails = true;
-
-/**
  * If set to true, images that contain certain the exif orientation tag will
  * be rotated accordingly. If set to null, try to auto-detect whether a scaler
  * is available that can rotate.
diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php
index 380252f..89476a8 100644
--- a/includes/page/ImagePage.php
+++ b/includes/page/ImagePage.php
@@ -1166,15 +1166,40 @@
         * @param ImagePage $imagePage
         */
        public function __construct( $imagePage ) {
-               global $wgShowArchiveThumbnails;
+               $this->setup( $imagePage );
+
                $this->current = $imagePage->getFile();
                $this->img = $imagePage->getDisplayedFile();
                $this->title = $imagePage->getTitle();
                $this->imagePage = $imagePage;
-               $this->showThumb = $wgShowArchiveThumbnails && 
$this->img->canRender();
+               $this->showThumb = !$this->opts->getValue( 'hidethumb' ) && 
$this->img->canRender();
                $this->setContext( $imagePage->getContext() );
        }
 
+       protected function setup( $par ) {
+               // To be able to add more options
+               $opts = new FormOptions();
+               $this->opts = $opts;
+               $opts->add( 'hidethumb', false );
+
+               // Set values
+               $opts->fetchValuesFromRequest( $this->getRequest() );
+               if ( $par ) {
+                       $this->parseParams( $par );
+               }
+
+               // Validate
+               $opts->validateIntBounds( 'limit', 0, 5000 );
+       }
+
+       protected function parseParams( $par ) {
+               $bits = preg_split( '/\s*,\s*/', trim( $par ) );
+               foreach ( $bits as $bit ) {
+                       if ( 'hidethumb' === $bit ) {
+                               $this->opts->setValue( 'hidethumb', true );
+                       }
+               }
+       }
        /**
         * @return ImagePage
         */
@@ -1198,6 +1223,9 @@
                        . "\n"
                        . "<div id=\"mw-imagepage-section-filehistory\">\n"
                        . $this->msg( 'filehist-help' )->parseAsBlock()
+                       . '<tr><td></td><td class="mw-input">'
+                       . $this->filterLinks()
+                       . '</td></tr>'
                        . $navLinks . "\n"
                        . Xml::openElement( 'table', array( 'class' => 
'wikitable filehistory' ) ) . "\n"
                        . '<tr><td></td>'
@@ -1436,6 +1464,34 @@
        public function getPreventClickjacking() {
                return $this->preventClickjacking;
        }
+
+       protected function filterLinks() {
+               // show/hide links
+               $showhide = array( $this->msg( 'show' )->escaped(), $this->msg( 
'hide' )->escaped() );
+
+               // Option value -> message mapping
+               $filters = array(
+                       'hidethumb' => 'filehist-showhidethumb',
+               );
+               foreach ( $this->customFilters as $key => $params ) {
+                       $filters[$key] = $params['msg'];
+               }
+
+               $links = array();
+               $changed = $this->opts->getChangedValues();
+               unset( $changed['offset'] ); // Reset offset if query type 
changes
+
+               $self = $this->getPageTitle();
+               foreach ( $filters as $key => $msg ) {
+                       $onoff = 1 - $this->opts->getValue( $key );
+                       $link = Linker::link( $self, $showhide[$onoff], array(),
+                               array( $key => $onoff ) + $changed
+                       );
+                       $links[$key] = $this->msg( $msg )->rawParams( $link 
)->escaped();
+               }
+
+               return $this->getLanguage()->pipeList( $links );
+       }
 }
 
 class ImageHistoryPseudoPager extends ReverseChronologicalPager {
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index e160327..4d21353 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1454,6 +1454,9 @@
        "filehist-dimensions": "Dimensions",
        "filehist-filesize": "File size",
        "filehist-comment": "Comment",
+       "filehist-hshowhidethumb": "$1 thumbnails",
+       "filehist-showhidethumb-show": "Show",
+       "filehist-showhidethumb-hide": "Hide",
        "imagelinks": "File usage",
        "linkstoimage": "The following {{PLURAL:$1|page links|$1 pages link}} 
to this file:",
        "linkstoimage-more": "More than $1 {{PLURAL:$1|page links|pages link}} 
to this file.\nThe following list shows the {{PLURAL:$1|first page link|first 
$1 page links}} to this file only.\nA [[Special:WhatLinksHere/$2|full list]] is 
available.",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 2000a8b..bffa2d5 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -1616,6 +1616,9 @@
        "filehist-dimensions": "Used as label in file description 
page.\n\nFollowed by length, filesize, and width x height. e.g. \"1.5 s (13 
KB)\".",
        "filehist-filesize": "Used in image description page.\n{{Identical|File 
size}}",
        "filehist-comment": "In file description page\n\n{{Identical|Comment}}",
+       "filehist-showhidethumb": "Option text on file pages in the history 
section. Parameters:\n* $1 - any one of the following messages:\n** 
{{msg-mw|fhshowhidethumb-show}}\n** {{msg-mw|fhshowhidethumb-hide}}",
+       "filehist-showhidethumb-show": "{{doc-actionlink}}\nOption text on file 
pages in the history section in conjunction with 
{{msg-mw|fhshowhidethumb}}.\n\nSee also:\n* 
{{msg-mw|fhshowhidethumb-hide}}\n{{Identical|Show}}",
+       "filehist-showhidethumb-hide": "{{doc-actionlink}}\nOption text on file 
pages in the history section in conjunction with 
{{msg-mw|fhshowhidethumb}}.\n\nSee also:\n* 
{{msg-mw|fhshowhidethumb-show}}\n{{Identical|Hide}}",
        "imagelinks": "In top header of the image description page, see for 
example [[:Image:Yes.png]]. Shows a list of pages where this file is 
used.\n{{Identical|File usage}}",
        "linkstoimage": "Used on image description, see for example 
[[:Image:Yes.png#filelinks]].\n\nParameters:\n* $1 - the number of pages that 
link to the file/image\nSee also:\n* {{msg-mw|Linkstoimage-more}}",
        "linkstoimage-more": "Shown on an image description page when a file is 
used/linked more than 100 times on other pages.\n\nParameters:\n* $1 - limit. 
At the moment hardcoded at 100\n* $2 - page title of the file\nSee also:\n* 
{{msg-mw|Linkstoimage}}",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie993204e8c2a3e52713479f7f2451fc3e7c65580
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ebe123 <beauleetien...@gmail.com>

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

Reply via email to