Suppress images in galleries which appear on the bad image list (when rendering for...
authorRob Church <robchurch@users.mediawiki.org>
Tue, 16 May 2006 19:15:58 +0000 (19:15 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Tue, 16 May 2006 19:15:58 +0000 (19:15 +0000)
RELEASE-NOTES
includes/Image.php
includes/ImageGallery.php
includes/Parser.php

index 2b30bbb..1806739 100644 (file)
@@ -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 ==
 
index 4547a8c..0904694 100644 (file)
@@ -1871,7 +1871,6 @@ function wfGetSVGsize( $filename ) {
  * @return bool
  */
 function wfIsBadImage( $name ) {
-       global $wgContLang;
        static $titleList = false;
        
        if( !$titleList ) {
index 7e18464..41a77e9 100644 (file)
@@ -1,4 +1,4 @@
-<?php
+t<?php
 if ( ! defined( 'MEDIAWIKI' ) )
        die( -1 );
 
@@ -16,6 +16,11 @@ if ( ! defined( 'MEDIAWIKI' ) )
 class ImageGallery
 {
        var $mImages, $mShowBytes, $mShowFilename;
+       
+       /**
+        * Is the gallery on a wiki page (i.e. not a special page)
+        */
+       var $mParsing;
 
        /**
         * Create a new image gallery object.
@@ -24,6 +29,14 @@ class ImageGallery
                $this->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) ? "<tr>\n" : '') .
                                        '<td><div class="gallerybox" style="height: 152px;">' .
index d2700c9..251e32a 100644 (file)
@@ -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 ) {