Skip to content
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
26 changes: 26 additions & 0 deletions Classes/Common/Solr/SolrSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,12 @@ public function submit(int $start, int $rows, bool $processResults = true): void
$documents[$doc['uid']] = $allDocuments[$doc['uid']];
}
if (isset($documents[$doc['uid']])) {
// get title of parent/grandparent/... if empty
if (empty($documents[$doc['uid']]['title']) && $documents[$doc['uid']]['partOf'] > 0) {
$doc['title'] = $this->getTitleFromPartOf($documents[$doc['uid']]['partOf']);
$documents[$doc['uid']]['title'] = $doc['title'];
}

$this->translateLanguageCode($doc);
if ($doc['toplevel'] === false) {
// this maybe a chapter, article, ..., year
Expand Down Expand Up @@ -991,4 +997,24 @@ private function translateLanguageCode(array &$doc): void
}
}
}

/**
* Gets the title of the superior document (parent/grandparent/...) enclosed in square brackets.
*
* @access private
*
* @param int $partOf UID of the superior document
*
* @return string The bracketed superior title or an empty string if none was found
*/
private function getTitleFromPartOf(int $partOf): string
{
$title = '';
$superiorTitle = AbstractDocument::getTitle($partOf, true);
if (!empty($superiorTitle)) {
$title = '[' . $superiorTitle . ']';
}
return $title;
}

}