Esempio n. 1
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * Get the facet data
  *
  * @return array
  */
 public function getExpandedSet()
 {
     return $this->searchObject->getFacetList($this->facets);
 }