Index: trunk/phase3/tests/phpunit/includes/media/BitmapScalingTest.php |
— | — | @@ -3,13 +3,16 @@ |
4 | 4 | class BitmapScalingTest extends MediaWikiTestCase { |
5 | 5 | |
6 | 6 | function setUp() { |
7 | | - global $wgMaxImageArea; |
| 7 | + global $wgMaxImageArea, $wgCustomConvertCommand; |
8 | 8 | $this->oldMaxImageArea = $wgMaxImageArea; |
| 9 | + $this->oldCustomConvertCommand = $wgCustomConvertCommand; |
9 | 10 | $wgMaxImageArea = 1.25e7; // 3500x3500 |
| 11 | + $wgCustomConvertCommand = 'dummy'; // Set so that we don't get client side rendering |
10 | 12 | } |
11 | 13 | function tearDown() { |
12 | | - global $wgMaxImageArea; |
| 14 | + global $wgMaxImageArea, $wgCustomConvertCommand; |
13 | 15 | $wgMaxImageArea = $this->oldMaxImageArea; |
| 16 | + $wgCustomConvertCommand = $this->oldCustomConvertCommand; |
14 | 17 | } |
15 | 18 | /** |
16 | 19 | * @dataProvider provideNormaliseParams |
— | — | @@ -105,14 +108,16 @@ |
106 | 109 | $file = new FakeDimensionFile( array( 4000, 4000 ) ); |
107 | 110 | $handler = new BitmapHandler; |
108 | 111 | $params = array( 'width' => '3700' ); // Still bigger than max size. |
109 | | - $this->assertFalse( $handler->normaliseParams( $file, $params ) ); |
| 112 | + $this->assertEquals( 'TransformParameterError', |
| 113 | + get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) ); |
110 | 114 | } |
111 | 115 | function testTooBigMustRenderImage() { |
112 | 116 | $file = new FakeDimensionFile( array( 4000, 4000 ) ); |
113 | 117 | $file->mustRender = true; |
114 | 118 | $handler = new BitmapHandler; |
115 | 119 | $params = array( 'width' => '5000' ); // Still bigger than max size. |
116 | | - $this->assertFalse( $handler->normaliseParams( $file, $params ) ); |
| 120 | + $this->assertEquals( 'TransformParameterError', |
| 121 | + get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) ); |
117 | 122 | } |
118 | 123 | } |
119 | 124 | |
— | — | @@ -120,7 +125,8 @@ |
121 | 126 | public $mustRender = false; |
122 | 127 | |
123 | 128 | public function __construct( $dimensions ) { |
124 | | - parent::__construct( Title::makeTitle( NS_FILE, 'Test' ), null ); |
| 129 | + parent::__construct( Title::makeTitle( NS_FILE, 'Test' ), |
| 130 | + new NullRepo( null ) ); |
125 | 131 | |
126 | 132 | $this->dimensions = $dimensions; |
127 | 133 | } |
— | — | @@ -133,4 +139,7 @@ |
134 | 140 | public function mustRender() { |
135 | 141 | return $this->mustRender; |
136 | 142 | } |
| 143 | + public function getPath() { |
| 144 | + return ''; |
| 145 | + } |
137 | 146 | } |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -471,6 +471,7 @@ |
472 | 472 | 'LocalFileMoveBatch' => 'includes/filerepo/LocalFile.php', |
473 | 473 | 'LocalFileRestoreBatch' => 'includes/filerepo/LocalFile.php', |
474 | 474 | 'LocalRepo' => 'includes/filerepo/LocalRepo.php', |
| 475 | + 'NullRepo' => 'includes/filerepo/NullRepo.php', |
475 | 476 | 'OldLocalFile' => 'includes/filerepo/OldLocalFile.php', |
476 | 477 | 'RepoGroup' => 'includes/filerepo/RepoGroup.php', |
477 | 478 | 'UnregisteredLocalFile' => 'includes/filerepo/UnregisteredLocalFile.php', |
Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -287,6 +287,9 @@ |
288 | 288 | $width = $width_orig; |
289 | 289 | $height_orig = $this->displayImg->getHeight( $page ); |
290 | 290 | $height = $height_orig; |
| 291 | + $mustRender = $this->displayImg->getHandler() && |
| 292 | + $this->displayImg->getHandler()->mustRender( $this->displayImg ); |
| 293 | + $addFullResolutionLink = false; |
291 | 294 | |
292 | 295 | $longDesc = wfMsg( 'parentheses', $this->displayImg->getLongDesc() ); |
293 | 296 | |
— | — | @@ -312,14 +315,19 @@ |
313 | 316 | # Note that $height <= $maxHeight now, but might not be identical |
314 | 317 | # because of rounding. |
315 | 318 | } |
316 | | - $msgbig = wfMsgHtml( 'show-big-image' ); |
| 319 | + |
317 | 320 | $otherSizes = array(); |
318 | 321 | foreach ( $wgImageLimits as $size ) { |
319 | 322 | if ( $size[0] < $width_orig && $size[1] < $height_orig && |
320 | 323 | $size[0] != $width && $size[1] != $height ) { |
321 | 324 | $otherSizes[] = $this->makeSizeLink( $params, $size[0], $size[1] ); |
322 | | - } |
| 325 | + } |
323 | 326 | } |
| 327 | + if ( $mustRender ) { |
| 328 | + $otherSizes[] = $this->makeSizeLink( $params, $width_orig, $height_orig, 'show-big-image' ); |
| 329 | + } else { |
| 330 | + $addFullResolutionLink = true; |
| 331 | + } |
324 | 332 | $msgsmall = wfMessage( 'show-big-image-preview' )-> |
325 | 333 | rawParams( $this->makeSizeLink( $params, $width, $height ) )-> |
326 | 334 | parse() . ' ' . |
— | — | @@ -347,7 +355,7 @@ |
348 | 356 | if ( $thumbnail ) { |
349 | 357 | $options = array( |
350 | 358 | 'alt' => $this->displayImg->getTitle()->getPrefixedText(), |
351 | | - 'file-link' => true, |
| 359 | + 'file-link' => !$mustRender, |
352 | 360 | ); |
353 | 361 | $wgOut->addHTML( '<div class="fullImageLink" id="file">' . |
354 | 362 | $thumbnail->toHtml( $options ) . |
— | — | @@ -428,8 +436,8 @@ |
429 | 437 | if ( $showLink ) { |
430 | 438 | $filename = wfEscapeWikiText( $this->displayImg->getName() ); |
431 | 439 | $linktext = $filename; |
432 | | - if ( isset( $msgbig ) ) { |
433 | | - $linktext = wfEscapeWikiText( $msgbig ); |
| 440 | + if ( $addFullResolutionLink ) { |
| 441 | + $linktext = wfMsg( 'show-big-image' ); |
434 | 442 | } |
435 | 443 | $medialink = "[[Media:$filename|$linktext]]"; |
436 | 444 | |
— | — | @@ -484,7 +492,7 @@ |
485 | 493 | * @param int $width |
486 | 494 | * @param int $height |
487 | 495 | */ |
488 | | - private function makeSizeLink( $params, $width, $height ) { |
| 496 | + private function makeSizeLink( $params, $width, $height, $msg = 'show-big-image-size' ) { |
489 | 497 | $params['width'] = $width; |
490 | 498 | $params['height'] = $height; |
491 | 499 | $thumbnail = $this->displayImg->transform( $params ); |
— | — | @@ -492,7 +500,7 @@ |
493 | 501 | return Html::rawElement( 'a', array( |
494 | 502 | 'href' => $thumbnail->getUrl(), |
495 | 503 | 'class' => 'mw-thumbnail-link' |
496 | | - ), wfMessage( 'show-big-image-size' )->numParams( |
| 504 | + ), wfMessage( $msg )->numParams( |
497 | 505 | $thumbnail->getWidth(), $thumbnail->getHeight() |
498 | 506 | )->parse() ); |
499 | 507 | } else { |