/**
  * Modifies the given query and adds the parameters necessary for faceted
  * search.
  *
  * @param	tx_solr_Query	The query to modify
  * @return	tx_solr_Query	The modified query with faceting parameters
  */
 public function modifyQuery(tx_solr_Query $query)
 {
     $this->buildFacetingParameters();
     $this->addFacetQueryFilters();
     foreach ($this->facetParameters as $facetParameter => $value) {
         $query->addQueryParameter($facetParameter, $value);
     }
     foreach ($this->facetFilters as $filter) {
         $query->addFilter($filter);
     }
     return $query;
 }
 /**
  * Returns an URL that switches sorting to the given sorting field
  *
  * @param array $arguments
  * @return	string
  */
 public function execute(array $arguments = array())
 {
     $sortUrl = '';
     $configuredSortingFields = $this->configuration['search.']['sorting.']['fields.'];
     $sortField = $arguments[0];
     $urlParameters = t3lib_div::_GP('tx_solr');
     $urlSortingParameter = $urlParameters['sort'];
     list($currentSortByField, $currentSortDirection) = explode(' ', $urlSortingParameter);
     if (array_key_exists($sortField, $configuredSortingFields) && $configuredSortingFields[$sortField] == 1) {
         $sortDirection = $this->configuration['search.']['sorting.']['defaultOrder'];
         $sortParameter = $sortField . ' ' . $sortDirection;
         // toggle sorting direction for the current sorting field
         if ($currentSortByField == $sortField) {
             switch ($currentSortDirection) {
                 case 'asc':
                     $sortDirection = 'desc';
                     break;
                 case 'desc':
                     $sortDirection = 'asc';
                     break;
             }
             $sortParameter = $sortField . ' ' . $sortDirection;
         }
         $sortUrl = $this->query->getQueryUrl(array('sort' => $sortParameter));
     }
     return $sortUrl;
 }
 /**
  * Executes a search against a Solr server.
  *
  * @param	tx_solr_Query	$query The query with keywords, filters, and so on.
  * @param	integer	$offset Result offset for pagination.
  * @param	integer	$limit Maximum number of results to return.
  * @return	Apache_Solr_Response	Solr response
  */
 public function search(tx_solr_Query $query, $offset = 0, $limit = 10)
 {
     // * get query string
     // * do actual search by calling the parent's search method
     // * obey the debug setting
     $this->query = $query;
     try {
         $response = $this->solr->search($query->getQueryString(), $offset, $limit, $query->getQueryParameters());
         if ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['logging.']['query.']['queryString']) {
             t3lib_div::devLog('querying solr, getting result', 'tx_solr', 0, array('query string' => $query->getQueryString(), 'query parameters' => $query->getQueryParameters(), 'response' => json_decode($response->getRawResponse(), TRUE)));
         }
     } catch (Exception $e) {
         // FIXME fix searches like "*.*", "-", "+"
         if ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['logging.']['exceptions']) {
             t3lib_div::devLog('exception while querying solr', 'tx_solr', 3, array($e->__toString()));
         }
     }
     return $response;
 }
 /**
  * constructor for class tx_solr_SuggestQuery
  */
 public function __construct($keywords)
 {
     parent::__construct('');
     $this->configuration = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['suggest.'];
     $matches = array();
     preg_match('/^(:?(.* |))([^ ]+)$/', $keywords, $matches);
     $fullKeywords = trim($matches[2]);
     $partialKeyword = trim($matches[3]);
     $this->setKeywords($fullKeywords);
     $this->prefix = $partialKeyword;
 }
 /**
  * Builds the url to a facet from a search result.
  *
  * @param	string	$facetToReplace A filter string to use in the link parameters
  * @return	string	Url to remooce a facet
  */
 protected function buildReplaceFacetUrl($facetToReplace)
 {
     $filterParameters = $this->replaceFacetAndEncodeFilterParameters($facetToReplace);
     return $this->query->getQueryUrl(array('filter' => $filterParameters));
 }
 public function removeSubQuery(tx_solr_Query $query)
 {
     unset($this->subQueries[$query->getId()]);
 }