From 169c5be7aa115a2e7cca5ca8d4d464a832864348 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 10 May 2013 10:30:29 -0400 Subject: [PATCH] Resolving VUFIND-655 (next/prev navigation in Summon/WorldCat). --- config/vufind/Summon.ini | 8 +++++++- config/vufind/WorldCat.ini | 4 ++++ module/VuFind/config/module.config.php | 7 +------ .../src/VuFind/Controller/AbstractRecord.php | 20 +++++++++++-------- .../src/VuFind/Controller/AbstractSearch.php | 20 +++++++++++-------- .../VuFind/Controller/AuthorController.php | 1 - .../VuFind/Controller/AuthorityController.php | 1 - .../VuFind/Controller/RecordController.php | 12 +++++++++++ .../VuFind/Controller/RecordsController.php | 1 - .../VuFind/Controller/SearchController.php | 12 +++++++++++ .../VuFind/Controller/SummonController.php | 13 +++++++++++- .../Controller/SummonrecordController.php | 13 +++++++++++- .../src/VuFind/Controller/TagController.php | 1 - .../VuFind/Controller/WorldcatController.php | 13 +++++++++++- .../Controller/WorldcatrecordController.php | 13 +++++++++++- 15 files changed, 108 insertions(+), 31 deletions(-) diff --git a/config/vufind/Summon.ini b/config/vufind/Summon.ini index 741c425b980..75af312285c 100644 --- a/config/vufind/Summon.ini +++ b/config/vufind/Summon.ini @@ -169,4 +169,10 @@ PublicationDate:asc = "sort_year asc" ; This section controls spell checking -- it can be disabled if desired. [Spelling] -enabled = true \ No newline at end of file +enabled = true + +; This section controls the behavior of the SummonRecord module. +[Record] +; Set this to true in order to enable "next" and "previous" links to navigate +; through the current result set from within the record view. +next_prev_navigation = false diff --git a/config/vufind/WorldCat.ini b/config/vufind/WorldCat.ini index b7f3da645cb..f223bc6a8f2 100644 --- a/config/vufind/WorldCat.ini +++ b/config/vufind/WorldCat.ini @@ -49,5 +49,9 @@ Title = sort_title ; This section controls the behavior of the WorldCatRecord module. See the ; [Record] section of the main config.ini for more detailed documentation. [Record] +; Because the WorldCat database changes frequently, this feature sometimes +; behaves unpredictably; it is recommended that you leave it disabled: +next_prev_navigation = false + related[] = "WorldCatSimilar" related[] = "WorldCatEditions" diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 92806792c76..2172f69990f 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -125,18 +125,13 @@ $config = array( && $config->Reserves->search_enabled; return new \VuFind\Controller\Plugin\Reserves($useIndex); }, - 'result-scroller' => function ($sm) { - $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); - $enabled = (isset($config->Record->next_prev_navigation) - && $config->Record->next_prev_navigation); - return new \VuFind\Controller\Plugin\ResultScroller($enabled); - }, ), 'invokables' => array( 'db-upgrade' => 'VuFind\Controller\Plugin\DbUpgrade', 'favorites' => 'VuFind\Controller\Plugin\Favorites', 'followup' => 'VuFind\Controller\Plugin\Followup', 'renewals' => 'VuFind\Controller\Plugin\Renewals', + 'result-scroller' => 'VuFind\Controller\Plugin\ResultScroller', ) ), 'service_manager' => array( diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index 71f61efdd84..35e07b053b1 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -61,13 +61,6 @@ class AbstractRecord extends AbstractBase */ protected $searchClassId = 'Solr'; - /** - * Should we use the result scroller? - * - * @var bool - */ - protected $useResultScroller = true; - /** * Should we log statistics? * @@ -563,6 +556,17 @@ class AbstractRecord extends AbstractBase return $this->allTabs; } + /** + * Is the result scroller active? + * + * @return bool + */ + protected function resultScrollerActive() + { + // Disabled by default: + return false; + } + /** * Display a particular tab. * @@ -592,7 +596,7 @@ class AbstractRecord extends AbstractBase $view->defaultTab = strtolower($this->defaultTab); // Set up next/previous record links (if appropriate) - if ($this->useResultScroller) { + if ($this->resultScrollerActive()) { $driver = $this->loadRecord(); $view->scrollData = $this->resultScroller()->getScrollData($driver); } diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php index 3f4d20bea38..6978ccfbf89 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -67,13 +67,6 @@ class AbstractSearch extends AbstractBase */ protected $rememberSearch = true; - /** - * Should we use the result scroller? - * - * @var bool - */ - protected $useResultScroller = true; - /** * Constructor */ @@ -160,6 +153,17 @@ class AbstractSearch extends AbstractBase } } + /** + * Is the result scroller active? + * + * @return bool + */ + protected function resultScrollerActive() + { + // Disabled by default: + return false; + } + /** * Send search results to results view * @@ -227,7 +231,7 @@ class AbstractSearch extends AbstractBase } // Set up results scroller: - if ($this->useResultScroller) { + if ($this->resultScrollerActive()) { $this->resultScroller()->init($results); } } catch (\VuFindSearch\Backend\Exception\RequestParseErrorException $e) { diff --git a/module/VuFind/src/VuFind/Controller/AuthorController.php b/module/VuFind/src/VuFind/Controller/AuthorController.php index 259d4043aa5..68c54b240b1 100644 --- a/module/VuFind/src/VuFind/Controller/AuthorController.php +++ b/module/VuFind/src/VuFind/Controller/AuthorController.php @@ -59,7 +59,6 @@ class AuthorController extends AbstractSearch { $this->searchClassId = 'SolrAuthorFacets'; $this->saveToHistory = false; - $this->useResultScroller = false; $this->rememberSearch = false; return parent::resultsAction(); } diff --git a/module/VuFind/src/VuFind/Controller/AuthorityController.php b/module/VuFind/src/VuFind/Controller/AuthorityController.php index b9e7e467196..b44a3956237 100644 --- a/module/VuFind/src/VuFind/Controller/AuthorityController.php +++ b/module/VuFind/src/VuFind/Controller/AuthorityController.php @@ -44,7 +44,6 @@ class AuthorityController extends AbstractSearch public function __construct() { $this->searchClassId = 'SolrAuth'; - $this->useResultScroller = false; parent::__construct(); } diff --git a/module/VuFind/src/VuFind/Controller/RecordController.php b/module/VuFind/src/VuFind/Controller/RecordController.php index bfa7bc0a93b..2bd185156d0 100644 --- a/module/VuFind/src/VuFind/Controller/RecordController.php +++ b/module/VuFind/src/VuFind/Controller/RecordController.php @@ -162,4 +162,16 @@ class RecordController extends AbstractRecord ) ); } + + /** + * Is the result scroller active? + * + * @return bool + */ + protected function resultScrollerActive() + { + $config = $this->getServiceLocator()->get('VuFind\Config')->get('config'); + return (isset($config->Record->next_prev_navigation) + && $config->Record->next_prev_navigation); + } } diff --git a/module/VuFind/src/VuFind/Controller/RecordsController.php b/module/VuFind/src/VuFind/Controller/RecordsController.php index ac56e47aba7..f4ed7f0d454 100644 --- a/module/VuFind/src/VuFind/Controller/RecordsController.php +++ b/module/VuFind/src/VuFind/Controller/RecordsController.php @@ -44,7 +44,6 @@ class RecordsController extends AbstractSearch public function __construct() { $this->searchClassId = 'MixedList'; - $this->useResultScroller = false; parent::__construct(); } diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index f081a100016..4d42b631bcb 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -659,4 +659,16 @@ class SearchController extends AbstractSearch ); return $response; } + + /** + * Is the result scroller active? + * + * @return bool + */ + protected function resultScrollerActive() + { + $config = $this->getServiceLocator()->get('VuFind\Config')->get('config'); + return (isset($config->Record->next_prev_navigation) + && $config->Record->next_prev_navigation); + } } diff --git a/module/VuFind/src/VuFind/Controller/SummonController.php b/module/VuFind/src/VuFind/Controller/SummonController.php index f03f622e84c..ff25373ab1c 100644 --- a/module/VuFind/src/VuFind/Controller/SummonController.php +++ b/module/VuFind/src/VuFind/Controller/SummonController.php @@ -46,10 +46,21 @@ class SummonController extends AbstractSearch public function __construct() { $this->searchClassId = 'Summon'; - $this->useResultScroller = false; parent::__construct(); } + /** + * Is the result scroller active? + * + * @return bool + */ + protected function resultScrollerActive() + { + $config = $this->getServiceLocator()->get('VuFind\Config')->get('Summon'); + return (isset($config->Record->next_prev_navigation) + && $config->Record->next_prev_navigation); + } + /** * preDispatch -- block access when appropriate. * diff --git a/module/VuFind/src/VuFind/Controller/SummonrecordController.php b/module/VuFind/src/VuFind/Controller/SummonrecordController.php index d6f8e825f18..8dade919a65 100644 --- a/module/VuFind/src/VuFind/Controller/SummonrecordController.php +++ b/module/VuFind/src/VuFind/Controller/SummonrecordController.php @@ -47,13 +47,24 @@ class SummonrecordController extends AbstractRecord { // Override some defaults: $this->searchClassId = 'Summon'; - $this->useResultScroller = false; $this->defaultTab = 'Description'; // Call standard record controller initialization: parent::__construct(); } + /** + * Is the result scroller active? + * + * @return bool + */ + protected function resultScrollerActive() + { + $config = $this->getServiceLocator()->get('VuFind\Config')->get('Summon'); + return (isset($config->Record->next_prev_navigation) + && $config->Record->next_prev_navigation); + } + /** * preDispatch -- block access when appropriate. * diff --git a/module/VuFind/src/VuFind/Controller/TagController.php b/module/VuFind/src/VuFind/Controller/TagController.php index 6376c241850..18d4a50420d 100644 --- a/module/VuFind/src/VuFind/Controller/TagController.php +++ b/module/VuFind/src/VuFind/Controller/TagController.php @@ -44,7 +44,6 @@ class TagController extends AbstractSearch public function __construct() { $this->searchClassId = 'Tags'; - $this->useResultScroller = false; parent::__construct(); } diff --git a/module/VuFind/src/VuFind/Controller/WorldcatController.php b/module/VuFind/src/VuFind/Controller/WorldcatController.php index 6c5aca78cd0..b5f5eba6a3c 100644 --- a/module/VuFind/src/VuFind/Controller/WorldcatController.php +++ b/module/VuFind/src/VuFind/Controller/WorldcatController.php @@ -44,10 +44,21 @@ class WorldcatController extends AbstractSearch public function __construct() { $this->searchClassId = 'WorldCat'; - $this->useResultScroller = false; parent::__construct(); } + /** + * Is the result scroller active? + * + * @return bool + */ + protected function resultScrollerActive() + { + $config = $this->getServiceLocator()->get('VuFind\Config')->get('WorldCat'); + return (isset($config->Record->next_prev_navigation) + && $config->Record->next_prev_navigation); + } + /** * Home action * diff --git a/module/VuFind/src/VuFind/Controller/WorldcatrecordController.php b/module/VuFind/src/VuFind/Controller/WorldcatrecordController.php index e5407e7b0ee..b88ab894e36 100644 --- a/module/VuFind/src/VuFind/Controller/WorldcatrecordController.php +++ b/module/VuFind/src/VuFind/Controller/WorldcatrecordController.php @@ -45,9 +45,20 @@ class WorldcatrecordController extends AbstractRecord { // Override some defaults: $this->searchClassId = 'WorldCat'; - $this->useResultScroller = false; // Call standard record controller initialization: parent::__construct(); } + + /** + * Is the result scroller active? + * + * @return bool + */ + protected function resultScrollerActive() + { + $config = $this->getServiceLocator()->get('VuFind\Config')->get('WorldCat'); + return (isset($config->Record->next_prev_navigation) + && $config->Record->next_prev_navigation); + } } -- GitLab