X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fmedia%2FFormatMetadata.php;h=f392bd1c9ef1d85a4cb05280ddbdfee6ca356b85;hb=8eac2feedb7ee093d2c48504e1eb2b8a9dbc8452;hp=73eeba667ae49b75f55fda5029dea64e03b4873a;hpb=25d33bacb3496e9acb6ec0d7147b48a6a552c81d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/FormatMetadata.php b/includes/media/FormatMetadata.php index 73eeba667a..f392bd1c9e 100644 --- a/includes/media/FormatMetadata.php +++ b/includes/media/FormatMetadata.php @@ -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 @@ -417,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. @@ -1092,7 +1092,7 @@ class FormatMetadata extends ContextSource { if ( $this->singleLang ) { return Html::rawElement( 'span', - array( 'lang' => $pLang ), $vals[$pLang] ); + [ 'lang' => $pLang ], $vals[$pLang] ); } } } @@ -1107,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 ) { @@ -1234,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 ); } @@ -1270,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] ); @@ -1498,7 +1498,7 @@ class FormatMetadata extends ContextSource { . ''; } 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 ) { @@ -1560,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]; } @@ -1585,7 +1585,7 @@ class FormatMetadata extends ContextSource { // If revision deleted, exit immediately if ( $file->isDeleted( File::DELETED_FILE ) ) { - return array(); + return []; } $cacheKey = wfMemcKey( @@ -1598,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 { @@ -1614,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 ); } @@ -1636,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 ) { @@ -1660,10 +1660,10 @@ class FormatMetadata extends ContextSource { $name = $text; } - $fileMetadata['ObjectName'] = array( + $fileMetadata['ObjectName'] = [ 'value' => $name, 'source' => 'mediawiki-metadata', - ); + ]; } return $fileMetadata; @@ -1683,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 ) { @@ -1755,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 ); }