More unused variables, whitespace
[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 try {
17 $image->parsedGIFMetadata = GIFMetadataExtractor::getMetadata( $filename );
18 } catch( Exception $e ) {
19 // Broken file?
20 wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
21 return '0';
22 }
23 }
24
25 return serialize($image->parsedGIFMetadata);
26
27 }
28
29 function formatMetadata( $image ) {
30 return false;
31 }
32
33 function getImageArea( $image, $width, $height ) {
34 $ser = $image->getMetadata();
35 if ($ser) {
36 $metadata = unserialize($ser);
37 return $width * $height * $metadata['frameCount'];
38 } else {
39 return $width * $height;
40 }
41 }
42
43 function isAnimatedImage( $image ) {
44 $ser = $image->getMetadata();
45 if ($ser) {
46 $metadata = unserialize($ser);
47 if( $metadata['frameCount'] > 1 ) return true;
48 }
49 return false;
50 }
51
52 function getMetadataType( $image ) {
53 return 'parsed-gif';
54 }
55
56 function isMetadataValid( $image, $metadata ) {
57 wfSuppressWarnings();
58 $data = unserialize( $metadata );
59 wfRestoreWarnings();
60 return (boolean) $data;
61 }
62
63 function getLongDesc( $image ) {
64 global $wgLang;
65
66 $original = parent::getLongDesc( $image );
67
68 wfSuppressWarnings();
69 $metadata = unserialize($image->getMetadata());
70 wfRestoreWarnings();
71
72 if (!$metadata || $metadata['frameCount'] <= 1)
73 return $original;
74
75 $info = array();
76 $info[] = substr( $original, 1, strlen( $original )-2 );
77
78 if ($metadata['looped'])
79 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
80
81 if ($metadata['frameCount'] > 1)
82 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
83
84 if ($metadata['duration'])
85 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
86
87 $infoString = $wgLang->commaList( $info );
88
89 return "($infoString)";
90 }
91 }