示例#1
0
 /**
  * Generates a html link - an anchor tag.
  *
  * TODO currently everything in $additionalQueryParameters is prefixed with tx_solr,
  * allow arbitrary parameters, too (either filter them out or introduce a new 4th parameter)
  *
  * @param string $linkText Link Text
  * @param array $additionalQueryParameters Additional query parameters
  * @param array $typolinkOptions Typolink Options
  * @return string A html link
  */
 public function getQueryLink($linkText, array $additionalQueryParameters = array(), array $typolinkOptions = array())
 {
     $queryParameters = array_merge($this->getPluginParameters(), $additionalQueryParameters);
     $queryParameters = $this->removeUnwantedUrlParameters($queryParameters);
     $queryGetParameter = '';
     $keywords = $this->query->getKeywords();
     if (!empty($keywords)) {
         $queryGetParameter = '&q=' . $keywords;
     }
     $linkConfiguration = array('useCacheHash' => false, 'no_cache' => false, 'parameter' => $this->linkTargetPageId, 'additionalParams' => $queryGetParameter . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', array($this->prefix => $queryParameters), '', true) . $this->getUrlParameters());
     // merge linkConfiguration with typolinkOptions
     $linkConfiguration = array_merge($linkConfiguration, $typolinkOptions);
     return $this->contentObject->typoLink($linkText, $linkConfiguration);
 }
示例#2
0
 /**
  * Processes a query and its response after searching for that query.
  *
  * @param Query $query The query that has been searched for.
  * @param \Apache_Solr_Response $response The response for the last query.
  */
 public function processResponse(Query $query, \Apache_Solr_Response $response)
 {
     $urlParameters = GeneralUtility::_GP('tx_solr');
     $keywords = $query->getKeywords();
     $filters = isset($urlParameters['filter']) ? $urlParameters['filter'] : array();
     if (empty($keywords)) {
         // do not track empty queries
         return;
     }
     $keywords = $this->sanitizeString($keywords);
     $sorting = '';
     if (!empty($urlParameters['sort'])) {
         $sorting = $this->sanitizeString($urlParameters['sort']);
     }
     $configuration = Util::getSolrConfiguration();
     if ($configuration['search.']['frequentSearches.']['useLowercaseKeywords']) {
         $keywords = strtolower($keywords);
     }
     $ipMaskLength = (int) $configuration['statistics.']['anonymizeIP'];
     $insertFields = array('pid' => $GLOBALS['TSFE']->id, 'root_pid' => $GLOBALS['TSFE']->tmpl->rootLine[0]['uid'], 'tstamp' => $GLOBALS['EXEC_TIME'], 'language' => $GLOBALS['TSFE']->sys_language_uid, 'num_found' => $response->response->numFound, 'suggestions_shown' => is_object($response->spellcheck->suggestions) ? (int) get_object_vars($response->spellcheck->suggestions) : 0, 'time_total' => $response->debug->timing->time, 'time_preparation' => $response->debug->timing->prepare->time, 'time_processing' => $response->debug->timing->process->time, 'feuser_id' => (int) $GLOBALS['TSFE']->fe_user->user['uid'], 'cookie' => $GLOBALS['TSFE']->fe_user->id, 'ip' => $this->applyIpMask(GeneralUtility::getIndpEnv('REMOTE_ADDR'), $ipMaskLength), 'page' => (int) $urlParameters['page'], 'keywords' => $keywords, 'filters' => serialize($filters), 'sorting' => $sorting, 'parameters' => serialize($response->responseHeader->params));
     $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_solr_statistics', $insertFields);
 }