r54748 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54747‎ | r54748 | r54749 >
Date:21:16, 10 August 2009
Author:btongminh
Status:reverted
Tags:
Comment:
Making demon happy (adding public/protected to function definitions) and add some comments along the way.
Modified paths:
  • /trunk/phase3/includes/media/Bitmap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/Bitmap.php
@@ -8,20 +8,31 @@
99 * @ingroup Media
1010 */
1111 class BitmapHandler extends ImageHandler {
12 - function getParamMap() {
 12+ /**
 13+ * Override parent method to add crop to param map.
 14+ */
 15+ public function getParamMap() {
1316 return array(
1417 'img_width' => 'width',
1518 'img_crop' => 'crop',
1619 );
1720 }
18 - function validateParam( $name, $value ) {
 21+
 22+ /**
 23+ * Override param map to validate the crop param.
 24+ */
 25+ public function validateParam( $name, $value ) {
1926 if ( $name == 'crop' ) {
2027 return $this->splitCropParam( $value ) !== false;
2128 } else {
2229 return parent::validateParam( $name, $value );
2330 }
2431 }
25 - function splitCropParam( $value ) {
 32+ /**
 33+ * Split the crop param into up to 4 parts and convert them to integers.
 34+ * Returns false in case of malformed param.
 35+ */
 36+ protected function splitCropParam( $value ) {
2637 $parts = explode( 'x', $value );
2738 if ( count( $parts ) > 4 )
2839 return false;
@@ -38,7 +49,11 @@
3950 return $parts;
4051 }
4152
42 - function parseParamString( $str ) {
 53+ /**
 54+ * Override parent method to check for optional crop parameter in param
 55+ * string.
 56+ */
 57+ public function parseParamString( $str ) {
4358 $res = parent::parseParamString( $str );
4459 if ( $res === false ) {
4560 $m = false;
@@ -49,15 +64,19 @@
5065 }
5166 }
5267 }
53 - function makeParamString( $params ) {
 68+ /**
 69+ * Add the crop parameter the string generated by the parent.
 70+ */
 71+ public function makeParamString( $params ) {
5472 $res = parent::makeParamString( $params );
5573 if ( !empty( $params['crop'] ) )
5674 $res .= '-'.implode( 'x', $params['crop'] ).'crop';
5775 return $res;
5876 }
5977
60 - function normaliseParams( $image, &$params ) {
 78+ public function normaliseParams( $image, &$params ) {
6179 global $wgMaxImageArea;
 80+ # Parent fills in width, height and page and normalizes them.
6281 if ( !parent::normaliseParams( $image, $params ) ) {
6382 return false;
6483 }
@@ -115,7 +134,6 @@
116135 }
117136 else
118137 {
119 - header("X-Size: {$targetWidth}x{$targetHeight}");
120138 $params['crop'] = $cropParams;
121139 $params['height'] = $params['physicalHeight'] = File::scaleHeight(
122140 $targetWidth, $targetHeight, $params['width'] );
@@ -128,13 +146,15 @@
129147 }
130148
131149
132 - // Function that returns the number of pixels to be thumbnailed.
133 - // Intended for animated GIFs to multiply by the number of frames.
134 - function getImageArea( $image, $width, $height ) {
 150+ /**
 151+ * Function that returns the number of pixels to be thumbnailed.
 152+ * Intended for animated GIFs to multiply by the number of frames.
 153+ */
 154+ protected function getImageArea( $image, $width, $height ) {
135155 return $width * $height;
136156 }
137157
138 - function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
 158+ public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
139159 global $wgUseImageMagick, $wgImageMagickConvertCommand, $wgImageMagickTempDir;
140160 global $wgCustomConvertCommand, $wgUseImageResize;
141161 global $wgSharpenParameter, $wgSharpenReductionThreshold;
@@ -341,13 +361,13 @@
342362 }
343363 }
344364
345 - static function imageJpegWrapper( $dst_image, $thumbPath ) {
 365+ public static function imageJpegWrapper( $dst_image, $thumbPath ) {
346366 imageinterlace( $dst_image );
347367 imagejpeg( $dst_image, $thumbPath, 95 );
348368 }
349369
350370
351 - function getMetadata( $image, $filename ) {
 371+ public function getMetadata( $image, $filename ) {
352372 global $wgShowEXIF;
353373 if( $wgShowEXIF && file_exists( $filename ) ) {
354374 $exif = new Exif( $filename );
@@ -363,11 +383,11 @@
364384 }
365385 }
366386
367 - function getMetadataType( $image ) {
 387+ public function getMetadataType( $image ) {
368388 return 'exif';
369389 }
370390
371 - function isMetadataValid( $image, $metadata ) {
 391+ public function isMetadataValid( $image, $metadata ) {
372392 global $wgShowEXIF;
373393 if ( !$wgShowEXIF ) {
374394 # Metadata disabled and so an empty field is expected
@@ -395,7 +415,7 @@
396416 * @return array of strings
397417 * @access private
398418 */
399 - function visibleMetadataFields() {
 419+ public function visibleMetadataFields() {
400420 $fields = array();
401421 $lines = explode( "\n", wfMsgForContent( 'metadata-fields' ) );
402422 foreach( $lines as $line ) {
@@ -408,7 +428,7 @@
409429 return $fields;
410430 }
411431
412 - function formatMetadata( $image ) {
 432+ public function formatMetadata( $image ) {
413433 $result = array(
414434 'visible' => array(),
415435 'collapsed' => array()

Follow-up revisions

RevisionCommit summaryAuthorDate
r55302Revert image crop for now:...brion02:07, 19 August 2009

Status & tagging log