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

refs #17990 [finc] avoid single record special handling in RecordsController's homeAction

* only apply for print
parent 14d453d8
No related merge requests found
...@@ -36,6 +36,7 @@ $config = [ ...@@ -36,6 +36,7 @@ $config = [
'finc\Controller\AmslResourceController' => 'finc\Controller\AmslResourceControllerFactory', 'finc\Controller\AmslResourceController' => 'finc\Controller\AmslResourceControllerFactory',
'finc\Controller\DocumentDeliveryServiceController' => 'finc\Controller\DocumentDeliveryServiceControllerFactory', 'finc\Controller\DocumentDeliveryServiceController' => 'finc\Controller\DocumentDeliveryServiceControllerFactory',
'finc\Controller\Admin\I18nController' => 'finc\Controller\Admin\I18nControllerFactory', 'finc\Controller\Admin\I18nController' => 'finc\Controller\Admin\I18nControllerFactory',
'finc\Controller\RecordsController' => 'VuFind\Controller\AbstractBaseFactory',
], ],
'aliases' => [ 'aliases' => [
'AdminI18n' => 'finc\Controller\Admin\I18nController', 'AdminI18n' => 'finc\Controller\Admin\I18nController',
...@@ -44,6 +45,7 @@ $config = [ ...@@ -44,6 +45,7 @@ $config = [
'dds' => 'finc\Controller\DocumentDeliveryServiceController', 'dds' => 'finc\Controller\DocumentDeliveryServiceController',
'VuFind\Controller\MyResearchController' => 'finc\Controller\MyResearchController', 'VuFind\Controller\MyResearchController' => 'finc\Controller\MyResearchController',
'VuFind\Controller\RecordController' => 'finc\Controller\RecordController', 'VuFind\Controller\RecordController' => 'finc\Controller\RecordController',
'VuFind\Controller\RecordsController' => 'finc\Controller\RecordsController',
], ],
], ],
'controller_plugins' => [ 'controller_plugins' => [
......
<?php
/**
* Records Controller
*
* PHP version 7
*
* Copyright (C) Villanova University 2010.
* Copyright (C) Leipzig University Library 2020.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Controller
* @author Demian Katz <demian.katz@villanova.edu>
* @author Dorian Merz <merz@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/
namespace finc\Controller;
use VuFind\Controller\RecordsController as BaseController;
/**
* Records Controller
*
* @category VuFind
* @package Controller
* @author Demian Katz <demian.katz@villanova.edu>
* @author Dorian Merz <merz@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/
class RecordsController extends BaseController
{
/**
* @var bool true to suppress jumping to single record
*/
protected $suppressJump;
/**
* Bypass the single record handling of the parent method when printing
* @return bool|mixed|\VuFind\Controller\ViewModel|\Zend\View\Model\ViewModel
*/
public function homeAction()
{
$this->suppressJump = false;
if ($this->params()->fromQuery('print')) {
$this->suppressJump = true;
return $this->resultsAction();
}
return parent::homeAction();
}
/**
* {@inheritDoc}
* This is mostly a copy of the parent function with an additional check for
* Missing Records.
* @see \VuFind\Controller\AbstractSearch::processJumpTo()
*
* @param \VuFind\Search\Base\Results $results
* @return bool|\Zend\Http\Response|\Zend\View\Model\ViewModel
*/
public function processJumpTo($results)
{
if ($this->suppressJump) {
return false;
}
// Jump to only result, if configured
$default = null;
$config = $this->serviceLocator->get('VuFind\Config\PluginManager')
->get('config');
if (isset($config->Record->jump_to_single_search_result)
&& $config->Record->jump_to_single_search_result
&& $results->getResultTotal() == 1
) {
$default = 1;
}
// Missing/invalid parameter? Ignore it:
$jumpto = $this->params()->fromQuery('jumpto', $default);
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 ($recordList[$jumpto - 1] instanceof \VuFind\RecordDriver\Missing) {
return false;
}
// If we got this far, we have a valid parameter so we should redirect
// and report success:
$details = $this->getRecordRouter()
->getTabRouteDetails($recordList[$jumpto - 1]);
return $this->redirect()->toRoute($details['route'], $details['params']);
}
}
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