public function resultsAction() { // defaults $this->max = $this->registry->getConfig("RECORDS_PER_PAGE", false, 10); $this->max = $this->config->getConfig("RECORDS_PER_PAGE", false, $this->max); $this->max_allowed = $this->registry->getConfig("MAX_RECORDS_PER_PAGE", false, 30); $this->max_allowed = $this->config->getConfig("MAX_RECORDS_PER_PAGE", false, $this->max_allowed); $this->sort = $this->registry->getConfig("SORT_ORDER", false, "relevance"); $this->sort = $this->config->getConfig("SORT_ORDER", false, $this->sort); // params $start = $this->request->getParam('start', 1); $max = $this->request->getParam('max', $this->max); $sort = $this->request->getParam('sort', $this->sort); // swap for internal $internal_sort = $this->config->swapForInternalSort($sort); // make sure records per page does not exceed upper bound if ($max > $this->max_allowed) { $max = $this->max_allowed; } // keep search refinements, if not set by user already and so configured if ($this->request->getSessionData('clear_facets') == '' && $this->config->getConfig('KEEP_SEARCH_REFINEMENT', false, false)) { $this->request->setSessionData('clear_facets', 'false'); } // search $results = $this->engine->searchRetrieve($this->query, $start, $max, $internal_sort); // total $total = $results->getTotal(); // check spelling if ($start <= 1) { $suggestion = $this->checkSpelling(); $this->helper->addSpellingLink($suggestion); $this->data->setVariable('spelling', $suggestion); } // track the query $id = $this->helper->getQueryID(); if ($this->request->getSessionData("stat-{$id}") == "") { // log it // @todo: make this an event try { $log = new \Application\Model\DataMap\Stats(); $log->logSearch($this->id, $this->query, $results); } catch (\Exception $e) { trigger_error('search stats warning: ' . $e->getMessage(), E_USER_WARNING); } // mark we've saved this search log $this->request->setSessionData("stat-{$id}", (string) $total); } // include original record if ($this->config->getConfig('INCLUDE_ORIGINAL_RECORD_IN_BRIEF_RESULTS', false)) { foreach ($results->getRecords() as $record) { $record->includeOriginalRecord(); } } // always cache the total based on the last action $this->request->setSessionData($id, (string) $total); // add links $this->helper->addRecordLinks($results); $this->helper->addFacetLinks($results); $this->helper->addQueryLinks($this->query); // summary, sort & paging elements $results->summary = $this->helper->summary($total, $start, $max); $results->pager = $this->helper->pager($total, $start, $max); $results->sort_display = $this->helper->sortDisplay($sort); // response $this->data->setVariable('query', $this->query); $this->data->setVariable('results', $results); // view template $this->data->setTemplate($this->id . '/results.xsl'); return $this->data; }
public function resultsAction() { // defaults $this->max = $this->registry->getConfig("RECORDS_PER_PAGE", false, 10); $this->max = $this->config->getConfig("RECORDS_PER_PAGE", false, $this->max); $this->max_allowed = $this->registry->getConfig("MAX_RECORDS_PER_PAGE", false, 30); $this->max_allowed = $this->config->getConfig("MAX_RECORDS_PER_PAGE", false, $this->max_allowed); $this->sort = $this->registry->getConfig("SORT_ORDER", false, "relevance"); $this->sort = $this->config->getConfig("SORT_ORDER", false, $this->sort); // params $start = $this->request->getParam('start', 1); $max = $this->request->getParam('max', $this->max); $sort = $this->request->getParam('sort', $this->sort); // swap for internal $internal_sort = $this->config->swapForInternalSort($sort); // make sure records per page does not exceed upper bound if ($max > $this->max_allowed) { $max = $this->max_allowed; } // search $results = $this->engine->searchRetrieve($this->query, $start, $max, $internal_sort); // total $total = $results->getTotal(); // check spelling if ($start <= 1) { $suggestion = $this->checkSpelling(); $this->helper->addSpellingLink($suggestion); $this->data["spelling"] = $suggestion; } // track the query $id = $this->helper->getQueryID(); if ($this->request->getSessionData("stat-{$id}") == "") { // log it // @todo: make this an event try { $log = new \Application\Model\DataMap\Stats(); $log->logSearch($this->id, $this->query, $results); } catch (\Exception $e) { trigger_error('search stats warning: ' . $e->getMessage(), E_USER_WARNING); } // mark we've saved this search log $this->request->setSessionData("stat-{$id}", (string) $total); // cache it $this->request->setSessionData($id, (string) $total); } // add links $this->helper->addRecordLinks($results); $this->helper->addFacetLinks($results); $this->helper->addQueryLinks($this->query); // summary, sort & paging elements $results->summary = $this->helper->summary($total, $start, $max); $results->pager = $this->helper->pager($total, $start, $max); $results->sort_display = $this->helper->sortDisplay($sort); // response $this->data["query"] = $this->query; $this->data["results"] = $results; return $this->data; }