当前位置: 首页>>代码示例>>PHP>>正文


PHP VuFindSearch\ParamBag类代码示例

本文整理汇总了PHP中VuFindSearch\ParamBag的典型用法代码示例。如果您正苦于以下问题:PHP ParamBag类的具体用法?PHP ParamBag怎么用?PHP ParamBag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ParamBag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build

 /**
  * Return Primo search parameters based on a user query and params.
  *
  * @param AbstractQuery $query User query
  *
  * @return ParamBag
  */
 public function build(AbstractQuery $query)
 {
     // Send back results
     $params = new ParamBag();
     $params->set('query', $this->abstractQueryToArray($query));
     return $params;
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:14,代码来源:QueryBuilder.php

示例2: getBackendParameters

 /**
  * Create search backend parameters for advanced features.
  *
  * @return ParamBag
  */
 public function getBackendParameters()
 {
     $backendParams = new ParamBag();
     // Sort
     $sort = $this->getSort();
     $backendParams->set('sortKeys', empty($sort) ? 'relevance' : $sort);
     return $backendParams;
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:13,代码来源:Params.php

示例3: testMergeWithAll

 /**
  * Test "merge with all"
  *
  * @return void
  */
 public function testMergeWithAll()
 {
     $bag1 = new ParamBag(['a' => 1]);
     $bag2 = new ParamBag(['b' => 2]);
     $bag3 = new ParamBag(['c' => 3]);
     $bag3->mergeWithAll([$bag1, $bag2]);
     $this->assertEquals(['a' => [1], 'b' => [2], 'c' => [3]], $bag3->getArrayCopy());
 }
开发者ID:grharry,项目名称:vufind,代码行数:13,代码来源:ParamBagTest.php

示例4: build

 /**
  * Return Summon search parameters based on a user query and params.
  *
  * @param AbstractQuery $query User query
  *
  * @return ParamBag
  */
 public function build(AbstractQuery $query)
 {
     // Build base query
     $queryStr = $this->abstractQueryToString($query);
     // Send back results
     $params = new ParamBag();
     $params->set('query', $queryStr);
     return $params;
 }
开发者ID:grharry,项目名称:vufind,代码行数:16,代码来源:QueryBuilder.php

示例5: testFilterTranslation

 /**
  * Test the listener without setting an authorization service.
  * This should return an empty array.
  *
  * @return void
  */
 public function testFilterTranslation()
 {
     $params = new ParamBag(['fq' => ['foo:value', 'baz:"foo:value"', 'foofoo:value', "foo\\:value", 'baz:value OR foo:value', '(foo:value)']]);
     $listener = new FilterFieldConversionListener(['foo' => 'bar', 'baz' => 'boo']);
     $backend = $this->getMockBuilder('VuFindSearch\\Backend\\Solr\\Backend')->disableOriginalConstructor()->getMock();
     $event = new Event('pre', $backend, ['params' => $params]);
     $listener->onSearchPre($event);
     $fq = $params->get('fq');
     $expected = ['bar:value', 'boo:"foo:value"', 'foofoo:value', "foo\\:value", 'boo:value OR bar:value', '(bar:value)'];
     $this->assertEquals($expected, $fq);
 }
开发者ID:tillk,项目名称:vufind,代码行数:17,代码来源:FilterFieldConversionListenerTest.php

示例6: getBackendParameters

 /**
  * Create search backend parameters for advanced features.
  *
  * @return ParamBag
  */
 public function getBackendParameters()
 {
     $backendParams = new ParamBag();
     // The "relevance" sort option is a VuFind reserved word; we need to make
     // this null in order to achieve the desired effect with Primo:
     $sort = $this->getSort();
     $finalSort = $sort == 'relevance' ? null : $sort;
     $backendParams->set('sort', $finalSort);
     $backendParams->set('filterList', $this->filterList);
     return $backendParams;
 }
开发者ID:tillk,项目名称:vufind,代码行数:16,代码来源:Params.php

示例7: createBackendFilterParameters

 /**
  * Set up filters based on VuFind settings.
  *
  * @param ParamBag $params     Parameter collection to update
  *
  * @return void
  */
 public function createBackendFilterParameters(ParamBag $params)
 {
     // flag our non-Standard checkbox filters:
     $foundIncludeNewspapers = false;
     # includeNewspapers
     $foundIncludeWithoutFulltext = false;
     # includeWithoutFulltext
     $filterList = $this->getFilterList();
     // Which filters should be applied to our query?
     if (!empty($filterList)) {
         // Loop through all filters and add appropriate values to request:
         foreach ($filterList as $filterArray) {
             foreach ($filterArray as $filt) {
                 $safeValue = SummonQuery::escapeParam($filt['value']);
                 if ($filt['field'] == 'holdingsOnly') {
                     // Special case -- "holdings only" is a separate parameter from
                     // other facets.
                     $params->set('holdings', strtolower(trim($safeValue)) == 'true');
                 } else {
                     if ($filt['field'] == 'excludeNewspapers') {
                         // support a checkbox for excluding newspapers:
                         // this is now the default behaviour.
                     } else {
                         if ($filt['field'] == 'includeNewspapers') {
                             // explicitly include newspaper articles
                             $foundIncludeNewspapers = true;
                         } else {
                             if ($range = SolrUtils::parseRange($filt['value'])) {
                                 // Special case -- range query (translate [x TO y] syntax):
                                 $from = SummonQuery::escapeParam($range['from']);
                                 $to = SummonQuery::escapeParam($range['to']);
                                 $params->add('rangeFilters', "PublicationDate,{$from}:{$to}");
                             } else {
                                 if ($filt['field'] == 'includeWithoutFulltext') {
                                     $foundIncludeWithoutFulltext = true;
                                 } else {
                                     // Standard case:
                                     $params->add('filters', "{$filt['field']},{$safeValue}");
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // special cases (apply also when filter list is empty)
     // newspaper articles
     if (!$foundIncludeNewspapers) {
         // this actually means: do *not* show newspaper articles
         $params->add('filters', "ContentType,Newspaper Article,true");
     }
     // combined facet "with holdings/with fulltext"
     if (!$foundIncludeWithoutFulltext) {
         $params->set('holdings', true);
         $params->add('filters', 'IsFullText,true');
     } else {
         $params->set('holdings', false);
     }
 }
开发者ID:CUSAT,项目名称:vufind,代码行数:67,代码来源:Params.php

示例8: search

 /**
  * Perform a search and return record collection.
  *
  * @param AbstractQuery $query  Search query
  * @param integer       $offset Search offset
  * @param integer       $limit  Search limit
  * @param ParamBag      $params Search backend parameters
  *
  * @return RecordCollectionInterface
  */
 public function search(AbstractQuery $query, $offset, $limit, ParamBag $params = null)
 {
     if (null === $params) {
         $params = new ParamBag();
     }
     $params->mergeWith($this->getQueryBuilder()->build($query));
     $response = $this->connector->search($params, $offset, $limit);
     $this->log('debug', print_r($response, true));
     $collection = $this->createRecordCollection($response);
     $this->injectSourceIdentifier($collection);
     return $collection;
 }
开发者ID:tillk,项目名称:vufind,代码行数:22,代码来源:Backend.php

示例9: getBrowserStats

 /**
  * Returns browser usage statistics
  *
  * @param bool $version    Include the version numbers in the list
  * @param int  $listLength How many items to return
  *
  * @return array
  */
 public function getBrowserStats($version, $listLength = 5)
 {
     $query = new Query('*:*');
     $params = new ParamBag();
     $params->add('fl', 'browser,browserVersion');
     $params->add('group', 'true');
     $params->add('group.field', 'session');
     $start = 0;
     $limit = 1000;
     $hashes = [];
     do {
         $response = $this->solrBackend->search($query, $start, $limit, $params);
         $groups = $response->getGroups();
         foreach ($groups['session']['groups'] as $group) {
             if ($version) {
                 // Version specific
                 $browser = $group['doclist']['docs'][0]['browser'] . ' ' . $group['doclist']['docs'][0]['browserVersion'];
                 if (isset($hashes[$browser])) {
                     $hashes[$browser]++;
                 } elseif (count($hashes) < $limit) {
                     $hashes[$browser] = 1;
                 }
             } else {
                 // Browser name
                 if (isset($hashes[$group['doclist']['docs'][0]['browser']])) {
                     $hashes[$group['doclist']['docs'][0]['browser']]++;
                 } elseif (count($hashes) < $limit) {
                     $hashes[$group['doclist']['docs'][0]['browser']] = 1;
                 }
             }
         }
         $start += $limit;
     } while (count($groups['session']['groups']) > 0);
     $solrBrowsers = [];
     foreach ($hashes as $browser => $count) {
         $newBrowser = ['browserName' => $browser, 'count' => $count];
         // Insert sort (limit to listLength)
         for ($i = 0; $i < $listLength - 1 && $i < count($solrBrowsers); $i++) {
             if ($count > $solrBrowsers[$i]['count']) {
                 // Insert in order
                 array_splice($solrBrowsers, $i, 0, [$newBrowser]);
                 continue 2;
                 // Skip the append after this loop
             }
         }
         if (count($solrBrowsers) < $listLength) {
             $solrBrowsers[] = $newBrowser;
         }
     }
     return $solrBrowsers;
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:59,代码来源:Solr.php

示例10: aggregateSpellcheck

 /**
  * Submit requests for more spelling suggestions.
  *
  * @param Spellcheck $spellcheck Aggregating spellcheck object
  * @param string     $query      Spellcheck query
  *
  * @return void
  */
 protected function aggregateSpellcheck(Spellcheck $spellcheck, $query)
 {
     while (next($this->dictionaries) !== false) {
         $params = new ParamBag();
         $params->set('spellcheck', 'true');
         $params->set('spellcheck.dictionary', current($this->dictionaries));
         $queryObj = new Query($query, 'AllFields');
         try {
             $collection = $this->backend->search($queryObj, 0, 0, $params);
             $spellcheck->mergeWith($collection->getSpellcheck());
         } catch (\Exception $ex) {
             if ($this->logger) {
                 $this->logger->err("Exception thrown when aggregating spellcheck, ignoring.", array('exception' => $ex));
             }
         }
     }
 }
开发者ID:paulusova,项目名称:VuFind-2.x,代码行数:25,代码来源:InjectSpellingListener.php

示例11: createBackendExpanderParameters

 /**
  * Set up expanders based on VuFind settings.
  *
  * @param ParamBag $params Parameter collection to update
  *
  * @return void
  */
 public function createBackendExpanderParameters(ParamBag $params)
 {
     // Which filters should be applied to our query?
     if (!empty($this->expanders)) {
         // Loop through all filters and add appropriate values to request:
         $value = '';
         foreach ($this->expanders as $expander) {
             $value = !empty($value) ? $value . ',' . $expander : $expander;
         }
         if (!empty($value)) {
             $params->add('expander', $value);
         }
     }
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:21,代码来源:Params.php

示例12: testAllShardsUsedForRecordRetrieval

 /**
  * Test that loading a record overrides the shard settings.
  *
  * @return void
  */
 public function testAllShardsUsedForRecordRetrieval()
 {
     $params = new ParamBag(['shards' => [self::$shards['b'], self::$shards['c']]]);
     $event = new Event('pre', $this->backend, ['params' => $params, 'context' => 'retrieve']);
     $this->listener->onSearchPre($event);
     $shards = $params->get('shards');
     $this->assertEquals([implode(',', [self::$shards['a'], self::$shards['b'], self::$shards['c']])], $shards);
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:13,代码来源:MultiIndexListenerTest.php

示例13: search

 /**
  * Execute a search.
  *
  * @param ParamBag $params Parameters
  * @param integer  $offset Search offset
  * @param integer  $limit  Search limit
  *
  * @return string
  */
 public function search(ParamBag $params, $offset, $limit)
 {
     $params->set('startRecord', $offset);
     $params->set('maximumRecords', $limit);
     $params->set('servicelevel', 'full');
     $params->set('wskey', $this->wskey);
     $response = $this->call('POST', $params->getArrayCopy(), false);
     $xml = simplexml_load_string($response);
     $docs = isset($xml->records->record) ? $xml->records->record : [];
     $finalDocs = [];
     foreach ($docs as $doc) {
         $finalDocs[] = $doc->recordData->asXML();
     }
     return ['docs' => $finalDocs, 'offset' => $offset, 'total' => isset($xml->numberOfRecords) ? (int) $xml->numberOfRecords : 0];
 }
开发者ID:grharry,项目名称:vufind,代码行数:24,代码来源:Connector.php

示例14: build

 /**
  * Return SOLR search parameters based on a user query and params.
  *
  * @param AbstractQuery $query User query
  *
  * @return ParamBag
  */
 public function build(AbstractQuery $query)
 {
     $params = new ParamBag();
     // Add spelling query if applicable -- note that we mus set this up before
     // we process the main query in order to avoid unwanted extra syntax:
     if ($this->createSpellingQuery) {
         $params->set('spellcheck.q', $query->getAllTerms());
     }
     if ($query instanceof QueryGroup) {
         $query = $this->reduceQueryGroup($query);
     } else {
         $query->setString($this->getLuceneHelper()->normalizeSearchString($query->getString()));
     }
     $string = $query->getString() ?: '*:*';
     if ($handler = $this->getSearchHandler($query->getHandler(), $string)) {
         if (!$handler->hasExtendedDismax() && $this->getLuceneHelper()->containsAdvancedLuceneSyntax($string)) {
             $newString = $this->createAdvancedInnerSearchString($string, $handler);
             if ($handler->hasDismax()) {
                 $oldString = $newString;
                 $newString = $handler->createBoostQueryString($newString);
                 // If a boost was added, we don't want to highlight based on
                 // the boost query, so we should use the non-boosted version:
                 if ($this->createHighlightingQuery && $oldString != $string) {
                     $params->set('hl.q', $oldString);
                 }
                 if ($string == '*:*') {
                     $params->set('hl.q', '*:*');
                 }
             }
             $string = $newString;
         } else {
             if ($handler->hasDismax()) {
                 $params->set('qf', implode(' ', $handler->getDismaxFields()));
                 $params->set('qt', $handler->getDismaxHandler());
                 foreach ($handler->getDismaxParams() as $param) {
                     $params->add(reset($param), next($param));
                 }
                 if ($handler->hasFilterQuery()) {
                     $params->add('fq', $handler->getFilterQuery());
                 }
             } else {
                 $string = $handler->createSimpleQueryString($string);
             }
         }
     }
     $params->set('q', $string);
     return $params;
 }
开发者ID:paulusova,项目名称:VuFind-2.x,代码行数:55,代码来源:QueryBuilder.php

示例15: metalibLinksAjax

 /**
  * Check if MetaLib databases are searchable.
  *
  * @return \Zend\Http\Response
  */
 public function metalibLinksAjax()
 {
     $this->disableSessionWrites();
     // avoid session write timing bug
     $config = $this->getServiceLocator()->get('VuFind\\Config')->get('MetaLib');
     if (!isset($config->General->enabled) || !$config->General->enabled) {
         throw new \Exception('MetaLib is not enabled');
     }
     $auth = $this->serviceLocator->get('ZfcRbac\\Service\\AuthorizationService');
     $authorized = $auth->isGranted('finna.authorized');
     $query = new Query();
     $metalib = $this->getServiceLocator()->get('VuFind\\Search');
     $results = [];
     $ids = $this->getRequest()->getQuery()->get('id');
     foreach ($ids as $id) {
         $backendParams = new ParamBag();
         $backendParams->add('irdInfo', [$id]);
         $result = $metalib->search('MetaLib', $query, false, false, $backendParams);
         $info = $result->getIRDInfo();
         $status = null;
         if ($info && ($authorized || strcasecmp($info['access'], 'guest') == 0)) {
             $status = $info['searchable'] ? 'allowed' : 'nonsearchable';
         } else {
             $status = 'denied';
         }
         $results = ['id' => $id, 'status' => $status];
     }
     return $this->output($results, self::STATUS_OK);
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:34,代码来源:AjaxController.php


注:本文中的VuFindSearch\ParamBag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。