http://www.mediawiki.org/wiki/Special:Code/MediaWiki/76231

Revision: 76231
Author:   bawolff
Date:     2010-11-07 05:08:48 +0000 (Sun, 07 Nov 2010)
Log Message:
-----------
Misc. things (fix some messages, add hooks, fix extraction for certain weird 
images):
*Some images (especially those from fickr) have weird application identifier 
for XMP APP1 segment
*Fix display of multiple emails from CiEmailWork (iptc4xmp) field.
*Add a hook to allow extensions to extract additional xmp fields
*Add a hook to allow extensions to post-process the result of extracting the XMP
*Rename the message exif-colorspace-ffff.h to exif-colorspace-65535 for any 
language that had a correct translation. 

Modified Paths:
--------------
    branches/img_metadata/phase3/docs/hooks.txt
    branches/img_metadata/phase3/includes/media/FormatMetadata.php
    branches/img_metadata/phase3/includes/media/JpegMetadataExtractor.php
    branches/img_metadata/phase3/includes/media/XMP.php
    branches/img_metadata/phase3/includes/media/XMPInfo.php
    branches/img_metadata/phase3/languages/messages/MessagesFr.php
    branches/img_metadata/phase3/languages/messages/MessagesFrp.php
    branches/img_metadata/phase3/languages/messages/MessagesIt.php
    branches/img_metadata/phase3/languages/messages/MessagesJa.php
    branches/img_metadata/phase3/languages/messages/MessagesNl.php
    branches/img_metadata/phase3/languages/messages/MessagesOc.php
    branches/img_metadata/phase3/languages/messages/MessagesPms.php
    branches/img_metadata/phase3/languages/messages/MessagesScn.php

Modified: branches/img_metadata/phase3/docs/hooks.txt
===================================================================
--- branches/img_metadata/phase3/docs/hooks.txt 2010-11-07 03:30:48 UTC (rev 
76230)
+++ branches/img_metadata/phase3/docs/hooks.txt 2010-11-07 05:08:48 UTC (rev 
76231)
@@ -1897,5 +1897,14 @@
 $row: The database row for the revision.
 $text: The revision text.
 
+'XMPGetInfo': Called when obtaining the list of XMP tags to extract. Can be 
used to add
+       additional tags to extract.
+$items: Array containing information on which items to extract. See XMPInfo 
for details on the format.
+
+'XMPGetResults': Called just before returning the results array of parsing xmp 
data. Can be
+       used to post-process the results.
+$data: Array of metadata sections (such as $data['xmp-general']) each section 
is an array of
+       metadata tags returned (each tag is either a value, or an array of 
values).
+
 More hooks might be available but undocumented, you can execute
 ./maintenance/findhooks.php to find hidden one.

Modified: branches/img_metadata/phase3/includes/media/FormatMetadata.php
===================================================================
--- branches/img_metadata/phase3/includes/media/FormatMetadata.php      
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/includes/media/FormatMetadata.php      
2010-11-07 05:08:48 UTC (rev 76231)
@@ -1243,12 +1243,30 @@
                                        . '</span>';
                        }
                        if ( isset( $vals['CiEmailWork'] ) ) {
-                               $email = '[mailto:'
-                                       . rawurlencode(
-                                               $vals['CiEmailWork'] )
-                                       . ' <span class="email">'
-                                       . $vals['CiEmailWork']
-                                       . '</span>]';
+                               $emails = array();
+                               // Have to split multiple emails at commas/new 
lines.
+                               $splitEmails = explode( "\n", 
$vals['CiEmailWork'] );
+                               foreach ( $splitEmails as $e1 ) {
+                                       // Also split on comma
+                                       foreach ( explode( ',', $e1 ) as $e2 ) {
+                                               $finalEmail = trim( $e2 );
+                                               if ( $finalEmail == ',' || 
$finalEmail == '' ) {
+                                                       continue;
+                                               }
+                                               if ( strpos( $finalEmail, '<' ) 
!== false ) {
+                                                       // Don't do fancy 
formatting to
+                                                       // "My name" 
<f...@bar.com> style stuff
+                                                       $emails[] = $finalEmail;
+                                               } else {
+                                                       $emails[] = '[mailto:'
+                                                       . $finalEmail
+                                                       . ' <span 
class="email">'
+                                                       . $finalEmail
+                                                       . '</span>]';
+                                               }
+                                       }
+                               }
+                               $email = implode( ', ', $emails );
                        }
                        if ( isset( $vals['CiTelWork'] ) ) {
                                $tel = '<span class="tel">'

Modified: branches/img_metadata/phase3/includes/media/JpegMetadataExtractor.php
===================================================================
--- branches/img_metadata/phase3/includes/media/JpegMetadataExtractor.php       
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/includes/media/JpegMetadataExtractor.php       
2010-11-07 05:08:48 UTC (rev 76231)
@@ -75,6 +75,13 @@
                                        $segments["XMP"] = substr( $temp, 29 );
                                } elseif ( substr( $temp, 0, 35 ) === 
"http://ns.adobe.com/xmp/extension/\x00"; ) {
                                        $segments["XMP_ext"][] = substr( $temp, 
35 );
+                               } elseif ( substr( $temp, 0, 29 ) === 
"XMP\x00://ns.adobe.com/xap/1.0/\x00" ) {
+                                       // Some images (especially flickr 
images) seem to have this.
+                                       // I really have no idea what the deal 
is with them, but
+                                       // whatever...
+                                       $segments["XMP"] = substr( $temp, 29 );
+                                       wfDebug( __METHOD__ . ' Found XMP 
section with wrong app identifier '
+                                               . "Using anyways.\n" ); 
                                }
                        } elseif ( $buffer === "\xED" ) {
                                // APP13 - PSIR. IPTC and some photoshop stuff
@@ -169,7 +176,7 @@
 
                        // this should not happen, but check.
                        if ( $lenData['len'] + $offset > $appLen ) {
-                               wfDebug( __METHOD__ . ' PSIR data too long.' );
+                               wfDebug( __METHOD__ . " PSIR data too long.\n" 
);
                                return 'iptc-no-hash';
                        }
 

Modified: branches/img_metadata/phase3/includes/media/XMP.php
===================================================================
--- branches/img_metadata/phase3/includes/media/XMP.php 2010-11-07 03:30:48 UTC 
(rev 76230)
+++ branches/img_metadata/phase3/includes/media/XMP.php 2010-11-07 05:08:48 UTC 
(rev 76231)
@@ -132,6 +132,8 @@
 
                $data = $this->results;
 
+               wfRunHooks('XMPGetResults', Array(&$data));
+
                if ( isset( $data['xmp-special']['AuthorsPosition'] )
                        && is_string( $data['xmp-special']['AuthorsPosition'] )
                        && isset( $data['xmp-general']['Artist'][0] )

Modified: branches/img_metadata/phase3/includes/media/XMPInfo.php
===================================================================
--- branches/img_metadata/phase3/includes/media/XMPInfo.php     2010-11-07 
03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/includes/media/XMPInfo.php     2010-11-07 
05:08:48 UTC (rev 76231)
@@ -10,9 +10,17 @@
         * @return Array XMP item configuration array.
        */
        public static function getItems ( ) {
+               if( !self::ranHooks ) {
+                       // This is for if someone makes a custom metadata 
extension.
+                       // For example, a medical wiki might want to decode 
DICOM xmp properties.
+                       wfRunHooks('XMPGetInfo', Array(&self::$items));
+                       self::ranHooks = true; // Only want to do this once.
+               }
                return self::$items;
        }
 
+       static private ranHooks = false;
+
        /**
        * XMPInfo::$items keeps a list of all the items
        * we are interested to extract, as well as

Modified: branches/img_metadata/phase3/languages/messages/MessagesFr.php
===================================================================
--- branches/img_metadata/phase3/languages/messages/MessagesFr.php      
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/languages/messages/MessagesFr.php      
2010-11-07 05:08:48 UTC (rev 76231)
@@ -3159,7 +3159,7 @@
 'exif-planarconfiguration-1' => 'Données contiguës',
 'exif-planarconfiguration-2' => 'Données séparées',
 
-'exif-colorspace-ffff.h' => 'Non calibré',
+'exif-colorspace-65535' => 'Non calibré',
 
 'exif-componentsconfiguration-0' => 'N’existe pas',
 'exif-componentsconfiguration-5' => 'V',

Modified: branches/img_metadata/phase3/languages/messages/MessagesFrp.php
===================================================================
--- branches/img_metadata/phase3/languages/messages/MessagesFrp.php     
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/languages/messages/MessagesFrp.php     
2010-11-07 05:08:48 UTC (rev 76231)
@@ -3214,7 +3214,7 @@
 'exif-planarconfiguration-1' => 'Balyês ategnentes',
 'exif-planarconfiguration-2' => 'Balyês sèparâs',
 
-'exif-colorspace-ffff.h' => 'Pas calibrâ',
+'exif-colorspace-65535' => 'Pas calibrâ',
 
 'exif-componentsconfiguration-0' => 'Ègziste pas',
 'exif-componentsconfiguration-5' => 'V',

Modified: branches/img_metadata/phase3/languages/messages/MessagesIt.php
===================================================================
--- branches/img_metadata/phase3/languages/messages/MessagesIt.php      
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/languages/messages/MessagesIt.php      
2010-11-07 05:08:48 UTC (rev 76231)
@@ -2974,7 +2974,7 @@
 'exif-xyresolution-i' => '$1 punti per pollice (dpi)',
 'exif-xyresolution-c' => '$1 punti per centimetro (dpc)',
 
-'exif-colorspace-ffff.h' => 'Non calibrato',
+'exif-colorspace-65535' => 'Non calibrato',
 
 'exif-componentsconfiguration-0' => 'assente',
 

Modified: branches/img_metadata/phase3/languages/messages/MessagesJa.php
===================================================================
--- branches/img_metadata/phase3/languages/messages/MessagesJa.php      
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/languages/messages/MessagesJa.php      
2010-11-07 05:08:48 UTC (rev 76231)
@@ -2981,7 +2981,7 @@
 'exif-planarconfiguration-1' => '点順次フォーマット',
 'exif-planarconfiguration-2' => '面順次フォーマット',
 
-'exif-colorspace-ffff.h' => 'その他',
+'exif-colorspace-65535' => 'その他',
 
 'exif-componentsconfiguration-0' => 'なし',
 

Modified: branches/img_metadata/phase3/languages/messages/MessagesNl.php
===================================================================
--- branches/img_metadata/phase3/languages/messages/MessagesNl.php      
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/languages/messages/MessagesNl.php      
2010-11-07 05:08:48 UTC (rev 76231)
@@ -3242,7 +3242,7 @@
 'exif-planarconfiguration-1' => 'chunky gegevensformaat',
 'exif-planarconfiguration-2' => 'planar gegevensformaat',
 
-'exif-colorspace-ffff.h' => 'Ongekalibreerd',
+'exif-colorspace-65535' => 'Ongekalibreerd',
 
 'exif-componentsconfiguration-0' => 'bestaat niet',
 

Modified: branches/img_metadata/phase3/languages/messages/MessagesOc.php
===================================================================
--- branches/img_metadata/phase3/languages/messages/MessagesOc.php      
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/languages/messages/MessagesOc.php      
2010-11-07 05:08:48 UTC (rev 76231)
@@ -3059,7 +3059,7 @@
 'exif-planarconfiguration-1' => 'Donadas atenentas',
 'exif-planarconfiguration-2' => 'Donadas separadas',
 
-'exif-colorspace-ffff.h' => 'Pas calibrat',
+'exif-colorspace-65535' => 'Pas calibrat',
 
 'exif-componentsconfiguration-0' => 'existís pas',
 'exif-componentsconfiguration-5' => 'V',

Modified: branches/img_metadata/phase3/languages/messages/MessagesPms.php
===================================================================
--- branches/img_metadata/phase3/languages/messages/MessagesPms.php     
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/languages/messages/MessagesPms.php     
2010-11-07 05:08:48 UTC (rev 76231)
@@ -2853,7 +2853,7 @@
 'exif-xyresolution-i' => '$1 pont për pòles (dpi)',
 'exif-xyresolution-c' => '$1 pont për centim (dpc)',
 
-'exif-colorspace-ffff.h' => 'Nen calibrà',
+'exif-colorspace-65535' => 'Nen calibrà',
 
 'exif-componentsconfiguration-0' => 'a esist pa',
 

Modified: branches/img_metadata/phase3/languages/messages/MessagesScn.php
===================================================================
--- branches/img_metadata/phase3/languages/messages/MessagesScn.php     
2010-11-07 03:30:48 UTC (rev 76230)
+++ branches/img_metadata/phase3/languages/messages/MessagesScn.php     
2010-11-07 05:08:48 UTC (rev 76231)
@@ -2674,7 +2674,7 @@
 'exif-xyresolution-i' => '$1 punti pi puseri (dpi)',
 'exif-xyresolution-c' => '$1 punti pi cintìmitru (dpc)',
 
-'exif-colorspace-ffff.h' => 'Nun calibbratu',
+'exif-colorspace-65535' => 'Nun calibbratu',
 
 'exif-componentsconfiguration-0' => 'assenti',
 


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to