Skip to content
Snippets Groups Projects
Commit 1b51004e authored by Frank Morgner's avatar Frank Morgner Committed by André Lahmann
Browse files

refs #7624 implementation of AllowFacetValue in SideFacets.phtml in finc View/Helper

* enable only a whitelist of facet value to display
* realized in View/Helper/Root for all instances
* configuration facets.ini
parent f2c1b713
No related merge requests found
...@@ -220,6 +220,12 @@ facet_limit = 20 ...@@ -220,6 +220,12 @@ facet_limit = 20
[HideFacetValue] [HideFacetValue]
;format[] = "Book" ;format[] = "Book"
; Allow only a defined set of facets to be displayed to the user as a kind of
; whitelist.
; Use facet field names as keys and untranslated facet values as values.
[AllowFacetValue]
;format[] = "Book"
; Added for finc project ; Added for finc project
; Array of stricter facets hiding to diminsh displaying ; Array of stricter facets hiding to diminsh displaying
; facet contents by starting searching. ; facet contents by starting searching.
......
...@@ -132,4 +132,19 @@ class Factory ...@@ -132,4 +132,19 @@ class Factory
isset($config->General) ? $config : null isset($config->General) ? $config : null
); );
} }
/**
* Construct the SideFacet helper.
*
* @param ServiceManager $sm Service manager.
*
* @return SideFacet
*/
public static function getSideFacet(ServiceManager $sm)
{
return new SideFacet(
$sm->getServiceLocator()->get('VuFind\Config')->get('facets')
);
}
} }
<?php
/**
* Side facet view helper
*
* PHP version 5
*
* Copyright (C) Villanova University 2010.
* Copyright (C) Leipzig University Library 2016.
*
* 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 VuFind
* @package View_Helpers
* @author Demian Katz <demian.katz@villanova.edu>
* @author Frank Morgner <morgnerf@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
namespace finc\View\Helper\Root;
/**
* Permissions view helper
*
* @category VuFind
* @package View_Helpers
* @author Demian Katz <demian.katz@villanova.edu>
* @author Frank Morgner <morgnerf@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class SideFacet extends \Zend\View\Helper\AbstractHelper
{
/**
* VuFind configuration
*
* @var \Zend\Config\Config
*/
protected $config;
/**
* Constructor
*
* @param \Zend\Config\Config $config VuFind configuration
* @access public
*/
public function __construct($config = null)
{
$this->config = $config;
}
/**
* Checks whether the user is logged in.
*
* @param array $sideFacets List of side facets
*
* @return array Filtered side facets
* @access public
*/
public function displayAllowedFacetValues($sideFacets)
{
if (!isset($this->config->AllowFacetValue) ||
count($this->config->AllowFacetValue) == 0
) {
return $sideFacets;
}
foreach ($this->config->AllowFacetValue as $label => $values) {
if (isset($sideFacets[$label])) {
foreach ($sideFacets[$label]['list'] as $key => &$item) {
if (!in_array($item['value'], $values->toArray())) {
unset($sideFacets[$label]['list'][$key]);
}
}
}
}
return $sideFacets;
}
}
This diff is collapsed.
...@@ -17,6 +17,7 @@ return array( ...@@ -17,6 +17,7 @@ return array(
'citation' => 'finc\View\Helper\Root\Factory::getCitation', 'citation' => 'finc\View\Helper\Root\Factory::getCitation',
'openurl' => 'finc\View\Helper\Root\Factory::getOpenUrl', 'openurl' => 'finc\View\Helper\Root\Factory::getOpenUrl',
'branchinfo' => 'finc\View\Helper\Root\Factory::getBranchInfo', 'branchinfo' => 'finc\View\Helper\Root\Factory::getBranchInfo',
'sidefacet' => 'finc\View\Helper\Root\Factory::getSideFacet'
), ),
'invokables' => array( 'invokables' => array(
'resultfeed' => 'finc\View\Helper\Root\ResultFeed' 'resultfeed' => 'finc\View\Helper\Root\ResultFeed'
......
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