diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 42901fc8e1..dd648466f3 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -320,6 +320,21 @@ abstract public function getFileInfo($id): ?array; */ abstract public function getFileLocation(string $id): string; + /** + * This gets the location of a file representing a physical page or track + * + * @access public + * + * @abstract + * + * @param string $id The "@ID" attribute of the file node (METS) or the "@id" property of the IIIF resource + * + * @param string $fileGrp The "@USE" attribute of the file node (METS) + * + * @return string The file's location as URL + */ + abstract public function getFileLocationInFilegroup(string $id, string $fileGrp): string; + /** * This gets the MIME type of a file representing a physical page or track * diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index 4d099fa88b..9464a7e662 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -245,6 +245,23 @@ public function getFileLocation(string $id): string } } + /** + * @see AbstractDocument::getFileLocationInFilegroup() + */ + public function getFileLocationInFilegroup(string $id, string $fileGrp): string + { + $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp[@USE="' . $fileGrp . '"]/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]'); + if ( + !empty($id) + && !empty($location) + ) { + return (string) $location[0]->attributes('http://www.w3.org/1999/xlink')->href; + } else { + $this->logger->warning('There is no file node with @ID "' . $id . '"'); + return ''; + } + } + /** * @see AbstractDocument::getFileMimeType() */ diff --git a/Classes/Controller/PageGridController.php b/Classes/Controller/PageGridController.php index 8346a26f4d..2272236b21 100644 --- a/Classes/Controller/PageGridController.php +++ b/Classes/Controller/PageGridController.php @@ -106,7 +106,7 @@ protected function getEntry(int $number, string $fileGrpThumbs): array if (array_intersect($fileGrpsThumb, array_keys($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['files'])) !== []) { while ($fileGrpThumb = array_shift($fileGrpsThumb)) { if (!empty($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['files'][$fileGrpThumb])) { - $entry['thumbnail'] = $this->document->getCurrentDocument()->getFileLocation($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['files'][$fileGrpThumb]); + $entry['thumbnail'] = $this->document->getCurrentDocument()->getFileLocationInFilegroup($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['files'][$fileGrpThumb], $fileGrpThumb); break; } }