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

Added FacetCloud recommendation module.

parent 3dbbf52c
No related merge requests found
......@@ -168,6 +168,9 @@ CallNumber = callnumber
; if [ini name] is left out, it defaults to "facets." Rather than using
; facets to limit the existing search, this module uses them to start a new
; search showing all records matching the selected facet value.
; FacetCloud:[ini section]:[ini name]
; Same functionality as ExpandFacets, but with a more compact interface to
; allow the display of more values.
; OpenLibrarySubjects:[GET parameter]:[limit]:[date filter]:[Subject types]
; Display full-text, public scans from the Open Library (OL) Subjects API.
; [GET parameter] (default = "lookfor"), [limit] (default = 5),
......
......@@ -250,6 +250,7 @@ $config = array(
'europeanaresults' => 'VuFind\Recommend\EuropeanaResults',
'europeanaresultsdeferred' => 'VuFind\Recommend\EuropeanaResultsDeferred',
'expandfacets' => 'VuFind\Recommend\ExpandFacets',
'facetcloud' => 'VuFind\Recommend\FacetCloud',
'favoritefacets' => 'VuFind\Recommend\FavoriteFacets',
'openlibrarysubjects' => 'VuFind\Recommend\OpenLibrarySubjects',
'openlibrarysubjectsdeferred' => 'VuFind\Recommend\OpenLibrarySubjectsDeferred',
......
<?php
/**
* FacetCloud Recommendations Module
*
* PHP Version 5
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu>
* @author Lutz Biedinger <lutz.biedinger@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://www.vufind.org Main Page
*/
namespace VuFind\Recommend;
/**
* FacetCloud Recommendations Module
*
* @category VuFind2
* @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu>
* @author Lutz Biedinger <lutz.biedinger@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://www.vufind.org Main Page
*/
class FacetCloud extends ExpandFacets
{
/**
* Get the facet limit.
*
* @return int
*/
public function getFacetLimit()
{
$params = $this->searchObject->getParams();
$settings = is_callable(array($params, 'getFacetSettings'))
? $params->getFacetSettings() : array();
// Figure out the facet limit -- if available, we can use this to display
// "..." when more facets are available than are currently being displayed,
// although this comes at the cost of not being able to display the last
// entry in the list -- otherwise we might show "..." when we've exactly
// reached (but not exceeded) the facet limit. If we can't get a facet
// limit, we will set an arbitrary high number so that all available values
// will display and "..." will never display.
return isset($settings['limit']) ? $settings['limit'] - 1 : 100000;
}
}
<?
$expandFacetSet = $this->recommend->getExpandedSet();
// Get empty search object to use as basis for parameter generation below:
$blankResults = $this->recommend->getEmptyResults();
$cloudLimit = $this->recommend->getFacetLimit();
?>
<? if ($expandFacetSet): ?>
<div class="sidegroup">
<? foreach ($expandFacetSet as $title=>$facets): ?>
<dl class="narrowList navmenu">
<dt><?=$this->translate($facets['label']) ?></dt>
<?
foreach ($facets['list'] as $i => $facetItem) {
if ($i < $cloudLimit) {
echo (($i == 0) ? '' : ', ')
. '<a href="' . $blankResults->getUrlQuery()->addFacet($title, $facetItem['value']) . '">'
. $this->escapeHtml($facetItem['displayText'])
. '</a> (' . $this->escapeHtml($facetItem['count']) . ')';
} else {
echo ', ...';
break;
}
}
?>
</dl>
<? endforeach; ?>
</div>
<? endif; ?>
<? /* 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