r10225 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10224‎ | r10225 | r10226 >
Date:16:37, 21 July 2005
Author:avar
Status:old
Tags:
Comment:
* Support SubjectDistance
* Reworked FormatExif::msg() to take an argument
* Broke off number formatting into FormatExif::formatNum()
Modified paths:
  • /trunk/phase3/includes/Exif.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Exif.php
@@ -677,6 +677,10 @@
678678 break;
679679 }
680680 break;
 681+
 682+ case 'SubjectDistance':
 683+ $tags[$tag] = $this->msg( $tag, '', $this->formatNum( $val ) );
 684+ break;
681685
682686 case 'MeteringMode':
683687 switch( $val ) {
@@ -927,14 +931,10 @@
928932 case 'Make':
929933 case 'Model':
930934 case 'Software':
931 - $tags[$tag] = wfMsg( strtolower( "exif-$tag-value" ), $val );
 935+ $tags[$tag] = $this->msg( $tag, '', $val );
932936 break;
933937 default:
934 - if ( preg_match( '/^(\d+)\/(\d+)$/', $val, $m ) ) {
935 - $tags[$tag] = $m[2] != 0 ? $m[1]/$m[2] : $val;
936 - break;
937 - }
938 - $tags[$tag] = $val;
 938+ $tags[$tag] = $this->formatNum( $val );
939939 break;
940940 }
941941 }
@@ -943,13 +943,27 @@
944944 }
945945
946946 /**
947 - * Conviniance function for format()
 947+ * Conviniance function for getFormattedData()
948948 *
949949 * @param string $tag The tag name to pass on
950950 * @param string $val The value of the tag
 951+ * @param string $arg An argument to pass ($1)
951952 * @return string A wfMsg of "exif-$tag-$val" in lower case
952953 */
953 - function msg( $tag, $val ) {
954 - return wfMsg( strtolower("exif-$tag-$val") );
 954+ function msg( $tag, $val, $arg = null ) {
 955+ if ($val == '')
 956+ $val = 'value';
 957+ return wfMsg( strtolower( "exif-$tag-$val" ), $arg );
955958 }
 959+
 960+ /**
 961+ * @param mixed $num The value to format
 962+ * @return mixed A floating point number or whatever we were fed
 963+ */
 964+ function formatNum( $num ) {
 965+ if ( preg_match( '/^(\d+)\/(\d+)$/', $num, $m ) )
 966+ return $m[2] != 0 ? $m[1] / $m[2] : $num;
 967+ else
 968+ return $num;
 969+ }
956970 }

Status & tagging log