/**
  * ResultsAction is called by statusAction once the search has completed
  * Uses parent (SearchController) resultsAction
  */
 public function resultsAction()
 {
     //var_dump($this->request); exit;
     $uo = new UserOptions($this->request);
     $sid = $uo->getSessionData('pz2session');
     try {
         // force restoration of client from cache
         $status = $this->engine->getSearchStatus($sid);
         // fetch the search results
         $result = parent::resultsAction();
     } catch (\Exception $e) {
         // Exception probably a session timeout; go back to front page
         $this->flashMessenger->addMessage('Error|Session timeout: ' . $e->getMessage());
         $params = $this->query->getAllSearchParams();
         $params['controller'] = 'pazpar2';
         $params['action'] = 'index';
         $params['Submit'] = '';
         $url = $this->request->url_for($params);
         return $this->redirect()->toUrl($url);
     }
     // keep the session number for the AJAX code in the output HTML
     $this->request->setSessionData('pz2session', $sid);
     $targets = $uo->getSessionData('targets');
     $type = $uo->getSessionData('source_type');
     $targets = new Targets($type, $targets);
     $result->setVariable('useroptions', $uo);
     $result->setVariable('targets', $targets->getTargetNames());
     // needed for the facets
     //$result['status'] = $status->getTargetStatuses($this->query->getTargets());
     //$result['externalLinks'] = $this->helper->addExternalLinks($this->config);
     return $result;
 }
 /**
  * ResultsAction is called by statusAction once the search has completed
  * Uses parent (SearchController) resultsAction
  */
 public function resultsAction()
 {
     $uo = new UserOptions($this->request);
     $sid = $uo->getSessionData('pz2session');
     try {
         // force restoration of client from cache
         $status = $this->engine->getSearchStatus($sid);
         // fetch the search results
         $result = parent::resultsAction();
     } catch (\Exception $e) {
         // Exception probably a session timeout; go back to front page
         $this->flashMessenger->addMessage('Error|Session timeout: ' . $e->getMessage());
         $params = $this->query->getAllSearchParams();
         $params['controller'] = 'pazpar2';
         $params['action'] = 'index';
         $params['Submit'] = '';
         $url = $this->request->url_for($params);
         return $this->redirect()->toUrl($url);
     }
     // keep the session number for the AJAX code in the output HTML
     $this->request->setSessionData('pz2session', $sid);
     $params = $this->query->getAllSearchParams();
     $pairs = array();
     foreach ($params as $k => $v) {
         if (is_array($v)) {
             foreach ($v as $e) {
                 $pairs[] = "{$k}={$e}";
             }
         } else {
             $pairs[] = "{$k}={$v}";
         }
     }
     $query_string = implode('&', $pairs);
     // needed by javascript (currently only for aim25)
     $this->request->setSessionData('querystring', $query_string);
     $targets = $uo->getSessionData('targets');
     $type = $uo->getSessionData('source_type');
     $targets = new Targets($type, $targets);
     $result->setVariable('externalLinks', $this->helper->addExternalLinks($this->config));
     $result->setVariable('useroptions', $uo);
     $result->setVariable('targets', $targets->getTargetNames());
     // needed for the facets
     //$result['status'] = $status->getTargetStatuses($this->query->getTargets());
     //$result['externalLinks'] = $this->helper->addExternalLinks($this->config);
     return $result;
 }