- Timestamp:
- Oct 26, 2010, 10:48:08 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AMetaData/JpegMetaData/Readers/IptcReader.class.php
r6949 r7399 217 217 /* for each entries, convert value to human readable tag value 218 218 * 219 * build a special 'keywords' tag made as an array from all iptc 'keywords' (0x0219) tags found 219 * repeatable values are stored in arrays 220 * 221 * for Subject Reference tags (0x020C), made derived tags (0x020Cnn) 220 222 */ 221 $ keywordsTag=null;223 $repeatableTags=array(); 222 224 foreach($this->entries as $key => $tag) 223 225 { 224 226 $this->setTagProperties($tag); 225 if($tag->getId()==0x0219) 226 { 227 if(is_null($keywordsTag)) 228 { 229 $keywordsTag=new Tag( 230 0x0219, 231 array($tag->getValue()), 232 $tag->getName(), 233 array($tag->getLabel()), 234 "", 235 $tag->isKnown(), 236 $tag->isImplemented(), 237 $tag->isTranslatable(), 238 $tag->getSchema() 239 ); 240 } 241 else 242 { 243 $keywordsTag->setValue(array_merge($keywordsTag->getValue(), array($tag->getValue()))); 244 $keywordsTag->setLabel(array_merge($keywordsTag->getLabel(), array($tag->getLabel()))); 245 } 246 } 247 } 248 if(!is_null($keywordsTag)) 227 228 $list=array(); 229 230 if($tag->getId()==0x020C) 231 { 232 $tmpValues=explode(':', $tag->getValue()); 233 $tmpLabels=explode(':', $tag->getLabel()); 234 235 $list=array( 236 array( 237 'id' => 0x020C, 238 'value' => $tag->getValue(), 239 'label' => $tag->getLabel(), 240 ), 241 array( 242 'id' => 0x020C00, 243 'value' => isset($tmpValues[0])?$tmpValues[0]:'', 244 'label' => isset($tmpLabels[0])?$tmpLabels[0]:'', 245 ), 246 array( 247 'id' => 0x020C01, 248 'value' => isset($tmpValues[1])?$tmpValues[1]:'', 249 'label' => isset($tmpLabels[1])?$tmpLabels[1]:'', 250 ), 251 array( 252 'id' => 0x020C02, 253 'value' => isset($tmpValues[2])?$tmpValues[2]:'', 254 'label' => isset($tmpLabels[2])?$tmpLabels[2]:'', 255 ), 256 array( 257 'id' => 0x020C03, 258 'value' => isset($tmpValues[3])?$tmpValues[3]:'', 259 'label' => isset($tmpLabels[3])?$tmpLabels[3]:'', 260 ), 261 array( 262 'id' => 0x020C04, 263 'value' => isset($tmpValues[4])?$tmpValues[4]:'', 264 'label' => isset($tmpLabels[4])?$tmpLabels[4]:'', 265 ) 266 ); 267 } 268 else 269 { 270 $list=array( 271 array( 272 'id' => $tag->getId(), 273 'value' => $tag->getValue(), 274 'label' => $tag->getLabel(), 275 ) 276 ); 277 } 278 279 280 foreach($list as $tagItem) 281 { 282 $tagDef=$this->tagDef->getTagById($tagItem['id']); 283 284 if($tagDef['repeatable']) 285 { 286 if(!array_key_exists($tagItem['id'], $repeatableTags)) 287 { 288 $repeatableTags[$tagItem['id']]=new Tag( 289 $tagItem['id'], 290 array($tagItem['value']), 291 $tagDef['tagName'], 292 array($tagItem['label']), 293 "", 294 $tag->isKnown(), 295 $tagDef['implemented'], 296 $tagDef['translatable'], 297 $tag->getSchema() 298 ); 299 } 300 else 301 { 302 $repeatableTags[$tagItem['id']]->setValue(array_merge($repeatableTags[$tagItem['id']]->getValue(), array($tagItem['value']))); 303 $repeatableTags[$tagItem['id']]->setLabel(array_merge($repeatableTags[$tagItem['id']]->getLabel(), array($tagItem['label']))); 304 } 305 } 306 unset($tagDef); 307 } 308 unset($tagId); 309 } 310 foreach($repeatableTags as $key => $tag) 249 311 { 250 312 /* 251 313 * IPTC 'keywords' is stored like XMP 'xmp.dc:subject' (as a 'seq') 252 314 */ 253 $ keywordsTag->setValue(315 $repeatableTags[$key]->setValue( 254 316 array( 255 317 'type' => 'seq', 256 'values' => $ keywordsTag->getValue()318 'values' => $repeatableTags[$key]->getValue() 257 319 ) 258 320 ); 259 321 260 $ keywordsTag->setLabel(322 $repeatableTags[$key]->setLabel( 261 323 array( 262 324 'type' => 'seq', 263 'values' => $ keywordsTag->getLabel()325 'values' => $repeatableTags[$key]->getLabel() 264 326 ) 265 327 ); 266 $this->entries[]=$keywordsTag; 267 unset($keywordsTag); 268 } 328 $this->entries[]=$repeatableTags[$key]; 329 unset($repeatableTags[$key]); 330 } 331 unset($repeatableTags); 269 332 } 270 333 … … 330 393 case 0x0205: // 2:05 - Title 331 394 case 0x0207: // 2:07 - Edit Status 395 case 0x020C: // 2:12 - Subject Reference 332 396 case 0x020F: // 2:15 - Category 333 397 case 0x0214: // 2:20 - Supplemental Category … … 359 423 case 0x0114: // 1:20 - File Format 360 424 $tag=$this->tagDef->getTagById(0x0114); 361 $returned=$tag['tagValues.special'][ConvertData::toUShort($values, BYTE_ORDER_BIG_ENDIAN)]; 425 $tmpValue=ConvertData::toUShort($values, BYTE_ORDER_BIG_ENDIAN); 426 if(array_key_exists($tmpValue, $tag['tagValues.special'])) 427 { 428 $returned=$tag['tagValues.special'][$tmpValue]; 429 } 430 else 431 { 432 $returned='Unknown file format : '.ConvertData::toHexDump($tmpValue, ByteType::USHORT); 433 } 362 434 unset($tag); 363 435 break;
Note: See TracChangeset
for help on using the changeset viewer.