Merge "Pass context to FormatMetadata class on ImagePage"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 13 Mar 2015 07:01:30 +0000 (07:01 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 13 Mar 2015 07:01:30 +0000 (07:01 +0000)
includes/filerepo/file/File.php
includes/media/ExifBitmap.php
includes/media/GIF.php
includes/media/MediaHandler.php
includes/media/PNG.php
includes/media/SVG.php
includes/page/ImagePage.php

index 4fd332b..6edd6fc 100644 (file)
@@ -1777,14 +1777,15 @@ abstract class File implements IDBAccessObject {
        }
 
        /**
+        * @param bool|IContextSource $context Context to use (optional)
         * @return bool
         */
-       function formatMetadata() {
+       function formatMetadata( $context = false ) {
                if ( !$this->getHandler() ) {
                        return false;
                }
 
-               return $this->getHandler()->formatMetadata( $this, $this->getMetadata() );
+               return $this->getHandler()->formatMetadata( $this, $context );
        }
 
        /**
index b7657cb..f56a947 100644 (file)
@@ -125,15 +125,16 @@ class ExifBitmapHandler extends BitmapHandler {
 
        /**
         * @param File $image
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image ) {
+       function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
                }
 
-               return $this->formatMetadataHelper( $meta );
+               return $this->formatMetadataHelper( $meta, $context );
        }
 
        public function getCommonMetaArray( File $file ) {
index 5992be1..e3621fb 100644 (file)
@@ -44,15 +44,16 @@ class GIFHandler extends BitmapHandler {
 
        /**
         * @param File $image
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image ) {
+       function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
                }
 
-               return $this->formatMetadataHelper( $meta );
+               return $this->formatMetadataHelper( $meta, $context );
        }
 
        /**
index b88a1b1..0103946 100644 (file)
@@ -507,9 +507,10 @@ abstract class MediaHandler {
         * to some standard. That makes it possible to do things like visual
         * indication of grouped and chained streams in ogg container files.
         * @param File $image
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image ) {
+       function formatMetadata( $image, $context = false ) {
                return false;
        }
 
@@ -520,15 +521,16 @@ abstract class MediaHandler {
         * This is used by the media handlers that use the FormatMetadata class
         *
         * @param array $metadataArray Metadata array
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array Array for use displaying metadata.
         */
-       function formatMetadataHelper( $metadataArray ) {
+       function formatMetadataHelper( $metadataArray, $context = false ) {
                $result = array(
                        'visible' => array(),
                        'collapsed' => array()
                );
 
-               $formatted = FormatMetadata::getFormattedData( $metadataArray );
+               $formatted = FormatMetadata::getFormattedData( $metadataArray, $context );
                // Sort fields into visible and collapsed
                $visibleFields = $this->visibleMetadataFields();
                foreach ( $formatted as $name => $value ) {
index 3cf8488..5f1aca5 100644 (file)
@@ -49,15 +49,16 @@ class PNGHandler extends BitmapHandler {
 
        /**
         * @param File $image
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image ) {
+       function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
                }
 
-               return $this->formatMetadataHelper( $meta );
+               return $this->formatMetadataHelper( $meta, $context );
        }
 
        /**
index 53abfef..0618f7e 100644 (file)
@@ -410,9 +410,10 @@ class SvgHandler extends ImageHandler {
 
        /**
         * @param File $file
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $file ) {
+       function formatMetadata( $file, $context = false ) {
                $result = array(
                        'visible' => array(),
                        'collapsed' => array()
index 855f233..504fa74 100644 (file)
@@ -140,7 +140,7 @@ class ImagePage extends Article {
 
                if ( $wgShowEXIF && $this->displayImg->exists() ) {
                        // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
-                       $formattedMetadata = $this->displayImg->formatMetadata();
+                       $formattedMetadata = $this->displayImg->formatMetadata( $this->getContext() );
                        $showmeta = $formattedMetadata !== false;
                } else {
                        $showmeta = false;