mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Merge pull request #2582 from aynsix/PHRAS-2031-porting-Add-xmpmm-documentId
PHRAS-2031 Port to 4.1 - Add XmpMM:DocumentID source
This commit is contained in:
@@ -49,6 +49,7 @@ class File
|
|||||||
protected $originalName;
|
protected $originalName;
|
||||||
protected $md5;
|
protected $md5;
|
||||||
protected $attributes;
|
protected $attributes;
|
||||||
|
public static $xmpTag = ['XMP-xmpMM:DocumentID'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -102,6 +103,7 @@ class File
|
|||||||
'IPTC:UniqueDocumentID',
|
'IPTC:UniqueDocumentID',
|
||||||
'ExifIFD:ImageUniqueID',
|
'ExifIFD:ImageUniqueID',
|
||||||
'Canon:ImageUniqueID',
|
'Canon:ImageUniqueID',
|
||||||
|
'XMP-xmpMM:DocumentID',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!$this->uuid) {
|
if (!$this->uuid) {
|
||||||
@@ -112,6 +114,9 @@ class File
|
|||||||
foreach ($availableUUIDs as $meta) {
|
foreach ($availableUUIDs as $meta) {
|
||||||
if ($metadatas->containsKey($meta)) {
|
if ($metadatas->containsKey($meta)) {
|
||||||
$candidate = $metadatas->get($meta)->getValue()->asString();
|
$candidate = $metadatas->get($meta)->getValue()->asString();
|
||||||
|
if(in_array($meta, self::$xmpTag)){
|
||||||
|
$candidate = self::sanitizeXmpUuid($candidate);
|
||||||
|
}
|
||||||
if (Uuid::isValid($candidate)) {
|
if (Uuid::isValid($candidate)) {
|
||||||
$uuid = $candidate;
|
$uuid = $candidate;
|
||||||
break;
|
break;
|
||||||
@@ -287,4 +292,13 @@ class File
|
|||||||
|
|
||||||
return new File($app, $media, $collection, $originalName);
|
return new File($app, $media, $collection, $originalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitize XMP UUID
|
||||||
|
* @param $uuid
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function sanitizeXmpUuid($uuid){
|
||||||
|
return str_replace('xmp.did:', '', $uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Metadata;
|
namespace Alchemy\Phrasea\Metadata;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Border\File;
|
||||||
use Alchemy\Phrasea\Databox\DataboxRepository;
|
use Alchemy\Phrasea\Databox\DataboxRepository;
|
||||||
use Alchemy\Phrasea\Metadata\Tag\NoSource;
|
use Alchemy\Phrasea\Metadata\Tag\NoSource;
|
||||||
use PHPExiftool\Driver\Metadata\Metadata;
|
use PHPExiftool\Driver\Metadata\Metadata;
|
||||||
@@ -119,8 +120,11 @@ class PhraseanetMetadataSetter
|
|||||||
if (!isset($metadataPerField[$fieldName])) {
|
if (!isset($metadataPerField[$fieldName])) {
|
||||||
$metadataPerField[$fieldName] = [];
|
$metadataPerField[$fieldName] = [];
|
||||||
}
|
}
|
||||||
|
if(in_array($tagName, File::$xmpTag)){
|
||||||
$metadataPerField[$fieldName] = array_merge($metadataPerField[$fieldName], $metadata->getValue()->asArray());
|
$metadataPerField[$fieldName] = array_merge($metadataPerField[$fieldName], (array) File::sanitizeXmpUuid($metadata->getValue()->asString()));
|
||||||
|
}else{
|
||||||
|
$metadataPerField[$fieldName] = array_merge($metadataPerField[$fieldName], $metadata->getValue()->asArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user