diff --git a/lib/Alchemy/Phrasea/Command/Record/RescanFilesMetadata.php b/lib/Alchemy/Phrasea/Command/Record/RescanFilesMetadata.php index aca6f6a631..899e793852 100644 --- a/lib/Alchemy/Phrasea/Command/Record/RescanFilesMetadata.php +++ b/lib/Alchemy/Phrasea/Command/Record/RescanFilesMetadata.php @@ -33,7 +33,7 @@ public function __construct() ->addOption('min_record_id', null, InputOption::VALUE_REQUIRED, "lowest record_id value") ->addOption('record_type', null, InputOption::VALUE_REQUIRED, 'Type of records(s) to scan.') ->addOption('partition', null, InputOption::VALUE_REQUIRED, 'n/N : work only on records belonging to partition') - ->addOption('source', null, InputOption::VALUE_REQUIRED, 'tag to search exemple IPTC:KEYWORD') + ->addOption('source', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'tag to search exemple IPTC:KEYWORD') ->addOption('destination', null, InputOption::VALUE_REQUIRED, "ID of the field de fill") ->addOption('overwrite', null, InputOption::VALUE_NONE, "act even if the destination field has a value in databox") ->addOption('method', null, InputOption::VALUE_REQUIRED, "replace or merge for multi value field") diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 4c659f8192..876da214ac 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -1287,12 +1287,15 @@ public function setMetadatasByActions(stdClass $actions) * @return array|null * @throws \PHPExiftool\Exception\EmptyCollectionException */ - public function getFileMetadataByTag($tag) + public function getFileMetadataByTag($tags) { $logger = new Logger('exif-tool'); $reader = Reader::create($logger); - $value = null; + if(!is_array($tags)) { + $tags = [$tags]; + } + $tags = array_fill_keys($tags, null); // throw exception $documentSubdef = $this->get_subdef('document'); @@ -1301,13 +1304,21 @@ public function getFileMetadataByTag($tag) /** @var Metadata $metadata */ foreach ($metadatas as $metadata) { - if ($metadata->getTag() == $tag) { - $value = explode(";", $metadata->getValue()); + /** @var string $t */ + $t = (string)$metadata->getTag(); + if (array_key_exists($t, $tags)) { + $tags[$t] = explode(";", $metadata->getValue()); break; } } - return $value; + foreach($tags as $tag => $value) { + if($value !== null) { + return $value; + } + } + + return null; }