Ignore:
Timestamp:
Aug 12, 2012, 11:22:20 PM (12 years ago)
Author:
grum
Message:

feature:2701
bug:2702
bug:2720
bug:2722

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/AMetaData/JpegMetaData/Readers/XmpReader.class.php

    r7441 r17554  
    247247              break;
    248248          }
     249
     250          $types=array('simple', 'seq', 'bag', 'alt');
     251          $tagProperties=$this->tagDef->getTagById($node->getName());
     252
    249253          if($type=="seq" or $type=="bag" or $type=="alt")
    250254          {
     255            if($type!=$types[$tagProperties['type']])
     256              $type=$types[$tagProperties['type']]; // if container type is not accorded with XMP schema, force it to right value
     257
    251258            $value=Array('type' => $type, 'values' => Array());
    252259            $childNode=$child->getFirstChild();
     
    270277                else
    271278                {
     279                  $childNode->delAttributes(); // remove all attributes => only 'alt' type can have attributes
    272280                  $value['values'][]=$childNode->getValue();
    273281                }
     
    454462        case "Iptc4xmpCore:IntellectualGenre":
    455463          $returned=explode(":", $value);
     464          if(!is_array($returned)) $returned=array($returned); // force the value to be an array
    456465          break;
    457466        case "exif:GPSLatitude":
     
    460469        case "exif:GPSDestLongitude":
    461470          $returned=Array('coord' => "", 'card'=>"");
     471
    462472          preg_match_all('/(\d{1,3}),(\d{1,2})(?:\.(\d*)){0,1}(N|S|E|W)/', $value, $result);
    463           $returned['coord']=$result[1][0]."° ".$result[2][0]."' ";
    464           if(trim($result[3][0])!="")
    465           {
    466             $returned['coord'].= round(("0.".$result[3][0])*60,2)."\"";
    467           }
    468           switch($result[4][0])
    469           {
    470             case "N":
    471               $returned['card']="North";
    472               break;
    473             case "S":
    474               $returned['card']="South";
    475               break;
    476             case "E":
    477               $returned['card']="East";
    478               break;
    479             case "W":
    480               $returned['card']="West";
    481               break;
    482           }
     473          if(is_array($result) and
     474             isset($result[1]) and
     475             isset($result[2]) and
     476             isset($result[3]) and
     477             isset($result[4]) and
     478             isset($result[1][0]) and
     479             isset($result[2][0]) and
     480             isset($result[3][0]) and
     481             isset($result[4][0]))
     482          {
     483            $returned['coord']=$result[1][0]."° ".$result[2][0]."' ";
     484            if(trim($result[3][0])!="")
     485            {
     486              $returned['coord'].= round(("0.".$result[3][0])*60,2)."\"";
     487            }
     488            switch($result[4][0])
     489            {
     490              case "N":
     491                $returned['card']="North";
     492                break;
     493              case "S":
     494                $returned['card']="South";
     495                break;
     496              case "E":
     497                $returned['card']="East";
     498                break;
     499              case "W":
     500                $returned['card']="West";
     501                break;
     502            }
     503          }
     504
    483505          $type=ByteType::UNDEFINED;
    484506          break;
     
    617639        case "exif:GPSAltitudeRef":
    618640        case "exif:GPSDifferential":
    619           $returned=(int)$xmpValue;
     641          if(is_int($xmpValue))
     642          {
     643            $returned=(int)$xmpValue;
     644          }
     645          else
     646          {
     647            $returned=0;
     648          }
    620649          $type=ByteType::ULONG;
    621650          break;
     
    666695        case "exif:GPSDestDistance":
    667696          $computed=explode("/", $xmpValue);
    668           $returned=Array((int)$computed[0], (int)$computed[1]);
     697          if(is_array($computed) and is_int($computed[0]) and is_int($computed[1]))
     698          {
     699            $returned=Array((int)$computed[0], (int)$computed[1]);
     700          }
     701          else
     702          {
     703            $returned=array(0,1);
     704          }
    669705          $type=ByteType::URATIONAL;
    670706          unset($computed);
Note: See TracChangeset for help on using the changeset viewer.