r82423 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82422‎ | r82423 | r82424 >
Date:23:34, 18 February 2011
Author:reedy
Status:ok
Tags:
Comment:
Parameter documentation
Modified paths:
  • /trunk/phase3/includes/media/Bitmap.php (modified) (history)
  • /trunk/phase3/includes/media/Bitmap_ClientOnly.php (modified) (history)
  • /trunk/phase3/includes/media/DjVu.php (modified) (history)
  • /trunk/phase3/includes/media/GIF.php (modified) (history)
  • /trunk/phase3/includes/media/Generic.php (modified) (history)
  • /trunk/phase3/includes/media/MediaTransformOutput.php (modified) (history)
  • /trunk/phase3/includes/media/PNG.php (modified) (history)
  • /trunk/phase3/includes/media/SVG.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/Bitmap.php
@@ -12,6 +12,12 @@
1313 * @ingroup Media
1414 */
1515 class BitmapHandler extends ImageHandler {
 16+
 17+ /**
 18+ * @param $image File
 19+ * @param $params
 20+ * @return bool
 21+ */
1622 function normaliseParams( $image, &$params ) {
1723 global $wgMaxImageArea;
1824 if ( !parent::normaliseParams( $image, $params ) ) {
@@ -65,6 +71,14 @@
6672 return $width * $height;
6773 }
6874
 75+ /**
 76+ * @param $image File
 77+ * @param $dstPath
 78+ * @param $dstUrl
 79+ * @param $params
 80+ * @param int $flags
 81+ * @return MediaTransformError|ThumbnailImage|TransformParameterError
 82+ */
6983 function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
7084 if ( !$this->normaliseParams( $image, $params ) ) {
7185 return new TransformParameterError( $params );
@@ -614,6 +628,10 @@
615629 return $fields;
616630 }
617631
 632+ /**
 633+ * @param $image File
 634+ * @return array|bool
 635+ */
618636 function formatMetadata( $image ) {
619637 $result = array(
620638 'visible' => array(),
Index: trunk/phase3/includes/media/Bitmap_ClientOnly.php
@@ -15,10 +15,24 @@
1616 * @ingroup Media
1717 */
1818 class BitmapHandler_ClientOnly extends BitmapHandler {
 19+
 20+ /**
 21+ * @param $image File
 22+ * @param $params
 23+ * @return bool
 24+ */
1925 function normaliseParams( $image, &$params ) {
2026 return ImageHandler::normaliseParams( $image, $params );
2127 }
2228
 29+ /**
 30+ * @param $image File
 31+ * @param $dstPath
 32+ * @param $dstUrl
 33+ * @param $params
 34+ * @param int $flags
 35+ * @return ThumbnailImage|TransformParameterError
 36+ */
2337 function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
2438 if ( !$this->normaliseParams( $image, $params ) ) {
2539 return new TransformParameterError( $params );
Index: trunk/phase3/includes/media/Generic.php
@@ -187,6 +187,8 @@
188188 * Currently "width" and "height" are understood, but this might be
189189 * expanded in the future.
190190 * Returns false if unknown or if the document is not multi-page.
 191+ *
 192+ * @param $image File
191193 */
192194 function getPageDimensions( $image, $page ) {
193195 $gis = $this->getImageSize( $image, $image->getPath() );
@@ -250,6 +252,10 @@
251253 );
252254 }
253255
 256+ /**
 257+ * @param $file File
 258+ * @return string
 259+ */
254260 function getShortDesc( $file ) {
255261 global $wgLang;
256262 $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
@@ -257,6 +263,10 @@
258264 return "$nbytes";
259265 }
260266
 267+ /**
 268+ * @param $file File
 269+ * @return string
 270+ */
261271 function getLongDesc( $file ) {
262272 global $wgUser;
263273 $sk = $wgUser->getSkin();
@@ -264,7 +274,11 @@
265275 $sk->formatSize( $file->getSize() ),
266276 $file->getMimeType() );
267277 }
268 -
 278+
 279+ /**
 280+ * @param $file File
 281+ * @return string
 282+ */
269283 static function getGeneralShortDesc( $file ) {
270284 global $wgLang;
271285 $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
@@ -272,6 +286,10 @@
273287 return "$nbytes";
274288 }
275289
 290+ /**
 291+ * @param $file File
 292+ * @return string
 293+ */
276294 static function getGeneralLongDesc( $file ) {
277295 global $wgUser;
278296 $sk = $wgUser->getSkin();
@@ -332,12 +350,13 @@
333351 * @ingroup Media
334352 */
335353 abstract class ImageHandler extends MediaHandler {
 354+
 355+ /**
 356+ * @param $file File
 357+ * @return bool
 358+ */
336359 function canRender( $file ) {
337 - if ( $file->getWidth() && $file->getHeight() ) {
338 - return true;
339 - } else {
340 - return false;
341 - }
 360+ return ( $file->getWidth() && $file->getHeight() );
342361 }
343362
344363 function getParamMap() {
@@ -382,6 +401,11 @@
383402 return array( 'width' => $params['width'] );
384403 }
385404
 405+ /**
 406+ * @param $image File
 407+ * @param $params
 408+ * @return bool
 409+ */
386410 function normaliseParams( $image, &$params ) {
387411 $mimeType = $image->getMimeType();
388412
@@ -449,6 +473,12 @@
450474 return true;
451475 }
452476
 477+ /**
 478+ * @param $image File
 479+ * @param $script
 480+ * @param $params
 481+ * @return bool|ThumbnailImage
 482+ */
453483 function getScriptedTransform( $image, $script, $params ) {
454484 if ( !$this->normaliseParams( $image, $params ) ) {
455485 return false;
@@ -472,6 +502,10 @@
473503 return false;
474504 }
475505
 506+ /**
 507+ * @param $file File
 508+ * @return string
 509+ */
476510 function getShortDesc( $file ) {
477511 global $wgLang;
478512 $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
@@ -481,6 +515,10 @@
482516 return "$widthheight ($nbytes)";
483517 }
484518
 519+ /**
 520+ * @param $file File
 521+ * @return string
 522+ */
485523 function getLongDesc( $file ) {
486524 global $wgLang;
487525 return wfMsgExt('file-info-size', 'parseinline',
@@ -490,6 +528,10 @@
491529 $file->getMimeType() );
492530 }
493531
 532+ /**
 533+ * @param $file File
 534+ * @return string
 535+ */
494536 function getDimensionsString( $file ) {
495537 global $wgLang;
496538 $pages = $file->pageCount();
Index: trunk/phase3/includes/media/MediaTransformOutput.php
@@ -12,8 +12,13 @@
1313 * @ingroup Media
1414 */
1515 abstract class MediaTransformOutput {
16 - var $file, $width, $height, $url, $page, $path;
 16+ /**
 17+ * @var File
 18+ */
 19+ var $file;
1720
 21+ var $width, $height, $url, $page, $path;
 22+
1823 /**
1924 * Get the width of the output box
2025 */
Index: trunk/phase3/includes/media/SVG.php
@@ -32,6 +32,10 @@
3333 return true;
3434 }
3535
 36+ /**
 37+ * @param $file File
 38+ * @return bool
 39+ */
3640 function isAnimatedImage( $file ) {
3741 # TODO: detect animated SVGs
3842 $metadata = $file->getMetadata();
@@ -44,6 +48,11 @@
4549 return false;
4650 }
4751
 52+ /**
 53+ * @param $image File
 54+ * @param $params
 55+ * @return bool
 56+ */
4857 function normaliseParams( $image, &$params ) {
4958 global $wgSVGMaxSize;
5059 if ( !parent::normaliseParams( $image, $params ) ) {
@@ -61,6 +70,14 @@
6271 return true;
6372 }
6473
 74+ /**
 75+ * @param $image File
 76+ * @param $dstPath
 77+ * @param $dstUrl
 78+ * @param $params
 79+ * @param int $flags
 80+ * @return bool|MediaTransformError|ThumbnailImage|TransformParameterError
 81+ */
6582 function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
6683 if ( !$this->normaliseParams( $image, $params ) ) {
6784 return new TransformParameterError( $params );
@@ -125,6 +142,12 @@
126143 return true;
127144 }
128145
 146+ /**
 147+ * @param $file File
 148+ * @param $path
 149+ * @param bool $metadata
 150+ * @return array
 151+ */
129152 function getImageSize( $file, $path, $metadata = false ) {
130153 if ( $metadata === false ) {
131154 $metadata = $file->getMetaData();
@@ -141,6 +164,10 @@
142165 return array( 'png', 'image/png' );
143166 }
144167
 168+ /**
 169+ * @param $file File
 170+ * @return string
 171+ */
145172 function getLongDesc( $file ) {
146173 global $wgLang;
147174 return wfMsgExt( 'svg-long-desc', 'parseinline',
@@ -183,6 +210,10 @@
184211 return $fields;
185212 }
186213
 214+ /**
 215+ * @param $file File
 216+ * @return array|bool
 217+ */
187218 function formatMetadata( $file ) {
188219 $result = array(
189220 'visible' => array(),
Index: trunk/phase3/includes/media/PNG.php
@@ -31,7 +31,11 @@
3232 function formatMetadata( $image ) {
3333 return false;
3434 }
35 -
 35+
 36+ /**
 37+ * @param $image File
 38+ * @return bool
 39+ */
3640 function isAnimatedImage( $image ) {
3741 $ser = $image->getMetadata();
3842 if ($ser) {
@@ -51,6 +55,11 @@
5256 wfRestoreWarnings();
5357 return (boolean) $data;
5458 }
 59+
 60+ /**
 61+ * @param $image File
 62+ * @return string
 63+ */
5564 function getLongDesc( $image ) {
5665 global $wgLang;
5766 $original = parent::getLongDesc( $image );
Index: trunk/phase3/includes/media/GIF.php
@@ -31,7 +31,13 @@
3232 function formatMetadata( $image ) {
3333 return false;
3434 }
35 -
 35+
 36+ /**
 37+ * @param $image File
 38+ * @param $width
 39+ * @param $height
 40+ * @return
 41+ */
3642 function getImageArea( $image, $width, $height ) {
3743 $ser = $image->getMetadata();
3844 if ($ser) {
@@ -42,6 +48,10 @@
4349 }
4450 }
4551
 52+ /**
 53+ * @param $image File
 54+ * @return bool
 55+ */
4656 function isAnimatedImage( $image ) {
4757 $ser = $image->getMetadata();
4858 if ($ser) {
@@ -62,6 +72,10 @@
6373 return (boolean) $data;
6474 }
6575
 76+ /**
 77+ * @param $image File
 78+ * @return string
 79+ */
6680 function getLongDesc( $image ) {
6781 global $wgLang;
6882
Index: trunk/phase3/includes/media/DjVu.php
@@ -68,6 +68,14 @@
6969 );
7070 }
7171
 72+ /**
 73+ * @param $image File
 74+ * @param $dstPath
 75+ * @param $dstUrl
 76+ * @param $params
 77+ * @param int $flags
 78+ * @return MediaTransformError|ThumbnailImage|TransformParameterError
 79+ */
7280 function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
7381 global $wgDjvuRenderer, $wgDjvuPostProcessor;
7482
@@ -139,6 +147,7 @@
140148
141149 /**
142150 * Cache a document tree for the DjVu XML metadata
 151+ * @param $image File
143152 */
144153 function getMetaTree( $image , $gettext = false ) {
145154 if ( isset( $image->dejaMetaTree ) ) {

Status & tagging log