Skip to content

Commit 78aeae0

Browse files
Adjust resolveMenuEntry function to facilitate newspapers
1 parent 9ab0995 commit 78aeae0

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Classes/Controller/TableOfContentsController.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Kitodo\Dlf\Common\Helper;
1515
use Kitodo\Dlf\Common\MetsDocument;
1616
use Psr\Http\Message\ResponseInterface;
17+
use TYPO3\CMS\Core\Utility\GeneralUtility;
1718
use TYPO3\CMS\Core\Utility\MathUtility;
1819

1920
/**
@@ -252,13 +253,18 @@ private function resolveMenuEntry(array $entry): array
252253
// If the menu entry points to the parent document,
253254
// resolve to the parent UID set on indexation.
254255
$doc = $this->document->getCurrentDocument();
255-
if (
256-
$doc instanceof MetsDocument
257-
&& ((array_key_exists('points', $entry) && $entry['points'] === $doc->parentHref) || $this->isMultiElement($entry['type']))
258-
&& !empty($this->document->getPartof())
259-
) {
260-
unset($entry['points']);
261-
$entry['targetUid'] = $this->document->getPartof();
256+
if ($doc instanceof MetsDocument && array_key_exists('points', $entry)) {
257+
if ($entry['points'] === $doc->parentHref || $this->isMultiElement($entry['type']) && !empty($this->document->getPartof())) {
258+
unset($entry['points']);
259+
$entry['targetUid'] = $this->document->getPartof();
260+
} elseif (GeneralUtility::isValidUrl((string) $entry['points'])) {
261+
// this case is for the newspaper issues pointing to the newspaper METS file (2 levels up)
262+
$document = $this->documentRepository->findOneBy(['location' => $entry['points']]);
263+
if ($document !== null) {
264+
unset($entry['points']);
265+
$entry['targetUid'] = $document->getUid();
266+
}
267+
}
262268
}
263269

264270
return $entry;

0 commit comments

Comments
 (0)