From e690ce7de69c241f9c7a3646504005314f137a66 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 29 Jun 2006 23:27:13 +0000 Subject: [PATCH] Gallery code cleanup patch by Ilmari Karonen http://bugzilla.wikimedia.org/attachment.cgi?id=2028&action=view --- includes/ImageGallery.php | 58 +++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 001305fa36..01c78da0cf 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -149,18 +149,24 @@ class ImageGallery $name = $img->getName(); $nt = $img->getTitle(); - # 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" : '') . - '
' . - htmlspecialchars( $nt->getText() ) . '
' . - (($i%4==3) ? "\n" : ''); - $i++; - - continue; + 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() ) ) { + # The image is blacklisted, just show it as a text link. + $thumbhtml = '
' + . $sk->makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) ) . '
'; + } + else if( !( $thumb = $img->getThumbnail( 120, 120 ) ) ) { + # Error generating thumbnail. + $thumbhtml = '
' + . htmlspecialchars( $img->getLastError() ) . '
'; + } + else { + $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2; + $thumbhtml = '
' + . $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '
'; } //TODO @@ -182,28 +188,14 @@ class ImageGallery $sk->makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20, '...' ) ) ) . "
\n" : '' ; + # ATTENTION: The newline after
is needed to accommodate htmltidy which + # in version 4.8.6 generated crackpot html in its absence, see: + # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar + $s .= ($i%4==0) ? '' : ''; - $thumb = $img->getThumbnail( 120, 120 ); - if ( $thumb ) { - $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2; - $s .= '
' . '
'; - - # ATTENTION: The newline after
is needed to accommodate htmltidy which - # in version 4.8.6 generated crackpot html in its absence, see: - # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar - $s .= $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '
' . "\n" . - $textlink . $text . $nb . - '
'; - $s .= "
\n"; - } else { - # Error during thumbnail generation - $s .= '
' . - #htmlspecialchars( $nt->getText() ) . "
\n" . - htmlspecialchars( $img->getLastError() ) . - "
\n" . - $textlink . $text . $nb . - "
\n"; - } + $s .= '
' . $thumbhtml + . '
' . "\n" . $textlink . $text . $nb + . "
\n"; $s .= ($i%4==3) ? '' : ''; $i++; } -- 2.20.1