Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. // SEARCH VIEW
  2. $app->get('/search', function ($request, $response, $args) {
  3. $api = $this->APIRequest->get($request->getAttribute('path'),$request->getQueryParams());
  4. $args['data'] = json_decode($api->getBody(), true);
  5. return $this->view->render($response, 'search.html.twig', $args);
  6. })->setName('search');
  7.  
  8. // ADVANCED SEARCH VIEW
  9. $app->get('/advanced_search', function ($request, $response, $args) {
  10. return $this->view->render($response, 'advanced_search.html.twig', $args);
  11. });
  12.  
  13. // ADVANCED SEARCH PROCESS
  14. $app->post('/advanced_search', function ($request, $response, $args) {
  15.  
  16. // get settings
  17. $settings = $this->get('settings');
  18.  
  19. // get post parameters
  20. $qp = $request->getParsedBody();
  21.  
  22. // translate advanced search form parameters to Solr-ese
  23. $search_params = array();
  24. $search_params['q'] = $qp['query'];
  25.  
  26. // redirect to GET:/search, with search parameters
  27. $url = $this->router->pathFor('search', $search_params);
  28. return $response->withStatus(302)->withHeader('Location', $url);
  29.  
  30. });
  31.  
  32. // SEARCH VIEW
  33. $app->get('/search', function ($request, $response, $args) {
  34. $api = $this->APIRequest->get($request->getAttribute('path'),$request->getQueryParams());
  35. $args['data'] = json_decode($api->getBody(), true);
  36. return $this->view->render($response, 'search.html.twig', $args);
  37. })->setName('search');
  38.  
  39. // ADVANCED SEARCH VIEW
  40. $app->get('/advanced_search', function ($request, $response, $args) {
  41. return $this->view->render($response, 'advanced_search.html.twig', $args);
  42. });
  43.  
  44. // ADVANCED SEARCH PROCESS
  45. $app->post('/advanced_search', function ($request, $response, $args) {
  46.  
  47. // get settings
  48. $settings = $this->get('settings');
  49.  
  50. // get post parameters
  51. $qp = $request->getParsedBody();
  52.  
  53. // translate advanced search form parameters to Solr-ese
  54. $search_params = array();
  55. $search_params['q'] = $qp['query'];
  56.  
  57. // redirect to GET:/search, with search parameters
  58. $url = $this->router->pathFor('search')."?".http_build_query($search_params);
  59. return $response->withStatus(302)->withHeader('Location', $url);
  60.  
  61. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement