Skip to content

Commit

Permalink
[MAINTENANCE] Add function for getting index annotations (kitodo#1409)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
  • Loading branch information
beatrycze-volk and sebastian-meyer authored Dec 18, 2024
1 parent 01456c4 commit 4220b12
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Classes/Common/IiifManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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).
*
Expand Down

0 comments on commit 4220b12

Please sign in to comment.