Skip to content
Snippets Groups Projects
Commit 53b0081e authored by Dorian Merz's avatar Dorian Merz Committed by Robert Lange
Browse files

refs #16914 [finc] simplify record link rendering

* do not check for existence of linked record on every call
* add fallback seacrh in case of calling a missing record
parent b9929178
No related merge requests found
...@@ -113,4 +113,30 @@ class RecordController extends \VuFind\Controller\RecordController implements ...@@ -113,4 +113,30 @@ class RecordController extends \VuFind\Controller\RecordController implements
// No followup info found? Send back to record view: // No followup info found? Send back to record view:
return $this->redirectToRecord(); return $this->redirectToRecord();
} }
/**
* Home (default) action -- forward to requested (or default) tab.
*
* @return mixed
*/
public function homeAction()
{
if ($this->params()->fromQuery('catchMissing', null)) {
try {
return parent::homeAction();
} catch (\VuFind\Exception\RecordMissing $ex) {
$lookfor = $this->params()->fromQuery('catchMissing_lookfor','');
if (empty($lookfor)) throw $ex;
$type = $this->params()->fromQuery('catchMissing_searchType','Allfields');
$link = $this->redirect()->toRoute(
'search-results',
[],
['query' => compact('lookfor','type')]
);
return $link;
}
}
return parent::homeAction();
}
} }
...@@ -150,13 +150,31 @@ class RecordLink extends \VuFind\View\Helper\Root\RecordLink ...@@ -150,13 +150,31 @@ class RecordLink extends \VuFind\View\Helper\Root\RecordLink
* *
* @return string * @return string
*/ */
public function getUrl($driver) public function getUrl(
$driver, $catchMissingLookfor = '', $catchMissingSearchType = 'AllFields'
)
{ {
try { if (is_object($driver)) {
return $this->getTabUrl($driver); try {
} catch (RecordMissingException $exception) { return $this->getTabUrl($driver);
// return default result on Missing Record } catch (RecordMissingException $exception) {
// throw all other Exceptions // return default result on Missing Record
// throw all other Exceptions
}
} elseif (is_string($driver)) {
$ids = explode('|',$driver);
$id = array_shift($ids);
if ($id === 'Solr') $id = array_shift($ids);
$params['id'] = $id;
if (!empty($catchMissingLookfor)) {
$options['query'] = [
'catchMissing' => true,
'catchMissing_lookfor' => $catchMissingLookfor,
'catchMissing_searchType' => $catchMissingSearchType
];
}
$urlHelper = $this->getView()->plugin('url');
return $urlHelper('record',$params,$options ?? []);
} }
return ""; return "";
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<?php $hierarchyParentId = $this->driver->tryMethod('getHierarchyParentID'); ?> <?php $hierarchyParentId = $this->driver->tryMethod('getHierarchyParentID'); ?>
<?php foreach ($data as $key => $title): ?> <?php foreach ($data as $key => $title): ?>
<?php if (isset($hierarchyParentId[$key])): ?> <?php if (isset($hierarchyParentId[$key])): ?>
<a href="<?=$this->recordLink()->getUrl($hierarchyParentId[$key]);?>"><?=$this->escapeHtml($title)?></a> <a href="<?=$this->recordLink()->getUrl($hierarchyParentId[$key],$hierarchyParentId[$key],'ParentID');?>"><?=$this->escapeHtml($title)?></a>
<?php else: ?> <?php else: ?>
<?=$this->escapeHtml($title)?> <?=$this->escapeHtml($title)?>
<?php endif; ?> <?php endif; ?>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
// try container id as link - VuFind native behaviour // try container id as link - VuFind native behaviour
if ($containerID) { if ($containerID) {
$journalLink = $this->recordLink()->getUrl("$containerSource|$containerID"); $journalLink = $this->recordLink()->getUrl("$containerSource|$containerID",$data,'JournalTitle');
} // try to link via issn - finc adapted behaviour } // try to link via issn - finc adapted behaviour
elseif (!empty($issns)) { elseif (!empty($issns)) {
$journalLink = $this->record($this->driver)->getLink('isn', $issns); $journalLink = $this->record($this->driver)->getLink('isn', $issns);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment