X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/mediawiki.git/blobdiff_plain/74c929b24b048c9f1e31e17db757ae4195cd7673..2acc6b86c3191c408dc027d5164c397bea97d37b:/includes/Exif.php diff --git a/includes/Exif.php b/includes/Exif.php index d5cf09cf..594e633a 100644 --- a/includes/Exif.php +++ b/includes/Exif.php @@ -1,10 +1,5 @@ - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -20,7 +15,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * + * @ingroup Media + * @author Ævar Arnfjörð Bjarmason + * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License * @see http://exif.org/Exif2-2.PDF The Exif 2.2 specification + * @file */ /** @@ -28,23 +28,21 @@ * @ingroup Media */ class Exif { + + const BYTE = 1; //!< An 8-bit (1-byte) unsigned integer. + const ASCII = 2; //!< An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL. + const SHORT = 3; //!< A 16-bit (2-byte) unsigned integer. + const LONG = 4; //!< A 32-bit (4-byte) unsigned integer. + const RATIONAL = 5; //!< Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator + const UNDEFINED = 7; //!< An 8-bit byte that can take any value depending on the field definition + const SLONG = 9; //!< A 32-bit (4-byte) signed integer (2's complement notation), + const SRATIONAL = 10; //!< Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator. + //@{ /* @var array * @private */ - /**#@+ - * Exif tag type definition - */ - const BYTE = 1; # An 8-bit (1-byte) unsigned integer. - const ASCII = 2; # An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL. - const SHORT = 3; # A 16-bit (2-byte) unsigned integer. - const LONG = 4; # A 32-bit (4-byte) unsigned integer. - const RATIONAL = 5; # Two LONGs. The first LONG is the numerator and the second LONG expresses the denominator - const UNDEFINED = 7; # An 8-bit byte that can take any value depending on the field definition - const SLONG = 9; # A 32-bit (4-byte) signed integer (2's complement notation), - const SRATIONAL = 10; # Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator. - /** * Exif tags grouped by category, the tagname itself is the key and the type * is the value, in the case of more than one possible value type they are @@ -560,7 +558,7 @@ class Exif { * @param $fname String: * @param $action Mixed: , default NULL. */ - function debug( $in, $fname, $action = NULL ) { + function debug( $in, $fname, $action = null ) { if ( !$this->log ) { return; } @@ -1045,6 +1043,14 @@ class FormatExif { $this->formatNum( $val ) ); break; + // Do not transform fields with pure text. + // For some languages the formatNum() conversion results to wrong output like + // foo,bar@example,com or foo٫bar@example٫com + case 'ImageDescription': + case 'Artist': + case 'Copyright': + $tags[$tag] = htmlspecialchars( $val ); + break; default: $tags[$tag] = $this->formatNum( $val ); break; @@ -1082,11 +1088,13 @@ class FormatExif { * @return mixed A floating point number or whatever we were fed */ function formatNum( $num ) { + global $wgLang; + $m = array(); if ( preg_match( '/^(\d+)\/(\d+)$/', $num, $m ) ) - return $m[2] != 0 ? $m[1] / $m[2] : $num; + return $wgLang->formatNum( $m[2] != 0 ? $m[1] / $m[2] : $num ); else - return $num; + return $wgLang->formatNum( $num ); } /** @@ -1105,7 +1113,7 @@ class FormatExif { $gcd = $this->gcd( $numerator, $denominator ); if( $gcd != 0 ) { // 0 shouldn't happen! ;) - return $numerator / $gcd . '/' . $denominator / $gcd; + return $this->formatNum( $numerator / $gcd ) . '/' . $this->formatNum( $denominator / $gcd ); } } return $this->formatNum( $num );