Skip to content
Snippets Groups Projects
Commit feac0aa5 authored by Demian Katz's avatar Demian Katz
Browse files

Added CollectionSideFacets recommendation module and set it up to be active by...

Added CollectionSideFacets recommendation module and set it up to be active by default in collection view.
parent 6b6318b4
No related merge requests found
......@@ -5,6 +5,24 @@
; details on recommendation modules).
[Recommend]
;top[] = "PubDateVisAjax:true:publishDate"
side[] = "CollectionSideFacets:Facets::Collection:true"
; This is a facet section similar to those found in facets.ini, but this is used for
; the Collection module screen.
[Facets]
geographic_facet = Location
topic_facet = Subjects
authorStr = Author
hierarchy_parent_title = Subcollection
genre_facet = Genre
era_facet = Era
publishDate = "adv_search_year" ; share year string w/advanced search page
; 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[] = publishDate
; These settings control which fields are available to sort on in the Collection
; module.
......
......@@ -174,6 +174,7 @@ Identifier = "Identifier"
Illustrated = Illustrated
Import Record = "Import Record"
Import to = "Import to "
In This Collection = "In This Collection"
Institution = Institution
Institutional Login = "Institutional Login"
Instructor = Instructor
......@@ -192,6 +193,8 @@ Journal Articles = "Journal Articles"
Journal Title = "Journal Title"
Journals = Journals
Jump to = "Jump to"
Keyword = Keyword
Keyword Filter = "Keyword Filter"
Kit = Kit
Language = Language
Last Modified = "Last Modified"
......@@ -351,6 +354,7 @@ Start Page = "Start Page"
Start a new Advanced Search = "Start a new Advanced Search"
Start a new Basic Search = "Start a new Basic Search"
Status = Status
Subcollection = Subcollection
Subject = Subject
Subject Area = "Subject Area"
Subject Recommendations = "Subject Recommendations"
......
......@@ -174,6 +174,7 @@ Identifier = "Identifier"
Illustrated = Illustrated
Import Record = "Import Record"
Import to = "Import to "
In This Collection = "In This Collection"
Institution = Institution
Institutional Login = "Institutional Login"
Instructor = Instructor
......@@ -192,6 +193,8 @@ Journal Articles = "Journal Articles"
Journal Title = "Journal Title"
Journals = Journals
Jump to = "Jump to"
Keyword = Keyword
Keyword Filter = "Keyword Filter"
Kit = Kit
Language = Language
Last Modified = "Last Modified"
......@@ -351,6 +354,7 @@ Start Page = "Start Page"
Start a new Advanced Search = "Start a new Advanced Search"
Start a new Basic Search = "Start a new Basic Search"
Status = Status
Subcollection = Subcollection
Subject = Subject
Subject Area = "Subject Area"
Subject Recommendations = "Subject Recommendations"
......
......@@ -255,6 +255,7 @@ $config = array(
'authorfacets' => 'VuFind\Recommend\AuthorFacets',
'authorityrecommend' => 'VuFind\Recommend\AuthorityRecommend',
'catalogresults' => 'VuFind\Recommend\CatalogResults',
'collectionsidefacets' => 'VuFind\Recommend\CollectionSideFacets',
'europeanaresults' => 'VuFind\Recommend\EuropeanaResults',
'europeanaresultsdeferred' => 'VuFind\Recommend\EuropeanaResultsDeferred',
'expandfacets' => 'VuFind\Recommend\ExpandFacets',
......
<?php
/**
* CollectionSideFacets Recommendations Module
*
* PHP version 5
*
* Copyright (C) Villanova University 2010.
*
* 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 Recommendations
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/
namespace VuFind\Recommend;
/**
* CollectionSideFacets Recommendations Module
*
* This class extends the SideFacets functionality for use in Collection display.
*
* @category VuFind2
* @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/building_a_recommendations_module Wiki
*/
class CollectionSideFacets extends SideFacets
{
/**
* Is the keyword filter box active?
*
* @var bool
*/
protected $keywordFilter = false;
/**
* setConfig
*
* Store the configuration of the recommendation module.
*
* @param string $settings Settings from searches.ini.
*
* @return void
*/
public function setConfig($settings)
{
parent::setConfig($settings);
// Parse the additional settings:
$settings = explode(':', $settings);
if (isset($settings[3]) && $settings[3] !== 'false') {
$this->keywordFilter = true;
}
}
/**
* Get the current value of the keyword filter.
*
* @return string
*/
public function getKeywordFilter()
{
return $this->results->getParams()->getDisplayQuery();
}
/**
* Is the keyword filter box enabled?
*
* @return bool
*/
public function keywordFilterEnabled()
{
return $this->keywordFilter;
}
}
......@@ -122,6 +122,6 @@ class Params extends \VuFind\Search\Solr\Params
$searchSettings = \VuFind\Config\Reader::getConfig('Collection');
return isset($searchSettings->Recommend)
? $searchSettings->Recommend->toArray()
: array();
: array('side' => array('CollectionSideFacets:Facets::Collection:true'));
}
}
\ No newline at end of file
<?
$this->overrideSideFacetCaption = 'In This Collection';
?>
<? if ($this->recommend->keywordFilterEnabled()): ?>
<?
$keywordFilter = $this->recommend->getKeywordFilter();
if (!empty($keywordFilter)) {
$this->extraSideFacetFilters = array(
'Keyword' => array(
array(
'value' => $keywordFilter,
'displayText' => $keywordFilter,
'specialType' => 'keyword'
)
)
);
}
?>
<? ob_start() ?>
<dl class="narrowList navmenu">
<dt><?=$this->transEsc('Keyword Filter')?></dt>
<dd style="padding: 0">
<form method="get" action="" name="keywordFilterForm" id="keywordFilterForm" class="keywordFilterForm">
<input id="keywordFilter_lookfor" type="text" name="lookfor" size="27" value="<?=$this->escapeHtml($keywordFilter)?>"/>
<? foreach ($this->recommend->getResults()->getParams()->getFilterList(true) as $field => $filters): ?>
<? foreach ($filters as $filter): ?>
<input type="hidden" name="filter[]" value="<?=$this->escapeHtml($filter['field'])?>:&quot;<?=$this->escapeHtml($filter['value'])?>&quot;" />
<? endforeach; ?>
<? endforeach; ?>
<input type="submit" name="submit" value="<?=$this->transEsc('Set')?>"/>
</form>
</dd>
</dl>
<? $this->sideFacetExtraControls = ob_get_contents(); ?>
<? ob_end_clean(); ?>
<? endif; ?>
<?=$this->render('Recommend/SideFacets.phtml')?>
\ No newline at end of file
<? $results = $this->recommend->getResults(); ?>
<div class="sidegroup">
<? if ($results->getResultTotal() > 0): ?><h4><?=$this->transEsc('Narrow Search')?></h4><? endif; ?>
<? if ($results->getResultTotal() > 0): ?><h4><?=$this->transEsc(isset($this->overrideSideFacetCaption) ? $this->overrideSideFacetCaption : 'Narrow Search')?></h4><? endif; ?>
<? $checkboxFilters = $results->getParams()->getCheckboxFacets(); if (count($checkboxFilters) > 0): ?>
<? foreach ($checkboxFilters as $current): ?>
<div class="checkboxFilter<?=($results->getResultTotal() < 1 && !$current['selected'] && !$current['alwaysVisible']) ? ' hide' : ''?>">
......@@ -11,13 +11,18 @@
</div>
<? endforeach; ?>
<? endif; ?>
<? $filterList = $results->getParams()->getFilterList(true); if (!empty($filterList)): ?>
<? $extraFilters = isset($this->extraSideFacetFilters) ? $this->extraSideFacetFilters : array(); ?>
<? $filterList = array_merge($results->getParams()->getFilterList(true), $extraFilters); if (!empty($filterList)): ?>
<strong><?=$this->transEsc('Remove Filters')?></strong>
<ul class="filters">
<? foreach ($filterList as $field => $filters): ?>
<? foreach ($filters as $filter): ?>
<?
$removeLink = $this->currentPath().$results->getUrlQuery()->removeFacet($filter['field'], $filter['value']);
if (isset($filter['specialType']) && $filter['specialType'] == 'keyword') {
$removeLink = $this->currentPath().$results->getUrlQuery()->replaceTerm($filter['value'], '');
} else {
$removeLink = $this->currentPath().$results->getUrlQuery()->removeFacet($filter['field'], $filter['value']);
}
if ($filter['displayText'] == '[* TO *]') $filter['displayText'] = $this->translate('filter_wildcard');
?>
<li>
......@@ -28,6 +33,7 @@
<? endforeach; ?>
</ul>
<? endif; ?>
<?= isset($this->sideFacetExtraControls) ? $this->sideFacetExtraControls : '' ?>
<? $sideFacetSet = $this->recommend->getFacetSet(); $dateFacets = $this->recommend->getDateFacets(); ?>
<? if (!empty($sideFacetSet) && $results->getResultTotal() > 0): ?>
<? foreach ($sideFacetSet as $title => $cluster): ?>
......
<? /* Not supported in mobile theme. */ ?>
\ No newline at end of file
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