Skip to content

Commit

Permalink
Merge pull request vufind-org#16 from samuli/search-tabs-filters
Browse files Browse the repository at this point in the history
[ALLI-3219] Handle active facet filters when moving between tabs.
  • Loading branch information
EreMaijala committed Feb 24, 2015
2 parents 6bae626 + 284d3fd commit 030a588
Show file tree
Hide file tree
Showing 14 changed files with 810 additions and 12 deletions.
172 changes: 172 additions & 0 deletions local/config/finna/Primo.ini.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
; This section contains global settings affecting search behavior.
; For PrimoCentral API documentation:
; http://www.exlibrisgroup.org/display/PrimoOI/Brief+Search
; Note: you will need your EL Commons credentials to access documentation
[General]
; This setting controls the default sort order of search results; the selected
; option should be one of the options present in the [Sorting] section below.
default_sort = relevance

; If this setting is true, boolean operators in searches (AND/OR/NOT) will only
; be recognized if they are ALL UPPERCASE. If set to false, they will be
; recognized regardless of case.
case_sensitive_bools = true

; HTTP timeout
timeout = 30

; Your API id (use "mlplus" if using Metalib Plus instead of Primo Central)
apiId = my-id

; The port to use when connecting to the API (normally 1701 for Primo Central, 80
; for Metalib Plus)
port = 1701

; This section controls the result limit options for search results. default_limit
; sets the default number of results per page. limit_options is a comma-separated
; list of numbers to be presented to the end-user. If only one limit is required,
; set default_limit and leave limit_options commented out.
; WARNING: using large limits may require you to raise your PHP memory limits to
; avoid errors.
default_limit = 20
limit_options = 20,50,100

; These are the default recommendations modules to use when no specific setting
; are found in the [TopRecommendations] or [SideRecommendations] sections below.
; See the comments above those sections for details on legal settings. You may
; repeat these lines to load multiple recommendations.
;default_top_recommend[] = TopFacets:FacetsTop:Primo
default_side_recommend[] = SideFacets:Facets:CheckboxFacets:Primo

; This section is used to set general parameters for URL generation to make a call to the Primo API
bulkSize = 20

; When you filter a search using facets, VuFind will present a checkbox that can
; be used to apply those filters to the next search you perform. This setting
; controls its default state: on (true) or off (false).
retain_filters_by_default = false

; The filters listed below will be applied to all new searches by default. Omit
; this setting to have no default filters applied. These differ from hidden
; filters because they are visible in the UI and may be removed by the user.
;default_filters[] = "rtype:Books"

; Primo has a fixed cap on how many results you can page through. Even though
; it may report more results than this number, you can't actually access results
; past the limit. This setting tells VuFind where to cut off its paging mechanism.
result_limit = 2000

; The following two sections can be used to associate specific recommendations
; modules with specific search types defined in the [Basic_Searches] section
; below. For all the details on how these sections work, see the comments above
; the equivalent sections of searches.ini. Recommendations work the same in
; Primo as they do in the regular Search module.
[SideRecommendations]
; No search-specific settings by default -- add your own here.
;[TopRecommendations]
; No search-specific settings by default -- add your own here.

; This section is used to identify facets for special treatment by the SideFacets
; recommendations module.
[SpecialFacets]
; Any fields listed below will be treated as date ranges rather than plain facets:
dateRange[] = creationdate

; The order of display is as shown below
; The name of the index field is on the left
; The display name of the field is on the right
[Facets]
tlevel = "Limit To"
rtype = "Format"
creator = "Author"
jtitle = "Journal Title"
topic = Subjects
creationdate = "Year of Publication"
domain = Source
;lang = Language

; Top facets (not used by default)
[FacetsTop]

; Facet display settings
[Results_Settings]
; Rows and columns for table used by top facets
top_rows = 2
top_cols = 3
; Do we want any facets to be collapsed by default?
;collapsedFacets = *

; These settings affect the way the facets are displayed
[Facet_Settings]
facet_limit = 30 ; how many values should we show for each facet?

; These settings affect the way facets are displayed on the advanced screen
[Advanced_Facet_Settings]
; Some special facets for advanced searching can be turned on by inclusion in
; the comma-separated list below, or turned off by being excluded. Currently,
; just one values is supported: "daterange" for the publication year range
; control.
special_facets = daterange

; Any facets named in the list below will have their values run through the
; translation code; unlisted facets will displayed as-is without translation. For
; translated facets, be sure that all of the necessary strings are included in the
; language files found in the web/lang directory. By default, no facets are
; translated -- uncomment or add lines below to turn on this feature.
translated_facets[] = tlevel

; This section shows which search types will display in the basic search box at
; the top of Primo pages. The name of each setting below corresponds with an
; index defined in the Primo API. The value of each setting is the text to
; display on screen. All on-screen text will be run through the translator, so
; be sure to update language files if necessary. The order of these settings
; will be maintained in the drop-down list in the UI.
[Basic_Searches]
AllFields = Keyword
Title = Title
Author = Author
Subject = Subject
;Abstract = Abstract
;ISSN = ISSN

; This section defines which search options will be included on the advanced
; search screen. All the notes above [Basic_Searches] also apply here.
[Advanced_Searches]
AllFields = Keyword
Title = Title
Author = Author
Subject = Subject
Abstract = Abstract
ISSN = ISSN

; This section controls the operators displayed on the advanced search screen;
; the left side contains the actual operator names, while the right side
; contains display text that will be run through the translator logic.
[Advanced_Operators]
contains = operator_contains
exact = operator_exact

; This section defines the sort options available on Primo search results.
; PrimoCentral sorting can only go in one direction - either ASC for ascending
; or DESC for descending. In order to change the sort direction you must go into
; the primo backend in Primo Home > Advanced Configuration > All Mapping Tables
; Sort Fields Config and make your changes there.
[Sorting]
relevance = sort_relevance
scdate = sort_year
screator = sort_author
stitle = sort_title

; You can set regular expression / institution code pairs here to match up
; IP addresses with institution codes.
[Institutions]
; Simple example:
regex[] = "/.*/" ; match all IPs
code[] = "MYINSTITUTION"
; Consortial example:
;regex[] = "/^1\.2\..*/" ; match IPs starting with 1.2.
;code[] = "MEMBER1"
;regex[] = "/^2\.3\..*/" ; match IPs starting with 2.3.
;code[] = "MEMBER2"
;regex[] = "/.*/" ; default if no previous rule was matched
;code[] = "DEFAULT"
5 changes: 5 additions & 0 deletions local/config/vufind/Primo.ini.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; Inherit main configuration
[Parent_Config]
relative_path = ../finna/Primo.ini

; Add any overrides below
10 changes: 9 additions & 1 deletion module/Finna/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
'invokables' => array(
'ajax' => 'Finna\Controller\AjaxController',
'contentpage' => 'Finna\Controller\ContentController',
'cover' => 'Finna\Controller\CoverController'
'cover' => 'Finna\Controller\CoverController',
'primo' => 'Finna\Controller\PrimoController',
'search' => 'Finna\Controller\SearchController'
),
),
'service_manager' => array(
Expand All @@ -75,6 +77,12 @@
'biblio' => 'Solr',
)
),
'search_results' => array(
'factories' => array(
'solr' => 'Finna\Search\Results\Factory::getSolr',
'primo' => 'Finna\Search\Results\Factory::getPrimo'
)
),
'content_covers' => array(
'invokables' => array(
'natlibfi' => 'Finna\Content\Covers\NatLibFi'
Expand Down
56 changes: 56 additions & 0 deletions module/Finna/src/Finna/Controller/PrimoController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Primo Central Controller
*
* PHP version 5
*
* Copyright (C) The National Library of Finland 2015.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Controller
* @author Samuli Sillanpää <samuli.sillanpaa@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
namespace Finna\Controller;

/**
* Primo Central Controller
*
* @category VuFind2
* @package Controller
* @author Samuli Sillanpää <samuli.sillanpaa@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
class PrimoController extends \VuFind\Controller\PrimoController
{
use SearchControllerTrait;

/**
* Search action -- call standard results action
*
* @return mixed
*/
public function searchAction()
{
$view = parent::resultsAction();
$this->initSavedTabs();

return $view;
}
}

55 changes: 55 additions & 0 deletions module/Finna/src/Finna/Controller/SearchController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Default Controller
*
* PHP version 5
*
* Copyright (C) The National Library of Finland 2015.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Controller
* @author Samuli Sillanpää <samuli.sillanpaa@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
namespace Finna\Controller;

/**
* Redirects the user to the appropriate default VuFind action.
*
* @category VuFind2
* @package Controller
* @author Samuli Sillanpää <samuli.sillanpaa@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
class SearchController extends \VuFind\Controller\SearchController
{
use SearchControllerTrait;

/**
* Results action.
*
* @return mixed
*/
public function resultsAction()
{
$view = parent::resultsAction();
$this->initSavedTabs();
return $view;
}
}

57 changes: 57 additions & 0 deletions module/Finna/src/Finna/Controller/SearchControllerTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Finna search controller trait.
*
* PHP version 5
*
* Copyright (C) The National Library of Finland 2015.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Controller
* @author Samuli Sillanpää <samuli.sillanpaa@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
namespace Finna\Controller;

/**
* Finna search controller trait.
*
* @category VuFind2
* @package Controller
* @author Samuli Sillanpää <samuli.sillanpaa@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/
trait SearchControllerTrait
{
/**
* Pass saved search ids from all tabs to layout.
*
* @return void
*/
protected function initSavedTabs()
{
if ($savedTabs = $this->getRequest()->getQuery()->get('search')) {
$saved = array();
foreach ($savedTabs as $tab) {
list($searchClass, $searchId) = explode(':', $tab);
$saved[$searchClass] = $searchId;
}
$this->layout()->savedTabs = $saved;
}
}
}
Loading

0 comments on commit 030a588

Please sign in to comment.