Skip to content
Snippets Groups Projects
Commit ca387e38 authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Merge branch 'master' of https://github.com/vufind-org/vufind

parents 24864ee5 5a1be070
Branches
Tags
No related merge requests found
Showing
with 170 additions and 31 deletions
...@@ -18,6 +18,15 @@ timeout = 30 ...@@ -18,6 +18,15 @@ timeout = 30
; Your API id ; Your API id
apiId = my-id apiId = my-id
; 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 = 10,20,40,60,80,100
; These are the default recommendations modules to use when no specific setting ; These are the default recommendations modules to use when no specific setting
; are found in the [TopRecommendations] or [SideRecommendations] sections below. ; are found in the [TopRecommendations] or [SideRecommendations] sections below.
; See the comments above those sections for details on legal settings. You may ; See the comments above those sections for details on legal settings. You may
...@@ -33,6 +42,11 @@ bulkSize = 20 ...@@ -33,6 +42,11 @@ bulkSize = 20
; controls its default state: on (true) or off (false). ; controls its default state: on (true) or off (false).
retain_filters_by_default = true retain_filters_by_default = true
; 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 ; 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 ; 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. ; past the limit. This setting tells VuFind where to cut off its paging mechanism.
......
...@@ -53,6 +53,12 @@ snippets = true ...@@ -53,6 +53,12 @@ snippets = true
; controls its default state: on (true) or off (false). ; controls its default state: on (true) or off (false).
retain_filters_by_default = true retain_filters_by_default = true
; 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[] = "IsFullText:true"
;default_filters[] = "excludeNewspapers:true"
; Summon has a fixed cap on how many results you can page through. Even though ; Summon 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 ; 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. ; past the limit. This setting tells VuFind where to cut off its paging mechanism.
......
...@@ -65,6 +65,12 @@ snippets = true ...@@ -65,6 +65,12 @@ snippets = true
; controls its default state: on (true) or off (false). ; controls its default state: on (true) or off (false).
retain_filters_by_default = true retain_filters_by_default = true
; 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[] = "format:Book"
;default_filters[] = "institution:MyInstitution"
[Cache] [Cache]
; This controls whether the parsed searchspecs.yaml file will be stored to ; This controls whether the parsed searchspecs.yaml file will be stored to
; improve search performance; legal options are APC (use APC cache), File (store ; improve search performance; legal options are APC (use APC cache), File (store
......
...@@ -353,6 +353,7 @@ AllFields: ...@@ -353,6 +353,7 @@ AllFields:
- fulltext_unstemmed^10 - fulltext_unstemmed^10
- allfields - allfields
- fulltext - fulltext
- description
- isbn - isbn
- issn - issn
QueryFields: QueryFields:
...@@ -407,6 +408,8 @@ AllFields: ...@@ -407,6 +408,8 @@ AllFields:
- [or, ~] - [or, ~]
fulltext: fulltext:
- [or, ~] - [or, ~]
description:
- [or, ~]
isbn: isbn:
- [onephrase, ~] - [onephrase, ~]
issn: issn:
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* *
* @category VuFind2 * @category VuFind2
* @package OpenLibrary * @package OpenLibrary
* @author Eoghan Carragin <eoghan.ocarragain@gmail.com> * @author Eoghan Ó Carragáin <eoghan.ocarragain@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki * @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/ */
...@@ -34,7 +34,7 @@ namespace VuFind\Connection; ...@@ -34,7 +34,7 @@ namespace VuFind\Connection;
* *
* @category VuFind2 * @category VuFind2
* @package OpenLibrary * @package OpenLibrary
* @author Eoghan Carragin <eoghan.ocarragain@gmail.com> * @author Eoghan Ó Carragáin <eoghan.ocarragain@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:developer_manual Wiki * @link http://vufind.org/wiki/vufind2:developer_manual Wiki
*/ */
......
...@@ -112,6 +112,17 @@ class AbstractSearch extends AbstractBase ...@@ -112,6 +112,17 @@ class AbstractSearch extends AbstractBase
$view->saved = $this->restoreAdvancedSearch($searchId); $view->saved = $this->restoreAdvancedSearch($searchId);
} }
// If we have default filters, set them up as a fake "saved" search
// to properly populate special controls on the advanced screen.
if (!$view->saved && count($view->options->getDefaultFilters()) > 0) {
$view->saved = $this->getServiceLocator()
->get('VuFind\SearchResultsPluginManager')
->get($this->searchClassId);
$view->saved->getParams()->initFromRequest(
new \Zend\StdLib\Parameters(array())
);
}
return $view; return $view;
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* @link http://vufind.org/wiki/vufind2:database_gateways Wiki * @link http://vufind.org/wiki/vufind2:database_gateways Wiki
*/ */
namespace VuFind\Db\Table; namespace VuFind\Db\Table;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Database table plugin manager * Database table plugin manager
...@@ -43,11 +44,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -43,11 +44,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
* *
* Make sure table gateways are properly initialized. * Make sure table gateways are properly initialized.
* *
* @param null|ConfigInterface $configuration Configuration settings (optional) * @param ConfigInterface $configuration Configuration settings (optional)
*/ */
public function __construct( public function __construct(ConfigInterface $configuration = null)
\Zend\ServiceManager\ConfigInterface $configuration = null {
) {
parent::__construct($configuration); parent::__construct($configuration);
$initializer = function ($instance, $manager) { $initializer = function ($instance, $manager) {
$instance $instance
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* @category VuFind2 * @category VuFind2
* @package Recommendations * @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu> * @author Demian Katz <demian.katz@villanova.edu>
* @author Eoghan Carragin <eoghan.ocarragain@gmail.com> * @author Eoghan Ó Carragáin <eoghan.ocarragain@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki * @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki
*/ */
...@@ -38,7 +38,7 @@ use VuFind\Connection\OpenLibrary, VuFind\Solr\Utils as SolrUtils; ...@@ -38,7 +38,7 @@ use VuFind\Connection\OpenLibrary, VuFind\Solr\Utils as SolrUtils;
* @category VuFind2 * @category VuFind2
* @package Recommendations * @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu> * @author Demian Katz <demian.katz@villanova.edu>
* @author Eoghan Carragin <eoghan.ocarragain@gmail.com> * @author Eoghan Ó Carragáin <eoghan.ocarragain@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki * @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki
*/ */
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* @category VuFind2 * @category VuFind2
* @package Recommendations * @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu> * @author Demian Katz <demian.katz@villanova.edu>
* @author Eoghan Ó Carragáin <eoghan.ocarragain@gmail.com> * @author Eoghan Ó Carragáin <eoghan.ocarragain@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki * @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki
*/ */
...@@ -37,7 +37,7 @@ namespace VuFind\Recommend; ...@@ -37,7 +37,7 @@ namespace VuFind\Recommend;
* @category VuFind2 * @category VuFind2
* @package Recommendations * @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu> * @author Demian Katz <demian.katz@villanova.edu>
* @author Eoghan Ó Carragáin <eoghan.ocarragain@gmail.com> * @author Eoghan Ó Carragáin <eoghan.ocarragain@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki * @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki
*/ */
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki * @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki
*/ */
namespace VuFind\Recommend; namespace VuFind\Recommend;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Recommendation module plugin manager * Recommendation module plugin manager
...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param null|ConfigInterface $configuration Configuration settings (optional) * @param ConfigInterface $configuration Configuration settings (optional)
*/ */
public function __construct( public function __construct(ConfigInterface $configuration = null)
\Zend\ServiceManager\ConfigInterface $configuration = null {
) {
// These plugins are not meant to be shared -- the same module may be used // These plugins are not meant to be shared -- the same module may be used
// multiple times with different configurations, so we need to build a new // multiple times with different configurations, so we need to build a new
// copy each time the plugin is retrieved. // copy each time the plugin is retrieved.
......
...@@ -253,6 +253,39 @@ class SideFacets extends AbstractFacets ...@@ -253,6 +253,39 @@ class SideFacets extends AbstractFacets
return array_map('trim', explode(',', $this->collapsedFacets)); return array_map('trim', explode(',', $this->collapsedFacets));
} }
/**
* Get the list of filters to display
*
* @param array $extraFilters Extra filters to add to the list.
*
* @return array
*/
public function getVisibleFilters($extraFilters = array())
{
// Merge extras into main list:
$filterList = array_merge(
$this->results->getParams()->getFilterList(true), $extraFilters
);
// Filter out suppressed values:
$final = array();
foreach ($filterList as $field => $filters) {
$current = array();
foreach ($filters as $i => $filter) {
if (!isset($filter['suppressDisplay'])
|| !$filter['suppressDisplay']
) {
$current[] = $filter;
}
}
if (!empty($current)) {
$final[$field] = $current;
}
}
return $final;
}
/** /**
* getRangeFacets * getRangeFacets
* *
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki * @link http://vufind.org/wiki/vufind2:record_drivers Wiki
*/ */
namespace VuFind\RecordDriver; namespace VuFind\RecordDriver;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Record driver plugin manager * Record driver plugin manager
...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param null|ConfigInterface $configuration Configuration settings (optional) * @param ConfigInterface $configuration Configuration settings (optional)
*/ */
public function __construct( public function __construct(ConfigInterface $configuration = null)
\Zend\ServiceManager\ConfigInterface $configuration = null {
) {
// Record drivers are not meant to be shared -- every time we retrieve one, // Record drivers are not meant to be shared -- every time we retrieve one,
// we are building a brand new object. // we are building a brand new object.
$this->setShareByDefault(false); $this->setShareByDefault(false);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* @link http://vufind.org/wiki/vufind2:building_a_related_record_module Wiki * @link http://vufind.org/wiki/vufind2:building_a_related_record_module Wiki
*/ */
namespace VuFind\Related; namespace VuFind\Related;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Related record plugin manager * Related record plugin manager
...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param null|ConfigInterface $configuration Configuration settings (optional) * @param ConfigInterface $configuration Configuration settings (optional)
*/ */
public function __construct( public function __construct(ConfigInterface $configuration = null)
\Zend\ServiceManager\ConfigInterface $configuration = null {
) {
// These plugins are not meant to be shared -- the same module may be used // These plugins are not meant to be shared -- the same module may be used
// multiple times with different configurations, so we need to build a new // multiple times with different configurations, so we need to build a new
// copy each time the plugin is retrieved. // copy each time the plugin is retrieved.
......
...@@ -68,7 +68,7 @@ class BackendManager implements SharedListenerAggregateInterface ...@@ -68,7 +68,7 @@ class BackendManager implements SharedListenerAggregateInterface
/** /**
* Constructor. * Constructor.
* *
* @param ServiceManager $registry Backend registry * @param ServiceLocatorInterface $registry Backend registry
* *
* @return void * @return void
*/ */
......
...@@ -54,6 +54,7 @@ abstract class Options implements TranslatorAwareInterface ...@@ -54,6 +54,7 @@ abstract class Options implements TranslatorAwareInterface
protected $basicHandlers = array(); protected $basicHandlers = array();
protected $specialAdvancedFacets = ''; protected $specialAdvancedFacets = '';
protected $retainFiltersByDefault = true; protected $retainFiltersByDefault = true;
protected $defaultFilters = array();
// Available limit options // Available limit options
protected $defaultLimit = 20; protected $defaultLimit = 20;
...@@ -552,6 +553,16 @@ abstract class Options implements TranslatorAwareInterface ...@@ -552,6 +553,16 @@ abstract class Options implements TranslatorAwareInterface
return isset($session->lastView) ? $session->lastView : null; return isset($session->lastView) ? $session->lastView : null;
} }
/**
* Get default filters to apply to an empty search.
*
* @return array
*/
public function getDefaultFilters()
{
return $this->defaultFilters;
}
/** /**
* Should filter settings be retained across searches by default? * Should filter settings be retained across searches by default?
* *
......
...@@ -87,6 +87,13 @@ class Params implements ServiceLocatorAwareInterface ...@@ -87,6 +87,13 @@ class Params implements ServiceLocatorAwareInterface
*/ */
protected $serviceLocator; protected $serviceLocator;
/**
* Are default filters applied?
*
* @var bool
*/
protected $defaultsApplied = false;
/** /**
* Constructor * Constructor
* *
...@@ -1291,6 +1298,20 @@ class Params implements ServiceLocatorAwareInterface ...@@ -1291,6 +1298,20 @@ class Params implements ServiceLocatorAwareInterface
} }
} }
// If we don't have the special flag indicating that defaults have
// been applied, and if we do have defaults, apply them:
if ($request->get('dfApplied')) {
$this->defaultsApplied = true;
} else {
$defaults = $this->getOptions()->getDefaultFilters();
if (!empty($defaults)) {
foreach ($defaults as $current) {
$this->addFilter($current);
}
$this->defaultsApplied = true;
}
}
// Handle range filters: // Handle range filters:
$this->initRangeFilters($request); $this->initRangeFilters($request);
} }
...@@ -1387,6 +1408,13 @@ class Params implements ServiceLocatorAwareInterface ...@@ -1387,6 +1408,13 @@ class Params implements ServiceLocatorAwareInterface
$this->filterList = $minified->f; $this->filterList = $minified->f;
$this->searchType = $minified->ty; $this->searchType = $minified->ty;
// Deminified searches will always have defaults already applied;
// we don't want to accidentally manipulate them further.
$defaults = $this->getOptions()->getDefaultFilters();
if (!empty($defaults)) {
$this->defaultsApplied = true;
}
// Search terms, we need to expand keys // Search terms, we need to expand keys
$this->query = QueryAdapter::deminify($minified->t); $this->query = QueryAdapter::deminify($minified->t);
} }
...@@ -1580,4 +1608,14 @@ class Params implements ServiceLocatorAwareInterface ...@@ -1580,4 +1608,14 @@ class Params implements ServiceLocatorAwareInterface
} }
return true; return true;
} }
/**
* Are default filters applied?
*
* @return bool
*/
public function hasDefaultsApplied()
{
return $this->defaultsApplied;
}
} }
\ No newline at end of file
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki * @link http://vufind.org/wiki/vufind2:record_drivers Wiki
*/ */
namespace VuFind\Search\Params; namespace VuFind\Search\Params;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Search params plugin manager * Search params plugin manager
...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param null|ConfigInterface $configuration Configuration settings (optional) * @param ConfigInterface $configuration Configuration settings (optional)
*/ */
public function __construct( public function __construct(ConfigInterface $configuration = null)
\Zend\ServiceManager\ConfigInterface $configuration = null {
) {
// These objects are not meant to be shared -- every time we retrieve one, // These objects are not meant to be shared -- every time we retrieve one,
// we are building a brand new object. // we are building a brand new object.
$this->setShareByDefault(false); $this->setShareByDefault(false);
......
...@@ -79,11 +79,24 @@ class Options extends \VuFind\Search\Base\Options ...@@ -79,11 +79,24 @@ class Options extends \VuFind\Search\Base\Options
// Load the search configuration file: // Load the search configuration file:
$searchSettings = $configLoader->get($this->searchIni); $searchSettings = $configLoader->get($this->searchIni);
// Set up limit preferences
if (isset($searchSettings->General->default_limit)) {
$this->defaultLimit = $searchSettings->General->default_limit;
}
if (isset($searchSettings->General->limit_options)) {
$this->limitOptions
= explode(",", $searchSettings->General->limit_options);
}
// Load search preferences: // Load search preferences:
if (isset($searchSettings->General->retain_filters_by_default)) { if (isset($searchSettings->General->retain_filters_by_default)) {
$this->retainFiltersByDefault $this->retainFiltersByDefault
= $searchSettings->General->retain_filters_by_default; = $searchSettings->General->retain_filters_by_default;
} }
if (isset($searchSettings->General->default_filters)) {
$this->defaultFilters = $searchSettings->General->default_filters
->toArray();
}
// Result limit: // Result limit:
if (isset($searchSettings->General->result_limit)) { if (isset($searchSettings->General->result_limit)) {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki * @link http://vufind.org/wiki/vufind2:record_drivers Wiki
*/ */
namespace VuFind\Search\Results; namespace VuFind\Search\Results;
use Zend\ServiceManager\ConfigInterface;
/** /**
* Search results plugin manager * Search results plugin manager
...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -41,11 +42,10 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
/** /**
* Constructor * Constructor
* *
* @param null|ConfigInterface $configuration Configuration settings (optional) * @param ConfigInterface $configuration Configuration settings (optional)
*/ */
public function __construct( public function __construct(ConfigInterface $configuration = null)
\Zend\ServiceManager\ConfigInterface $configuration = null {
) {
// These objects are not meant to be shared -- every time we retrieve one, // These objects are not meant to be shared -- every time we retrieve one,
// we are building a brand new object. // we are building a brand new object.
$this->setShareByDefault(false); $this->setShareByDefault(false);
......
...@@ -84,6 +84,10 @@ class Options extends \VuFind\Search\Base\Options ...@@ -84,6 +84,10 @@ class Options extends \VuFind\Search\Base\Options
$this->retainFiltersByDefault $this->retainFiltersByDefault
= $searchSettings->General->retain_filters_by_default; = $searchSettings->General->retain_filters_by_default;
} }
if (isset($searchSettings->General->default_filters)) {
$this->defaultFilters = $searchSettings->General->default_filters
->toArray();
}
if (isset($searchSettings->Basic_Searches)) { if (isset($searchSettings->Basic_Searches)) {
foreach ($searchSettings->Basic_Searches as $key => $value) { foreach ($searchSettings->Basic_Searches as $key => $value) {
$this->basicHandlers[$key] = $value; $this->basicHandlers[$key] = $value;
......
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