/**
  * 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 Tx_Solr_IndexQueue_Item $item Item to index
  * @param integer $language The language id
  * @return string URL to send the index request to
  */
 protected function getDataUrl(Tx_Solr_IndexQueue_Item $item, $language = 0)
 {
     $scheme = 'http';
     $host = $item->getSite()->getDomain();
     $path = '/';
     $pageId = $item->getRecordUid();
     // deprecated
     if (!empty($this->options['scheme'])) {
         t3lib_div::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'];
     }
     $dataUrl = $scheme . '://' . $host . $path . 'index.php?id=' . $pageId;
     $dataUrl .= $this->getMountPageDataUrlParameter($item);
     $dataUrl .= '&L=' . $language;
     if (!t3lib_div::isValidUrl($dataUrl)) {
         t3lib_div::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 = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueuePageIndexer']['dataUrlModifier']);
         if ($dataUrlModifier instanceof Tx_Solr_IndexQueuePageIndexerDataUrlModifier) {
             $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 Tx_Solr_IndexQueuePageIndexerDataUrlModifier', 1290523345);
         }
     }
     return $dataUrl;
 }
示例#2
0
文件: Indexer.php 项目: punktDe/solr
 /**
  * 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 Tx_Solr_IndexQueue_Item $item An index queue item
  * @return array An array of Tx_Solr_SolrService connections, the array's keys are the sys_language_uid of the language of the connection
  */
 protected function getSolrConnectionsByItem(Tx_Solr_IndexQueue_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;
 }