diff --git a/local/languages/de.ini b/local/languages/de.ini index ce9f68c9a274aae9eaf4b6b032abe912d8be48df..654d7be086de4d27bf9376af9f0a928533a9cb92 100644 --- a/local/languages/de.ini +++ b/local/languages/de.ini @@ -2076,3 +2076,6 @@ select_item_storage_retrieval_request_cancel = "Titel auswählen, um Magazinbest ; #17915 toggle-dropdown = "Untermenü aufklappen" + +missing_record_redirect = "Der aufgerufene Titel ist nicht vorhanden. Stattdessen wurde eine Suche ausgelöst" +missing_record_exception = "Der aufgerufene Titel (%%id%%) ist nicht vorhanden." diff --git a/local/languages/en.ini b/local/languages/en.ini index 6e6fe79543163c9fa66e95716aad65d6e83e69f4..b8214638d2844e780925629d63b8b94b7c3793a0 100644 --- a/local/languages/en.ini +++ b/local/languages/en.ini @@ -2156,3 +2156,6 @@ Start a new Basic Search = "New Basic Search" ; #17915 toggle-dropdown = "Toggle Dropdown" + +missing_record_redirect = "Record unavailable. You have been redirected to a search." +missing_record_exception = "Record %%id%% is unavailable." diff --git a/module/finc/src/finc/Controller/RecordController.php b/module/finc/src/finc/Controller/RecordController.php index ee9b3d49e75883ef2668a262f5024d94a658cbd5..be0586f12052331b212685c8fb24545d0ebd19ce 100644 --- a/module/finc/src/finc/Controller/RecordController.php +++ b/module/finc/src/finc/Controller/RecordController.php @@ -30,6 +30,7 @@ namespace finc\Controller; use finc\Rewrite\EblRewrite; +use VuFind\Exception\RecordMissing; use Zend\Log\LoggerAwareInterface as LoggerAwareInterface; use Zend\View\View; @@ -121,19 +122,25 @@ class RecordController extends \VuFind\Controller\RecordController implements */ 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'); + try { + return parent::homeAction(); + } catch (\VuFind\Exception\RecordMissing $ex) { + if ( + $this->params()->fromQuery('catchMissing', null) + && + $lookfor = $this->params()->fromQuery('catchMissing_lookfor', '') + ) { + $type = $this->params()->fromQuery('catchMissing_searchType', 'Allfields'); $link = $this->redirect()->toRoute( 'search-results', [], - ['query' => compact('lookfor','type')] + ['query' => compact('lookfor', 'type')] ); + $this->flashMessenger()->addErrorMessage('missing_record_redirect'); return $link; + } else { + $id = $this->params()->fromRoute('id'); + throw new RecordMissing($id); } } diff --git a/themes/finc/templates/error/RecordMissing.phtml b/themes/finc/templates/error/RecordMissing.phtml new file mode 100644 index 0000000000000000000000000000000000000000..6cc0d7358a97bf8c9dc34b77e38896fa5299f44f --- /dev/null +++ b/themes/finc/templates/error/RecordMissing.phtml @@ -0,0 +1,46 @@ +<!-- finc: RuntimeException --> +<?php /* largely copied from /bootstrap3/templates/error/index.phtml #17035 - RL */?> +<?php + // Set page title. + $this->headTitle($this->translate('Missing Record')); + + $this->layout()->breadcrumbs = '<li class="active">Error</li>'; +?> +<div class="alert alert-danger"> + <p><?=$this->transEsc('An error has occurred')?></p> + <p><?=$this->transEsc( + 'missing_record_exception', + ['%%id%%' => $this->exception->getMessage()] + ) + ?></p> +</div> +<form> + <input type="button" class="btn" value="<?=$this->translate('navigate_back')?>" onclick="history.back()"> +</form> + +<?php if (isset($this->display_exceptions) && $this->display_exceptions): ?> + <h2><?=$this->transEsc('Exception')?>:</h2> + <p> + <b><?=$this->transEsc('Message')?>:</b> <?=$this->escapeHtml($this->exception->getMessage())?> + </p> + + <h2><?=$this->transEsc('Backtrace')?>:</h2> + <pre><?=$this->exception->getTraceAsString()?> + </pre> + + <?php if ($e = $this->exception->getPrevious()): ?> + <h3>Previous exceptions:</h3> + <?php while ($e): ?> + <h4><?php echo get_class($e); ?></h4> + <p><?=$e->getMessage()?></p> + <pre><?=$e->getTraceAsString()?></pre> + <?php $e = $e->getPrevious(); ?> + <?php endwhile; ?> + <?php endif; ?> + + <?php if (isset($this->request)): ?> + <h2><?=$this->transEsc('error_page_parameter_list_heading')?>:</h2> + <pre><?=$this->escapeHtml(var_export($this->request->getParams(), true))?></pre> + <?php endif; ?> +<?php endif ?> +<!-- finc: RuntimeException - END -->