Fix silly bug in r54703 r53546
[lhc/web/wiklou.git] / includes / media / GIF.php
1 <?php
2 /**
3 * @file
4 * @ingroup Media
5 */
6
7 /**
8 * Handler for GIF images.
9 *
10 * @ingroup Media
11 */
12 class GIFHandler extends BitmapHandler {
13
14 function getMetadata( $image, $filename ) {
15 if ( !isset($image->parsedGIFMetadata) )
16 $image->parsedGIFMetadata = GIFMetadataExtractor::getMetadata( $filename );
17
18 return serialize($image->parsedGIFMetadata);
19
20 }
21
22 function formatMetadata( $image ) {
23 return false;
24 }
25
26 function getImageArea( $image, $width, $height ) {
27 $ser = $image->getMetadata()
28 if ($ser) {
29 $metadata = unserialize($ser);
30 return $width * $height * $metadata['frameCount'];
31 } else {
32 return $width * $height;
33 }
34 }
35
36 function getMetadataType( $image ) {
37 return 'parsed-gif';
38 }
39
40 function getLongDesc( $image ) {
41 global $wgUser, $wgLang;
42 $sk = $wgUser->getSkin();
43
44 $metadata = @unserialize($image->getMetadata());
45
46 if (!$metadata) return parent::getLongDesc( $image );
47
48 $info = array();
49 $info[] = $image->getMimeType();
50 $info[] = $sk->formatSize( $image->getSize() );
51
52 if ($metadata['looped'])
53 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
54
55 if ($metadata['frameCount'] > 1)
56 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
57
58 if ($metadata['duration'])
59 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
60
61 $infoString = $wgLang->commaList( $info );
62
63 return "($infoString)";
64 }
65 }