Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Add function for getting index annotations #1409

Merged
merged 2 commits into from
Dec 18, 2024
Merged
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
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
Loading