diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php index 497e4fa86a..1851a61dab 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php @@ -23,6 +23,9 @@ use Alchemy\Phrasea\Record\RecordWasRotated; use DataURI\Parser; use MediaAlchemyst\Alchemyst; use MediaVorus\MediaVorus; +use PHPExiftool\Driver\Metadata\Metadata; +use PHPExiftool\Driver\Metadata\MetadataBag; +use PHPExiftool\Driver\TagFactory; use PHPExiftool\Exception\ExceptionInterface as PHPExiftoolException; use PHPExiftool\Reader; use Symfony\Component\HttpFoundation\Request; @@ -82,12 +85,12 @@ class ToolsController extends Controller ); } } - if (!$record->isStory()) { try { - $metadata = $this->getExifToolReader() + $metadatas = $this->getExifToolReader() ->files($record->get_subdef('document')->getRealPath()) ->first()->getMetadatas(); + $metadatas = $this->getNoBinaryMetadataValue($metadatas, $record); } catch (PHPExiftoolException $e) { // ignore } catch (\Exception_Media_SubdefNotFound $e) { @@ -102,7 +105,7 @@ class ToolsController extends Controller 'record' => $record, 'videoEditorConfig' => $conf->get(['video-editor']), 'recordSubdefs' => $recordAccessibleSubdefs, - 'metadatas' => $metadata, + 'metadatas' => $metadatas, ]); } @@ -433,4 +436,28 @@ class ToolsController extends Controller unset($media); $this->getFilesystem()->remove($fileName); } + + /** + * @param MetadataBag $metadatas + * @param $record + * @return MetadataBag + */ + private function getNoBinaryMetadataValue(MetadataBag $metadatas, $record) + { + $metadataBag = new MetadataBag(); + $fileEntity = $this->getExifToolReader() + ->files($record->get_subdef('document')->getRealPath()) + ->first(); + foreach($metadatas as $metadata){ + $valuedata = $fileEntity->executeQuery($metadata->getTag()->getTagname()."[not(@rdf:datatype = 'http://www.w3.org/2001/XMLSchema#base64Binary')]"); + + if(!empty($valuedata)){ + $tag = TagFactory::getFromRDFTagname($metadata->getTag()->getTagname()); + $metadataBagElement = new Metadata($tag, $valuedata); + $metadataBag->set($metadata->getTag()->getTagname(), $metadataBagElement); + } + } + + return $metadataBag; + } } diff --git a/templates/web/prod/actions/Tools/index.html.twig b/templates/web/prod/actions/Tools/index.html.twig index 77ac006eed..e1f19508b9 100644 --- a/templates/web/prod/actions/Tools/index.html.twig +++ b/templates/web/prod/actions/Tools/index.html.twig @@ -329,16 +329,29 @@ - {% for metadata in metadatas %} - - - {{ metadata.getTag().getTagname() }} - - - {{ metadata.getValue().asString() }} - - - {% endfor %} + {% if app.getAclForUser(app.getAuthenticatedUser()).is_admin() %} + {% for metadata in metadatas %} + + + {{ metadata.getTag().getTagname() }} + + + {{ metadata.getValue().asString() }} + + + {% endfor %} + {% else %} + {% for metadata in metadatas if 'System' not in metadata.getTag().getTagname() %} + + + {{ metadata.getTag().getTagname() }} + + + {{ metadata.getValue().asString() }} + + + {% endfor %} + {% endif %}