From e50db01a6903d9c0f91cd356792f0cc2d75ef1eb Mon Sep 17 00:00:00 2001 From: Dorian Merz <merz@ub.uni-leipzig.de> Date: Fri, 22 May 2020 12:29:42 +0200 Subject: [PATCH] refs #17575 [fid_bbi] configure Browse page * only allow tags browsing * remove letter level from alphabetical search --- fid_bbi/config/vufind/config.ini | 22 +++++ module/fid_bbi/config/module.config.php | 2 + .../fid_bbi/Controller/BrowseController.php | 95 +++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 module/fid_bbi/src/fid_bbi/Controller/BrowseController.php diff --git a/fid_bbi/config/vufind/config.ini b/fid_bbi/config/vufind/config.ini index 41b7cc48ab8..20a216bbfa5 100644 --- a/fid_bbi/config/vufind/config.ini +++ b/fid_bbi/config/vufind/config.ini @@ -131,3 +131,25 @@ WorldcatTab = enabled EndNote = "record,bulk" BibTeX = "record,bulk" RIS = "record,bulk" + +; This section controls the behavior of the Browse module. The result_limit +; setting controls the maximum number of results that may display in any given +; result box on the Browse screen. You can set to -1 for no limit; however, +; setting a very high (or no) limit may result in "out of memory" errors if you +; have a large index! +[Browse] +result_limit = 100 +tag = true ; allow browsing of Tags +dewey = false ; allow browsing of Dewey Decimal call numbers +lcc = false ; allow browsing of LC call numbers +author = false ; allow browsing of authors +topic = false ; allow browsing of subject headings +genre = false ; allow browsing of genre subdivisions +region = false ; allow browsing of region subdivisions +era = false ; allow browsing of era subdivisions +; You can use this setting to change the default alphabet provided for browsing: +alphabet_letters = "AÄBCDEFGHIJKLMNOÖPQRSTUÜVWXYZ" +; Uncomment to sort lists alphabetically (instead of by popularity); note that +; this will not changed the values returned -- you will still get only the +; <result_limit> most popular entries -- it only affects display order. +alphabetical_order = true \ No newline at end of file diff --git a/module/fid_bbi/config/module.config.php b/module/fid_bbi/config/module.config.php index db2ec71a6cc..bb88f25d16d 100644 --- a/module/fid_bbi/config/module.config.php +++ b/module/fid_bbi/config/module.config.php @@ -38,6 +38,7 @@ $config = [ 'fid_bbi\Controller\SearchController' => 'VuFind\Controller\AbstractBaseFactory', 'fid_bbi\Controller\MyResearchController' => 'VuFind\Controller\AbstractBaseFactory', 'fid_bbi\Controller\RecordController' => 'VuFind\Controller\AbstractBaseWithConfigFactory', + 'fid_bbi\Controller\BrowseController' => 'VuFind\Controller\AbstractBaseWithConfigFactory', ], 'aliases' => [ 'feedback' => 'fid_bbi\Controller\FeedbackController', @@ -47,6 +48,7 @@ $config = [ 'Record' => 'fid_bbi\Controller\RecordController', 'record' => 'fid_bbi\Controller\RecordController', 'VuFind\Controller\MyResearchController' => 'fid_bbi\Controller\MyResearchController', + 'VuFind\Controller\BrowseController' => 'fid_bbi\Controller\BrowseController', ], ], 'vufind' => [ diff --git a/module/fid_bbi/src/fid_bbi/Controller/BrowseController.php b/module/fid_bbi/src/fid_bbi/Controller/BrowseController.php new file mode 100644 index 00000000000..43a0c6a29eb --- /dev/null +++ b/module/fid_bbi/src/fid_bbi/Controller/BrowseController.php @@ -0,0 +1,95 @@ +<?php +/** + * Browse Module Controller + * + * PHP version 7 + * + * Copyright (C) Villanova University 2011. + * + * 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 Chris Hallberg <challber@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/wiki/development:plugins:controllers Wiki + */ +namespace fid_bbi\Controller; + +use VuFind\Controller\BrowseController as BaseController; + +/** + * BrowseController Class + * + * Controls the browsing feature + * + * This fid_bbi specific instance removes the letter + * level for alphabetical tag browsing + * + * @category VuFind + * @package Controller + * @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/wiki/development:plugins:controllers Wiki + */ +class BrowseController extends BaseController +{ + /** + * Browse tags + * this is mostly a copy of the + * parent method with the alphabetical special case + * removed + * + * @return \Zend\View\Model\ViewModel + */ + public function tagAction() + { + if (!$this->tagsEnabled()) { + throw new ForbiddenException('Tags disabled.'); + } + + $this->setCurrentAction('Tag'); + $view = $this->createViewModel(); + + $view->categoryList = [ + 'alphabetical' => 'By Alphabetical', + 'popularity' => 'By Popularity', + 'recent' => 'By Recent' + ]; + + if ($this->params()->fromQuery('findby')) { + $params = $this->getRequest()->getQuery()->toArray(); + $tagTable = $this->getTable('Tags'); + // Default case: always display tag list for non-alphabetical modes: + $tagList = $tagTable->getTagList( + $params['findby'], + $this->config->Browse->result_limit + ); + $resultList = []; + foreach ($tagList as $i => $tag) { + $resultList[$i] = [ + 'displayText' => $tag['tag'], + 'value' => $tag['tag'], + 'count' => $tag['cnt'] + ]; + } + $view->resultList = $resultList; + $view->paramTitle = 'lookfor='; + $view->searchParams = []; + } + + return $this->performSearch($view); + } +} -- GitLab