&& not and, || not or
[lhc/web/wiklou.git] / includes / Exif.php
index 5581f1d..630821c 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 /**
+ * Exif metadata reader
+ *
  * 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
@@ -558,7 +560,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;
                }
@@ -618,7 +620,7 @@ class FormatExif {
         * @param $exif Array: the Exif data to format ( as returned by
         *                    Exif::getFilteredData() )
         */
-       function FormatExif( $exif ) {
+       function __construct( $exif ) {
                $this->mExif = $exif;
        }
 
@@ -1043,6 +1045,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;
@@ -1080,6 +1090,8 @@ 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 $wgLang->formatNum( $m[2] != 0 ? $m[1] / $m[2] : $num );
@@ -1136,15 +1148,3 @@ class FormatExif {
                return $a;
        }
 }
-
-/**
- * MW 1.6 compatibility
- */
-define( 'MW_EXIF_BYTE', Exif::BYTE );
-define( 'MW_EXIF_ASCII', Exif::ASCII );
-define( 'MW_EXIF_SHORT', Exif::SHORT );
-define( 'MW_EXIF_LONG', Exif::LONG );
-define( 'MW_EXIF_RATIONAL', Exif::RATIONAL );
-define( 'MW_EXIF_UNDEFINED', Exif::UNDEFINED );
-define( 'MW_EXIF_SLONG', Exif::SLONG );
-define( 'MW_EXIF_SRATIONAL', Exif::SRATIONAL );