From fccc27c9751db82f97eb5a2cd121ca7322b9c4b9 Mon Sep 17 00:00:00 2001 From: j3nsch Date: Fri, 27 Oct 2023 20:04:21 +0200 Subject: [PATCH 1/3] #1115 Add options for browsing Visibility of lastest documents, document types and years in browsing --- application/configs/application.ini | 3 + .../controllers/BrowseController.php | 30 ++++++++ .../views/scripts/browse/index.phtml | 6 ++ .../controllers/BrowseControllerTest.php | 77 ++++++++++++++++++- 4 files changed, 113 insertions(+), 3 deletions(-) diff --git a/application/configs/application.ini b/application/configs/application.ini index d308ae6d6..8e2eecb9a 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -355,6 +355,9 @@ plugins.export.publist.stylesheetDirectory = 'publist' ; BROWSING SETTINGS browsing.disableEmptyCollections = 1 browsing.series.sortByTitle = 0 +browsing.showLatestDocuments = 1 +browsing.showDocumentTypes = 1 +browsing.showYears = 1 ; SERIES SETTINGS ; If series.sortByTitle is enabled (1) the sort_order will be ignored and series diff --git a/modules/solrsearch/controllers/BrowseController.php b/modules/solrsearch/controllers/BrowseController.php index 1392774bd..fe16cc0e6 100644 --- a/modules/solrsearch/controllers/BrowseController.php +++ b/modules/solrsearch/controllers/BrowseController.php @@ -55,10 +55,31 @@ public function indexAction() $collectionRoles = new Solrsearch_Model_CollectionRoles(); $this->view->collectionRoles = $collectionRoles->getAllVisible(); $this->view->showSeriesBrowsing = $this->seriesUtil->hasDisplayableSeries(); + + $config = $this->getConfig(); + // TODO there are no unit tests for showing/hiding the following sections + if (isset($config->browsing->showLatestDocuments)) { + $this->view->showLatestDocuments = filter_var($config->browsing->showLatestDocuments, FILTER_VALIDATE_BOOLEAN); + } + if (isset($config->browsing->showDocumentTypes)) { + $this->view->showDocumentTypes = filter_var($config->browsing->showDocumentTypes, FILTER_VALIDATE_BOOLEAN); + } + if (isset($config->browsing->showYears)) { + $this->view->showYears = filter_var($config->browsing->showYears, FILTER_VALIDATE_BOOLEAN); + } } public function doctypesAction() { + $config = $this->getConfig(); + + if (isset($config->browsing->showDocumentTypes) && + ! filter_var($config->browsing->showDocumentTypes, FILTER_VALIDATE_BOOLEAN)) { + $this->_helper->Redirector->redirectTo( + 'index' + ); + } + $facetname = 'doctype'; $query = new Opus\Search\Util\Query(Opus\Search\Util\Query::FACET_ONLY); $query->setFacetField($facetname); @@ -83,6 +104,15 @@ public function doctypesAction() public function yearsAction() { + $config = $this->getConfig(); + + if (isset($config->browsing->showYears) && + ! filter_var($config->browsing->showYears, FILTER_VALIDATE_BOOLEAN)) { + $this->_helper->Redirector->redirectTo( + 'index' + ); + } + $facetname = 'year'; $query = new Opus\Search\Util\Query(Opus\Search\Util\Query::FACET_ONLY); diff --git a/modules/solrsearch/views/scripts/browse/index.phtml b/modules/solrsearch/views/scripts/browse/index.phtml index 2345e0687..eb469f268 100644 --- a/modules/solrsearch/views/scripts/browse/index.phtml +++ b/modules/solrsearch/views/scripts/browse/index.phtml @@ -41,18 +41,24 @@