r76231 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76230‎ | r76231 | r76232 >
Date:05:08, 7 November 2010
Author:bawolff
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /branches/img_metadata/phase3/includes/media/FormatMetadata.php (modified) (history)
  • /branches/img_metadata/phase3/includes/media/JpegMetadataExtractor.php (modified) (history)
  • /branches/img_metadata/phase3/includes/media/XMP.php (modified) (history)
  • /branches/img_metadata/phase3/includes/media/XMPInfo.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesFr.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesFrp.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesIt.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesJa.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesNl.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesOc.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesPms.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesScn.php (modified) (history)

Diff [purge]

Index: branches/img_metadata/phase3/docs/hooks.txt
@@ -1897,5 +1897,14 @@
18981898 $row: The database row for the revision.
18991899 $text: The revision text.
19001900
 1901+'XMPGetInfo': Called when obtaining the list of XMP tags to extract. Can be used to add
 1902+ additional tags to extract.
 1903+$items: Array containing information on which items to extract. See XMPInfo for details on the format.
 1904+
 1905+'XMPGetResults': Called just before returning the results array of parsing xmp data. Can be
 1906+ used to post-process the results.
 1907+$data: Array of metadata sections (such as $data['xmp-general']) each section is an array of
 1908+ metadata tags returned (each tag is either a value, or an array of values).
 1909+
19011910 More hooks might be available but undocumented, you can execute
19021911 ./maintenance/findhooks.php to find hidden one.
Index: branches/img_metadata/phase3/includes/media/FormatMetadata.php
@@ -1243,12 +1243,30 @@
12441244 . '</span>';
12451245 }
12461246 if ( isset( $vals['CiEmailWork'] ) ) {
1247 - $email = '[mailto:'
1248 - . rawurlencode(
1249 - $vals['CiEmailWork'] )
1250 - . ' <span class="email">'
1251 - . $vals['CiEmailWork']
1252 - . '</span>]';
 1247+ $emails = array();
 1248+ // Have to split multiple emails at commas/new lines.
 1249+ $splitEmails = explode( "\n", $vals['CiEmailWork'] );
 1250+ foreach ( $splitEmails as $e1 ) {
 1251+ // Also split on comma
 1252+ foreach ( explode( ',', $e1 ) as $e2 ) {
 1253+ $finalEmail = trim( $e2 );
 1254+ if ( $finalEmail == ',' || $finalEmail == '' ) {
 1255+ continue;
 1256+ }
 1257+ if ( strpos( $finalEmail, '<' ) !== false ) {
 1258+ // Don't do fancy formatting to
 1259+ // "My name" <foo@bar.com> style stuff
 1260+ $emails[] = $finalEmail;
 1261+ } else {
 1262+ $emails[] = '[mailto:'
 1263+ . $finalEmail
 1264+ . ' <span class="email">'
 1265+ . $finalEmail
 1266+ . '</span>]';
 1267+ }
 1268+ }
 1269+ }
 1270+ $email = implode( ', ', $emails );
12531271 }
12541272 if ( isset( $vals['CiTelWork'] ) ) {
12551273 $tel = '<span class="tel">'
Index: branches/img_metadata/phase3/includes/media/XMP.php
@@ -132,6 +132,8 @@
133133
134134 $data = $this->results;
135135
 136+ wfRunHooks('XMPGetResults', Array(&$data));
 137+
136138 if ( isset( $data['xmp-special']['AuthorsPosition'] )
137139 && is_string( $data['xmp-special']['AuthorsPosition'] )
138140 && isset( $data['xmp-general']['Artist'][0] )
Index: branches/img_metadata/phase3/includes/media/XMPInfo.php
@@ -10,9 +10,17 @@
1111 * @return Array XMP item configuration array.
1212 */
1313 public static function getItems ( ) {
 14+ if( !self::ranHooks ) {
 15+ // This is for if someone makes a custom metadata extension.
 16+ // For example, a medical wiki might want to decode DICOM xmp properties.
 17+ wfRunHooks('XMPGetInfo', Array(&self::$items));
 18+ self::ranHooks = true; // Only want to do this once.
 19+ }
1420 return self::$items;
1521 }
1622
 23+ static private ranHooks = false;
 24+
1725 /**
1826 * XMPInfo::$items keeps a list of all the items
1927 * we are interested to extract, as well as
Index: branches/img_metadata/phase3/includes/media/JpegMetadataExtractor.php
@@ -75,6 +75,13 @@
7676 $segments["XMP"] = substr( $temp, 29 );
7777 } elseif ( substr( $temp, 0, 35 ) === "http://ns.adobe.com/xmp/extension/\x00" ) {
7878 $segments["XMP_ext"][] = substr( $temp, 35 );
 79+ } elseif ( substr( $temp, 0, 29 ) === "XMP\x00://ns.adobe.com/xap/1.0/\x00" ) {
 80+ // Some images (especially flickr images) seem to have this.
 81+ // I really have no idea what the deal is with them, but
 82+ // whatever...
 83+ $segments["XMP"] = substr( $temp, 29 );
 84+ wfDebug( __METHOD__ . ' Found XMP section with wrong app identifier '
 85+ . "Using anyways.\n" );
7986 }
8087 } elseif ( $buffer === "\xED" ) {
8188 // APP13 - PSIR. IPTC and some photoshop stuff
@@ -169,7 +176,7 @@
170177
171178 // this should not happen, but check.
172179 if ( $lenData['len'] + $offset > $appLen ) {
173 - wfDebug( __METHOD__ . ' PSIR data too long.' );
 180+ wfDebug( __METHOD__ . " PSIR data too long.\n" );
174181 return 'iptc-no-hash';
175182 }
176183
Index: branches/img_metadata/phase3/languages/messages/MessagesFrp.php
@@ -3214,7 +3214,7 @@
32153215 'exif-planarconfiguration-1' => 'Balyês ategnentes',
32163216 'exif-planarconfiguration-2' => 'Balyês sèparâs',
32173217
3218 -'exif-colorspace-ffff.h' => 'Pas calibrâ',
 3218+'exif-colorspace-65535' => 'Pas calibrâ',
32193219
32203220 'exif-componentsconfiguration-0' => 'Ègziste pas',
32213221 'exif-componentsconfiguration-5' => 'V',
Index: branches/img_metadata/phase3/languages/messages/MessagesIt.php
@@ -2974,7 +2974,7 @@
29752975 'exif-xyresolution-i' => '$1 punti per pollice (dpi)',
29762976 'exif-xyresolution-c' => '$1 punti per centimetro (dpc)',
29772977
2978 -'exif-colorspace-ffff.h' => 'Non calibrato',
 2978+'exif-colorspace-65535' => 'Non calibrato',
29792979
29802980 'exif-componentsconfiguration-0' => 'assente',
29812981
Index: branches/img_metadata/phase3/languages/messages/MessagesScn.php
@@ -2674,7 +2674,7 @@
26752675 'exif-xyresolution-i' => '$1 punti pi puseri (dpi)',
26762676 'exif-xyresolution-c' => '$1 punti pi cintìmitru (dpc)',
26772677
2678 -'exif-colorspace-ffff.h' => 'Nun calibbratu',
 2678+'exif-colorspace-65535' => 'Nun calibbratu',
26792679
26802680 'exif-componentsconfiguration-0' => 'assenti',
26812681
Index: branches/img_metadata/phase3/languages/messages/MessagesJa.php
@@ -2981,7 +2981,7 @@
29822982 'exif-planarconfiguration-1' => '点順次フォーマット',
29832983 'exif-planarconfiguration-2' => '面順次フォーマット',
29842984
2985 -'exif-colorspace-ffff.h' => 'その他',
 2985+'exif-colorspace-65535' => 'その他',
29862986
29872987 'exif-componentsconfiguration-0' => 'なし',
29882988
Index: branches/img_metadata/phase3/languages/messages/MessagesFr.php
@@ -3159,7 +3159,7 @@
31603160 'exif-planarconfiguration-1' => 'Données contiguës',
31613161 'exif-planarconfiguration-2' => 'Données séparées',
31623162
3163 -'exif-colorspace-ffff.h' => 'Non calibré',
 3163+'exif-colorspace-65535' => 'Non calibré',
31643164
31653165 'exif-componentsconfiguration-0' => 'N’existe pas',
31663166 'exif-componentsconfiguration-5' => 'V',
Index: branches/img_metadata/phase3/languages/messages/MessagesNl.php
@@ -3242,7 +3242,7 @@
32433243 'exif-planarconfiguration-1' => 'chunky gegevensformaat',
32443244 'exif-planarconfiguration-2' => 'planar gegevensformaat',
32453245
3246 -'exif-colorspace-ffff.h' => 'Ongekalibreerd',
 3246+'exif-colorspace-65535' => 'Ongekalibreerd',
32473247
32483248 'exif-componentsconfiguration-0' => 'bestaat niet',
32493249
Index: branches/img_metadata/phase3/languages/messages/MessagesOc.php
@@ -3059,7 +3059,7 @@
30603060 'exif-planarconfiguration-1' => 'Donadas atenentas',
30613061 'exif-planarconfiguration-2' => 'Donadas separadas',
30623062
3063 -'exif-colorspace-ffff.h' => 'Pas calibrat',
 3063+'exif-colorspace-65535' => 'Pas calibrat',
30643064
30653065 'exif-componentsconfiguration-0' => 'existís pas',
30663066 'exif-componentsconfiguration-5' => 'V',
Index: branches/img_metadata/phase3/languages/messages/MessagesPms.php
@@ -2853,7 +2853,7 @@
28542854 'exif-xyresolution-i' => '$1 pont për pòles (dpi)',
28552855 'exif-xyresolution-c' => '$1 pont për centim (dpc)',
28562856
2857 -'exif-colorspace-ffff.h' => 'Nen calibrà',
 2857+'exif-colorspace-65535' => 'Nen calibrà',
28582858
28592859 'exif-componentsconfiguration-0' => 'a esist pa',
28602860

Follow-up revisions

RevisionCommit summaryAuthorDate
r76232follow-up to r76231 - For some reason I forgot to test before hitting commit ...bawolff05:27, 7 November 2010

Status & tagging log