Merge "mediawiki.page.ajax.watch: Clean up and simplify code"
[lhc/web/wiklou.git] / includes / media / ExifBitmap.php
index aa9db3a..4bbafc1 100644 (file)
@@ -28,7 +28,6 @@
  * @ingroup Media
  */
 class ExifBitmapHandler extends BitmapHandler {
-
        const BROKEN_FILE = '-1'; // error extracting metadata
        const OLD_BROKEN_FILE = '0'; // outdated error extracting metadata.
 
@@ -76,9 +75,15 @@ class ExifBitmapHandler extends BitmapHandler {
                        }
                }
                $metadata['MEDIAWIKI_EXIF_VERSION'] = 1;
+
                return $metadata;
        }
 
+       /**
+        * @param $image
+        * @param array $metadata
+        * @return bool|int
+        */
        function isMetadataValid( $image, $metadata ) {
                global $wgShowEXIF;
                if ( !$wgShowEXIF ) {
@@ -89,6 +94,7 @@ class ExifBitmapHandler extends BitmapHandler {
                        # Old special value indicating that there is no Exif data in the file.
                        # or that there was an error well extracting the metadata.
                        wfDebug( __METHOD__ . ": back-compat version\n" );
+
                        return self::METADATA_COMPATIBLE;
                }
                if ( $metadata === self::BROKEN_FILE ) {
@@ -105,17 +111,20 @@ class ExifBitmapHandler extends BitmapHandler {
                        ) {
                                //back-compatible but old
                                wfDebug( __METHOD__ . ": back-compat version\n" );
+
                                return self::METADATA_COMPATIBLE;
                        }
                        # Wrong (non-compatible) version
                        wfDebug( __METHOD__ . ": wrong version\n" );
+
                        return self::METADATA_BAD;
                }
+
                return self::METADATA_GOOD;
        }
 
        /**
-        * @param $image File
+        * @param File $image
         * @return array|bool
         */
        function formatMetadata( $image ) {
@@ -160,12 +169,11 @@ class ExifBitmapHandler extends BitmapHandler {
         * @return array
         */
        function getImageSize( $image, $path ) {
-               global $wgEnableAutoRotation;
                $gis = parent::getImageSize( $image, $path );
 
                // Don't just call $image->getMetadata(); FSFile::getPropsFromPath() calls us with a bogus object.
                // This may mean we read EXIF data twice on initial upload.
-               if ( $wgEnableAutoRotation ) {
+               if ( BitmapHandler::autoRotateEnabled() ) {
                        $meta = $this->getMetadata( $image, $path );
                        $rotation = $this->getRotationForExif( $meta );
                } else {
@@ -177,6 +185,7 @@ class ExifBitmapHandler extends BitmapHandler {
                        $gis[0] = $gis[1];
                        $gis[1] = $width;
                }
+
                return $gis;
        }
 
@@ -193,12 +202,12 @@ class ExifBitmapHandler extends BitmapHandler {
         * @return int 0, 90, 180 or 270
         */
        public function getRotation( $file ) {
-               global $wgEnableAutoRotation;
-               if ( !$wgEnableAutoRotation ) {
+               if ( !BitmapHandler::autoRotateEnabled() ) {
                        return 0;
                }
 
                $data = $file->getMetadata();
+
                return $this->getRotationForExif( $data );
        }
 
@@ -208,8 +217,7 @@ class ExifBitmapHandler extends BitmapHandler {
         *
         * @param string $data
         * @return int 0, 90, 180 or 270
-        * @todo FIXME orientation can include flipping as well; see if this is an
-        * issue!
+        * @todo FIXME: Orientation can include flipping as well; see if this is an issue!
         */
        protected function getRotationForExif( $data ) {
                if ( !$data ) {
@@ -231,6 +239,7 @@ class ExifBitmapHandler extends BitmapHandler {
                                        return 0;
                        }
                }
+
                return 0;
        }
 }