don't display binary data

This commit is contained in:
aina-esokia
2018-02-12 14:43:36 +04:00
parent 431ae31945
commit 9018254602
2 changed files with 53 additions and 13 deletions

View File

@@ -23,6 +23,9 @@ use Alchemy\Phrasea\Record\RecordWasRotated;
use DataURI\Parser; use DataURI\Parser;
use MediaAlchemyst\Alchemyst; use MediaAlchemyst\Alchemyst;
use MediaVorus\MediaVorus; 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\Exception\ExceptionInterface as PHPExiftoolException;
use PHPExiftool\Reader; use PHPExiftool\Reader;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@@ -82,12 +85,12 @@ class ToolsController extends Controller
); );
} }
} }
if (!$record->isStory()) { if (!$record->isStory()) {
try { try {
$metadata = $this->getExifToolReader() $metadatas = $this->getExifToolReader()
->files($record->get_subdef('document')->getRealPath()) ->files($record->get_subdef('document')->getRealPath())
->first()->getMetadatas(); ->first()->getMetadatas();
$metadatas = $this->getNoBinaryMetadataValue($metadatas, $record);
} catch (PHPExiftoolException $e) { } catch (PHPExiftoolException $e) {
// ignore // ignore
} catch (\Exception_Media_SubdefNotFound $e) { } catch (\Exception_Media_SubdefNotFound $e) {
@@ -102,7 +105,7 @@ class ToolsController extends Controller
'record' => $record, 'record' => $record,
'videoEditorConfig' => $conf->get(['video-editor']), 'videoEditorConfig' => $conf->get(['video-editor']),
'recordSubdefs' => $recordAccessibleSubdefs, 'recordSubdefs' => $recordAccessibleSubdefs,
'metadatas' => $metadata, 'metadatas' => $metadatas,
]); ]);
} }
@@ -433,4 +436,28 @@ class ToolsController extends Controller
unset($media); unset($media);
$this->getFilesystem()->remove($fileName); $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;
}
} }

View File

@@ -329,16 +329,29 @@
<td></td> <td></td>
<td></td> <td></td>
</tr> </tr>
{% for metadata in metadatas %} {% if app.getAclForUser(app.getAuthenticatedUser()).is_admin() %}
<tr> {% for metadata in metadatas %}
<td> <tr>
{{ metadata.getTag().getTagname() }} <td>
</td> {{ metadata.getTag().getTagname() }}
<td> </td>
{{ metadata.getValue().asString() }} <td>
</td> {{ metadata.getValue().asString() }}
</tr> </td>
{% endfor %} </tr>
{% endfor %}
{% else %}
{% for metadata in metadatas if 'System' not in metadata.getTag().getTagname() %}
<tr>
<td>
{{ metadata.getTag().getTagname() }}
</td>
<td>
{{ metadata.getValue().asString() }}
</td>
</tr>
{% endfor %}
{% endif %}
</tbody> </tbody>
</table> </table>
</div> </div>