Index: trunk/phase3/includes/media/Bitmap.php |
— | — | @@ -12,6 +12,12 @@ |
13 | 13 | * @ingroup Media |
14 | 14 | */ |
15 | 15 | class BitmapHandler extends ImageHandler { |
| 16 | + |
| 17 | + /** |
| 18 | + * @param $image File |
| 19 | + * @param $params |
| 20 | + * @return bool |
| 21 | + */ |
16 | 22 | function normaliseParams( $image, &$params ) { |
17 | 23 | global $wgMaxImageArea; |
18 | 24 | if ( !parent::normaliseParams( $image, $params ) ) { |
— | — | @@ -65,6 +71,14 @@ |
66 | 72 | return $width * $height; |
67 | 73 | } |
68 | 74 | |
| 75 | + /** |
| 76 | + * @param $image File |
| 77 | + * @param $dstPath |
| 78 | + * @param $dstUrl |
| 79 | + * @param $params |
| 80 | + * @param int $flags |
| 81 | + * @return MediaTransformError|ThumbnailImage|TransformParameterError |
| 82 | + */ |
69 | 83 | function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
70 | 84 | if ( !$this->normaliseParams( $image, $params ) ) { |
71 | 85 | return new TransformParameterError( $params ); |
— | — | @@ -614,6 +628,10 @@ |
615 | 629 | return $fields; |
616 | 630 | } |
617 | 631 | |
| 632 | + /** |
| 633 | + * @param $image File |
| 634 | + * @return array|bool |
| 635 | + */ |
618 | 636 | function formatMetadata( $image ) { |
619 | 637 | $result = array( |
620 | 638 | 'visible' => array(), |
Index: trunk/phase3/includes/media/Bitmap_ClientOnly.php |
— | — | @@ -15,10 +15,24 @@ |
16 | 16 | * @ingroup Media |
17 | 17 | */ |
18 | 18 | class BitmapHandler_ClientOnly extends BitmapHandler { |
| 19 | + |
| 20 | + /** |
| 21 | + * @param $image File |
| 22 | + * @param $params |
| 23 | + * @return bool |
| 24 | + */ |
19 | 25 | function normaliseParams( $image, &$params ) { |
20 | 26 | return ImageHandler::normaliseParams( $image, $params ); |
21 | 27 | } |
22 | 28 | |
| 29 | + /** |
| 30 | + * @param $image File |
| 31 | + * @param $dstPath |
| 32 | + * @param $dstUrl |
| 33 | + * @param $params |
| 34 | + * @param int $flags |
| 35 | + * @return ThumbnailImage|TransformParameterError |
| 36 | + */ |
23 | 37 | function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
24 | 38 | if ( !$this->normaliseParams( $image, $params ) ) { |
25 | 39 | return new TransformParameterError( $params ); |
Index: trunk/phase3/includes/media/Generic.php |
— | — | @@ -187,6 +187,8 @@ |
188 | 188 | * Currently "width" and "height" are understood, but this might be |
189 | 189 | * expanded in the future. |
190 | 190 | * Returns false if unknown or if the document is not multi-page. |
| 191 | + * |
| 192 | + * @param $image File |
191 | 193 | */ |
192 | 194 | function getPageDimensions( $image, $page ) { |
193 | 195 | $gis = $this->getImageSize( $image, $image->getPath() ); |
— | — | @@ -250,6 +252,10 @@ |
251 | 253 | ); |
252 | 254 | } |
253 | 255 | |
| 256 | + /** |
| 257 | + * @param $file File |
| 258 | + * @return string |
| 259 | + */ |
254 | 260 | function getShortDesc( $file ) { |
255 | 261 | global $wgLang; |
256 | 262 | $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), |
— | — | @@ -257,6 +263,10 @@ |
258 | 264 | return "$nbytes"; |
259 | 265 | } |
260 | 266 | |
| 267 | + /** |
| 268 | + * @param $file File |
| 269 | + * @return string |
| 270 | + */ |
261 | 271 | function getLongDesc( $file ) { |
262 | 272 | global $wgUser; |
263 | 273 | $sk = $wgUser->getSkin(); |
— | — | @@ -264,7 +274,11 @@ |
265 | 275 | $sk->formatSize( $file->getSize() ), |
266 | 276 | $file->getMimeType() ); |
267 | 277 | } |
268 | | - |
| 278 | + |
| 279 | + /** |
| 280 | + * @param $file File |
| 281 | + * @return string |
| 282 | + */ |
269 | 283 | static function getGeneralShortDesc( $file ) { |
270 | 284 | global $wgLang; |
271 | 285 | $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), |
— | — | @@ -272,6 +286,10 @@ |
273 | 287 | return "$nbytes"; |
274 | 288 | } |
275 | 289 | |
| 290 | + /** |
| 291 | + * @param $file File |
| 292 | + * @return string |
| 293 | + */ |
276 | 294 | static function getGeneralLongDesc( $file ) { |
277 | 295 | global $wgUser; |
278 | 296 | $sk = $wgUser->getSkin(); |
— | — | @@ -332,12 +350,13 @@ |
333 | 351 | * @ingroup Media |
334 | 352 | */ |
335 | 353 | abstract class ImageHandler extends MediaHandler { |
| 354 | + |
| 355 | + /** |
| 356 | + * @param $file File |
| 357 | + * @return bool |
| 358 | + */ |
336 | 359 | function canRender( $file ) { |
337 | | - if ( $file->getWidth() && $file->getHeight() ) { |
338 | | - return true; |
339 | | - } else { |
340 | | - return false; |
341 | | - } |
| 360 | + return ( $file->getWidth() && $file->getHeight() ); |
342 | 361 | } |
343 | 362 | |
344 | 363 | function getParamMap() { |
— | — | @@ -382,6 +401,11 @@ |
383 | 402 | return array( 'width' => $params['width'] ); |
384 | 403 | } |
385 | 404 | |
| 405 | + /** |
| 406 | + * @param $image File |
| 407 | + * @param $params |
| 408 | + * @return bool |
| 409 | + */ |
386 | 410 | function normaliseParams( $image, &$params ) { |
387 | 411 | $mimeType = $image->getMimeType(); |
388 | 412 | |
— | — | @@ -449,6 +473,12 @@ |
450 | 474 | return true; |
451 | 475 | } |
452 | 476 | |
| 477 | + /** |
| 478 | + * @param $image File |
| 479 | + * @param $script |
| 480 | + * @param $params |
| 481 | + * @return bool|ThumbnailImage |
| 482 | + */ |
453 | 483 | function getScriptedTransform( $image, $script, $params ) { |
454 | 484 | if ( !$this->normaliseParams( $image, $params ) ) { |
455 | 485 | return false; |
— | — | @@ -472,6 +502,10 @@ |
473 | 503 | return false; |
474 | 504 | } |
475 | 505 | |
| 506 | + /** |
| 507 | + * @param $file File |
| 508 | + * @return string |
| 509 | + */ |
476 | 510 | function getShortDesc( $file ) { |
477 | 511 | global $wgLang; |
478 | 512 | $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), |
— | — | @@ -481,6 +515,10 @@ |
482 | 516 | return "$widthheight ($nbytes)"; |
483 | 517 | } |
484 | 518 | |
| 519 | + /** |
| 520 | + * @param $file File |
| 521 | + * @return string |
| 522 | + */ |
485 | 523 | function getLongDesc( $file ) { |
486 | 524 | global $wgLang; |
487 | 525 | return wfMsgExt('file-info-size', 'parseinline', |
— | — | @@ -490,6 +528,10 @@ |
491 | 529 | $file->getMimeType() ); |
492 | 530 | } |
493 | 531 | |
| 532 | + /** |
| 533 | + * @param $file File |
| 534 | + * @return string |
| 535 | + */ |
494 | 536 | function getDimensionsString( $file ) { |
495 | 537 | global $wgLang; |
496 | 538 | $pages = $file->pageCount(); |
Index: trunk/phase3/includes/media/MediaTransformOutput.php |
— | — | @@ -12,8 +12,13 @@ |
13 | 13 | * @ingroup Media |
14 | 14 | */ |
15 | 15 | abstract class MediaTransformOutput { |
16 | | - var $file, $width, $height, $url, $page, $path; |
| 16 | + /** |
| 17 | + * @var File |
| 18 | + */ |
| 19 | + var $file; |
17 | 20 | |
| 21 | + var $width, $height, $url, $page, $path; |
| 22 | + |
18 | 23 | /** |
19 | 24 | * Get the width of the output box |
20 | 25 | */ |
Index: trunk/phase3/includes/media/SVG.php |
— | — | @@ -32,6 +32,10 @@ |
33 | 33 | return true; |
34 | 34 | } |
35 | 35 | |
| 36 | + /** |
| 37 | + * @param $file File |
| 38 | + * @return bool |
| 39 | + */ |
36 | 40 | function isAnimatedImage( $file ) { |
37 | 41 | # TODO: detect animated SVGs |
38 | 42 | $metadata = $file->getMetadata(); |
— | — | @@ -44,6 +48,11 @@ |
45 | 49 | return false; |
46 | 50 | } |
47 | 51 | |
| 52 | + /** |
| 53 | + * @param $image File |
| 54 | + * @param $params |
| 55 | + * @return bool |
| 56 | + */ |
48 | 57 | function normaliseParams( $image, &$params ) { |
49 | 58 | global $wgSVGMaxSize; |
50 | 59 | if ( !parent::normaliseParams( $image, $params ) ) { |
— | — | @@ -61,6 +70,14 @@ |
62 | 71 | return true; |
63 | 72 | } |
64 | 73 | |
| 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 | + */ |
65 | 82 | function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
66 | 83 | if ( !$this->normaliseParams( $image, $params ) ) { |
67 | 84 | return new TransformParameterError( $params ); |
— | — | @@ -125,6 +142,12 @@ |
126 | 143 | return true; |
127 | 144 | } |
128 | 145 | |
| 146 | + /** |
| 147 | + * @param $file File |
| 148 | + * @param $path |
| 149 | + * @param bool $metadata |
| 150 | + * @return array |
| 151 | + */ |
129 | 152 | function getImageSize( $file, $path, $metadata = false ) { |
130 | 153 | if ( $metadata === false ) { |
131 | 154 | $metadata = $file->getMetaData(); |
— | — | @@ -141,6 +164,10 @@ |
142 | 165 | return array( 'png', 'image/png' ); |
143 | 166 | } |
144 | 167 | |
| 168 | + /** |
| 169 | + * @param $file File |
| 170 | + * @return string |
| 171 | + */ |
145 | 172 | function getLongDesc( $file ) { |
146 | 173 | global $wgLang; |
147 | 174 | return wfMsgExt( 'svg-long-desc', 'parseinline', |
— | — | @@ -183,6 +210,10 @@ |
184 | 211 | return $fields; |
185 | 212 | } |
186 | 213 | |
| 214 | + /** |
| 215 | + * @param $file File |
| 216 | + * @return array|bool |
| 217 | + */ |
187 | 218 | function formatMetadata( $file ) { |
188 | 219 | $result = array( |
189 | 220 | 'visible' => array(), |
Index: trunk/phase3/includes/media/PNG.php |
— | — | @@ -31,7 +31,11 @@ |
32 | 32 | function formatMetadata( $image ) { |
33 | 33 | return false; |
34 | 34 | } |
35 | | - |
| 35 | + |
| 36 | + /** |
| 37 | + * @param $image File |
| 38 | + * @return bool |
| 39 | + */ |
36 | 40 | function isAnimatedImage( $image ) { |
37 | 41 | $ser = $image->getMetadata(); |
38 | 42 | if ($ser) { |
— | — | @@ -51,6 +55,11 @@ |
52 | 56 | wfRestoreWarnings(); |
53 | 57 | return (boolean) $data; |
54 | 58 | } |
| 59 | + |
| 60 | + /** |
| 61 | + * @param $image File |
| 62 | + * @return string |
| 63 | + */ |
55 | 64 | function getLongDesc( $image ) { |
56 | 65 | global $wgLang; |
57 | 66 | $original = parent::getLongDesc( $image ); |
Index: trunk/phase3/includes/media/GIF.php |
— | — | @@ -31,7 +31,13 @@ |
32 | 32 | function formatMetadata( $image ) { |
33 | 33 | return false; |
34 | 34 | } |
35 | | - |
| 35 | + |
| 36 | + /** |
| 37 | + * @param $image File |
| 38 | + * @param $width |
| 39 | + * @param $height |
| 40 | + * @return |
| 41 | + */ |
36 | 42 | function getImageArea( $image, $width, $height ) { |
37 | 43 | $ser = $image->getMetadata(); |
38 | 44 | if ($ser) { |
— | — | @@ -42,6 +48,10 @@ |
43 | 49 | } |
44 | 50 | } |
45 | 51 | |
| 52 | + /** |
| 53 | + * @param $image File |
| 54 | + * @return bool |
| 55 | + */ |
46 | 56 | function isAnimatedImage( $image ) { |
47 | 57 | $ser = $image->getMetadata(); |
48 | 58 | if ($ser) { |
— | — | @@ -62,6 +72,10 @@ |
63 | 73 | return (boolean) $data; |
64 | 74 | } |
65 | 75 | |
| 76 | + /** |
| 77 | + * @param $image File |
| 78 | + * @return string |
| 79 | + */ |
66 | 80 | function getLongDesc( $image ) { |
67 | 81 | global $wgLang; |
68 | 82 | |
Index: trunk/phase3/includes/media/DjVu.php |
— | — | @@ -68,6 +68,14 @@ |
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
| 72 | + /** |
| 73 | + * @param $image File |
| 74 | + * @param $dstPath |
| 75 | + * @param $dstUrl |
| 76 | + * @param $params |
| 77 | + * @param int $flags |
| 78 | + * @return MediaTransformError|ThumbnailImage|TransformParameterError |
| 79 | + */ |
72 | 80 | function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
73 | 81 | global $wgDjvuRenderer, $wgDjvuPostProcessor; |
74 | 82 | |
— | — | @@ -139,6 +147,7 @@ |
140 | 148 | |
141 | 149 | /** |
142 | 150 | * Cache a document tree for the DjVu XML metadata |
| 151 | + * @param $image File |
143 | 152 | */ |
144 | 153 | function getMetaTree( $image , $gettext = false ) { |
145 | 154 | if ( isset( $image->dejaMetaTree ) ) { |