Making demon happy (adding public/protected to function definitions) and add some...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Mon, 10 Aug 2009 21:16:33 +0000 (21:16 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Mon, 10 Aug 2009 21:16:33 +0000 (21:16 +0000)
includes/media/Bitmap.php

index b3a0c8a..e573e23 100644 (file)
@@ -8,20 +8,31 @@
  * @ingroup Media
  */
 class BitmapHandler extends ImageHandler {
-       function getParamMap() {
+       /**
+        * Override parent method to add crop to param map.
+        */
+       public function getParamMap() {
                return array(
                        'img_width'     => 'width',
                        'img_crop' => 'crop',
                );
        }
-       function validateParam( $name, $value ) {
+       
+       /**
+        * Override param map to validate the crop param.
+        */
+       public function validateParam( $name, $value ) {
                if ( $name == 'crop' ) {
                        return $this->splitCropParam( $value ) !== false;
                } else {
                        return parent::validateParam( $name, $value );
                }               
        }
-       function splitCropParam( $value ) {
+       /**
+        * Split the crop param into up to 4 parts and convert them to integers.
+        * Returns false in case of malformed param.
+        */
+       protected function splitCropParam( $value ) {
                $parts = explode( 'x', $value );
                if ( count( $parts ) > 4 )
                        return false;
@@ -38,7 +49,11 @@ class BitmapHandler extends ImageHandler {
                return $parts;
        }
        
-       function parseParamString( $str ) {
+       /**
+        * Override parent method to check for optional crop parameter in param 
+        * string.
+        */
+       public function parseParamString( $str ) {
                $res = parent::parseParamString( $str );
                if ( $res === false ) {
                        $m = false;
@@ -49,15 +64,19 @@ class BitmapHandler extends ImageHandler {
                        }
                }
        }
-       function makeParamString( $params ) { 
+       /**
+        * Add the crop parameter the string generated by the parent.
+        */
+       public function makeParamString( $params ) { 
                $res = parent::makeParamString( $params );
                if ( !empty( $params['crop'] ) )
                        $res .= '-'.implode( 'x', $params['crop'] ).'crop';
                return $res;
        }
        
-       function normaliseParams( $image, &$params ) {
+       public function normaliseParams( $image, &$params ) {
                global $wgMaxImageArea;
+               # Parent fills in width, height and page and normalizes them.
                if ( !parent::normaliseParams( $image, $params ) ) {
                        return false;
                }
@@ -115,7 +134,6 @@ class BitmapHandler extends ImageHandler {
                        }
                        else
                        {
-                               header("X-Size: {$targetWidth}x{$targetHeight}");
                                $params['crop'] = $cropParams;
                                $params['height'] = $params['physicalHeight'] = File::scaleHeight( 
                                                $targetWidth, $targetHeight, $params['width'] );
@@ -128,13 +146,15 @@ class BitmapHandler extends ImageHandler {
        }
        
        
-       // Function that returns the number of pixels to be thumbnailed.
-       // Intended for animated GIFs to multiply by the number of frames.
-       function getImageArea( $image, $width, $height ) {
+       /**
+        * Function that returns the number of pixels to be thumbnailed.
+        * Intended for animated GIFs to multiply by the number of frames.
+        */
+       protected function getImageArea( $image, $width, $height ) {
                return $width * $height;
        }
 
-       function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
+       public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
                global $wgUseImageMagick, $wgImageMagickConvertCommand, $wgImageMagickTempDir;
                global $wgCustomConvertCommand, $wgUseImageResize;
                global $wgSharpenParameter, $wgSharpenReductionThreshold;
@@ -341,13 +361,13 @@ class BitmapHandler extends ImageHandler {
                }
        }
 
-       static function imageJpegWrapper( $dst_image, $thumbPath ) {
+       public static function imageJpegWrapper( $dst_image, $thumbPath ) {
                imageinterlace( $dst_image );
                imagejpeg( $dst_image, $thumbPath, 95 );
        }
 
 
-       function getMetadata( $image, $filename ) {
+       public function getMetadata( $image, $filename ) {
                global $wgShowEXIF;
                if( $wgShowEXIF && file_exists( $filename ) ) {
                        $exif = new Exif( $filename );
@@ -363,11 +383,11 @@ class BitmapHandler extends ImageHandler {
                }
        }
 
-       function getMetadataType( $image ) {
+       public function getMetadataType( $image ) {
                return 'exif';
        }
 
-       function isMetadataValid( $image, $metadata ) {
+       public function isMetadataValid( $image, $metadata ) {
                global $wgShowEXIF;
                if ( !$wgShowEXIF ) {
                        # Metadata disabled and so an empty field is expected
@@ -395,7 +415,7 @@ class BitmapHandler extends ImageHandler {
         * @return array of strings
         * @access private
         */
-       function visibleMetadataFields() {
+       public function visibleMetadataFields() {
                $fields = array();
                $lines = explode( "\n", wfMsgForContent( 'metadata-fields' ) );
                foreach( $lines as $line ) {
@@ -408,7 +428,7 @@ class BitmapHandler extends ImageHandler {
                return $fields;
        }
 
-       function formatMetadata( $image ) {
+       public function formatMetadata( $image ) {
                $result = array(
                        'visible' => array(),
                        'collapsed' => array()