MediaWiki  REL1_19
Tiff.php
Go to the documentation of this file.
00001 <?php
00014 class TiffHandler extends ExifBitmapHandler {
00015 
00028         function canRender( $file ) {
00029                 global $wgTiffThumbnailType;
00030                 return (bool)$wgTiffThumbnailType
00031                         || ($file->getRepo() instanceof ForeignAPIRepo);
00032         }
00033 
00042         function mustRender( $file ) {
00043                 return true;
00044         }
00045 
00052         function getThumbType( $ext, $mime, $params = null ) {
00053                 global $wgTiffThumbnailType;
00054                 return $wgTiffThumbnailType;
00055         }
00056 
00062         function getMetadata( $image, $filename ) {
00063                 global $wgShowEXIF;
00064                 if ( $wgShowEXIF ) {
00065                         try {
00066                                 $meta = BitmapMetadataHandler::Tiff( $filename );
00067                                 if ( !is_array( $meta ) ) {
00068                                         // This should never happen, but doesn't hurt to be paranoid.
00069                                         throw new MWException('Metadata array is not an array');
00070                                 }
00071                                 $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
00072                                 return serialize( $meta );
00073                         }
00074                         catch ( MWException $e ) {
00075                                 // BitmapMetadataHandler throws an exception in certain exceptional
00076                                 // cases like if file does not exist.
00077                                 wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
00078                                 return ExifBitmapHandler::BROKEN_FILE;
00079                         }
00080                 } else {
00081                         return '';
00082                 }
00083         }
00084 }