public function execute()
 {
     $searchWord = trim($this->parentPlugin->piVars['q']);
     $searchWord = t3lib_div::removeXSS($searchWord);
     $nothingFound = strtr($this->parentPlugin->pi_getLL('no_results_nothing_found'), array('@searchWord' => htmlentities($searchWord, ENT_QUOTES, $GLOBALS['TSFE']->metaCharset)));
     $searchedFor = strtr($this->parentPlugin->pi_getLL('results_searched_for'), array('@searchWord' => htmlentities($searchWord, ENT_QUOTES, $GLOBALS['TSFE']->metaCharset)));
     return array('nothing_found' => $nothingFound, 'searched_for' => $searchedFor);
 }
 protected function getSortingLinks()
 {
     $configuredSortingFields = $this->configuration['search.']['sorting.']['fields.'];
     $query = $this->search->getQuery();
     $query->setLinkTargetPageId($this->parentPlugin->getLinkTargetPageId());
     $sortingFields = array();
     $urlParameters = t3lib_div::_GP('tx_solr');
     $urlSortingParameter = $urlParameters['sort'];
     list($currentSortByField, $currentSortDirection) = explode(' ', $urlSortingParameter);
     foreach ($configuredSortingFields as $fieldName => $enabled) {
         if (substr($fieldName, -1) != '.' && $enabled) {
             $sortDirection = $this->configuration['search.']['sorting.']['defaultOrder'];
             $sortIndicator = $sortDirection;
             $sortParameter = $fieldName . ' ' . $sortDirection;
             // toggle sorting direction for the current sorting field
             if ($currentSortByField == $fieldName) {
                 switch ($currentSortDirection) {
                     case 'asc':
                         $sortDirection = 'desc';
                         $sortIndicator = 'asc';
                         break;
                     case 'desc':
                         $sortDirection = 'asc';
                         $sortIndicator = 'desc';
                         break;
                 }
                 $sortParameter = $fieldName . ' ' . $sortDirection;
             }
             $temp = array('link' => $query->getQueryLink('###LLL:' . $configuredSortingFields[$fieldName . '.']['label'] . '###', array('sort' => $sortParameter)), 'url' => $query->getQueryUrl(array('sort' => $sortParameter)), 'field' => $fieldName, 'label' => '###LLL:' . $configuredSortingFields[$fieldName . '.']['label'] . '###', 'is_current' => $currentSortByField == $fieldName ? '1' : '0', 'direction' => $sortDirection, 'indicator' => $sortIndicator, 'current_direction' => ' ');
             // set sort indicator for the current sorting field
             if ($currentSortByField == $fieldName) {
                 $temp['selected'] = 'selected="selected"';
                 $temp['current'] = 'current';
                 $temp['current_direction'] = $sortIndicator;
             }
             // special case relevancy: just reset the search to normal behavior
             if ($fieldName == 'relevancy') {
                 $temp['link'] = $query->getQueryLink('###LLL:' . $configuredSortingFields[$fieldName . '.']['label'] . '###', array('sort' => NULL));
                 unset($temp['direction'], $temp['indicator']);
             }
             $sortingFields[] = $temp;
         }
     }
     return $sortingFields;
 }
 /**
  * Returns the URL to which the Ajax request for the suggest functionality should be sent.
  *
  * @author Mario Rimann <*****@*****.**>
  * @return string the full URL to the eID script including the needed parameters
  */
 protected function getSuggestUrl()
 {
     $suggestUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
     if ($this->parentPlugin->conf['suggest.']['forceHttps']) {
         $suggestUrl = str_replace('http://', 'https://', $suggestUrl);
     }
     $suggestUrl .= '?eID=tx_solr_suggest&id=' . $GLOBALS['TSFE']->id;
     // add filters
     $additionalFilters = $this->parentPlugin->getAdditionalFilters();
     if (!empty($additionalFilters)) {
         $additionalFilters = json_encode($additionalFilters);
         $additionalFilters = urlencode($additionalFilters);
         $suggestUrl .= '&filters=' . $additionalFilters;
     }
     // adds the language parameter to the suggest URL
     if ($GLOBALS['TSFE']->sys_language_uid > 0) {
         $suggestUrl .= '&L=' . $GLOBALS['TSFE']->sys_language_uid;
     }
     return $suggestUrl;
 }
    protected function addFacetsJavascript()
    {
        $jsFilePath = t3lib_extMgm::siteRelPath('solr') . 'resources/javascript/pi_results/results.js';
        // TODO make configurable once someone wants to use something other than jQuery
        $GLOBALS['TSFE']->additionalHeaderData[$this->parentPlugin->prefixId . '_faceting'] = '
			<script type="text/javascript">
			/*<![CDATA[*/

			var tx_solr_facetLabels = {
				\'showMore\' : \'' . $this->parentPlugin->pi_getLL('faceting_showMore') . '\',
				\'showFewer\' : \'' . $this->parentPlugin->pi_getLL('faceting_showFewer') . '\'
			};

			/*]]>*/
			</script>
			';
        if ($this->parentPlugin->conf['addDefaultJs']) {
            $GLOBALS['TSFE']->additionalHeaderData[$this->parentPlugin->prefixId . '_faceting'] .= '<script type="text/javascript" src="' . $jsFilePath . '"></script>';
        }
    }
 protected function getResultsPerPageSwitch()
 {
     $template = clone $this->parentPlugin->getTemplate();
     $template->workOnSubpart('results_per_page_switch');
     $configuration = tx_solr_Util::getSolrConfiguration();
     $resultsPerPageSwitchOptions = t3lib_div::intExplode(',', $configuration['search.']['results.']['resultsPerPageSwitchOptions']);
     $currentNumberOfResultsShown = $this->parentPlugin->getNumberOfResultsPerPage();
     $selectOptions = array();
     foreach ($resultsPerPageSwitchOptions as $option) {
         $selected = '';
         $selectedClass = '';
         if ($option == $currentNumberOfResultsShown) {
             $selected = ' selected="selected"';
             $selectedClass = ' class="currentNumberOfResults"';
         }
         $selectOptions[] = array('value' => $option, 'selected' => $selected, 'selectedClass' => $selectedClass, 'url' => $this->parentPlugin->pi_linkTP_keepPIvars_url(array('resultsPerPage' => $option)));
     }
     $template->addLoop('options', 'option', $selectOptions);
     $form = array('action' => $this->parentPlugin->pi_linkTP_keepPIvars_url());
     $template->addVariable('form', $form);
     return $template->render();
 }