Exemple #1
0
 /**
  * Creates the HTML for the relevance output
  *
  * @param array $arguments Array of arguments, [0] is expected to contain the result document.
  * @return string The score as percent value.
  */
 public function execute(array $arguments = array())
 {
     $content = '';
     $document = $arguments[0];
     if (count($arguments) > 1) {
         // a pipe character caused the serialized document to be split up
         $document = implode('|', $arguments);
     }
     if ($this->search->hasSearched() && $this->search->getNumberOfResults()) {
         $score = $this->getScore($document);
         $maximumScore = $this->getMaximumScore($document);
         $content = $this->render($score, $maximumScore);
     }
     return $content;
 }
Exemple #2
0
 /**
  * Creates a link to a given page with a given link text with the current
  * tx_solr parameters appended to the URL
  *
  * @param array Array of arguments, [0] is the link text, [1] is the (optional) page Id to link to (otherwise TSFE->id), [2] are additional URL parameters, [3] use cache, defaults to FALSE
  * @return string complete anchor tag with URL and link text
  */
 public function execute(array $arguments = array())
 {
     $linkText = $arguments[0];
     $pageId = $this->determinePageId(trim($arguments[1]));
     $additionalUrlParameters = $arguments[2] ? $arguments[2] : '';
     $useCache = $arguments[3] ? true : false;
     $returnOnlyUrl = $arguments[4] ? true : false;
     // FIXME pass anything not prefixed with tx_solr in $additionalParameters as 4th parameter
     $additionalUrlParameters = GeneralUtility::explodeUrl2Array($additionalUrlParameters, true);
     $solrUrlParameters = array();
     if (!empty($additionalUrlParameters['tx_solr'])) {
         $solrUrlParameters = $additionalUrlParameters['tx_solr'];
     }
     $linkConfiguration = array('useCacheHash' => $useCache);
     if ($returnOnlyUrl) {
         $linkConfiguration['returnLast'] = 'url';
     }
     if ($this->search->hasSearched()) {
         $query = $this->search->getQuery();
     } else {
         $query = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Query', '');
     }
     $linkBuilder = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Query\\LinkBuilder', $query);
     $linkBuilder->setLinkTargetPageId($pageId);
     $queryLink = $linkBuilder->getQueryLink($linkText, $solrUrlParameters, $linkConfiguration);
     return $queryLink;
 }
Exemple #3
0
 /**
  * Generates a link with spell checking suggestions if it is activated and
  * spell checking suggestions are returned by Solr.
  *
  * @return string A link to start over with a new search using the suggested keywords.
  */
 public function getSpellCheckingSuggestions()
 {
     $suggestionsLink = '';
     if ($this->configuration['search.']['spellchecking'] && $this->search->hasSearched()) {
         $suggestions = $this->getSuggestions();
         if ($suggestions && !$suggestions['correctlySpelled'] && !empty($suggestions['collation'])) {
             $suggestionsLink = $GLOBALS['TSFE']->cObj->noTrimWrap($this->getSuggestionQueryLink(), $this->configuration['search.']['spellchecking.']['wrap']);
         }
     }
     return $suggestionsLink;
 }
 /**
  * @return bool
  */
 public function getHasSearched()
 {
     return $this->search->hasSearched();
 }