From cfe62d958718e4dc905e11325f4edcc15f433f7b Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 20 Oct 2015 12:57:03 -0400 Subject: [PATCH] Fixed broken jumpTo parameter in web module. --- .../src/VuFind/Controller/WebController.php | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/Controller/WebController.php b/module/VuFind/src/VuFind/Controller/WebController.php index 97354395182..817e30ad85c 100644 --- a/module/VuFind/src/VuFind/Controller/WebController.php +++ b/module/VuFind/src/VuFind/Controller/WebController.php @@ -57,5 +57,32 @@ class WebController extends AbstractSearch // Do nothing -- just display template return $this->createViewModel(); } -} + /** + * Process the jumpto parameter -- either redirect to a specific record and + * return view model, or ignore the parameter and return false. + * + * @param \VuFind\Search\Base\Results $results Search results object. + * + * @return mixed + */ + protected function processJumpTo($results) + { + // Missing/invalid parameter? Ignore it: + $jumpto = $this->params()->fromQuery('jumpto'); + if (empty($jumpto) || !is_numeric($jumpto)) { + return false; + } + + // Parameter out of range? Ignore it: + $recordList = $results->getResults(); + if (!isset($recordList[$jumpto - 1])) { + return false; + } + + // If we got this far, we have a valid parameter so we should redirect + // and report success: + $url = $recordList[$jumpto - 1]->getUrl(); + return $url ? $this->redirect()->toUrl($url) : false; + } +} -- GitLab