Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Classes/Common/AbstractDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
17 changes: 17 additions & 0 deletions Classes/Common/MetsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
*/
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/PageGridController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down