Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -550,13 +550,6 @@ |
551 | 551 | Change $bad and return false to override. If an image is "bad", it is not |
552 | 552 | rendered inline in wiki pages or galleries in category pages. |
553 | 553 | |
554 | | -'BeforeGalleryFindFile': before an image is fetched for a gallery |
555 | | -&$gallery,: the gallery object |
556 | | -&$nt: the image title |
557 | | -&$time: image timestamp (used to specify the file) |
558 | | -&$descQuery: query string to add to thumbnail URL |
559 | | -&$sha1: image base 36 sha1 (used to specify the file, $nt will be ignored if this is set) |
560 | | - |
561 | 554 | 'BeforeInitialize': before anything is initialized in performRequestForTitle() |
562 | 555 | &$title: Title being used for request |
563 | 556 | &$article: The associated Article object |
— | — | @@ -569,20 +562,19 @@ |
570 | 563 | &$out: OutputPage object |
571 | 564 | &$skin: Skin object |
572 | 565 | |
| 566 | +'BeforeParserFetchFileAndTitle': before an image is rendered by Parser |
| 567 | +&$parser: Parser object |
| 568 | +&$nt: the image title |
| 569 | +&$time: the image timestamp (use '0' to force a broken thumbnail) |
| 570 | +&$sha1: image base 36 sha1 (used to specify the file, $nt will be ignored if this is set) |
| 571 | +&$descQuery: query string to add to thumbnail URL |
| 572 | + |
573 | 573 | 'BeforeParserFetchTemplateAndtitle': before a template is fetched by Parser |
574 | 574 | &$parser: Parser object |
575 | 575 | &$title: title of the template |
576 | 576 | &$skip: skip this template and link it? |
577 | 577 | &$id: the id of the revision being parsed |
578 | 578 | |
579 | | -'BeforeParserMakeImageLinkObj': before an image is rendered by Parser |
580 | | -&$parser: Parser object |
581 | | -&$nt: the image title |
582 | | -&$skip: skip this image and link it? |
583 | | -&$time: the image timestamp |
584 | | -&$descQuery: query string to add to thumbnail URL |
585 | | -&$sha1: image base 36 sha1 (used to specify the file, $nt will be ignored if this is set) |
586 | | - |
587 | 579 | 'BeforeParserrenderImageGallery': before an image gallery is rendered by Parser |
588 | 580 | &$parser: Parser object |
589 | 581 | &$ig: ImageGallery object |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -1909,19 +1909,14 @@ |
1910 | 1910 | if ( $ns == NS_MEDIA ) { |
1911 | 1911 | wfProfileIn( __METHOD__."-media" ); |
1912 | 1912 | # Give extensions a chance to select the file revision for us |
1913 | | - $skip = $time = $sha1 = $descQuery = false; |
1914 | | - wfRunHooks( 'BeforeParserMakeImageLinkObj', |
1915 | | - array( &$this, &$nt, &$skip, &$time, &$descQuery, &$sha1 ) ); |
1916 | | - if ( $skip ) { |
1917 | | - $this->mOutput->addImage( $nt->getDBkey(), null, null ); // register |
1918 | | - $link = $sk->link( $nt ); |
1919 | | - } else { |
1920 | | - # Fetch and register the file (file title may be different via hooks) |
1921 | | - list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $time, $sha1 ); |
1922 | | - $link = $sk->makeMediaLinkFile( $nt, $file, $text ); |
1923 | | - } |
| 1913 | + $time = $sha1 = $descQuery = false; |
| 1914 | + wfRunHooks( 'BeforeParserFetchFileAndTitle', |
| 1915 | + array( &$this, &$nt, &$time, &$sha1, &$descQuery ) ); |
| 1916 | + # Fetch and register the file (file title may be different via hooks) |
| 1917 | + list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $time, $sha1 ); |
1924 | 1918 | # Cloak with NOPARSE to avoid replacement in replaceExternalLinks |
1925 | | - $s .= $prefix . $this->armorLinks( $link ) . $trail; |
| 1919 | + $s .= $prefix . $this->armorLinks( |
| 1920 | + $sk->makeMediaLinkFile( $nt, $file, $text ) ) . $trail; |
1926 | 1921 | wfProfileOut( __METHOD__."-media" ); |
1927 | 1922 | continue; |
1928 | 1923 | } |
— | — | @@ -4702,15 +4697,12 @@ |
4703 | 4698 | $sk = $this->mOptions->getSkin( $this->mTitle ); |
4704 | 4699 | |
4705 | 4700 | # Give extensions a chance to select the file revision for us |
4706 | | - $skip = $time = $sha1 = $descQuery = false; |
4707 | | - wfRunHooks( 'BeforeParserMakeImageLinkObj', |
4708 | | - array( &$this, &$title, &$skip, &$time, &$descQuery, &$sha1 ) ); |
4709 | | - if ( $skip ) { |
4710 | | - $this->mOutput->addImage( $title->getDBkey(), null, null ); // register |
4711 | | - return $sk->link( $title ); |
4712 | | - } |
| 4701 | + $time = $sha1 = $descQuery = false; |
| 4702 | + wfRunHooks( 'BeforeParserFetchFileAndTitle', |
| 4703 | + array( &$this, &$title, &$time, &$sha1, &$descQuery ) ); |
4713 | 4704 | # Fetch and register the file (file title may be different via hooks) |
4714 | 4705 | list( $file, $title ) = $this->fetchFileAndTitle( $title, $time, $sha1 ); |
| 4706 | + |
4715 | 4707 | # Get parameter map |
4716 | 4708 | $handler = $file ? $file->getHandler() : false; |
4717 | 4709 | |
Index: trunk/phase3/includes/ImageGallery.php |
— | — | @@ -239,9 +239,8 @@ |
240 | 240 | } |
241 | 241 | |
242 | 242 | $attribs = Sanitizer::mergeAttributes( |
243 | | - array( |
244 | | - 'class' => 'gallery'), |
245 | | - $this->mAttribs ); |
| 243 | + array( 'class' => 'gallery' ), $this->mAttribs ); |
| 244 | + |
246 | 245 | $s = Xml::openElement( 'ul', $attribs ); |
247 | 246 | if ( $this->mCaption ) { |
248 | 247 | $s .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>"; |
— | — | @@ -253,24 +252,18 @@ |
254 | 253 | $nt = $pair[0]; |
255 | 254 | $text = $pair[1]; # "text" means "caption" here |
256 | 255 | |
| 256 | + $descQuery = false; |
257 | 257 | if ( $nt->getNamespace() == NS_FILE ) { |
258 | | - # Give extensions a chance to select the file revision for us |
259 | | - $time = $sha1 = $descQuery = false; |
260 | | - wfRunHooks( 'BeforeGalleryFindFile', |
261 | | - array( &$this, &$nt, &$time, &$descQuery, &$sha1 ) ); |
262 | 258 | # Get the file... |
263 | 259 | if ( $this->mParser instanceof Parser ) { |
| 260 | + # Give extensions a chance to select the file revision for us |
| 261 | + $time = $sha1 = false; |
| 262 | + wfRunHooks( 'BeforeParserFetchFileAndTitle', |
| 263 | + array( &$this->mParser, &$nt, &$time, &$sha1, &$descQuery ) ); |
264 | 264 | # Fetch and register the file (file title may be different via hooks) |
265 | 265 | list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $time, $sha1 ); |
266 | 266 | } else { |
267 | | - if ( $time === '0' ) { |
268 | | - $img = false; // broken thumbnail forced by hook |
269 | | - } elseif ( $sha1 ) { // get by (sha1,timestamp) |
270 | | - $img = RepoGroup::singleton()->findFileFromKey( |
271 | | - $sha1, array( 'time' => $time ) ); |
272 | | - } else { // get by (name,timestamp) |
273 | | - $img = wfFindFile( $nt, array( 'time' => $time ) ); |
274 | | - } |
| 267 | + $img = wfFindFile( $nt ); |
275 | 268 | } |
276 | 269 | } else { |
277 | 270 | $img = false; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -436,8 +436,7 @@ |
437 | 437 | # Parser hooks, selects the desired images/templates |
438 | 438 | $wgHooks['ParserClearState'][] = 'FlaggedRevsHooks::parserAddFields'; |
439 | 439 | $wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'FlaggedRevsHooks::parserFetchStableTemplate'; |
440 | | -$wgHooks['BeforeParserMakeImageLinkObj'][] = 'FlaggedRevsHooks::parserFetchStableFile'; |
441 | | -$wgHooks['BeforeGalleryFindFile'][] = 'FlaggedRevsHooks::galleryFetchStableFile'; |
| 440 | +$wgHooks['BeforeParserFetchFileAndTitle'][] = 'FlaggedRevsHooks::parserFetchStableFile'; |
442 | 441 | # ######## |
443 | 442 | |
444 | 443 | # ######## DB write operations ######### |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -329,12 +329,9 @@ |
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
333 | | - * (a) Select the desired images based on the selected stable version time/SHA-1 |
334 | | - * (b) Set specified versions in mImageTimeKeys |
| 333 | + * Select the desired images based on the selected stable version time/SHA-1 |
335 | 334 | */ |
336 | | - public static function parserFetchStableFile( |
337 | | - $parser, Title $nt, &$skip, &$time, &$query, &$sha1 |
338 | | - ) { |
| 335 | + public static function parserFetchStableFile( $parser, Title $nt, &$time, &$sha1, &$query ) { |
339 | 336 | if ( !( $parser instanceof Parser ) ) { |
340 | 337 | return true; // nothing to do |
341 | 338 | } |
— | — | @@ -359,31 +356,8 @@ |
360 | 357 | } |
361 | 358 | |
362 | 359 | /** |
363 | | - * (a) Select the desired images based on the selected stable version time/SHA-1 |
364 | | - * (b) Set specified versions in mImageTimeKeys |
| 360 | + * Select the desired images based on the selected stable version time/SHA-1 |
365 | 361 | */ |
366 | | - public static function galleryFetchStableFile( $ig, Title $nt, &$time, &$query, &$sha1 ) { |
367 | | - $parser =& $ig->mParser; // convenience |
368 | | - if ( !( $parser instanceof Parser ) || $nt->getNamespace() != NS_FILE ) { |
369 | | - return true; // nothing to do |
370 | | - } |
371 | | - if ( !FRInclusionManager::singleton()->parserOutputIsStabilized() ) { |
372 | | - return true; // trigger for stable version parsing only |
373 | | - } |
374 | | - # Get version, update mImageTimeKeys... |
375 | | - list( $time, $sha1 ) = self::parserFindStableFile( $parser, $nt ); |
376 | | - # Stabilize the file link |
377 | | - if ( $time ) { |
378 | | - if ( $query != '' ) $query .= '&'; |
379 | | - $query = "filetimestamp=" . urlencode( wfTimestamp( TS_MW, $time ) ); |
380 | | - } |
381 | | - return true; |
382 | | - } |
383 | | - |
384 | | - /** |
385 | | - * (a) Select the desired images based on the selected stable version time/SHA-1 |
386 | | - * (b) Set specified versions in mImageTimeKeys |
387 | | - */ |
388 | 362 | protected static function parserFindStableFile( Parser $parser, Title $title ) { |
389 | 363 | $time = false; // current version |
390 | 364 | $sha1 = false; // corresponds to $time |