Esempio n. 1
0
 /**
  * Provides the values for the markers in the simple form template
  *
  * @return array An array containing values for markers in the simple form template
  * @throws InvalidArgumentException if an registered form modifier fails to implement the required interface Tx_Solr_FormModifier
  */
 public function execute()
 {
     $url = $this->cObj->getTypoLink_URL($this->parentPlugin->conf['search.']['targetPage']);
     $marker = array('action' => htmlspecialchars($url), 'action_id' => intval($this->parentPlugin->conf['search.']['targetPage']), 'action_language' => intval($GLOBALS['TSFE']->sys_page->sys_language_uid), 'action_language_parameter' => 'L', 'accept-charset' => $GLOBALS['TSFE']->metaCharset, 'q' => $this->parentPlugin->getCleanUserQuery());
     // hook to modify the search form
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchForm'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchForm'] as $classReference) {
             $formModifier = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classReference);
             if ($formModifier instanceof Tx_Solr_FormModifier) {
                 if ($formModifier instanceof Tx_Solr_CommandPluginAware) {
                     $formModifier->setParentPlugin($this->parentPlugin);
                 }
                 $marker = $formModifier->modifyForm($marker, $this->parentPlugin->getTemplate());
             } else {
                 throw new InvalidArgumentException('Form modifier "' . $classReference . '" must implement the Tx_Solr_FormModifier interface.', 1262864703);
             }
         }
     }
     return $marker;
 }
Esempio n. 2
0
 /**
  * Returns the eID URL for the AJAX suggestion request.
  *
  * @author Mario Rimann <*****@*****.**>
  * @return string the full URL to the eID script including the needed parameters
  */
 protected function getSuggestEidUrl()
 {
     $suggestUrl = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
     if ($this->configuration['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 = rawurlencode($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;
 }
Esempio n. 3
0
 /**
  * Performs special search initialization for the result plugin.
  *
  * @see Tx_Solr_PluginBase_PluginBase#initializeSearch()
  */
 protected function initializeSearch()
 {
     parent::initializeSearch();
     $this->initializeAdditionalFilters();
 }
Esempio n. 4
0
 /**
  * Performs special search initialization for the result plugin.
  *
  * @see Tx_Solr_pluginbase_PluginBase#initializeSearch()
  */
 protected function initializeSearch()
 {
     parent::initializeSearch();
     $this->initializeAdditionalFilters();
     $rawUserQuery = $this->getRawUserQuery();
     // TODO check whether a search has been conducted already?
     if ($this->solrAvailable && (isset($rawUserQuery) || $this->conf['search.']['initializeWithEmptyQuery'] || $this->conf['search.']['initializeWithQuery'])) {
         if ($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['logging.']['query.']['searchWords']) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('received search query', 'solr', 0, array($rawUserQuery));
         }
         $query = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_Query', $rawUserQuery);
         /* @var	$query	Tx_Solr_Query */
         $resultsPerPage = $this->getNumberOfResultsPerPage();
         $query->setResultsPerPage($resultsPerPage);
         $searchComponents = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_Search_SearchComponentManager')->getSearchComponents();
         foreach ($searchComponents as $searchComponent) {
             $searchComponent->setSearchConfiguration($this->conf['search.']);
             if ($searchComponent instanceof Tx_Solr_QueryAware) {
                 $searchComponent->setQuery($query);
             }
             if ($searchComponent instanceof Tx_Solr_PluginAware) {
                 $searchComponent->setParentPlugin($this);
             }
             $searchComponent->initializeSearchComponent();
         }
         if ($this->conf['search.']['initializeWithEmptyQuery'] || $this->conf['search.']['query.']['allowEmptyQuery']) {
             // empty main query, but using a "return everything"
             // alternative query in q.alt
             $query->setAlternativeQuery('*:*');
         }
         if ($this->conf['search.']['initializeWithQuery']) {
             $query->setAlternativeQuery($this->conf['search.']['initializeWithQuery']);
         }
         foreach ($this->additionalFilters as $additionalFilter) {
             $query->addFilter($additionalFilter);
         }
         $this->query = $query;
     }
 }
 /**
  * Modifies the search form by providing an additional marker showing
  * the parsed lucene query used by Solr.
  *
  * @param array $markers An array of existing form markers
  * @param Template $template An instance of the template engine
  * @return array Array with additional markers for queryAnalysis
  */
 public function modifyForm(array $markers, Template $template)
 {
     $markers['debug_query'] = '<br><strong>Parsed Query:</strong><br>' . $this->parentPlugin->getSearch()->getDebugResponse()->parsedquery;
     return $markers;
 }
Esempio n. 6
0
 /**
  * Constructor.
  *
  * @param Tx_Solr_PluginBase_CommandPluginBase $parentPlugin Parent plugin object.
  */
 public function __construct(Tx_Solr_PluginBase_CommandPluginBase $parentPlugin)
 {
     $this->parentPlugin = $parentPlugin;
     $this->configuration = $parentPlugin->conf;
     $this->search = $parentPlugin->getSearch();
 }