diff --git a/code/web/services/Record/AJAX.php b/code/web/services/Record/AJAX.php index 57e04d7a39..6fb67847ce 100644 --- a/code/web/services/Record/AJAX.php +++ b/code/web/services/Record/AJAX.php @@ -1996,10 +1996,18 @@ function viewItem(): array { if ($item->itemId == $itemId) { $relatedUrls = $item->getRelatedUrls(); foreach ($relatedUrls as $relatedUrl) { - return [ - 'success' => true, - 'url' => $relatedUrl['url'] - ]; + $libKeyLink = $this->getLibKeyUrl($relatedUrl['url']); + if (!empty($libKeyLink)) { + return [ + 'success' => true, + 'url' => $libKeyLink + ]; + } else { + return [ + 'success' => true, + 'url' => $relatedUrl['url'] + ]; + } } } } @@ -2017,4 +2025,11 @@ function viewItem(): array { 'modalButtons' => "", ]; } + + private function getLibKeyUrl($doiUrl) { + require_once ROOT_DIR . "/Drivers/LibKeyDriver.php"; + $libKeyDriver = new LibKeyDriver(); + return $libKeyDriver->getLibKeyLink($doiUrl); + } } +