Convert core to use new ThumbnailImage() constructor
authorjarry1250 <jarry1250@gmail.com>
Sat, 1 Sep 2012 16:12:48 +0000 (17:12 +0100)
committerjarry1250 <jarry1250@gmail.com>
Sat, 1 Sep 2012 16:12:48 +0000 (17:12 +0100)
See change #21321 for the introduction of that new constructor
and the reasoning behind it.

Change-Id: I15843fab4217333077e16ae187e7c09f76d47e58

includes/filerepo/file/File.php
includes/media/Bitmap.php
includes/media/Bitmap_ClientOnly.php
includes/media/DjVu.php
includes/media/ImageHandler.php
includes/media/SVG.php

index 4cc47f0..3d1e270 100644 (file)
@@ -1000,7 +1000,8 @@ abstract class File {
                        $path = '/common/images/icons/' . $icon;
                        $filepath = $wgStyleDirectory . $path;
                        if ( file_exists( $filepath ) ) { // always FS
-                               return new ThumbnailImage( $this, $wgStylePath . $path, 120, 120 );
+                               $params = array( 'width' => 120, 'height' => 120 );
+                               return new ThumbnailImage( $this, $wgStylePath . $path, false, $params );
                        }
                }
                return null;
index 8a4b943..99ac854 100644 (file)
@@ -167,8 +167,11 @@ class BitmapHandler extends ImageHandler {
 
                if ( $flags & self::TRANSFORM_LATER ) {
                        wfDebug( __METHOD__ . ": Transforming later per flags.\n" );
-                       return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'],
-                               $scalerParams['clientHeight'], false );
+                       $params = array(
+                               'width' => $scalerParams['clientWidth'],
+                               'height' => $scalerParams['clientHeight']
+                       );
+                       return new ThumbnailImage( $image, $dstUrl, false, $params );
                }
 
                # Try to make a target path for the thumbnail
@@ -220,8 +223,11 @@ class BitmapHandler extends ImageHandler {
                } elseif ( $mto ) {
                        return $mto;
                } else {
-                       return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'],
-                               $scalerParams['clientHeight'], $dstPath );
+                       $params = array(
+                               'width' => $scalerParams['clientWidth'],
+                               'height' => $scalerParams['clientHeight']
+                       );
+                       return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
                }
        }
 
@@ -258,14 +264,17 @@ class BitmapHandler extends ImageHandler {
         * client side
         *
         * @param $image File File associated with this thumbnail
-        * @param $params array Array with scaler params
+        * @param $scalerParams array Array with scaler params
         * @return ThumbnailImage
         *
         * @todo fixme: no rotation support
         */
-       protected function getClientScalingThumbnailImage( $image, $params ) {
-               return new ThumbnailImage( $image, $image->getURL(),
-                       $params['clientWidth'], $params['clientHeight'], null );
+       protected function getClientScalingThumbnailImage( $image, $scalerParams ) {
+               $params = array(
+                       'width' => $scalerParams['clientWidth'],
+                       'height' => $scalerParams['clientHeight']
+               );
+               return new ThumbnailImage( $image, $image->getURL(), null, $params );
        }
 
        /**
index 8cb5138..63af255 100644 (file)
@@ -52,7 +52,6 @@ class BitmapHandler_ClientOnly extends BitmapHandler {
                if ( !$this->normaliseParams( $image, $params ) ) {
                        return new TransformParameterError( $params );
                }
-               return new ThumbnailImage( $image, $image->getURL(), $params['width'], 
-                       $params['height'], $image->getLocalRefPath() );
+               return new ThumbnailImage( $image, $image->getURL(), $image->getLocalRefPath(), $params );
        }
 }
index ea4888a..84672e0 100644 (file)
@@ -157,7 +157,12 @@ class DjVuHandler extends ImageHandler {
                }
 
                if ( $flags & self::TRANSFORM_LATER ) {
-                       return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page );
+                       $params = array(
+                               'width' => $width,
+                               'height' => $height,
+                               'page' => $page
+                       );
+                       return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
                }
 
                if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
@@ -192,7 +197,12 @@ class DjVuHandler extends ImageHandler {
                                        wfHostname(), $retval, trim($err), $cmd ) );
                        return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
                } else {
-                       return new ThumbnailImage( $image, $dstUrl, $width, $height, $dstPath, $page );
+                       $params = array(
+                               'width' => $width,
+                               'height' => $height,
+                               'page' => $page
+                       );
+                       return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
                }
        }
 
index 65757c9..6175907 100644 (file)
@@ -189,11 +189,9 @@ abstract class ImageHandler extends MediaHandler {
                        return false;
                }
                $url = $script . '&' . wfArrayToCGI( $this->getScriptParams( $params ) );
-               $page = isset( $params['page'] ) ? $params['page'] : false;
 
                if( $image->mustRender() || $params['width'] < $image->getWidth() ) {
-                       return new ThumbnailImage( $image,
-                               $url, $params['width'], $params['height'], false, $page );
+                       return new ThumbnailImage( $image, $url, false, $params );
                }
        }
 
index a9d1758..55fa554 100644 (file)
@@ -117,7 +117,7 @@ class SvgHandler extends ImageHandler {
                $physicalHeight = $params['physicalHeight'];
 
                if ( $flags & self::TRANSFORM_LATER ) {
-                       return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
+                       return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
                }
 
                if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
@@ -128,7 +128,7 @@ class SvgHandler extends ImageHandler {
                $srcPath = $image->getLocalRefPath();
                $status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight );
                if( $status === true ) {
-                       return new ThumbnailImage( $image, $dstUrl, $clientWidth, $clientHeight, $dstPath );
+                       return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
                } else {
                        return $status; // MediaTransformError
                }