From b01da48ba223a3a7c0f67b79917c1458099a0c42 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Tue, 16 May 2006 19:15:58 +0000 Subject: [PATCH] Suppress images in galleries which appear on the bad image list (when rendering for a wiki page; galleries in special pages and categories are unaffected) --- RELEASE-NOTES | 2 ++ includes/Image.php | 1 - includes/ImageGallery.php | 21 ++++++++++++++++++--- includes/Parser.php | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2b30bbb5d1..18067393d2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -279,6 +279,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 5849) Remove some hard-coded references to "Wikipedia" in messages * (bug 5967) Improvement to German localisation (de) * (bug 5962) Update for Italian language (it) +* Suppress images in galleries which appear on the bad image list (when rendering + for a wiki page; galleries in special pages and categories are unaffected) == Compatibility == diff --git a/includes/Image.php b/includes/Image.php index 4547a8c480..090469469a 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -1871,7 +1871,6 @@ function wfGetSVGsize( $filename ) { * @return bool */ function wfIsBadImage( $name ) { - global $wgContLang; static $titleList = false; if( !$titleList ) { diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 7e18464d2a..41a77e9853 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -1,4 +1,4 @@ -mImages = array(); $this->mShowBytes = true; $this->mShowFilename = true; + $this->mParsing = false; + } + + /** + * Set the "parse" bit so we know to hide "bad" images + */ + function setParsing( $val = true ) { + $this->mParsing = $val; } /** @@ -98,8 +111,10 @@ class ImageGallery $name = $img->getName(); $nt = $img->getTitle(); - // Not an image. Just print the name and skip. - if ( $nt->getNamespace() != NS_IMAGE ) { + # If we're dealing with a non-image, or a blacklisted image, + # spit out the name and be done with it + if( $nt->getNamespace() != NS_IMAGE + || ( $this->mParsing && wfIsBadImage( $nt->getDBkey() ) ) ) { $s .= (($i%4==0) ? "\n" : '') . '
' . diff --git a/includes/Parser.php b/includes/Parser.php index d2700c9574..251e32a2ab 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -3924,6 +3924,7 @@ class Parser $ig = new ImageGallery(); $ig->setShowBytes( false ); $ig->setShowFilename( false ); + $ig->setParsing(); $lines = explode( "\n", $text ); foreach ( $lines as $line ) { -- 2.20.1