/** * Get the build from current search page. */ protected function build() { pager_default_initialize($this->result->getTotalCount(), $this->resultsPerPage); $build = array(); if ($this->fullPage) { $build['results'] = array('#theme' => 'culturefeed_search_page', '#searchresult' => $this->result); } else { $build['results'] = array('#theme' => 'culturefeed_search_list', '#items' => $this->result, '#nowrapper' => TRUE); } if ($this->result->getTotalCount() > 0) { $build['pager-container'] = array('#type' => 'container', '#attributes' => array()); if ($this->pagerType == self::PAGER_NORMAL) { $build['pager-container']['pager_summary'] = array('#theme' => 'culturefeed_search_pager_summary', '#result' => $this->result, '#start' => ($this->pageNumber - 1) * $this->resultsPerPage); $build['pager-container']['pager'] = array('#theme' => 'pager', '#quantity' => 5); } elseif ($this->pagerType == self::PAGER_INFINITE_SCROLL) { $params = drupal_get_query_parameters(); $rest = $this->result->getTotalCount() - ($this->pageNumber - 1) * $this->resultsPerPage; $params['page'] = $this->pageNumber; $build['pager-container'] = array('#type' => 'container', '#attributes' => array('class' => array('more-link infinite-scroll'))); if ($rest >= 0) { $build['pager-container']['pager'] = array('#type' => 'link', '#title' => t('More results'), '#href' => strpos($_GET['q'], 'nojs') === FALSE ? $_GET['q'] . '/nojs' : $_GET['q'], '#options' => array('query' => $params), '#ajax' => array(), '#attributes' => array('class' => array('btn btn-primary btn-block btn-large'), 'rel' => array('nofollow'))); } if ($rest <= $this->resultsPerPage) { $link = l(t('perform a new search.'), str_replace("/ajax", "", $_GET['q'])); $build['pager-container']['pager'] = array('#markup' => '<div class="alert"><p><strong>' . t('There are no more search results.') . '</strong></p> <p>' . t('Refine your search results or') . ' ' . $link . '</p></div>'); } if ($this->fullPage) { $build['#prefix'] = '<div id="culturefeed-search-results-more-wrapper">'; $build['#suffix'] = '</div>'; } } } return $build; }
public function obtainResults(SearchResult $result) { $xmlElement = $result->getXmlElement(); $factory = new FacetFactory(); $this->facets = $factory->createFromXML($xmlElement, $this->facets); }
/** * Execute a pages search call to the service. * @param array $parameters * Parameters to be used in the request. * @return SearchResult */ public function searchPages($parameters = array()) { $response = $this->executeSearch('search/page', $parameters, false); return SearchResult::fromPagesXml(new SimpleXMLElement($response->getBody(true))); }
/** @var \Symfony\Component\HttpFoundation\Session\Session $session */ $session = $app['session']; $session->invalidate(); return new Response('Logged out'); }); $app->get('search', function (Request $request, Application $app) { $q = $request->query->get('q'); $limit = new \CultuurNet\Search\Parameter\Rows($request->query->get('limit', 30)); $start = new \CultuurNet\Search\Parameter\Start($request->query->get('start', 0)); $group = new \CultuurNet\Search\Parameter\Group(); $typeFilter = new \CultuurNet\Search\Parameter\FilterQuery('type:event'); /** @var SearchAPI2 $service */ $service = $app['search_api_2']; $q = new \CultuurNet\Search\Parameter\Query($q); $response = $service->search(array($q, $limit, $start, $group, $typeFilter)); $results = \CultuurNet\Search\SearchResult::fromXml(new SimpleXMLElement($response->getBody(true), 0, false, \CultureFeed_Cdb_Default::CDB_SCHEME_URL)); $response = Response::create()->setContent($results->getXml())->setPublic()->setClientTtl(60 * 1)->setTtl(60 * 5); $response->headers->set('Content-Type', 'text/xml'); return $response; })->before($checkAuthenticated); $app->get('api/1.0/event.jsonld', function (Request $request, Application $app) { $response = new \Symfony\Component\HttpFoundation\BinaryFileResponse('api/1.0/event.jsonld'); $response->headers->set('Content-Type', 'application/ld+json'); return $response; }); $app->get('api/1.0/search', function (Request $request, Application $app) { $query = $request->query->get('query', '*.*'); $limit = $request->query->get('limit', 30); $start = $request->query->get('start', 0); $sort = $request->query->get('sort', 'lastupdated desc'); /** @var Psr\Log\LoggerInterface $logger */