/** * 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 $hiddenFilters The current hidden filters * * @return array */ public function getTabConfig($activeSearchClass, $query, $handler, $type = 'basic', $hiddenFilters = []) { $retVal = []; $matchFound = false; $allFilters = $this->helper->getTabFilterConfig(); foreach ($this->helper->getTabConfig() as $key => $label) { $class = $this->helper->extractClassName($key); $filters = isset($allFilters[$key]) ? (array) $allFilters[$key] : []; if ($class == $activeSearchClass && $this->helper->filtersMatch($class, $hiddenFilters, $filters)) { $matchFound = true; $retVal[] = $this->createSelectedTab($key, $class, $label); } else { if ($type == 'basic') { if (!isset($activeOptions)) { $activeOptions = $this->results->get($activeSearchClass)->getOptions(); } $newUrl = $this->remapBasicSearch($activeOptions, $class, $query, $handler, $filters); $retVal[] = $this->createBasicTab($key, $class, $label, $newUrl); } else { if ($type == 'advanced') { $retVal[] = $this->createAdvancedTab($key, $class, $label, $filters); } else { $retVal[] = $this->createHomeTab($key, $class, $label, $filters); } } } } if (!$matchFound && !empty($retVal)) { // Make the first tab for the given search class selected foreach ($retVal as &$tab) { if ($tab['class'] == $activeSearchClass) { $tab['selected'] = true; break; } } } return $retVal; }