/** * Gets the results for the suggested keywords. * * Conducts a new search using the suggested keywords and uses that search * to render the regular results command. * * @return string The rendered results command for the results of the suggested keywords. */ protected function getSuggestionResults() { $spellChecker = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\SpellChecker'); $suggestedKeywords = $spellChecker->getCollatedSuggestion(); $suggestionResults = ''; if (!empty($suggestedKeywords)) { $plugin = $this->parentPlugin; $search = $this->parentPlugin->getSearch(); $query = clone $search->getQuery(); $query->setKeywords($suggestedKeywords); $search->search($query); $resultsCommand = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Plugin\\Results\\ResultsCommand', $plugin); $commandVariables = $resultsCommand->execute(); $suggestionResults = $plugin->renderCommand('results', $commandVariables); } return $suggestionResults; }
/** * Generates the options for the results per page switch. * * @return array Array of results per page switch options. */ public function getResultsPerPageOptions() { $resultsPerPageOptions = array(); $resultsPerPageSwitchOptions = GeneralUtility::intExplode(',', $this->configuration['search.']['results.']['resultsPerPageSwitchOptions'], true); $currentNumberOfResultsShown = $this->parentPlugin->getNumberOfResultsPerPage(); $queryLinkBuilder = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Query\\LinkBuilder', $this->parentPlugin->getSearch()->getQuery()); $queryLinkBuilder->removeUnwantedUrlParameter('resultsPerPage'); $queryLinkBuilder->setLinkTargetPageId($this->parentPlugin->getLinkTargetPageId()); foreach ($resultsPerPageSwitchOptions as $option) { $selected = ''; $selectedClass = ''; if ($option == $currentNumberOfResultsShown) { $selected = ' selected="selected"'; $selectedClass = ' class="currentNumberOfResults"'; } $resultsPerPageOptions[] = array('value' => $option, 'selected' => $selected, 'selectedClass' => $selectedClass, 'url' => $queryLinkBuilder->getQueryUrl(array('resultsPerPage' => $option))); } return $resultsPerPageOptions; }