Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / media / FormatMetadata.php
index 25f4806..f392bd1 100644 (file)
@@ -106,7 +106,7 @@ class FormatMetadata extends ContextSource {
                        // This seems ugly to wrap non-array's in an array just to unwrap again,
                        // especially when most of the time it is not an array
                        if ( !is_array( $tags[$tag] ) ) {
-                               $vals = array( $vals );
+                               $vals = [ $vals ];
                        }
 
                        // _type is a special value to say what array type
@@ -190,8 +190,18 @@ class FormatMetadata extends ContextSource {
 
                                        case 'PhotometricInterpretation':
                                                switch ( $val ) {
+                                                       case 0:
+                                                       case 1:
                                                        case 2:
+                                                       case 3:
+                                                       case 4:
+                                                       case 5:
                                                        case 6:
+                                                       case 8:
+                                                       case 9:
+                                                       case 10:
+                                                       case 32803:
+                                                       case 34892:
                                                                $val = $this->exifMsg( $tag, $val );
                                                                break;
                                                        default:
@@ -407,15 +417,15 @@ class FormatMetadata extends ContextSource {
                                                break;
 
                                        case 'Flash':
-                                               $flashDecode = array(
+                                               $flashDecode = [
                                                        '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();
+                                               ];
+                                               $flashMsgs = [];
                                                # 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.
@@ -1082,7 +1092,7 @@ class FormatMetadata extends ContextSource {
 
                                                        if ( $this->singleLang ) {
                                                                return Html::rawElement( 'span',
-                                                                       array( 'lang' => $pLang ), $vals[$pLang] );
+                                                                       [ 'lang' => $pLang ], $vals[$pLang] );
                                                        }
                                                }
                                        }
@@ -1097,7 +1107,7 @@ class FormatMetadata extends ContextSource {
                                                        $lang, false, $noHtml );
                                                if ( $this->singleLang ) {
                                                        return Html::rawElement( 'span',
-                                                               array( 'lang' => $lang ), $item );
+                                                               [ 'lang' => $lang ], $item );
                                                }
                                        }
                                        if ( $defaultItem !== false ) {
@@ -1224,9 +1234,9 @@ class FormatMetadata extends ContextSource {
         * @return mixed A floating point number or whatever we were fed
         */
        private function formatNum( $num, $round = false ) {
-               $m = array();
+               $m = [];
                if ( is_array( $num ) ) {
-                       $out = array();
+                       $out = [];
                        foreach ( $num as $number ) {
                                $out[] = $this->formatNum( $number );
                        }
@@ -1260,7 +1270,7 @@ class FormatMetadata extends ContextSource {
         * @return mixed A floating point number or whatever we were fed
         */
        private function formatFraction( $num ) {
-               $m = array();
+               $m = [];
                if ( preg_match( '/^(-?\d+)\/(\d+)$/', $num, $m ) ) {
                        $numerator = intval( $m[1] );
                        $denominator = intval( $m[2] );
@@ -1488,7 +1498,7 @@ class FormatMetadata extends ContextSource {
                                        . '</span>';
                        }
                        if ( isset( $vals['CiEmailWork'] ) ) {
-                               $emails = array();
+                               $emails = [];
                                // Have to split multiple emails at commas/new lines.
                                $splitEmails = explode( "\n", $vals['CiEmailWork'] );
                                foreach ( $splitEmails as $e1 ) {
@@ -1550,10 +1560,10 @@ class FormatMetadata extends ContextSource {
         * @since 1.23
         */
        public static function getVisibleFields() {
-               $fields = array();
+               $fields = [];
                $lines = explode( "\n", wfMessage( 'metadata-fields' )->inContentLanguage()->text() );
                foreach ( $lines as $line ) {
-                       $matches = array();
+                       $matches = [];
                        if ( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
                                $fields[] = $matches[1];
                        }
@@ -1575,7 +1585,7 @@ class FormatMetadata extends ContextSource {
 
                // If revision deleted, exit immediately
                if ( $file->isDeleted( File::DELETED_FILE ) ) {
-                       return array();
+                       return [];
                }
 
                $cacheKey = wfMemcKey(
@@ -1588,7 +1598,7 @@ class FormatMetadata extends ContextSource {
                $cachedValue = $cache->get( $cacheKey );
                if (
                        $cachedValue
-                       && Hooks::run( 'ValidateExtendedMetadataCache', array( $cachedValue['timestamp'], $file ) )
+                       && Hooks::run( 'ValidateExtendedMetadataCache', [ $cachedValue['timestamp'], $file ] )
                ) {
                        $extendedMetadata = $cachedValue['data'];
                } else {
@@ -1604,7 +1614,7 @@ class FormatMetadata extends ContextSource {
                        // outside fetchExtendedMetadata, but this way we don't need to redo the
                        // computation on a cache hit.
                        $this->sanitizeArrayForAPI( $extendedMetadata );
-                       $valueToCache = array( 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() );
+                       $valueToCache = [ 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() ];
                        $cache->set( $cacheKey, $valueToCache, $maxCacheTime );
                }
 
@@ -1626,18 +1636,18 @@ class FormatMetadata extends ContextSource {
                if ( $file instanceof ForeignAPIFile ) {
                        // In case of error we pretend no metadata - this will get cached.
                        // Might or might not be a good idea.
-                       return $file->getExtendedMetadata() ?: array();
+                       return $file->getExtendedMetadata() ?: [];
                }
 
                $uploadDate = wfTimestamp( TS_ISO_8601, $file->getTimestamp() );
 
-               $fileMetadata = array(
+               $fileMetadata = [
                        // This is modification time, which is close to "upload" time.
-                       'DateTime' => array(
+                       'DateTime' => [
                                'value' => $uploadDate,
                                'source' => 'mediawiki-metadata',
-                       ),
-               );
+                       ],
+               ];
 
                $title = $file->getTitle();
                if ( $title ) {
@@ -1650,10 +1660,10 @@ class FormatMetadata extends ContextSource {
                                $name = $text;
                        }
 
-                       $fileMetadata['ObjectName'] = array(
+                       $fileMetadata['ObjectName'] = [
                                'value' => $name,
                                'source' => 'mediawiki-metadata',
-                       );
+                       ];
                }
 
                return $fileMetadata;
@@ -1673,13 +1683,13 @@ class FormatMetadata extends ContextSource {
                &$maxCacheTime
        ) {
 
-               Hooks::run( 'GetExtendedMetadata', array(
+               Hooks::run( 'GetExtendedMetadata', [
                        &$extendedMetadata,
                        $file,
                        $this->getContext(),
                        $this->singleLang,
                        &$maxCacheTime
-               ) );
+               ] );
 
                $visible = array_flip( self::getVisibleFields() );
                foreach ( $extendedMetadata as $key => $value ) {
@@ -1745,7 +1755,7 @@ class FormatMetadata extends ContextSource {
                        return $value;
                } elseif ( isset( $value['_type'] ) && $value['_type'] === 'lang' ) {
                        // if this is a multilang array, process fields separately
-                       $newValue = array();
+                       $newValue = [];
                        foreach ( $value as $k => $v ) {
                                $newValue[$k] = $this->resolveMultivalueValue( $v );
                        }