/** * @param string $activeSearchClass The search class ID of the active search * @param string $query The current search query * @param string $handler The current search handler * @param string $type The current search type (basic/advanced) * @param string $view variable to determine which tab config should be used * * @return array */ public function __invoke($activeSearchClass, $query, $handler, $type = 'basic', $view = 'default') { $backupConfig = $this->config; $this->config = $this->injectViewDependentConfig($view); $tabs = parent::__invoke($activeSearchClass, $query, $handler, $type); $this->config = $backupConfig; return $tabs; }
/** * Determine information about search tabs * * @param string $activeSearchClass The search class ID of the active search * @param string $query The current search query * @param string $handler The current search handler * @param string $type The current search type (basic/advanced) * @param array $savedSearches Saved search ids from all search tabs * * @return array */ public function __invoke($activeSearchClass, $query, $handler, $type = 'basic', $savedSearches = []) { $this->activeSearchClass = $activeSearchClass; $helper = $this->getView()->results->getUrlQuery(); $tabs = parent::__invoke($activeSearchClass, $query, $handler, $type); $searchTable = $this->table->get('Search'); foreach ($tabs as &$tab) { if (isset($tab['url'])) { $parts = parse_url($tab['url']); $params = []; if (isset($parts['query'])) { parse_str($parts['query'], $params); } // Remove daterange type from URL // (to be added later from a saved search) $dropParams = [SolrParams::SPATIAL_DATERANGE_FIELD . '_type']; $params = array_diff_key($params, array_flip($dropParams)); $filterQuery = false; $searchClass = $tab['class']; if (isset($savedSearches[$searchClass])) { $searchId = $savedSearches[$tab['class']]; $searchSettings = $this->getSearchSettings($searchId); $targetClass = $tab['class']; // Make sure that tab url does not contain the // search id for the same tab. if (isset($searchSettings['params'])) { $params = array_merge($params, $searchSettings['params']); } if (isset($params['search'])) { $filtered = []; foreach ($params['search'] as $search) { list($searchClass, $searchId) = explode(':', $search); if ($searchClass !== $targetClass) { $filtered[] = $search; } } if (!empty($filtered)) { $params['search'] = $filtered; } else { unset($params['search']); } } if (isset($searchSettings['filters'])) { $filterQuery .= '&' . $helper->buildQueryString(['filter' => $searchSettings['filters']], false); } } $url = $parts['path'] . '?' . http_build_query($params); if ($filterQuery) { $url .= '&' . $filterQuery; } $tab['url'] = $url; } } return $tabs; }