Example #1
0
 /**
  * Determines a page ID's URL.
  *
  * Tries to find a domain record to use to build an URL for a given page ID
  * and then actually build and return the page URL.
  *
  * @param Item $item Item to index
  * @param integer $language The language id
  * @return string URL to send the index request to
  * @throws \RuntimeException
  */
 protected function getDataUrl(Item $item, $language = 0)
 {
     $scheme = 'http';
     $host = $item->getSite()->getDomain();
     $path = '/';
     $pageId = $item->getRecordUid();
     // deprecated
     if (!empty($this->options['scheme'])) {
         GeneralUtility::devLog('Using deprecated option "scheme" to set the scheme (http / https) for the page indexer frontend helper. Use plugin.tx_solr.index.queue.pages.indexer.frontendDataHelper.scheme instead', 'solr', 2);
         $scheme = $this->options['scheme'];
     }
     // check whether we should use ssl / https
     if (!empty($this->options['frontendDataHelper.']['scheme'])) {
         $scheme = $this->options['frontendDataHelper.']['scheme'];
     }
     // overwriting the host
     if (!empty($this->options['frontendDataHelper.']['host'])) {
         $host = $this->options['frontendDataHelper.']['host'];
     }
     // setting a path if TYPO3 is installed in a sub directory
     if (!empty($this->options['frontendDataHelper.']['path'])) {
         $path = $this->options['frontendDataHelper.']['path'];
     }
     $mountPointParameter = $this->getMountPageDataUrlParameter($item);
     $dataUrl = $scheme . '://' . $host . $path . 'index.php?id=' . $pageId;
     $dataUrl .= $mountPointParameter !== '' ? '&MP=' . $mountPointParameter : '';
     $dataUrl .= '&L=' . $language;
     if (!GeneralUtility::isValidUrl($dataUrl)) {
         GeneralUtility::devLog('Could not create a valid URL to get frontend data while trying to index a page.', 'solr', 3, array('item' => (array) $item, 'constructed URL' => $dataUrl, 'scheme' => $scheme, 'host' => $host, 'path' => $path, 'page ID' => $pageId, 'indexer options' => $this->options));
         throw new \RuntimeException('Could not create a valid URL to get frontend data while trying to index a page. Created URL: ' . $dataUrl, 1311080805);
     }
     if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueuePageIndexer']['dataUrlModifier']) {
         $dataUrlModifier = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueuePageIndexer']['dataUrlModifier']);
         if ($dataUrlModifier instanceof PageIndexerDataUrlModifier) {
             $dataUrl = $dataUrlModifier->modifyDataUrl($dataUrl, array('item' => $item, 'scheme' => $scheme, 'host' => $host, 'path' => $path, 'pageId' => $pageId, 'language' => $language));
         } else {
             throw new \RuntimeException($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueuePageIndexer']['dataUrlModifier'] . ' is not an implementation of ApacheSolrForTypo3\\Solr\\IndexQueue\\PageIndexerDataUrlModifier', 1290523345);
         }
     }
     return $dataUrl;
 }
Example #2
0
 /**
  * Gets the Solr connections applicaple for an item.
  *
  * The connections include the default connection and connections to be used
  * for translations of an item.
  *
  * @param Item $item An index queue item
  * @return array An array of ApacheSolrForTypo3\Solr\SolrService connections, the array's keys are the sys_language_uid of the language of the connection
  */
 protected function getSolrConnectionsByItem(Item $item)
 {
     $solrConnections = array();
     $pageId = $item->getRootPageUid();
     if ($item->getType() == 'pages') {
         $pageId = $item->getRecordUid();
     }
     // Solr configurations possible for this item
     $solrConfigurationsBySite = $this->connectionManager->getConfigurationsBySite($item->getSite());
     $siteLanguages = array();
     foreach ($solrConfigurationsBySite as $solrConfiguration) {
         $siteLanguages[] = $solrConfiguration['language'];
     }
     $translationOverlays = $this->getTranslationOverlaysForPage($pageId);
     foreach ($translationOverlays as $key => $translationOverlay) {
         if (!in_array($translationOverlay['sys_language_uid'], $siteLanguages)) {
             unset($translationOverlays[$key]);
         }
     }
     $defaultConnection = $this->connectionManager->getConnectionByPageId($pageId);
     $translationConnections = $this->getConnectionsForIndexableLanguages($translationOverlays);
     $solrConnections[0] = $defaultConnection;
     foreach ($translationConnections as $systemLanguageUid => $solrConnection) {
         $solrConnections[$systemLanguageUid] = $solrConnection;
     }
     return $solrConnections;
 }