本文整理汇总了PHP中VuFind\Search\Base\Results::getFacetList方法的典型用法代码示例。如果您正苦于以下问题:PHP Results::getFacetList方法的具体用法?PHP Results::getFacetList怎么用?PHP Results::getFacetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VuFind\Search\Base\Results
的用法示例。
在下文中一共展示了Results::getFacetList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* Return the count of records when checkbox filter is activated.
*
* @param array $checkboxFilter Checkbox filter
* @param \VuFind\Search\Base\Results $results Search result set
*
* @return int Record count
*/
public function __invoke($checkboxFilter, $results)
{
$ret = 0;
list($field, $value) = $results->getParams()->parseFilter($checkboxFilter['filter']);
$facets = $results->getFacetList([$field => $value]);
if (isset($facets[$field])) {
foreach ($facets[$field]['list'] as $item) {
if ($item['value'] == $value || substr($value, -1) == '*' && preg_match('/^' . $value . '/', $item['value']) || $item['value'] == 'true' && $value == '1' || $item['value'] == 'false' && $value == '0') {
$ret += $item['count'];
}
}
}
return $ret;
}
示例2: __invoke
/**
* Return the count of records when checkbox filter is activated.
*
* @param array $checkboxFilter Checkbox filter
* @param \VuFind\Search\Base\Results $results Search result set
*
* @return int Record count
*/
public function __invoke($checkboxFilter, $results)
{
$ret = 0;
list($field, $value) = $results->getParams()->parseFilter($checkboxFilter['filter']);
$facets = $results->getFacetList([$field => $value]);
if (isset($facets[$field])) {
foreach ($facets[$field]['list'] as $item) {
if ($item['value'] == $value || substr($value, -1) == '*' && preg_match('/^' . $value . '/', $item['value']) || $item['value'] == 'true' && $value == '1' || $item['value'] == 'false' && $value == '0') {
$ret += $item['count'];
}
}
} elseif ($field == 'online_boolean' && $value == '1') {
// Special case for online_boolean, which is translated to online_str_mv
// when deduplication is enabled.
// If we don't have a facet value for online_boolean it means we need to
// do an additional lookup for online_str_mv.
$results = clone $results;
$params = $results->getParams();
$options = $results->getOptions();
$searchConfig = $this->getView()->getHelperPluginManager()->getServiceLocator()->get('VuFind\\Config')->get($options->getSearchIni());
if (!empty($searchConfig->Records->sources)) {
$sources = explode(',', $searchConfig->Records->sources);
$sources = array_map(function ($s) {
return "\"{$s}\"";
}, $sources);
$params->addFilter('(online_str_mv:' . implode(' OR online_str_mv:', $sources) . ')');
} else {
$params->addFilter('online_str_mv:*');
}
$params->setLimit(0);
$params->resetFacetConfig();
$options->disableHighlighting();
$options->spellcheckEnabled(false);
$results->performAndProcessSearch();
return $results->getResultTotal();
}
return $ret;
}
示例3: process
/**
* process
*
* Called after the Search Results object has performed its main search. This
* may be used to extract necessary information from the Search Results object
* or to perform completely unrelated processing.
*
* @param \VuFind\Search\Base\Results $results Search results object
*
* @return void
*/
public function process($results)
{
$this->results = $results;
$filter = array();
foreach ($this->config as $baseFacet => $exp) {
$filter[$exp['field']] = $exp['label'];
}
$facetsToFilter = $results->getFacetList($filter);
$filteredFacets = array();
foreach ($facetsToFilter as $field => $cluster) {
if (count($cluster['list']) > 1) {
$filteredFacets[$field] = $cluster;
}
}
$this->facets = $filteredFacets;
}
示例4: getExpandedSet
/**
* Get the facet data
*
* @return array
*/
public function getExpandedSet()
{
return $this->searchObject->getFacetList($this->facets);
}