Skip to content

Commit

Permalink
[BUGFIX] Fix regression for METS files without physical structure (#1417
Browse files Browse the repository at this point in the history
)

Signed-off-by: Stefan Weil <[email protected]>
Co-authored-by: Sebastian Meyer <[email protected]>
  • Loading branch information
stweil and sebastian-meyer authored Dec 27, 2024
1 parent b452185 commit 4b3a130
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
21 changes: 12 additions & 9 deletions Classes/Common/MetsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,19 @@ private function getThumbnail(string $id = '')

$thumbnail = null;

while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (empty($id)) {
$thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null;
} else {
$parentId = $this->smLinks['l2p'][$id][0] ?? null;
$thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null;
}
if (!empty($this->physicalStructure)) {
// There is a physical structure (no anchor or year mets).
while ($fileGrpThumb = array_shift($fileGrpsThumb)) {
if (empty($id)) {
$thumbnail = $this->physicalStructureInfo[$this->physicalStructure[1]]['files'][$fileGrpThumb] ?? null;
} else {
$parentId = $this->smLinks['l2p'][$id][0] ?? null;
$thumbnail = $this->physicalStructureInfo[$parentId]['files'][$fileGrpThumb] ?? null;
}

if (!empty($thumbnail)) {
break;
if (!empty($thumbnail)) {
break;
}
}
}
return $thumbnail;
Expand Down
28 changes: 15 additions & 13 deletions Classes/Controller/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ protected function getCalendarYear(array &$calendarData, array $calendarIssuesBy
$dayLinksText = [];
$dayLinkDiv = [];
$currentMonth = date('n', $currentDayTime);
if (is_array($calendarIssuesByMonth[$currentMonth])) {
if (array_key_exists($currentMonth, $calendarIssuesByMonth) && is_array($calendarIssuesByMonth[$currentMonth])) {
foreach ($calendarIssuesByMonth[$currentMonth] as $id => $day) {
if ($id == date('j', $currentDayTime)) {
$dayLinks = $id;
Expand Down Expand Up @@ -492,19 +492,21 @@ private function getIssuesFromTableOfContents(): Generator
$toc = $this->document->getCurrentDocument()->tableOfContents;

foreach ($toc[0]['children'] as $year) {
foreach ($year['children'] as $month) {
foreach ($month['children'] as $day) {
foreach ($day['children'] as $issue) {
$title = $issue['label'] ?: $issue['orderlabel'];
if (strtotime($title) !== false) {
$title = strftime('%x', strtotime($title));
}
if (array_key_exists('children', $year)) {
foreach ($year['children'] as $month) {
foreach ($month['children'] as $day) {
foreach ($day['children'] as $issue) {
$title = $issue['label'] ?: $issue['orderlabel'];
if (strtotime($title) !== false) {
$title = strftime('%x', strtotime($title));
}

yield [
'uid' => $issue['points'],
'title' => $title,
'year' => $day['orderlabel'],
];
yield [
'uid' => $issue['points'],
'title' => $title,
'year' => $day['orderlabel'],
];
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/MetadataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ private function getMetadata(): array
if ($this->settings['rootline'] < 2) {
// Get current structure's @ID.
$ids = [];
if (isset($this->requestData['page'])) {
if (!empty($this->currentDocument->physicalStructure) && isset($this->requestData['page'])) {
$page = $this->currentDocument->physicalStructure[$this->requestData['page']];
if (!empty($page) && !empty($this->currentDocument->smLinks['p2l'][$page])) {
foreach ($this->currentDocument->smLinks['p2l'][$page] as $logId) {
Expand Down

0 comments on commit 4b3a130

Please sign in to comment.