http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96709
Revision: 96709
Author: bawolff
Date: 2011-09-10 01:09:45 +0000 (Sat, 10 Sep 2011)
Log Message:
-----------
Make it support the newer exif stuff in 1.18 where values can be an array. Also
add <span class="error"> arround errors
Modified Paths:
--------------
trunk/extensions/MediaFunctions/MediaFunctions.class.php
Modified: trunk/extensions/MediaFunctions/MediaFunctions.class.php
===================================================================
--- trunk/extensions/MediaFunctions/MediaFunctions.class.php 2011-09-10
00:07:41 UTC (rev 96708)
+++ trunk/extensions/MediaFunctions/MediaFunctions.class.php 2011-09-10
01:09:45 UTC (rev 96709)
@@ -98,15 +98,26 @@
* @param Parser $parser Calling parser
* @param string $name File name
* @param string $meta Metadata name
+ * @param string $index Index for compound exif fields
* @return string
*/
- public static function mediaexif( $parser, $name = '', $meta = '' ) {
+ public static function mediaexif( $parser, $name = '', $meta = '',
$index = '0' ) {
if ( ( $file = self::resolve( $name ) ) instanceof File ) {
$parser->mOutput->addImage(
$file->getTitle()->getDBkey() );
if ( $meta && $file->getHandler()->getMetadataType(
$file ) == 'exif' ) {
$data = unserialize( $file->getMetadata() );
- if ( $data && isset( $data[$meta] ) )
- return htmlspecialchars( $data[$meta] );
+ if ( $data && isset( $data[$meta] ) ) {
+ if ( is_array( $data[$meta] ) ) {
+ // Compound exif data (New in
1.18!)
+ if ( isset(
$data[$meta][$index] )
+ && !is_array(
$data[$meta][$index] )
+ ) {
+ return
htmlspecialchars( $data[$meta][$index] );
+ }
+ } elseif ( $index === '0' /* and
!is_array */ ) {
+ return htmlspecialchars(
$data[$meta] );
+ }
+ }
}
return '';
}
@@ -164,7 +175,6 @@
* @return string
*/
private static function error( $error, $name ) {
-
- return htmlspecialchars( wfMsgForContent( $error, $name ) );
+ return '<span class="error">' . htmlspecialchars(
wfMsgForContent( $error, $name ) ) . '</span>';
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs