Merge "mediawiki.searchSuggest: Unbreak browser blacklist"
[lhc/web/wiklou.git] / includes / media / FormatMetadata.php
index 390b217..adaba76 100644 (file)
  * is already a large number of messages using the 'exif' prefix.
  *
  * @ingroup Media
- * @since 1.23 the class extends ContextSource and various formerly-public internal methods are private
+ * @since 1.23 the class extends ContextSource and various formerly-public
+ *   internal methods are private
  */
 class FormatMetadata extends ContextSource {
-
        /**
         * Only output a single language for multi-language fields
-        * @var boolean
+        * @var bool
         * @since 1.23
         */
        protected $singleLang = false;
@@ -57,7 +57,7 @@ class FormatMetadata extends ContextSource {
        /**
         * Trigger only outputting single language for multilanguage fields
         *
-        * @param Boolean $val
+        * @param bool $val
         * @since 1.23
         */
        public function setSingleLanguage( $val ) {
@@ -73,8 +73,8 @@ class FormatMetadata extends ContextSource {
         * This is the usual entry point for this class.
         *
         * @param array $tags the Exif data to format ( as returned by
-        *                    Exif::getFilteredData() or BitmapMetadataHandler )
-        * @param IContextSource $context Context to use (optional)
+        *   Exif::getFilteredData() or BitmapMetadataHandler )
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array
         */
        public static function getFormattedData( $tags, $context = false ) {
@@ -82,6 +82,7 @@ class FormatMetadata extends ContextSource {
                if ( $context ) {
                        $obj->setContext( $context );
                }
+
                return $obj->makeFormattedData( $tags );
        }
 
@@ -92,7 +93,7 @@ class FormatMetadata extends ContextSource {
         * formats Exif (and other metadata) values into human readable form.
         *
         * @param array $tags the Exif data to format ( as returned by
-        *                    Exif::getFilteredData() or BitmapMetadataHandler )
+        *   Exif::getFilteredData() or BitmapMetadataHandler )
         * @return array
         * @since 1.23
         */
@@ -166,719 +167,830 @@ class FormatMetadata extends ContextSource {
                        foreach ( $vals as &$val ) {
 
                                switch ( $tag ) {
-                               case 'Compression':
-                                       switch ( $val ) {
-                                       case 1: case 2: case 3: case 4:
-                                       case 5: case 6: case 7: case 8:
-                                       case 32773: case 32946: case 34712:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'Compression':
+                                               switch ( $val ) {
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                       case 4:
+                                                       case 5:
+                                                       case 6:
+                                                       case 7:
+                                                       case 8:
+                                                       case 32773:
+                                                       case 32946:
+                                                       case 34712:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'PhotometricInterpretation':
-                                       switch ( $val ) {
-                                       case 2: case 6:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'PhotometricInterpretation':
+                                               switch ( $val ) {
+                                                       case 2:
+                                                       case 6:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'Orientation':
-                                       switch ( $val ) {
-                                       case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'Orientation':
+                                               switch ( $val ) {
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                       case 4:
+                                                       case 5:
+                                                       case 6:
+                                                       case 7:
+                                                       case 8:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'PlanarConfiguration':
-                                       switch ( $val ) {
-                                       case 1: case 2:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
-                                               break;
-                                       }
-                                       break;
-
-                               // TODO: YCbCrSubSampling
-                               case 'YCbCrPositioning':
-                                       switch ( $val ) {
-                                       case 1:
-                                       case 2:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'PlanarConfiguration':
+                                               switch ( $val ) {
+                                                       case 1:
+                                                       case 2:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
-
-                               case 'XResolution':
-                               case 'YResolution':
-                                       switch ( $resolutionunit ) {
-                                               case 2:
-                                                       $val = $this->exifMsg( 'XYResolution', 'i', $this->formatNum( $val ) );
-                                                       break;
-                                               case 3:
-                                                       $val = $this->exifMsg( 'XYResolution', 'c', $this->formatNum( $val ) );
-                                                       break;
-                                               default:
-                                                       /* If not recognized, display as is. */
-                                                       break;
-                                       }
-                                       break;
-
-                               // TODO: YCbCrCoefficients  #p27 (see annex E)
-                               case 'ExifVersion': case 'FlashpixVersion':
-                                       $val = "$val" / 100;
-                                       break;
 
-                               case 'ColorSpace':
-                                       switch ( $val ) {
-                                       case 1: case 65535:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       // TODO: YCbCrSubSampling
+                                       case 'YCbCrPositioning':
+                                               switch ( $val ) {
+                                                       case 1:
+                                                       case 2:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'ComponentsConfiguration':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2: case 3: case 4: case 5: case 6:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'XResolution':
+                                       case 'YResolution':
+                                               switch ( $resolutionunit ) {
+                                                       case 2:
+                                                               $val = $this->exifMsg( 'XYResolution', 'i', $this->formatNum( $val ) );
+                                                               break;
+                                                       case 3:
+                                                               $val = $this->exifMsg( 'XYResolution', 'c', $this->formatNum( $val ) );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       // TODO: YCbCrCoefficients  #p27 (see annex E)
+                                       case 'ExifVersion':
+                                       case 'FlashpixVersion':
+                                               $val = "$val" / 100;
                                                break;
-                                       }
-                                       break;
-
-                               case 'DateTime':
-                               case 'DateTimeOriginal':
-                               case 'DateTimeDigitized':
-                               case 'DateTimeReleased':
-                               case 'DateTimeExpires':
-                               case 'GPSDateStamp':
-                               case 'dc-date':
-                               case 'DateTimeMetadata':
-                                       if ( $val == '0000:00:00 00:00:00' || $val == '    :  :     :  :  ' ) {
-                                               $val = $this->msg( 'exif-unknowndate' )->text();
-                                       } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d):(?:\d\d)$/D', $val ) ) {
-                                               // Full date.
-                                               $time = wfTimestamp( TS_MW, $val );
-                                               if ( $time && intval( $time ) > 0 ) {
-                                                       $val = $this->getLanguage()->timeanddate( $time );
-                                               }
-                                       } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d)$/D', $val ) ) {
-                                               // No second field. Still format the same
-                                               // since timeanddate doesn't include seconds anyways,
-                                               // but second still available in api
-                                               $time = wfTimestamp( TS_MW, $val . ':00' );
-                                               if ( $time && intval( $time ) > 0 ) {
-                                                       $val = $this->getLanguage()->timeanddate( $time );
-                                               }
-                                       } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d)$/D', $val ) ) {
-                                               // If only the date but not the time is filled in.
-                                               $time = wfTimestamp( TS_MW, substr( $val, 0, 4 )
-                                                       . substr( $val, 5, 2 )
-                                                       . substr( $val, 8, 2 )
-                                                       . '000000' );
-                                               if ( $time && intval( $time ) > 0 ) {
-                                                       $val = $this->getLanguage()->date( $time );
-                                               }
-                                       }
-                                       // else it will just output $val without formatting it.
-                                       break;
 
-                               case 'ExposureProgram':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'ColorSpace':
+                                               switch ( $val ) {
+                                                       case 1:
+                                                       case 65535:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'ComponentsConfiguration':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                       case 4:
+                                                       case 5:
+                                                       case 6:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'SubjectDistance':
-                                       $val = $this->exifMsg( $tag, '', $this->formatNum( $val ) );
-                                       break;
+                                       case 'DateTime':
+                                       case 'DateTimeOriginal':
+                                       case 'DateTimeDigitized':
+                                       case 'DateTimeReleased':
+                                       case 'DateTimeExpires':
+                                       case 'GPSDateStamp':
+                                       case 'dc-date':
+                                       case 'DateTimeMetadata':
+                                               if ( $val == '0000:00:00 00:00:00' || $val == '    :  :     :  :  ' ) {
+                                                       $val = $this->msg( 'exif-unknowndate' )->text();
+                                               } elseif ( preg_match(
+                                                       '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d):(?:\d\d)$/D',
+                                                       $val
+                                               ) ) {
+                                                       // Full date.
+                                                       $time = wfTimestamp( TS_MW, $val );
+                                                       if ( $time && intval( $time ) > 0 ) {
+                                                               $val = $this->getLanguage()->timeanddate( $time );
+                                                       }
+                                               } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d)$/D', $val ) ) {
+                                                       // No second field. Still format the same
+                                                       // since timeanddate doesn't include seconds anyways,
+                                                       // but second still available in api
+                                                       $time = wfTimestamp( TS_MW, $val . ':00' );
+                                                       if ( $time && intval( $time ) > 0 ) {
+                                                               $val = $this->getLanguage()->timeanddate( $time );
+                                                       }
+                                               } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d)$/D', $val ) ) {
+                                                       // If only the date but not the time is filled in.
+                                                       $time = wfTimestamp( TS_MW, substr( $val, 0, 4 )
+                                                               . substr( $val, 5, 2 )
+                                                               . substr( $val, 8, 2 )
+                                                               . '000000' );
+                                                       if ( $time && intval( $time ) > 0 ) {
+                                                               $val = $this->getLanguage()->date( $time );
+                                                       }
+                                               }
+                                               // else it will just output $val without formatting it.
+                                               break;
 
-                               case 'MeteringMode':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 255:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'ExposureProgram':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                       case 4:
+                                                       case 5:
+                                                       case 6:
+                                                       case 7:
+                                                       case 8:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'SubjectDistance':
+                                               $val = $this->exifMsg( $tag, '', $this->formatNum( $val ) );
                                                break;
-                                       }
-                                       break;
-
-                               case 'LightSource':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2: case 3: case 4: case 9: case 10: case 11:
-                                       case 12: case 13: case 14: case 15: case 17: case 18: case 19: case 20:
-                                       case 21: case 22: case 23: case 24: case 255:
-                                               $val = $this->exifMsg( $tag, $val );
+
+                                       case 'MeteringMode':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                       case 4:
+                                                       case 5:
+                                                       case 6:
+                                                       case 7:
+                                                       case 255:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'LightSource':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                       case 4:
+                                                       case 9:
+                                                       case 10:
+                                                       case 11:
+                                                       case 12:
+                                                       case 13:
+                                                       case 14:
+                                                       case 15:
+                                                       case 17:
+                                                       case 18:
+                                                       case 19:
+                                                       case 20:
+                                                       case 21:
+                                                       case 22:
+                                                       case 23:
+                                                       case 24:
+                                                       case 255:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
-
-                               case 'Flash':
-                                       $flashDecode = array(
-                                               'fired' => $val & bindec( '00000001' ),
-                                               'return' => ( $val & bindec( '00000110' ) ) >> 1,
-                                               'mode' => ( $val & bindec( '00011000' ) ) >> 3,
-                                               'function' => ( $val & bindec( '00100000' ) ) >> 5,
-                                               'redeye' => ( $val & bindec( '01000000' ) ) >> 6,
+
+                                       case 'Flash':
+                                               $flashDecode = array(
+                                                       'fired' => $val & bindec( '00000001' ),
+                                                       'return' => ( $val & bindec( '00000110' ) ) >> 1,
+                                                       'mode' => ( $val & bindec( '00011000' ) ) >> 3,
+                                                       'function' => ( $val & bindec( '00100000' ) ) >> 5,
+                                                       'redeye' => ( $val & bindec( '01000000' ) ) >> 6,
 //                                             'reserved' => ($val & bindec( '10000000' )) >> 7,
-                                       );
-                                       $flashMsgs = array();
-                                       # We do not need to handle unknown values since all are used.
-                                       foreach ( $flashDecode as $subTag => $subValue ) {
-                                               # We do not need any message for zeroed values.
-                                               if ( $subTag != 'fired' && $subValue == 0 ) {
-                                                       continue;
+                                               );
+                                               $flashMsgs = array();
+                                               # We do not need to handle unknown values since all are used.
+                                               foreach ( $flashDecode as $subTag => $subValue ) {
+                                                       # We do not need any message for zeroed values.
+                                                       if ( $subTag != 'fired' && $subValue == 0 ) {
+                                                               continue;
+                                                       }
+                                                       $fullTag = $tag . '-' . $subTag;
+                                                       $flashMsgs[] = $this->exifMsg( $fullTag, $subValue );
                                                }
-                                               $fullTag = $tag . '-' . $subTag;
-                                               $flashMsgs[] = $this->exifMsg( $fullTag, $subValue );
-                                       }
-                                       $val = $this->getLanguage()->commaList( $flashMsgs );
-                                       break;
-
-                               case 'FocalPlaneResolutionUnit':
-                                       switch ( $val ) {
-                                       case 2:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                               $val = $this->getLanguage()->commaList( $flashMsgs );
                                                break;
-                                       }
-                                       break;
 
-                               case 'SensingMethod':
-                                       switch ( $val ) {
-                                       case 1: case 2: case 3: case 4: case 5: case 7: case 8:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'FocalPlaneResolutionUnit':
+                                               switch ( $val ) {
+                                                       case 2:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'FileSource':
-                                       switch ( $val ) {
-                                       case 3:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'SensingMethod':
+                                               switch ( $val ) {
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                       case 4:
+                                                       case 5:
+                                                       case 7:
+                                                       case 8:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'SceneType':
-                                       switch ( $val ) {
-                                       case 1:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'FileSource':
+                                               switch ( $val ) {
+                                                       case 3:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'CustomRendered':
-                                       switch ( $val ) {
-                                       case 0: case 1:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'SceneType':
+                                               switch ( $val ) {
+                                                       case 1:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'ExposureMode':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2:
-                                               $val = $this->exifMsg( $tag, $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'CustomRendered':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'WhiteBalance':
-                                       switch ( $val ) {
-                                       case 0: case 1:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'ExposureMode':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'WhiteBalance':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'SceneCaptureType':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2: case 3:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'SceneCaptureType':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'GainControl':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                       case 4:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'GainControl':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2: case 3: case 4:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'Contrast':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'Saturation':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'Contrast':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'Sharpness':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'SubjectDistanceRange':
+                                               switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
+                                                       case 2:
+                                                       case 3:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'Saturation':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       //The GPS...Ref values are kept for compatibility, probably won't be reached.
+                                       case 'GPSLatitudeRef':
+                                       case 'GPSDestLatitudeRef':
+                                               switch ( $val ) {
+                                                       case 'N':
+                                                       case 'S':
+                                                               $val = $this->exifMsg( 'GPSLatitude', $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'GPSLongitudeRef':
+                                       case 'GPSDestLongitudeRef':
+                                               switch ( $val ) {
+                                                       case 'E':
+                                                       case 'W':
+                                                               $val = $this->exifMsg( 'GPSLongitude', $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'Sharpness':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'GPSAltitude':
+                                               if ( $val < 0 ) {
+                                                       $val = $this->exifMsg( 'GPSAltitude', 'below-sealevel', $this->formatNum( -$val, 3 ) );
+                                               } else {
+                                                       $val = $this->exifMsg( 'GPSAltitude', 'above-sealevel', $this->formatNum( $val, 3 ) );
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'GPSStatus':
+                                               switch ( $val ) {
+                                                       case 'A':
+                                                       case 'V':
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'SubjectDistanceRange':
-                                       switch ( $val ) {
-                                       case 0: case 1: case 2: case 3:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'GPSMeasureMode':
+                                               switch ( $val ) {
+                                                       case 2:
+                                                       case 3:
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'GPSTrackRef':
+                                       case 'GPSImgDirectionRef':
+                                       case 'GPSDestBearingRef':
+                                               switch ( $val ) {
+                                                       case 'T':
+                                                       case 'M':
+                                                               $val = $this->exifMsg( 'GPSDirection', $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
-
-                               //The GPS...Ref values are kept for compatibility, probably won't be reached.
-                               case 'GPSLatitudeRef':
-                               case 'GPSDestLatitudeRef':
-                                       switch ( $val ) {
-                                       case 'N': case 'S':
-                                               $val = $this->exifMsg( 'GPSLatitude', $val );
+
+                                       case 'GPSLatitude':
+                                       case 'GPSDestLatitude':
+                                               $val = $this->formatCoords( $val, 'latitude' );
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'GPSLongitude':
+                                       case 'GPSDestLongitude':
+                                               $val = $this->formatCoords( $val, 'longitude' );
                                                break;
-                                       }
-                                       break;
 
-                               case 'GPSLongitudeRef':
-                               case 'GPSDestLongitudeRef':
-                                       switch ( $val ) {
-                                       case 'E': case 'W':
-                                               $val = $this->exifMsg( 'GPSLongitude', $val );
-                                               break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'GPSSpeedRef':
+                                               switch ( $val ) {
+                                                       case 'K':
+                                                       case 'M':
+                                                       case 'N':
+                                                               $val = $this->exifMsg( 'GPSSpeed', $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'GPSAltitude':
-                                       if ( $val < 0 ) {
-                                               $val = $this->exifMsg( 'GPSAltitude', 'below-sealevel', $this->formatNum( -$val, 3 ) );
-                                       } else {
-                                               $val = $this->exifMsg( 'GPSAltitude', 'above-sealevel', $this->formatNum( $val, 3 ) );
-                                       }
-                                       break;
+                                       case 'GPSDestDistanceRef':
+                                               switch ( $val ) {
+                                                       case 'K':
+                                                       case 'M':
+                                                       case 'N':
+                                                               $val = $this->exifMsg( 'GPSDestDistance', $val );
+                                                               break;
+                                                       default:
+                                                               /* If not recognized, display as is. */
+                                                               break;
+                                               }
+                                               break;
 
-                               case 'GPSStatus':
-                                       switch ( $val ) {
-                                       case 'A': case 'V':
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'GPSDOP':
+                                               // See http://en.wikipedia.org/wiki/Dilution_of_precision_(GPS)
+                                               if ( $val <= 2 ) {
+                                                       $val = $this->exifMsg( $tag, 'excellent', $this->formatNum( $val ) );
+                                               } elseif ( $val <= 5 ) {
+                                                       $val = $this->exifMsg( $tag, 'good', $this->formatNum( $val ) );
+                                               } elseif ( $val <= 10 ) {
+                                                       $val = $this->exifMsg( $tag, 'moderate', $this->formatNum( $val ) );
+                                               } elseif ( $val <= 20 ) {
+                                                       $val = $this->exifMsg( $tag, 'fair', $this->formatNum( $val ) );
+                                               } else {
+                                                       $val = $this->exifMsg( $tag, 'poor', $this->formatNum( $val ) );
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       // This is not in the Exif standard, just a special
+                                       // case for our purposes which enables wikis to wikify
+                                       // the make, model and software name to link to their articles.
+                                       case 'Make':
+                                       case 'Model':
+                                               $val = $this->exifMsg( $tag, '', $val );
                                                break;
-                                       }
-                                       break;
 
-                               case 'GPSMeasureMode':
-                                       switch ( $val ) {
-                                       case 2: case 3:
-                                               $val = $this->exifMsg( $tag, $val );
+                                       case 'Software':
+                                               if ( is_array( $val ) ) {
+                                                       //if its a software, version array.
+                                                       $val = $this->msg( 'exif-software-version-value', $val[0], $val[1] )->text();
+                                               } else {
+                                                       $val = $this->exifMsg( $tag, '', $val );
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'ExposureTime':
+                                               // Show the pretty fraction as well as decimal version
+                                               $val = $this->msg( 'exif-exposuretime-format',
+                                                       $this->formatFraction( $val ), $this->formatNum( $val ) )->text();
                                                break;
-                                       }
-                                       break;
-
-                               case 'GPSTrackRef':
-                               case 'GPSImgDirectionRef':
-                               case 'GPSDestBearingRef':
-                                       switch ( $val ) {
-                                       case 'T': case 'M':
-                                               $val = $this->exifMsg( 'GPSDirection', $val );
+                                       case 'ISOSpeedRatings':
+                                               // If its = 65535 that means its at the
+                                               // limit of the size of Exif::short and
+                                               // is really higher.
+                                               if ( $val == '65535' ) {
+                                                       $val = $this->exifMsg( $tag, 'overflow' );
+                                               } else {
+                                                       $val = $this->formatNum( $val );
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'FNumber':
+                                               $val = $this->msg( 'exif-fnumber-format',
+                                                       $this->formatNum( $val ) )->text();
                                                break;
-                                       }
-                                       break;
-
-                               case 'GPSLatitude':
-                               case 'GPSDestLatitude':
-                                       $val = $this->formatCoords( $val, 'latitude' );
-                                       break;
-                               case 'GPSLongitude':
-                               case 'GPSDestLongitude':
-                                       $val = $this->formatCoords( $val, 'longitude' );
-                                       break;
-
-                               case 'GPSSpeedRef':
-                                       switch ( $val ) {
-                                       case 'K': case 'M': case 'N':
-                                               $val = $this->exifMsg( 'GPSSpeed', $val );
+
+                                       case 'FocalLength':
+                                       case 'FocalLengthIn35mmFilm':
+                                               $val = $this->msg( 'exif-focallength-format',
+                                                       $this->formatNum( $val ) )->text();
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+
+                                       case 'MaxApertureValue':
+                                               if ( strpos( $val, '/' ) !== false ) {
+                                                       // need to expand this earlier to calculate fNumber
+                                                       list( $n, $d ) = explode( '/', $val );
+                                                       if ( is_numeric( $n ) && is_numeric( $d ) ) {
+                                                               $val = $n / $d;
+                                                       }
+                                               }
+                                               if ( is_numeric( $val ) ) {
+                                                       $fNumber = pow( 2, $val / 2 );
+                                                       if ( $fNumber !== false ) {
+                                                               $val = $this->msg( 'exif-maxaperturevalue-value',
+                                                                       $this->formatNum( $val ),
+                                                                       $this->formatNum( $fNumber, 2 )
+                                                               )->text();
+                                                       }
+                                               }
                                                break;
-                                       }
-                                       break;
 
-                               case 'GPSDestDistanceRef':
-                                       switch ( $val ) {
-                                       case 'K': case 'M': case 'N':
-                                               $val = $this->exifMsg( 'GPSDestDistance', $val );
+                                       case 'iimCategory':
+                                               switch ( strtolower( $val ) ) {
+                                                       // See pg 29 of IPTC photo
+                                                       // metadata standard.
+                                                       case 'ace':
+                                                       case 'clj':
+                                                       case 'dis':
+                                                       case 'fin':
+                                                       case 'edu':
+                                                       case 'evn':
+                                                       case 'hth':
+                                                       case 'hum':
+                                                       case 'lab':
+                                                       case 'lif':
+                                                       case 'pol':
+                                                       case 'rel':
+                                                       case 'sci':
+                                                       case 'soi':
+                                                       case 'spo':
+                                                       case 'war':
+                                                       case 'wea':
+                                                               $val = $this->exifMsg(
+                                                                       'iimcategory',
+                                                                       $val
+                                                               );
+                                               }
                                                break;
-                                       default:
-                                               /* If not recognized, display as is. */
+                                       case 'SubjectNewsCode':
+                                               // Essentially like iimCategory.
+                                               // 8 (numeric) digit hierarchical
+                                               // classification. We decode the
+                                               // first 2 digits, which provide
+                                               // a broad category.
+                                               $val = $this->convertNewsCode( $val );
                                                break;
-                                       }
-                                       break;
-
-                               case 'GPSDOP':
-                                       // See http://en.wikipedia.org/wiki/Dilution_of_precision_(GPS)
-                                       if ( $val <= 2 ) {
-                                               $val = $this->exifMsg( $tag, 'excellent', $this->formatNum( $val ) );
-                                       } elseif ( $val <= 5 ) {
-                                               $val = $this->exifMsg( $tag, 'good', $this->formatNum( $val ) );
-                                       } elseif ( $val <= 10 ) {
-                                               $val = $this->exifMsg( $tag, 'moderate', $this->formatNum( $val ) );
-                                       } elseif ( $val <= 20 ) {
-                                               $val = $this->exifMsg( $tag, 'fair', $this->formatNum( $val ) );
-                                       } else {
-                                               $val = $this->exifMsg( $tag, 'poor', $this->formatNum( $val ) );
-                                       }
-                                       break;
-
-                               // This is not in the Exif standard, just a special
-                               // case for our purposes which enables wikis to wikify
-                               // the make, model and software name to link to their articles.
-                               case 'Make':
-                               case 'Model':
-                                       $val = $this->exifMsg( $tag, '', $val );
-                                       break;
-
-                               case 'Software':
-                                       if ( is_array( $val ) ) {
-                                               //if its a software, version array.
-                                               $val = $this->msg( 'exif-software-version-value', $val[0], $val[1] )->text();
-                                       } else {
-                                               $val = $this->exifMsg( $tag, '', $val );
-                                       }
-                                       break;
-
-                               case 'ExposureTime':
-                                       // Show the pretty fraction as well as decimal version
-                                       $val = $this->msg( 'exif-exposuretime-format',
-                                               $this->formatFraction( $val ), $this->formatNum( $val ) )->text();
-                                       break;
-                               case 'ISOSpeedRatings':
-                                       // If its = 65535 that means its at the
-                                       // limit of the size of Exif::short and
-                                       // is really higher.
-                                       if ( $val == '65535' ) {
-                                               $val = $this->exifMsg( $tag, 'overflow' );
-                                       } else {
-                                               $val = $this->formatNum( $val );
-                                       }
-                                       break;
-                               case 'FNumber':
-                                       $val = $this->msg( 'exif-fnumber-format',
-                                               $this->formatNum( $val ) )->text();
-                                       break;
-
-                               case 'FocalLength': case 'FocalLengthIn35mmFilm':
-                                       $val = $this->msg( 'exif-focallength-format',
-                                               $this->formatNum( $val ) )->text();
-                                       break;
-
-                               case 'MaxApertureValue':
-                                       if ( strpos( $val, '/' ) !== false ) {
-                                               // need to expand this earlier to calculate fNumber
-                                               list( $n, $d ) = explode( '/', $val );
-                                               if ( is_numeric( $n ) && is_numeric( $d ) ) {
-                                                       $val = $n / $d;
+                                       case 'Urgency':
+                                               // 1-8 with 1 being highest, 5 normal
+                                               // 0 is reserved, and 9 is 'user-defined'.
+                                               $urgency = '';
+                                               if ( $val == 0 || $val == 9 ) {
+                                                       $urgency = 'other';
+                                               } elseif ( $val < 5 && $val > 1 ) {
+                                                       $urgency = 'high';
+                                               } elseif ( $val == 5 ) {
+                                                       $urgency = 'normal';
+                                               } elseif ( $val <= 8 && $val > 5 ) {
+                                                       $urgency = 'low';
                                                }
-                                       }
-                                       if ( is_numeric( $val ) ) {
-                                               $fNumber = pow( 2, $val / 2 );
-                                               if ( $fNumber !== false ) {
-                                                       $val = $this->msg( 'exif-maxaperturevalue-value',
-                                                               $this->formatNum( $val ),
-                                                               $this->formatNum( $fNumber, 2 )
-                                                       )->text();
-                                               }
-                                       }
-                                       break;
-
-                               case 'iimCategory':
-                                       switch ( strtolower( $val ) ) {
-                                               // See pg 29 of IPTC photo
-                                               // metadata standard.
-                                               case 'ace': case 'clj':
-                                               case 'dis': case 'fin':
-                                               case 'edu': case 'evn':
-                                               case 'hth': case 'hum':
-                                               case 'lab': case 'lif':
-                                               case 'pol': case 'rel':
-                                               case 'sci': case 'soi':
-                                               case 'spo': case 'war':
-                                               case 'wea':
-                                                       $val = $this->exifMsg(
-                                                               'iimcategory',
-                                                               $val
+
+                                               if ( $urgency !== '' ) {
+                                                       $val = $this->exifMsg( 'urgency',
+                                                               $urgency, $val
                                                        );
-                                       }
-                                       break;
-                               case 'SubjectNewsCode':
-                                       // Essentially like iimCategory.
-                                       // 8 (numeric) digit hierarchical
-                                       // classification. We decode the
-                                       // first 2 digits, which provide
-                                       // a broad category.
-                                       $val = $this->convertNewsCode( $val );
-                                       break;
-                               case 'Urgency':
-                                       // 1-8 with 1 being highest, 5 normal
-                                       // 0 is reserved, and 9 is 'user-defined'.
-                                       $urgency = '';
-                                       if ( $val == 0 || $val == 9 ) {
-                                               $urgency = 'other';
-                                       } elseif ( $val < 5 && $val > 1 ) {
-                                               $urgency = 'high';
-                                       } elseif ( $val == 5 ) {
-                                               $urgency = 'normal';
-                                       } elseif ( $val <= 8 && $val > 5 ) {
-                                               $urgency = 'low';
-                                       }
+                                               }
+                                               break;
 
-                                       if ( $urgency !== '' ) {
-                                               $val = $this->exifMsg( 'urgency',
-                                                       $urgency, $val
-                                               );
-                                       }
-                                       break;
-
-                               // Things that have a unit of pixels.
-                               case 'OriginalImageHeight':
-                               case 'OriginalImageWidth':
-                               case 'PixelXDimension':
-                               case 'PixelYDimension':
-                               case 'ImageWidth':
-                               case 'ImageLength':
-                                       $val = $this->formatNum( $val ) . ' ' . $this->msg( 'unit-pixel' )->text();
-                                       break;
-
-                               // Do not transform fields with pure text.
-                               // For some languages the formatNum()
-                               // conversion results to wrong output like
-                               // foo,bar@example,com or fooÙ«bar@exampleÙ«com.
-                               // Also some 'numeric' things like Scene codes
-                               // are included here as we really don't want
-                               // commas inserted.
-                               case 'ImageDescription':
-                               case 'Artist':
-                               case 'Copyright':
-                               case 'RelatedSoundFile':
-                               case 'ImageUniqueID':
-                               case 'SpectralSensitivity':
-                               case 'GPSSatellites':
-                               case 'GPSVersionID':
-                               case 'GPSMapDatum':
-                               case 'Keywords':
-                               case 'WorldRegionDest':
-                               case 'CountryDest':
-                               case 'CountryCodeDest':
-                               case 'ProvinceOrStateDest':
-                               case 'CityDest':
-                               case 'SublocationDest':
-                               case 'WorldRegionCreated':
-                               case 'CountryCreated':
-                               case 'CountryCodeCreated':
-                               case 'ProvinceOrStateCreated':
-                               case 'CityCreated':
-                               case 'SublocationCreated':
-                               case 'ObjectName':
-                               case 'SpecialInstructions':
-                               case 'Headline':
-                               case 'Credit':
-                               case 'Source':
-                               case 'EditStatus':
-                               case 'FixtureIdentifier':
-                               case 'LocationDest':
-                               case 'LocationDestCode':
-                               case 'Writer':
-                               case 'JPEGFileComment':
-                               case 'iimSupplementalCategory':
-                               case 'OriginalTransmissionRef':
-                               case 'Identifier':
-                               case 'dc-contributor':
-                               case 'dc-coverage':
-                               case 'dc-publisher':
-                               case 'dc-relation':
-                               case 'dc-rights':
-                               case 'dc-source':
-                               case 'dc-type':
-                               case 'Lens':
-                               case 'SerialNumber':
-                               case 'CameraOwnerName':
-                               case 'Label':
-                               case 'Nickname':
-                               case 'RightsCertificate':
-                               case 'CopyrightOwner':
-                               case 'UsageTerms':
-                               case 'WebStatement':
-                               case 'OriginalDocumentID':
-                               case 'LicenseUrl':
-                               case 'MorePermissionsUrl':
-                               case 'AttributionUrl':
-                               case 'PreferredAttributionName':
-                               case 'PNGFileComment':
-                               case 'Disclaimer':
-                               case 'ContentWarning':
-                               case 'GIFFileComment':
-                               case 'SceneCode':
-                               case 'IntellectualGenre':
-                               case 'Event':
-                               case 'OrginisationInImage':
-                               case 'PersonInImage':
-
-                                       $val = htmlspecialchars( $val );
-                                       break;
-
-                               case 'ObjectCycle':
-                                       switch ( $val ) {
-                                       case 'a': case 'p': case 'b':
-                                               $val = $this->exifMsg( $tag, $val );
+                                       // Things that have a unit of pixels.
+                                       case 'OriginalImageHeight':
+                                       case 'OriginalImageWidth':
+                                       case 'PixelXDimension':
+                                       case 'PixelYDimension':
+                                       case 'ImageWidth':
+                                       case 'ImageLength':
+                                               $val = $this->formatNum( $val ) . ' ' . $this->msg( 'unit-pixel' )->text();
                                                break;
-                                       default:
+
+                                       // Do not transform fields with pure text.
+                                       // For some languages the formatNum()
+                                       // conversion results to wrong output like
+                                       // foo,bar@example,com or fooÙ«bar@exampleÙ«com.
+                                       // Also some 'numeric' things like Scene codes
+                                       // are included here as we really don't want
+                                       // commas inserted.
+                                       case 'ImageDescription':
+                                       case 'Artist':
+                                       case 'Copyright':
+                                       case 'RelatedSoundFile':
+                                       case 'ImageUniqueID':
+                                       case 'SpectralSensitivity':
+                                       case 'GPSSatellites':
+                                       case 'GPSVersionID':
+                                       case 'GPSMapDatum':
+                                       case 'Keywords':
+                                       case 'WorldRegionDest':
+                                       case 'CountryDest':
+                                       case 'CountryCodeDest':
+                                       case 'ProvinceOrStateDest':
+                                       case 'CityDest':
+                                       case 'SublocationDest':
+                                       case 'WorldRegionCreated':
+                                       case 'CountryCreated':
+                                       case 'CountryCodeCreated':
+                                       case 'ProvinceOrStateCreated':
+                                       case 'CityCreated':
+                                       case 'SublocationCreated':
+                                       case 'ObjectName':
+                                       case 'SpecialInstructions':
+                                       case 'Headline':
+                                       case 'Credit':
+                                       case 'Source':
+                                       case 'EditStatus':
+                                       case 'FixtureIdentifier':
+                                       case 'LocationDest':
+                                       case 'LocationDestCode':
+                                       case 'Writer':
+                                       case 'JPEGFileComment':
+                                       case 'iimSupplementalCategory':
+                                       case 'OriginalTransmissionRef':
+                                       case 'Identifier':
+                                       case 'dc-contributor':
+                                       case 'dc-coverage':
+                                       case 'dc-publisher':
+                                       case 'dc-relation':
+                                       case 'dc-rights':
+                                       case 'dc-source':
+                                       case 'dc-type':
+                                       case 'Lens':
+                                       case 'SerialNumber':
+                                       case 'CameraOwnerName':
+                                       case 'Label':
+                                       case 'Nickname':
+                                       case 'RightsCertificate':
+                                       case 'CopyrightOwner':
+                                       case 'UsageTerms':
+                                       case 'WebStatement':
+                                       case 'OriginalDocumentID':
+                                       case 'LicenseUrl':
+                                       case 'MorePermissionsUrl':
+                                       case 'AttributionUrl':
+                                       case 'PreferredAttributionName':
+                                       case 'PNGFileComment':
+                                       case 'Disclaimer':
+                                       case 'ContentWarning':
+                                       case 'GIFFileComment':
+                                       case 'SceneCode':
+                                       case 'IntellectualGenre':
+                                       case 'Event':
+                                       case 'OrginisationInImage':
+                                       case 'PersonInImage':
+
                                                $val = htmlspecialchars( $val );
                                                break;
-                                       }
-                                       break;
-                               case 'Copyrighted':
-                                       switch ( $val ) {
-                                       case 'True': case 'False':
-                                               $val = $this->exifMsg( $tag, $val );
+
+                                       case 'ObjectCycle':
+                                               switch ( $val ) {
+                                                       case 'a':
+                                                       case 'p':
+                                                       case 'b':
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                                       default:
+                                                               $val = htmlspecialchars( $val );
+                                                               break;
+                                               }
+                                               break;
+                                       case 'Copyrighted':
+                                               switch ( $val ) {
+                                                       case 'True':
+                                                       case 'False':
+                                                               $val = $this->exifMsg( $tag, $val );
+                                                               break;
+                                               }
+                                               break;
+                                       case 'Rating':
+                                               if ( $val == '-1' ) {
+                                                       $val = $this->exifMsg( $tag, 'rejected' );
+                                               } else {
+                                                       $val = $this->formatNum( $val );
+                                               }
                                                break;
-                                       }
-                                       break;
-                               case 'Rating':
-                                       if ( $val == '-1' ) {
-                                               $val = $this->exifMsg( $tag, 'rejected' );
-                                       } else {
-                                               $val = $this->formatNum( $val );
-                                       }
-                                       break;
 
-                               case 'LanguageCode':
-                                       $lang = Language::fetchLanguageName( strtolower( $val ), $this->getLanguage()->getCode() );
-                                       if ( $lang ) {
-                                               $val = htmlspecialchars( $lang );
-                                       } else {
-                                               $val = htmlspecialchars( $val );
-                                       }
-                                       break;
+                                       case 'LanguageCode':
+                                               $lang = Language::fetchLanguageName( strtolower( $val ), $this->getLanguage()->getCode() );
+                                               if ( $lang ) {
+                                                       $val = htmlspecialchars( $lang );
+                                               } else {
+                                                       $val = htmlspecialchars( $val );
+                                               }
+                                               break;
 
-                               default:
-                                       $val = $this->formatNum( $val );
-                                       break;
+                                       default:
+                                               $val = $this->formatNum( $val );
+                                               break;
                                }
                        }
                        // End formatting values, start flattening arrays.
                        $vals = $this->flattenArrayReal( $vals, $type );
-
                }
+
                return $tags;
        }
 
        /**
         * Flatten an array, using the content language for any messages.
         *
-        * @param array $vals array of values
+        * @param array $vals Array of values
         * @param string $type Type of array (either lang, ul, ol).
-        *     lang = language assoc array with keys being the lang code
-        *     ul = unordered list, ol = ordered list
-        *     type can also come from the '_type' member of $vals.
-        * @param $noHtml Boolean If to avoid returning anything resembling
-        *     html. (Ugly hack for backwards compatibility with old mediawiki).
-        * @param IContextSource $context
+        *   lang = language assoc array with keys being the lang code
+        *   ul = unordered list, ol = ordered list
+        *   type can also come from the '_type' member of $vals.
+        * @param bool $noHtml If to avoid returning anything resembling HTML.
+        *   (Ugly hack for backwards compatibility with old MediaWiki).
+        * @param bool|IContextSource $context
         * @return String single value (in wiki-syntax).
         * @since 1.23
         */
-       public static function flattenArrayContentLang( $vals, $type = 'ul', $noHtml = false, $context = false ) {
+       public static function flattenArrayContentLang( $vals, $type = 'ul',
+               $noHtml = false, $context = false
+       ) {
                global $wgContLang;
                $obj = new FormatMetadata;
                if ( $context ) {
@@ -887,6 +999,7 @@ class FormatMetadata extends ContextSource {
                $context = new DerivativeContext( $obj->getContext() );
                $context->setLanguage( $wgContLang );
                $obj->setContext( $context );
+
                return $obj->flattenArrayReal( $vals, $type, $noHtml );
        }
 
@@ -895,19 +1008,20 @@ class FormatMetadata extends ContextSource {
         *
         * @param array $vals array of values
         * @param string $type Type of array (either lang, ul, ol).
-        *     lang = language assoc array with keys being the lang code
-        *     ul = unordered list, ol = ordered list
-        *     type can also come from the '_type' member of $vals.
-        * @param $noHtml Boolean If to avoid returning anything resembling
-        *     html. (Ugly hack for backwards compatibility with old mediawiki).
-        * @param IContextSource $context
-        * @return String single value (in wiki-syntax).
+        *   lang = language assoc array with keys being the lang code
+        *   ul = unordered list, ol = ordered list
+        *   type can also come from the '_type' member of $vals.
+        * @param bool $noHtml If to avoid returning anything resembling HTML.
+        *   (Ugly hack for backwards compatibility with old MediaWiki).
+        * @param bool|IContextSource $context
+        * @return string Single value (in wiki-syntax).
         */
        public static function flattenArray( $vals, $type = 'ul', $noHtml = false, $context = false ) {
                $obj = new FormatMetadata;
                if ( $context ) {
                        $obj->setContext( $context );
                }
+
                return $obj->flattenArrayReal( $vals, $type, $noHtml );
        }
 
@@ -922,8 +1036,8 @@ class FormatMetadata extends ContextSource {
         *     lang = language assoc array with keys being the lang code
         *     ul = unordered list, ol = ordered list
         *     type can also come from the '_type' member of $vals.
-        * @param $noHtml Boolean If to avoid returning anything resembling
-        *     html. (Ugly hack for backwards compatibility with old mediawiki).
+        * @param $noHtml Boolean If to avoid returning anything resembling HTML.
+        *   (Ugly hack for backwards compatibility with old mediawiki).
         * @return String single value (in wiki-syntax).
         * @since 1.23
         */
@@ -939,102 +1053,103 @@ class FormatMetadata extends ContextSource {
 
                if ( !is_array( $vals ) ) {
                        return $vals; // do nothing if not an array;
-               }
-               elseif ( count( $vals ) === 1 && $type !== 'lang' ) {
+               } elseif ( count( $vals ) === 1 && $type !== 'lang' ) {
                        return $vals[0];
-               }
-               elseif ( count( $vals ) === 0 ) {
+               } elseif ( count( $vals ) === 0 ) {
                        wfDebug( __METHOD__ . " metadata array with 0 elements!\n" );
+
                        return ""; // paranoia. This should never happen
-               }
-               /* @todo FIXME: This should hide some of the list entries if there are
-                * say more than four. Especially if a field is translated into 20
-                * languages, we don't want to show them all by default
-                */
-               else {
+               } else {
+                       /* @todo FIXME: This should hide some of the list entries if there are
+                        * say more than four. Especially if a field is translated into 20
+                        * languages, we don't want to show them all by default
+                        */
                        switch ( $type ) {
-                       case 'lang':
-                               // Display default, followed by ContLang,
-                               // followed by the rest in no particular
-                               // order.
-
-                               // Todo: hide some items if really long list.
-
-                               $content = '';
-
-                               $priorityLanguages = $this->getPriorityLanguages();
-                               $defaultItem = false;
-                               $defaultLang = false;
-
-                               // If default is set, save it for later,
-                               // as we don't know if it's equal to
-                               // one of the lang codes. (In xmp
-                               // you specify the language for a
-                               // default property by having both
-                               // a default prop, and one in the language
-                               // that are identical)
-                               if ( isset( $vals['x-default'] ) ) {
-                                       $defaultItem = $vals['x-default'];
-                                       unset( $vals['x-default'] );
-                               }
-                               foreach ( $priorityLanguages as $pLang ) {
-                                       if ( isset( $vals[$pLang] ) ) {
-                                               $isDefault = false;
-                                               if ( $vals[$pLang] === $defaultItem ) {
-                                                       $defaultItem = false;
-                                                       $isDefault = true;
+                               case 'lang':
+                                       // Display default, followed by ContLang,
+                                       // followed by the rest in no particular
+                                       // order.
+
+                                       // Todo: hide some items if really long list.
+
+                                       $content = '';
+
+                                       $priorityLanguages = $this->getPriorityLanguages();
+                                       $defaultItem = false;
+                                       $defaultLang = false;
+
+                                       // If default is set, save it for later,
+                                       // as we don't know if it's equal to
+                                       // one of the lang codes. (In xmp
+                                       // you specify the language for a
+                                       // default property by having both
+                                       // a default prop, and one in the language
+                                       // that are identical)
+                                       if ( isset( $vals['x-default'] ) ) {
+                                               $defaultItem = $vals['x-default'];
+                                               unset( $vals['x-default'] );
+                                       }
+                                       foreach ( $priorityLanguages as $pLang ) {
+                                               if ( isset( $vals[$pLang] ) ) {
+                                                       $isDefault = false;
+                                                       if ( $vals[$pLang] === $defaultItem ) {
+                                                               $defaultItem = false;
+                                                               $isDefault = true;
+                                                       }
+                                                       $content .= $this->langItem(
+                                                               $vals[$pLang], $pLang,
+                                                               $isDefault, $noHtml );
+
+                                                       unset( $vals[$pLang] );
+
+                                                       if ( $this->singleLang ) {
+                                                               return Html::rawElement( 'span',
+                                                                       array( 'lang' => $pLang ), $vals[$pLang] );
+                                                       }
                                                }
-                                               $content .= $this->langItem(
-                                                       $vals[$pLang], $pLang,
-                                                       $isDefault, $noHtml );
-
-                                               unset( $vals[$pLang] );
+                                       }
 
+                                       // Now do the rest.
+                                       foreach ( $vals as $lang => $item ) {
+                                               if ( $item === $defaultItem ) {
+                                                       $defaultLang = $lang;
+                                                       continue;
+                                               }
+                                               $content .= $this->langItem( $item,
+                                                       $lang, false, $noHtml );
                                                if ( $this->singleLang ) {
                                                        return Html::rawElement( 'span',
-                                                               array( 'lang' => $pLang ), $vals[$pLang] );
+                                                               array( 'lang' => $lang ), $item );
                                                }
                                        }
-                               }
-
-                               // Now do the rest.
-                               foreach ( $vals as $lang => $item ) {
-                                       if ( $item === $defaultItem ) {
-                                               $defaultLang = $lang;
-                                               continue;
-                                       }
-                                       $content .= $this->langItem( $item,
-                                               $lang, false, $noHtml );
-                                       if ( $this->singleLang ) {
-                                               return Html::rawElement( 'span',
-                                                       array( 'lang' => $lang ), $item );
+                                       if ( $defaultItem !== false ) {
+                                               $content = $this->langItem( $defaultItem,
+                                                               $defaultLang, true, $noHtml ) .
+                                                       $content;
+                                               if ( $this->singleLang ) {
+                                                       return $defaultItem;
+                                               }
                                        }
-                               }
-                               if ( $defaultItem !== false ) {
-                                       $content = $this->langItem( $defaultItem,
-                                               $defaultLang, true, $noHtml ) .
-                                               $content;
-                                       if ( $this->singleLang ) {
-                                               return $defaultItem;
+                                       if ( $noHtml ) {
+                                               return $content;
                                        }
-                               }
-                               if ( $noHtml ) {
-                                       return $content;
-                               }
-                               return '<ul class="metadata-langlist">' .
+
+                                       return '<ul class="metadata-langlist">' .
                                        $content .
                                        '</ul>';
-                       case 'ol':
-                               if ( $noHtml ) {
-                                       return "\n#" . implode( "\n#", $vals );
-                               }
-                               return "<ol><li>" . implode( "</li>\n<li>", $vals ) . '</li></ol>';
-                       case 'ul':
-                       default:
-                               if ( $noHtml ) {
-                                       return "\n*" . implode( "\n*", $vals );
-                               }
-                               return "<ul><li>" . implode( "</li>\n<li>", $vals ) . '</li></ul>';
+                               case 'ol':
+                                       if ( $noHtml ) {
+                                               return "\n#" . implode( "\n#", $vals );
+                                       }
+
+                                       return "<ol><li>" . implode( "</li>\n<li>", $vals ) . '</li></ol>';
+                               case 'ul':
+                               default:
+                                       if ( $noHtml ) {
+                                               return "\n*" . implode( "\n*", $vals );
+                                       }
+
+                                       return "<ul><li>" . implode( "</li>\n<li>", $vals ) . '</li></ul>';
                        }
                }
        }
@@ -1043,11 +1158,11 @@ class FormatMetadata extends ContextSource {
         *
         * @param string $value value (this is not escaped)
         * @param string $lang lang code of item or false
-        * @param $default Boolean if it is default value.
-        * @param $noHtml Boolean If to avoid html (for back-compat)
+        * @param bool $default If it is default value.
+        * @param bool $noHtml If to avoid html (for back-compat)
         * @throws MWException
-        * @return string language item (Note: despite how this looks,
-        * this is treated as wikitext not html).
+        * @return string Language item (Note: despite how this looks, this is
+        *   treated as wikitext, not as HTML).
         */
        private function langItem( $value, $lang, $default = false, $noHtml = false ) {
                if ( $lang === false && $default === false ) {
@@ -1067,6 +1182,7 @@ class FormatMetadata extends ContextSource {
                        if ( $noHtml ) {
                                return $msg->text() . "\n\n";
                        } /* else */
+
                        return '<li class="mw-metadata-lang-default">'
                                . $msg->text()
                                . "</li>\n";
@@ -1098,18 +1214,17 @@ class FormatMetadata extends ContextSource {
                $item .= '" lang="' . $lang . '">';
                $item .= $msg->text();
                $item .= "</li>\n";
+
                return $item;
        }
 
        /**
         * Convenience function for getFormattedData()
         *
-        * @private
-        *
-        * @param string $tag the tag name to pass on
-        * @param string $val the value of the tag
-        * @param string $arg an argument to pass ($1)
-        * @param string $arg2 a 2nd argument to pass ($2)
+        * @param string $tag The tag name to pass on
+        * @param string $val The value of the tag
+        * @param string $arg An argument to pass ($1)
+        * @param string $arg2 A 2nd argument to pass ($2)
         * @return string The text content of "exif-$tag-$val" message in lower case
         */
        private function exifMsg( $tag, $val, $arg = null, $arg2 = null ) {
@@ -1118,6 +1233,7 @@ class FormatMetadata extends ContextSource {
                if ( $val === '' ) {
                        $val = 'value';
                }
+
                return $this->msg( $wgContLang->lc( "exif-$tag-$val" ), $arg, $arg2 )->text();
        }
 
@@ -1125,8 +1241,8 @@ class FormatMetadata extends ContextSource {
         * Format a number, convert numbers from fractions into floating point
         * numbers, joins arrays of numbers with commas.
         *
-        * @param $num Mixed: the value to format
-        * @param $round float|int|bool digits to round to or false.
+        * @param mixed $num The value to format
+        * @param float|int|bool $round Digits to round to or false.
         * @return mixed A floating point number or whatever we were fed
         */
        private function formatNum( $num, $round = false ) {
@@ -1136,6 +1252,7 @@ class FormatMetadata extends ContextSource {
                        foreach ( $num as $number ) {
                                $out[] = $this->formatNum( $number );
                        }
+
                        return $this->getLanguage()->commaList( $out );
                }
                if ( preg_match( '/^(-?\d+)\/(\d+)$/', $num, $m ) ) {
@@ -1153,6 +1270,7 @@ class FormatMetadata extends ContextSource {
                        if ( is_numeric( $num ) && $round !== false ) {
                                $num = round( $num, $round );
                        }
+
                        return $this->getLanguage()->formatNum( $num );
                }
        }
@@ -1160,9 +1278,7 @@ class FormatMetadata extends ContextSource {
        /**
         * Format a rational number, reducing fractions
         *
-        * @private
-        *
-        * @param $num Mixed: the value to format
+        * @param mixed $num The value to format
         * @return mixed A floating point number or whatever we were fed
         */
        private function formatFraction( $num ) {
@@ -1176,14 +1292,15 @@ class FormatMetadata extends ContextSource {
                                return $this->formatNum( $numerator / $gcd ) . '/' . $this->formatNum( $denominator / $gcd );
                        }
                }
+
                return $this->formatNum( $num );
        }
 
        /**
         * Calculate the greatest common divisor of two integers.
         *
-        * @param $a Integer: Numerator
-        * @param $b Integer: Denominator
+        * @param int $a Numerator
+        * @param int $b Denominator
         * @return int
         * @private
         */
@@ -1203,6 +1320,7 @@ class FormatMetadata extends ContextSource {
                        $a = $b;
                        $b = $remainder;
                }
+
                return $a;
        }
 
@@ -1281,6 +1399,7 @@ class FormatMetadata extends ContextSource {
                        $catMsg = $this->exifMsg( 'iimcategory', $cat );
                        $val = $this->exifMsg( 'subjectnewscode', '', $val, $catMsg );
                }
+
                return $val;
        }
 
@@ -1288,8 +1407,8 @@ class FormatMetadata extends ContextSource {
         * Format a coordinate value, convert numbers from floating point
         * into degree minute second representation.
         *
-        * @param int $coord degrees, minutes and seconds
-        * @param string $type latitude or longitude (for if its a NWS or E)
+        * @param int $coord Degrees, minutes and seconds
+        * @param string $type Latitude or longitude (for if its a NWS or E)
         * @return mixed A floating point number or whatever we were fed
         */
        private function formatCoords( $coord, $type ) {
@@ -1324,16 +1443,15 @@ class FormatMetadata extends ContextSource {
        /**
         * Format the contact info field into a single value.
         *
-        * @param array $vals array with fields of the ContactInfo
-        *    struct defined in the IPTC4XMP spec. Or potentially
-        *    an array with one element that is a free form text
-        *    value from the older iptc iim 1:118 prop.
-        *
         * This function might be called from
         * JpegHandler::convertMetadataVersion which is why it is
         * public.
         *
-        * @return String of html-ish looking wikitext
+        * @param array $vals Array with fields of the ContactInfo
+        *    struct defined in the IPTC4XMP spec. Or potentially
+        *    an array with one element that is a free form text
+        *    value from the older iptc iim 1:118 prop.
+        * @return string HTML-ish looking wikitext
         * @since 1.23 no longer static
         */
        public function collapseContactInfo( $vals ) {
@@ -1358,6 +1476,7 @@ class FormatMetadata extends ContextSource {
                        foreach ( $vals as &$val ) {
                                $val = htmlspecialchars( $val );
                        }
+
                        return $this->flattenArrayReal( $vals );
                } else {
                        // We have a real ContactInfo field.
@@ -1408,10 +1527,10 @@ class FormatMetadata extends ContextSource {
                                                        $emails[] = $finalEmail;
                                                } else {
                                                        $emails[] = '[mailto:'
-                                                       . $finalEmail
-                                                       . ' <span class="email">'
-                                                       . $finalEmail
-                                                       . '</span>]';
+                                                               . $finalEmail
+                                                               . ' <span class="email">'
+                                                               . $finalEmail
+                                                               . '</span>]';
                                                }
                                        }
                                }
@@ -1440,6 +1559,7 @@ class FormatMetadata extends ContextSource {
                                        . htmlspecialchars( $vals['CiUrlWork'] )
                                        . '</span>';
                        }
+
                        return $this->msg( 'exif-contact-value', $email, $url,
                                $street, $city, $region, $postal, $country,
                                $tel )->text();
@@ -1462,6 +1582,7 @@ class FormatMetadata extends ContextSource {
                        }
                }
                $fields = array_map( 'strtolower', $fields );
+
                return $fields;
        }
 
@@ -1480,13 +1601,14 @@ class FormatMetadata extends ContextSource {
                // If revision deleted, exit immediately
                if ( $file->isDeleted( File::DELETED_FILE ) ) {
                        wfProfileOut( __METHOD__ );
+
                        return array();
                }
 
                $cacheKey = wfMemcKey(
                        'getExtendedMetadata',
                        $this->getLanguage()->getCode(),
-                       (int) $this->singleLang,
+                       (int)$this->singleLang,
                        $file->getSha1()
                );
 
@@ -1513,6 +1635,7 @@ class FormatMetadata extends ContextSource {
                }
 
                wfProfileOut( __METHOD__ );
+
                return $extendedMetadata;
        }
 
@@ -1529,7 +1652,8 @@ class FormatMetadata extends ContextSource {
                // If this is a remote file accessed via an API request, we already
                // have remote metadata so we just ignore any local one
                if ( $file instanceof ForeignAPIFile ) {
-                       // in case of error we pretend no metadata - this will get cached. Might or might not be a good idea.
+                       // In case of error we pretend no metadata - this will get cached.
+                       // Might or might not be a good idea.
                        return $file->getExtendedMetadata() ?: array();
                }
 
@@ -1556,7 +1680,7 @@ class FormatMetadata extends ContextSource {
                                $name = $text;
                        }
 
-                       $fileMetadata[ 'ObjectName' ] = array(
+                       $fileMetadata['ObjectName'] = array(
                                'value' => $name,
                                'source' => 'mediawiki-metadata',
                        );
@@ -1574,6 +1698,7 @@ class FormatMetadata extends ContextSource {
                }
 
                wfProfileOut( __METHOD__ );
+
                return $fileMetadata;
        }
 
@@ -1587,7 +1712,9 @@ class FormatMetadata extends ContextSource {
         * @return array [<property name> => ['value' => <value>]], or [] on error
         * @since 1.23
         */
-       protected function getExtendedMetadataFromHook( File $file, array $extendedMetadata, &$maxCacheTime ) {
+       protected function getExtendedMetadataFromHook( File $file, array $extendedMetadata,
+               &$maxCacheTime
+       ) {
                wfProfileIn( __METHOD__ );
 
                wfRunHooks( 'GetExtendedMetadata', array(
@@ -1600,12 +1727,13 @@ class FormatMetadata extends ContextSource {
 
                $visible = array_flip( self::getVisibleFields() );
                foreach ( $extendedMetadata as $key => $value ) {
-                       if ( !isset( $visible[ strtolower( $key ) ] ) ) {
+                       if ( !isset( $visible[strtolower( $key )] ) ) {
                                $extendedMetadata[$key]['hidden'] = '';
                        }
                }
 
                wfProfileOut( __METHOD__ );
+
                return $extendedMetadata;
        }
 
@@ -1617,8 +1745,7 @@ class FormatMetadata extends ContextSource {
         * @return mixed value in best language, null if there were no languages at all
         * @since 1.23
         */
-       protected function resolveMultilangValue( $value )
-       {
+       protected function resolveMultilangValue( $value ) {
                if (
                        !is_array( $value )
                        || !isset( $value['_type'] )
@@ -1732,10 +1859,15 @@ class FormatMetadata extends ContextSource {
         * @return array
         * @since 1.23
         */
-       protected function getPriorityLanguages()
-       {
-               $priorityLanguages = Language::getFallbacksIncludingSiteLanguage( $this->getLanguage()->getCode() );
-               $priorityLanguages = array_merge( (array) $this->getLanguage()->getCode(), $priorityLanguages[0], $priorityLanguages[1] );
+       protected function getPriorityLanguages() {
+               $priorityLanguages =
+                       Language::getFallbacksIncludingSiteLanguage( $this->getLanguage()->getCode() );
+               $priorityLanguages = array_merge(
+                       (array)$this->getLanguage()->getCode(),
+                       $priorityLanguages[0],
+                       $priorityLanguages[1]
+               );
+
                return $priorityLanguages;
        }
 }
@@ -1747,12 +1879,13 @@ class FormatMetadata extends ContextSource {
  *
  */
 class FormatExif {
-       var $meta;
+       /** @var array */
+       private $meta;
 
        /**
-        * @param $meta array
+        * @param array $meta
         */
-       function FormatExif( $meta ) {
+       function __construct( $meta ) {
                wfDeprecated( __METHOD__, '1.18' );
                $this->meta = $meta;
        }