Skip to content

Commit 6e63ad8

Browse files
authored
Merge pull request #10 from michaelkubina-subhh/5.0.6_subhh_optimize_pagegrid
[OPTIMIZATION] Speed up pagegrid generation
2 parents fc39af5 + 290df49 commit 6e63ad8

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

Classes/Common/AbstractDocument.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,21 @@ abstract public function getFileInfo($id): ?array;
320320
*/
321321
abstract public function getFileLocation(string $id): string;
322322

323+
/**
324+
* This gets the location of a file representing a physical page or track
325+
*
326+
* @access public
327+
*
328+
* @abstract
329+
*
330+
* @param string $id The "@ID" attribute of the file node (METS) or the "@id" property of the IIIF resource
331+
*
332+
* @param string $fileGrp The "@USE" attribute of the file node (METS)
333+
*
334+
* @return string The file's location as URL
335+
*/
336+
abstract public function getFileLocationInFilegroup(string $id, string $fileGrp): string;
337+
323338
/**
324339
* This gets the MIME type of a file representing a physical page or track
325340
*

Classes/Common/MetsDocument.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,23 @@ public function getFileLocation(string $id): string
245245
}
246246
}
247247

248+
/**
249+
* @see AbstractDocument::getFileLocationInFilegroup()
250+
*/
251+
public function getFileLocationInFilegroup(string $id, string $fileGrp): string
252+
{
253+
$location = $this->mets->xpath('./mets:fileSec/mets:fileGrp[@USE="' . $fileGrp . '"]/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]');
254+
if (
255+
!empty($id)
256+
&& !empty($location)
257+
) {
258+
return (string) $location[0]->attributes('http://www.w3.org/1999/xlink')->href;
259+
} else {
260+
$this->logger->warning('There is no file node with @ID "' . $id . '"');
261+
return '';
262+
}
263+
}
264+
248265
/**
249266
* @see AbstractDocument::getFileMimeType()
250267
*/

Classes/Controller/PageGridController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function getEntry(int $number, string $fileGrpThumbs): array
106106
if (array_intersect($fileGrpsThumb, array_keys($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['files'])) !== []) {
107107
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
108108
if (!empty($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['files'][$fileGrpThumb])) {
109-
$entry['thumbnail'] = $this->document->getCurrentDocument()->getFileLocation($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['files'][$fileGrpThumb]);
109+
$entry['thumbnail'] = $this->document->getCurrentDocument()->getFileLocationInFilegroup($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['files'][$fileGrpThumb], $fileGrpThumb);
110110
break;
111111
}
112112
}

0 commit comments

Comments
 (0)