From 7aaac9ca3a2aeebdb35c786bfe693d9e9fddb9f7 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Thu, 12 Dec 2024 11:20:12 +0100 Subject: [PATCH] Add function for getting index annotations --- 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 b5924f85a..b25dfc9a7 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -264,7 +264,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; @@ -307,7 +307,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; } @@ -768,7 +768,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']; @@ -867,8 +867,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) { @@ -940,6 +940,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). *