r69657 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69656‎ | r69657 | r69658 >
Date:06:35, 21 July 2010
Author:bawolff
Status:ok
Tags:
Comment:
Do the last couple iptc-iim tags

2:15 (category), 2:20 (suppl. category),
2:30, 2:35 (release date), 2:37, 2:38 (expire date)
2:85 (byline title), 2:103 (original transmission reference)
Modified paths:
  • /branches/img_metadata/phase3/includes/Exif.php (modified) (history)
  • /branches/img_metadata/phase3/includes/media/IPTC.php (modified) (history)
  • /branches/img_metadata/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /branches/img_metadata/phase3/maintenance/language/messageTypes.inc (modified) (history)
  • /branches/img_metadata/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: branches/img_metadata/phase3/maintenance/language/messages.inc
@@ -2720,6 +2720,11 @@
27212721 'exif-writer',
27222722 'exif-languagecode',
27232723 'exif-iimversion',
 2724+ 'exif-iimcategory',
 2725+ 'exif-iimsupplementalcategory',
 2726+ 'exif-datetimeexpires',
 2727+ 'exif-datetimereleased',
 2728+ 'exif-originaltransmissionref',
27242729 ),
27252730 'exif-values' => array(
27262731 'exif-make-value',
Index: branches/img_metadata/phase3/maintenance/language/messageTypes.inc
@@ -632,4 +632,9 @@
633633 'exif-writer',
634634 'exif-languagecode',
635635 'exif-iimversion',
 636+ 'exif-iimcategory',
 637+ 'exif-iimsupplementalcategory',
 638+ 'exif-datetimeexpires',
 639+ 'exif-datetimereleased',
 640+ 'exif-originaltransmissionref',
636641 );
Index: branches/img_metadata/phase3/includes/Exif.php
@@ -969,6 +969,8 @@
970970 case 'DateTime':
971971 case 'DateTimeOriginal':
972972 case 'DateTimeDigitized':
 973+ case 'DateTimeReleased':
 974+ case 'DateTimeExpires':
973975 case 'GPSDateStamp':
974976 if ( $val == '0000:00:00 00:00:00' || $val == ' : : : : ' ) {
975977 $val = wfMsg( 'exif-unknowndate' );
@@ -1368,6 +1370,9 @@
13691371 case 'Contact':
13701372 case 'Writer':
13711373 case 'JPEGFileComment':
 1374+ case 'iimCategory':
 1375+ case 'iimSupplementalCategory':
 1376+ case 'OriginalTransmissionRef':
13721377
13731378 $val = htmlspecialchars( $val );
13741379 break;
Index: branches/img_metadata/phase3/includes/media/IPTC.php
@@ -51,8 +51,28 @@
5252 $data['Copyright'] = self::convIPTC( $val, $c );
5353 break;
5454 case '2#080': /* byline. Mapped with exif Artist */
55 - /* TODO: figure out how to handle byline title (2:85) */
56 - $data['Artist'] = self::convIPTC( $val, $c );
 55+ /* merge with byline title (2:85)
 56+ * like how exif does it with
 57+ * Title, person. Not sure if this is best
 58+ * approach since we no longer have the two fields
 59+ * seperate. each byline title entry corresponds to a
 60+ * specific byline. */
 61+
 62+ $bylines = self::convIPTC( $val, $c );
 63+ if ( isset( $parsed['2#085'] ) ) {
 64+ $titles = self::convIPTC( $parsed['2#085'], $c );
 65+ } else {
 66+ $titles = array();
 67+ }
 68+
 69+ for ( $i = 0; $i < count( $titles ); $i++ ) {
 70+ if ( isset( $bylines[$i] ) ) {
 71+ // theoretically this should always be set
 72+ // but doesn't hurt to be careful.
 73+ $bylines[$i] = $titles[$i] . ', ' . $bylines[$i];
 74+ }
 75+ }
 76+ $data['Artist'] = $bylines;
5777 break;
5878 case '2#025': /* keywords */
5979 $data['Keywords'] = self::convIPTC( $val, $c );
@@ -89,9 +109,16 @@
90110 *an individual." */
91111 $data['Source'] = self::convIPTC( $val, $c );
92112 break;
 113+
93114 case '2#007': /* edit status (lead, correction, etc) */
94115 $data['EditStatus'] = self::convIPTC( $val, $c );
95116 break;
 117+ case '2#015': /* category. deprected. max 3 letters in theory, often more */
 118+ $data['iimCategory'] = self::convIPTC( $val, $c );
 119+ break;
 120+ case '2#020': /* category. deprected. */
 121+ $data['iimSupplementalCategory'] = self::convIPTC( $val, $c );
 122+ break;
96123 case '2#010': /*urgency (1-8. 1 most, 5 normal, 8 low priority)*/
97124 $data['Urgency'] = self::convIPTC( $val, $c );
98125 break;
@@ -149,6 +176,13 @@
150177 */
151178 $data['CountryDestCode'] = self::convIPTC( $val, $c );
152179 break;
 180+ case '2#103':
 181+ /* original transmission ref.
 182+ * "A code representing the location of original transmission ac-
 183+ * cording to practices of the provider."
 184+ */
 185+ $data['OriginalTransmissionRef'] = self::convIPTC( $val, $c );
 186+ break;
153187 case '2#118': /*contact*/
154188 $data['Contact'] = self::convIPTC( $val, $c );
155189 break;
@@ -195,7 +229,32 @@
196230 }
197231 break;
198232
 233+ case '2#030':
 234+ //Date released.
 235+ if ( isset( $parsed['2#035'] ) ) {
 236+ $time = $parsed['2#035'];
 237+ } else {
 238+ $time = Array();
 239+ }
 240+ $timestamp = self::timeHelper( $val, $time, $c );
 241+ if ($timestamp) {
 242+ $data['DateTimeReleased'] = $timestamp;
 243+ }
 244+ break;
199245
 246+ case '2#037':
 247+ //Date expires.
 248+ if ( isset( $parsed['2#038'] ) ) {
 249+ $time = $parsed['2#038'];
 250+ } else {
 251+ $time = Array();
 252+ }
 253+ $timestamp = self::timeHelper( $val, $time, $c );
 254+ if ($timestamp) {
 255+ $data['DateTimeExpires'] = $timestamp;
 256+ }
 257+ break;
 258+
200259 case '2#000': /* iim version */
201260 // unlike other tags, this is a 2-byte binary number.
202261 //technically this is required if there is iptc data
@@ -209,10 +268,7 @@
210269 break;
211270
212271
213 - // TODO: the date related tags
214 - // does not do 2:103. Unsure if there is useful data there.
215 - // TODO: 2:15, 2:20
216 - // other things not currently done, and not sure if should:
 272+ // Things not currently done, and not sure if should:
217273 // 2:12
218274 // purposely does not do 2:125, 2:130, 2:131,
219275 // 2:47, 2:50, 2:45, 2:42, 2:8, 2:4, 2:3
Index: branches/img_metadata/phase3/languages/messages/MessagesEn.php
@@ -3786,6 +3786,11 @@
37873787 'exif-writer' => 'Writer',
37883788 'exif-languagecode' => 'Language',
37893789 'exif-iimversion' => 'IIM version',
 3790+'exif-iimcategory' => 'Category',
 3791+'exif-iimsupplementalcategory' => 'Supplemental categories',
 3792+'exif-datetimeexpires' => 'Do not use after',
 3793+'exif-datetimereleased' => 'Released on',
 3794+'exif-originaltransmissionref' => 'Original transmission location code',
37903795
37913796 # Make & model, can be wikified in order to link to the camera and model name
37923797 'exif-make-value' => '$1', # do not translate or duplicate this message to other languages

Status & tagging log