Index: trunk/phase3/includes/CategoryPage.php |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | $this->children_start_char = array(); |
108 | 108 | if( $this->showGallery ) { |
109 | 109 | $this->gallery = new ImageGallery(); |
110 | | - $this->gallery->setParsing(); |
| 110 | + $this->gallery->setHideBadImages(); |
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -4411,7 +4411,8 @@ |
4412 | 4412 | $ig->setContextTitle( $this->mTitle ); |
4413 | 4413 | $ig->setShowBytes( false ); |
4414 | 4414 | $ig->setShowFilename( false ); |
4415 | | - $ig->setParsing(); |
| 4415 | + $ig->setParser( $this ); |
| 4416 | + $ig->setHideBadImages(); |
4416 | 4417 | $ig->setAttributes( Sanitizer::validateTagAttributes( $params, 'table' ) ); |
4417 | 4418 | $ig->useSkin( $this->mOptions->getSkin() ); |
4418 | 4419 | $ig->mRevisionId = $this->mRevisionId; |
Index: trunk/phase3/includes/ImageGallery.php |
— | — | @@ -20,11 +20,16 @@ |
21 | 21 | var $mRevisionId = 0; |
22 | 22 | |
23 | 23 | /** |
24 | | - * Is the gallery on a wiki page (i.e. not a special page) |
| 24 | + * Hide blacklisted images? |
25 | 25 | */ |
26 | | - var $mParsing; |
| 26 | + var $mHideBadImages; |
27 | 27 | |
28 | 28 | /** |
| 29 | + * Registered parser object for output callbacks |
| 30 | + */ |
| 31 | + var $mParser; |
| 32 | + |
| 33 | + /** |
29 | 34 | * Contextual title, used when images are being screened |
30 | 35 | * against the bad image list |
31 | 36 | */ |
— | — | @@ -42,17 +47,25 @@ |
43 | 48 | $this->mImages = array(); |
44 | 49 | $this->mShowBytes = true; |
45 | 50 | $this->mShowFilename = true; |
46 | | - $this->mParsing = false; |
| 51 | + $this->mParser = false; |
| 52 | + $this->mHideBadImages = false; |
47 | 53 | } |
48 | 54 | |
49 | 55 | /** |
50 | | - * Set the "parse" bit so we know to hide "bad" images |
| 56 | + * Register a parser object |
51 | 57 | */ |
52 | | - function setParsing( $val = true ) { |
53 | | - $this->mParsing = $val; |
| 58 | + function setParser( $parser ) { |
| 59 | + $this->mParser = $parser; |
54 | 60 | } |
55 | 61 | |
56 | 62 | /** |
| 63 | + * Set bad image flag |
| 64 | + */ |
| 65 | + function setHideBadImages( $flag = true ) { |
| 66 | + $this->mHideBadImages = $flag; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
57 | 70 | * Set the caption (as plain text) |
58 | 71 | * |
59 | 72 | * @param $caption Caption |
— | — | @@ -238,7 +251,7 @@ |
239 | 252 | # We're dealing with a non-image, spit out the name and be done with it. |
240 | 253 | $thumbhtml = "\n\t\t\t".'<div style="height: '.($this->mHeights*1.25+2).'px;">' |
241 | 254 | . htmlspecialchars( $nt->getText() ) . '</div>'; |
242 | | - } elseif( $this->mParsing && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) { |
| 255 | + } elseif( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) { |
243 | 256 | # The image is blacklisted, just show it as a text link. |
244 | 257 | $thumbhtml = "\n\t\t\t".'<div style="height: '.($this->mHeights*1.25+2).'px;">' |
245 | 258 | . $sk->makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) ) . '</div>'; |
— | — | @@ -248,8 +261,18 @@ |
249 | 262 | . htmlspecialchars( $img->getLastError() ) . '</div>'; |
250 | 263 | } else { |
251 | 264 | $vpad = floor( ( 1.25*$this->mHeights - $thumb->height ) /2 ) - 2; |
| 265 | + $linkAttribs = array( |
| 266 | + 'title' => $nt->getPrefixedText(), |
| 267 | + 'href' => $nt->getLocalURL(), |
| 268 | + ); |
| 269 | + |
252 | 270 | $thumbhtml = "\n\t\t\t".'<div class="thumb" style="padding: ' . $vpad . 'px 0; width: '.($this->mWidths+30).'px;">' |
253 | | - . $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '</div>'; |
| 271 | + . $thumb->toHtml( array(), $linkAttribs ) . '</div>'; |
| 272 | + |
| 273 | + // Call parser transform hook |
| 274 | + if ( $this->mParser && $img->getHandler() ) { |
| 275 | + $img->getHandler()->parserTransformHook( $this->mParser, $img ); |
| 276 | + } |
254 | 277 | } |
255 | 278 | |
256 | 279 | //TODO |