/**
  * Renders the complete facet.
  *
  * @see	tx_solr_FacetRenderer::render()
  * @return	string	Rendered HTML representing the facet.
  */
 public function render()
 {
     $facetOptionLinks = array();
     $solrConfiguration = tx_solr_Util::getSolrConfiguration();
     $this->template->workOnSubpart('single_facet_option');
     $i = 0;
     foreach ($this->facetOptions as $facetOption => $facetOptionResultCount) {
         if ($facetOption == '_empty_') {
             // TODO - for now we don't handle facet missing.
             continue;
         }
         $facetText = $this->renderOption($facetOption);
         $facetLink = $this->buildAddFacetLink($facetText, $this->facetName . ':' . $facetOption);
         $facetLinkUrl = $this->buildAddFacetUrl($this->facetName . ':' . $facetOption);
         $facetHidden = '';
         if (++$i > $solrConfiguration['search.']['faceting.']['limit']) {
             $facetHidden = 'tx-solr-facet-hidden';
         }
         $facetSelected = $this->isSelectedFacetOption($facetOption);
         // negating the facet option links to remove a filter
         if ($this->facetConfiguration['selectingSelectedFacetOptionRemovesFilter'] && $facetSelected) {
             $facetLink = $this->buildRemoveFacetLink($facetText, $this->facetName . ':' . $facetOption);
             $facetLinkUrl = $this->buildRemoveFacetUrl($this->facetName . ':' . $facetOption);
         }
         if ($this->facetConfiguration['singleOptionMode']) {
             $facetLink = $this->buildReplaceFacetLink($facetText, $this->facetName . ':' . $facetOption);
             $facetLinkUrl = $this->buildReplaceFacetUrl($this->facetName . ':' . $facetOption);
         }
         $facetOptionLinks[] = array('hidden' => $facetHidden, 'link' => $facetLink, 'url' => $facetLinkUrl, 'text' => $facetText, 'value' => $facetOption, 'count' => $facetOptionResultCount, 'selected' => $facetSelected ? '1' : '0');
     }
     $this->template->addLoop('facet_links', 'facet_link', $facetOptionLinks);
     return $this->template->render();
 }
 /**
  * Modifies the given document and returns the modified document as result.
  *
  * @param Tx_Solr_PiResults_ResultsCommand $resultCommand The search result command
  * @param array $resultDocument Result document as array
  * @return array The document with fields as array
  */
 public function modifyResultDocument($resultCommand, array $resultDocument)
 {
     $this->search = $resultCommand->getParentPlugin()->getSearch();
     $configuration = Tx_Solr_Util::getSolrConfiguration();
     $highlightedContent = $this->search->getHighlightedContent();
     $highlightFields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $configuration['search.']['results.']['resultsHighlighting.']['highlightFields'], TRUE);
     foreach ($highlightFields as $highlightField) {
         if (!empty($highlightedContent->{$resultDocument['id']}->{$highlightField}[0])) {
             $fragments = array();
             foreach ($highlightedContent->{$resultDocument['id']}->{$highlightField} as $fragment) {
                 $fragments[] = tx_solr_Template::escapeMarkers($fragment);
             }
             $resultDocument[$highlightField] = implode(' ' . $configuration['search.']['results.']['resultsHighlighting.']['fragmentSeparator'] . ' ', $fragments);
         }
     }
     return $resultDocument;
 }
 /**
  * Renders a solr exception.
  *
  * @return	string	A representation of the exception that should be understandable for the user.
  */
 protected function renderException()
 {
     $this->template->workOnSubpart('solr_search_error');
     return $this->template->render();
 }