本文整理汇总了PHP中VuFind\Search\Base\Results::getResultTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP Results::getResultTotal方法的具体用法?PHP Results::getResultTotal怎么用?PHP Results::getResultTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VuFind\Search\Base\Results
的用法示例。
在下文中一共展示了Results::getResultTotal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVisFacets
/**
* Get visual facet details.
*
* @return array
*/
public function getVisFacets()
{
// Don't bother processing if the result set is empty:
if ($this->searchObject->getResultTotal() == 0) {
return [];
}
return $this->processDateFacets($this->searchObject->getParams()->getFilters());
}
示例2: init
/**
* Initialize this result set scroller. This should only be called
* prior to displaying the results of a new search.
*
* @param \VuFind\Search\Base\Results $searchObject The search object that was
* used to execute the last search.
*
* @return bool
*/
public function init($searchObject)
{
// Do nothing if disabled:
if (!$this->enabled) {
return false;
}
// Save the details of this search in the session
$this->data->searchId = $searchObject->getSearchId();
$this->data->page = $searchObject->getParams()->getPage();
$this->data->limit = $searchObject->getParams()->getLimit();
$this->data->total = $searchObject->getResultTotal();
// save the IDs of records on the current page to the session
// so we can "slide" from one record to the next/previous records
// spanning 2 consecutive pages
$this->data->currIds = $this->fetchPage($searchObject);
// clear the previous/next page
unset($this->data->prevIds);
unset($this->data->nextIds);
return (bool) $this->data->currIds;
}
示例3: __invoke
/**
* Represent the current search results as a feed.
*
* @param \VuFind\Search\Base\Results $results Search results to convert to
* feed
* @param string $currentPath Base path to display in feed
* (leave null to load dynamically using currentpath view helper)
*
* @return Feed
*/
public function __invoke($results, $currentPath = null)
{
$this->registerExtension();
// Determine base URL if not already provided:
if (is_null($currentPath)) {
$currentPath = $this->getView()->plugin('currentpath')->__invoke();
}
$serverUrl = $this->getView()->plugin('serverurl');
$baseUrl = $serverUrl($currentPath);
// Create the parent feed
$feed = new Feed();
$feed->setTitle($this->translate('Results for') . ' ' . $results->getParams()->getDisplayQuery());
$feed->setLink($baseUrl . $results->getUrlQuery()->setViewParam(null, false));
$feed->setFeedLink($baseUrl . $results->getUrlQuery()->getParams(false), $results->getParams()->getView());
$feed->setDescription($this->translate('Showing') . ' ' . $results->getStartRecord() . '-' . $results->getEndRecord() . ' ' . $this->translate('of') . ' ' . $results->getResultTotal());
$params = $results->getParams();
// add atom links for easier paging
$feed->addOpensearchLink($baseUrl . $results->getUrlQuery()->setPage(1, false), 'first', $params->getView());
if ($params->getPage() > 1) {
$feed->addOpensearchLink($baseUrl . $results->getUrlQuery()->setPage($params->getPage() - 1, false), 'previous', $params->getView());
}
$lastPage = ceil($results->getResultTotal() / $params->getLimit());
if ($params->getPage() < $lastPage) {
$feed->addOpensearchLink($baseUrl . $results->getUrlQuery()->setPage($params->getPage() + 1, false), 'next', $params->getView());
}
$feed->addOpensearchLink($baseUrl . $results->getUrlQuery()->setPage($lastPage, false), 'last', $params->getView());
// add opensearch fields
$feed->setOpensearchTotalResults($results->getResultTotal());
$feed->setOpensearchItemsPerPage($params->getLimit());
$feed->setOpensearchStartIndex($results->getStartRecord() - 1);
$feed->setOpensearchSearchTerms($params->getQuery()->getString());
$records = $results->getResults();
foreach ($records as $current) {
$this->addEntry($feed, $current);
}
return $feed;
}
示例4: log
/**
* Saves the search to wherever the config [Statistics] says so
*
* @param \VuFind\Search\Base\Results $data Results from Search controller
* @param Zend_Controller_Request_Http $request Request data from the controller
*
* @return void
*/
public function log($data, $request)
{
$stat = ['phrase' => $data->getParams()->getDisplayQuery(), 'searchSource' => $data->getParams()->getSearchClassId(), 'type' => $data->getParams()->getSearchHandler(), 'resultCount' => $data->getResultTotal(), 'noresults' => $data->getResultTotal() == 0];
$this->save($stat, $request);
}
示例5: processJumpTo
/**
* Process the jumpto parameter -- either redirect to a specific record and
* return view model, or ignore the parameter and return false.
*
* @param \VuFind\Search\Base\Results $results Search results object.
*
* @return bool|\Zend\View\Model\ViewModel
*/
protected function processJumpTo($results)
{
// Jump to only result, if configured
$default = null;
$config = $this->getServiceLocator()->get('VuFind\\Config')->get('config');
if (isset($config->Record->jump_to_single_search_result) && $config->Record->jump_to_single_search_result && $results->getResultTotal() == 1) {
$default = 1;
}
// Missing/invalid parameter? Ignore it:
$jumpto = $this->params()->fromQuery('jumpto', $default);
if (empty($jumpto) || !is_numeric($jumpto)) {
return false;
}
// Parameter out of range? Ignore it:
$recordList = $results->getResults();
if (!isset($recordList[$jumpto - 1])) {
return false;
}
// If we got this far, we have a valid parameter so we should redirect
// and report success:
$details = $this->getRecordRouter()->getTabRouteDetails($recordList[$jumpto - 1]);
return $this->redirect()->toRoute($details['route'], $details['params']);
}
示例6: 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;
// function will return blank on Advanced Search
if ($results->getParams()->getSearchType() == 'advanced') {
return;
}
// check result limit before proceeding...
if ($this->resultLimit > 0 && $this->resultLimit < $results->getResultTotal()) {
return;
}
// Build an advanced search request that prevents Solr from retrieving
// records that would already have been retrieved by a search of the biblio
// core, i.e. it only returns results where $lookfor IS found in in the
// "Heading" search and IS NOT found in the "MainHeading" search defined
// in authsearchspecs.yaml.
$request = new Parameters(['join' => 'AND', 'bool0' => ['AND'], 'lookfor0' => [$this->lookfor], 'type0' => ['Heading'], 'bool1' => ['NOT'], 'lookfor1' => [$this->lookfor], 'type1' => ['MainHeading']]);
// Initialise and process search (ignore Solr errors -- no reason to fail
// just because search syntax is not compatible with Authority core):
try {
$authResults = $this->resultsManager->get('SolrAuth');
$authParams = $authResults->getParams();
$authParams->initFromRequest($request);
foreach ($this->filters as $filter) {
$authParams->addHiddenFilter($filter);
}
$results = $authResults->getResults();
} catch (RequestErrorException $e) {
return;
}
// loop through records and assign id and headings to separate arrays defined
// above
foreach ($results as $result) {
// Extract relevant details:
$recordArray = ['id' => $result->getUniqueID(), 'heading' => $result->getBreadcrumb()];
// check for duplicates before adding record to recordSet
if (!$this->inArrayR($recordArray['heading'], $this->recommendations)) {
array_push($this->recommendations, $recordArray);
} else {
continue;
}
}
}
示例7: __invoke
/**
* Represent the current search results as a feed.
*
* @param \VuFind\Search\Base\Results $results Search results to convert to
* feed
* @param string $currentPath Base path to display in feed
* (leave null to load dynamically using currentpath view helper)
*
* @return Feed
*/
public function __invoke($results, $currentPath = null)
{
$this->registerExtension();
// Determine base URL if not already provided:
if (is_null($currentPath)) {
$currentPath = $this->getView()->plugin('currentpath')->__invoke();
}
$serverUrl = $this->getView()->plugin('serverurl');
$baseUrl = $serverUrl($currentPath);
// Create the parent feed
$feed = new Feed();
$translator = $this->getTranslator();
$feed->setTitle($translator('Results for') . ' ' . $results->getParams()->getDisplayQuery());
$feed->setLink($baseUrl . $results->getUrlQuery()->setViewParam(null, false));
$feed->setFeedLink($baseUrl . $results->getUrlQuery()->getParams(false), $results->getParams()->getView());
$records = $results->getResults();
$feed->setDescription($translator('Displaying the top') . ' ' . count($records) . ' ' . $translator('search results of') . ' ' . $results->getResultTotal() . ' ' . $translator('found'));
foreach ($records as $current) {
$this->addEntry($feed, $current);
}
return $feed;
}