From 4220b12d4ec4b7446fbf85d3c76a68203be2dfbf Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Wed, 18 Dec 2024 08:55:22 +0100 Subject: [PATCH] [MAINTENANCE] Add function for getting index annotations (#1409) Co-authored-by: Sebastian Meyer --- Classes/Common/IiifManifest.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index 47045815f..ba44e57fe 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -211,7 +211,7 @@ protected function magicGetPhysicalStructure(): array if ($this->iiif == null || !($this->iiif instanceof ManifestInterface)) { return []; } - $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey, 'iiif'); + $iiifId = $this->iiif->getId(); $this->physicalStructureInfo[$iiifId]['id'] = $iiifId; $this->physicalStructureInfo[$iiifId]['dmdId'] = $iiifId; @@ -254,7 +254,7 @@ protected function magicGetPhysicalStructure(): array $this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'] = []; foreach ($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING) as $annotationContainer) { $this->physicalStructureInfo[$elements[$canvasOrder]]['annotationContainers'][] = $annotationContainer->getId(); - if ($extConf['indexAnnotations']) { + if ($this->getIndexAnnotations() == 1) { $this->hasFulltext = true; $this->hasFulltextSet = true; } @@ -712,7 +712,7 @@ public function getFullText(string $id): string break; } } - if ($extConf['iiif']['indexAnnotations'] == 1) { + if ($this->getIndexAnnotations() == 1) { $iiifResource = $this->iiif->getContainedResourceById($id); // Get annotation containers $annotationContainerIds = $physicalStructureNode['annotationContainers']; @@ -811,8 +811,8 @@ protected function ensureHasFulltextIsSet(): void $this->hasFulltext = true; return; } - $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey, 'iiif'); - if ($extConf['indexAnnotations'] == 1 && !empty($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING))) { + + if ($this->getIndexAnnotations() == 1 && !empty($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING))) { foreach ($canvas->getPossibleTextAnnotationContainers(Motivation::PAINTING) as $annotationContainer) { $textAnnotations = $annotationContainer->getTextAnnotations(Motivation::PAINTING); if ($textAnnotations != null) { @@ -884,6 +884,18 @@ private function getAnnotationTexts($annotationContainerIds, $iiifId): array return $annotationTexts; } + /** + * Get index annotations setting from extension configuration. + * + * @access private + * + * @return integer value 0 or 1 + */ + private function getIndexAnnotations(): int + { + return (int) GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey, 'iiif')['indexAnnotations']; + } + /** * Set files used for download (PDF). *