From d03c0c2c6b89203c6ededcb2893b1ec3d83e6fdc Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 20 Jan 2007 22:34:05 +0000 Subject: [PATCH] (bug 8403) Respect bad image list exceptions in galleries on wiki pages --- RELEASE-NOTES | 1 + includes/ImageGallery.php | 32 ++++++++++++++++++++++++++++---- includes/Parser.php | 1 + 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f3ed5cf173..4bc70e9f1b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -134,6 +134,7 @@ they are currently editing. * (bug 8712) Expose user groups as a JavaScript global * Introduce 'CustomEditor' hook; see docs/hooks.txt for more information * (bug 8671) Expose "wpDestFile" as a parameter to "uploadtext" +* (bug 8403) Respect bad image list exceptions in galleries on wiki pages == Languages updated == diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 22b557823d..cfbc6ead32 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -21,6 +21,12 @@ class ImageGallery * Is the gallery on a wiki page (i.e. not a special page) */ var $mParsing; + + /** + * Contextual title, used when images are being screened + * against the bad image list + */ + private $contextTitle = false; /** * Create a new image gallery object. @@ -159,8 +165,7 @@ class ImageGallery if( $nt->getNamespace() != NS_IMAGE ) { # We're dealing with a non-image, spit out the name and be done with it. $thumbhtml = '
' . htmlspecialchars( $nt->getText() ) . '
'; - } - else if( $this->mParsing && wfIsBadImage( $nt->getDBkey() ) ) { + } elseif( $this->mParsing && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) { # The image is blacklisted, just show it as a text link. $thumbhtml = '
' . $sk->makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) ) . '
'; @@ -168,8 +173,7 @@ class ImageGallery # Error generating thumbnail. $thumbhtml = '
' . htmlspecialchars( $img->getLastError() ) . '
'; - } - else { + } else { $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2; $thumbhtml = '
' . $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '
'; @@ -219,6 +223,26 @@ class ImageGallery public function count() { return count( $this->mImages ); } + + /** + * Set the contextual title + * + * @param Title $title Contextual title + */ + public function setContextTitle( $title ) { + $this->contextTitle = $title; + } + + /** + * Get the contextual title, if applicable + * + * @return mixed Title or false + */ + public function getContextTitle() { + return is_object( $this->contextTitle ) && $this->contextTitle instanceof Title + ? $this->contextTitle + : false; + } } //class ?> diff --git a/includes/Parser.php b/includes/Parser.php index 78c4a983d6..17ee937c58 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -4298,6 +4298,7 @@ class Parser */ function renderImageGallery( $text, $params ) { $ig = new ImageGallery(); + $ig->setContextTitle( $this->mTitle ); $ig->setShowBytes( false ); $ig->setShowFilename( false ); $ig->setParsing(); -- 2.20.1