From 35782b66182d7ae66aef61208eccd413bd6f4c2e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 21 Jul 2005 16:37:39 +0000 Subject: [PATCH] * Support SubjectDistance * Reworked FormatExif::msg() to take an argument * Broke off number formatting into FormatExif::formatNum() --- includes/Exif.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/includes/Exif.php b/includes/Exif.php index f826da95da..1bd46870cd 100644 --- a/includes/Exif.php +++ b/includes/Exif.php @@ -677,6 +677,10 @@ class FormatExif { break; } break; + + case 'SubjectDistance': + $tags[$tag] = $this->msg( $tag, '', $this->formatNum( $val ) ); + break; case 'MeteringMode': switch( $val ) { @@ -927,14 +931,10 @@ class FormatExif { case 'Make': case 'Model': case 'Software': - $tags[$tag] = wfMsg( strtolower( "exif-$tag-value" ), $val ); + $tags[$tag] = $this->msg( $tag, '', $val ); break; default: - if ( preg_match( '/^(\d+)\/(\d+)$/', $val, $m ) ) { - $tags[$tag] = $m[2] != 0 ? $m[1]/$m[2] : $val; - break; - } - $tags[$tag] = $val; + $tags[$tag] = $this->formatNum( $val ); break; } } @@ -943,13 +943,27 @@ class FormatExif { } /** - * Conviniance function for format() + * Conviniance function for getFormattedData() * * @param string $tag The tag name to pass on * @param string $val The value of the tag + * @param string $arg An argument to pass ($1) * @return string A wfMsg of "exif-$tag-$val" in lower case */ - function msg( $tag, $val ) { - return wfMsg( strtolower("exif-$tag-$val") ); + function msg( $tag, $val, $arg = null ) { + if ($val == '') + $val = 'value'; + return wfMsg( strtolower( "exif-$tag-$val" ), $arg ); + } + + /** + * @param mixed $num The value to format + * @return mixed A floating point number or whatever we were fed + */ + function formatNum( $num ) { + if ( preg_match( '/^(\d+)\/(\d+)$/', $num, $m ) ) + return $m[2] != 0 ? $m[1] / $m[2] : $num; + else + return $num; } } -- 2.20.1