Beispiel #1
0
 /**
  * Map a search query from one class to another.
  *
  * @param \VuFind\Search\Base\Options $activeOptions Search options for source
  * @param string                      $targetClass   Search class ID for target
  * @param string                      $query         Search query to map
  * @param string                      $handler       Search handler to map
  * @param array                       $filters       Tab filters
  *
  * @return string
  */
 protected function remapBasicSearch($activeOptions, $targetClass, $query, $handler, $filters)
 {
     // Set up results object for URL building:
     $targetResults = $this->results->get($targetClass);
     $targetParams = $targetResults->getParams();
     $targetUrlQuery = $targetResults->getUrlQuery();
     foreach ($filters as $filter) {
         $targetParams->addHiddenFilter($filter);
     }
     // Remove any remembered search hash for this tab:
     $targetTabId = $this->getTabId($targetClass, $targetParams->getHiddenFilters());
     if (method_exists($targetUrlQuery, 'removeSearchId')) {
         $targetUrlQuery->removeSearchId($targetTabId);
     }
     // Find matching handler for new query (and use default if no match):
     $targetOptions = $targetResults->getOptions();
     $targetHandler = $targetOptions->getHandlerForLabel($activeOptions->getLabelForBasicHandler($handler));
     $targetParams->setBasicSearch($query, $targetHandler);
     // Clone the active query so that we can remove active filters
     $currentResults = clone $this->getView()->results;
     $urlQuery = $currentResults->getUrlQuery();
     // Remove current filters
     $oldFilters = $currentResults->getParams()->getFilters();
     $tabId = $this->getTabId($this->activeSearchClass, $currentResults->getParams()->getHiddenFilters());
     $currentResults->getParams()->removeHiddenFilters();
     $currentResults->getParams()->removeAllFilters();
     $queryString = null;
     if (!empty($oldFilters)) {
         // Filters were active, include current search id in the url
         if (method_exists($currentResults, 'getSearchHash')) {
             $searchId = $currentResults->getSearchHash();
             if (method_exists($urlQuery, 'setSearchId')) {
                 $queryString = $urlQuery->setSearchId($tabId, $searchId);
             }
         }
     }
     if (null === $queryString) {
         $queryString = $urlQuery->getParams(false);
     }
     // Build new URL:
     $hiddenFilterQuery = substr($targetResults->getUrlQuery()->getParams(false), 1);
     $url = $this->url->__invoke($targetOptions->getSearchAction()) . $queryString;
     if ($hiddenFilterQuery) {
         $url .= "&{$hiddenFilterQuery}";
     }
     return $url;
 }
Beispiel #2
0
 /**
  * Map a search query from one class to another.
  *
  * @param \VuFind\Search\Base\Options $activeOptions Search options for source
  * @param string                      $targetClass   Search class ID for target
  * @param string                      $query         Search query to map
  * @param string                      $handler       Search handler to map
  * @param array                       $filters       Tab filters
  *
  * @return string
  */
 protected function remapBasicSearch($activeOptions, $targetClass, $query, $handler, $filters)
 {
     // Set up results object for URL building:
     $results = $this->results->get($targetClass);
     $params = $results->getParams();
     foreach ($filters as $filter) {
         $params->addHiddenFilter($filter);
     }
     // Find matching handler for new query (and use default if no match):
     $options = $results->getOptions();
     $targetHandler = $options->getHandlerForLabel($activeOptions->getLabelForBasicHandler($handler));
     // Build new URL:
     $results->getParams()->setBasicSearch($query, $targetHandler);
     return $this->url->__invoke($options->getSearchAction()) . $results->getUrlQuery()->getParams(false);
 }
Beispiel #3
0
 /**
  * Map a search query from one class to another.
  *
  * @param \VuFind\Search\Base\Options $activeOptions Search options for source
  * @param string                      $targetClass   Search class ID for target
  * @param string                      $query         Search query to map
  * @param string                      $handler       Search handler to map
  *
  * @return string
  */
 protected function remapBasicSearch($activeOptions, $targetClass, $query, $handler)
 {
     // Set up results object for URL building:
     $results = $this->results->get($targetClass);
     $options = $results->getOptions();
     // Find matching handler for new query (and use default if no match):
     $targetHandler = $options->getHandlerForLabel($activeOptions->getLabelForBasicHandler($handler));
     // Clone helper so that we can remove active filters
     $urlQuery = $this->getView()->results->getUrlQuery();
     $urlQuery = clone $urlQuery;
     // Remove current filters
     if (method_exists($urlQuery, 'removeAllFilters')) {
         $urlQuery->removeAllFilters();
     }
     $filters = $this->getView()->results->getParams()->getFilters();
     if (!empty($filters)) {
         // Filters active, include current search id in the url
         $searchClass = $this->activeSearchClass;
         if (method_exists($this->getView()->results, 'getSearchHash')) {
             $searchId = $this->getView()->results->getSearchHash();
             if (method_exists($urlQuery, 'setSearchId')) {
                 $query = $urlQuery->setSearchId($searchClass, $searchId);
             }
         }
     } else {
         $query = $urlQuery->getParams(false);
     }
     // Build new URL:
     $results->getParams()->setBasicSearch($query, $targetHandler);
     return $this->url->__invoke($options->getSearchAction()) . $query;
 }