diff --git a/config/vufind/searches.ini b/config/vufind/searches.ini index 742ac5a4353285f9d6944ff0eaa56bd2cfd87139..9ace9c2cfba15fe9a8fc666fbca3fa25c98cc04f 100644 --- a/config/vufind/searches.ini +++ b/config/vufind/searches.ini @@ -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), diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index bf149c7a8367ddacb6a8bcf8663fb4d94bbf3ca6..b2119e961456982dd52e08f7e7f7077ea8d8e026 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -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', diff --git a/module/VuFind/src/VuFind/Recommend/FacetCloud.php b/module/VuFind/src/VuFind/Recommend/FacetCloud.php new file mode 100644 index 0000000000000000000000000000000000000000..9239c2f074babbdf4b1d9b49b11c21d155cfd4ec --- /dev/null +++ b/module/VuFind/src/VuFind/Recommend/FacetCloud.php @@ -0,0 +1,63 @@ +<?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; + } +} diff --git a/themes/blueprint/templates/Recommend/FacetCloud.phtml b/themes/blueprint/templates/Recommend/FacetCloud.phtml new file mode 100644 index 0000000000000000000000000000000000000000..4ece12d95662dcf89347565a1df09c5bffbe62fd --- /dev/null +++ b/themes/blueprint/templates/Recommend/FacetCloud.phtml @@ -0,0 +1,28 @@ +<? + $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; ?> diff --git a/themes/jquerymobile/templates/Recommend/FacetCloud.phtml b/themes/jquerymobile/templates/Recommend/FacetCloud.phtml new file mode 100644 index 0000000000000000000000000000000000000000..0df1e74df188b2630299fe4da6e7178c92ad5afc --- /dev/null +++ b/themes/jquerymobile/templates/Recommend/FacetCloud.phtml @@ -0,0 +1 @@ +<? /* Not supported in mobile theme. */ ?> \ No newline at end of file