예제 #1
0
파일: Site.php 프로젝트: kalypso63/ext-solr
 /**
  * Gets the Site for a specific page Id.
  *
  * @param integer $pageId The page Id to get a Site object for.
  * @return Site Site for the given page Id.
  */
 public static function getSiteByPageId($pageId)
 {
     $rootPageId = Util::getRootPageId($pageId);
     if (!isset(self::$sitesCache[$rootPageId])) {
         self::$sitesCache[$rootPageId] = GeneralUtility::makeInstance(__CLASS__, $rootPageId);
     }
     return self::$sitesCache[$rootPageId];
 }
예제 #2
0
파일: Queue.php 프로젝트: nxpthx/ext-solr
 /**
  * Adds an item to the index queue.
  *
  * Not meant for public use.
  *
  * @param string $itemType The item's type, usually a table name.
  * @param string $itemUid The item's uid, usually an integer uid, could be a
  *      different value for non-database-record types.
  * @param string $indexingConfiguration The item's indexing configuration to use.
  *      Optional, overwrites existing / determined configuration.
  * @return void
  */
 private function addItem($itemType, $itemUid, $indexingConfiguration)
 {
     $additionalRecordFields = '';
     if ($itemType == 'pages') {
         $additionalRecordFields = ', doktype, uid';
     }
     $record = BackendUtility::getRecord($itemType, $itemUid, 'pid' . $additionalRecordFields);
     if (empty($record) || $itemType == 'pages' && !Util::isAllowedPageType($record)) {
         return;
     }
     if ($itemType == 'pages') {
         $rootPageId = Util::getRootPageId($itemUid);
     } else {
         $rootPageId = Util::getRootPageId($record['pid']);
     }
     if (Util::isRootPage($rootPageId)) {
         $item = array('root' => $rootPageId, 'item_type' => $itemType, 'item_uid' => $itemUid, 'changed' => $this->getItemChangedTime($itemType, $itemUid));
         if (!empty($indexingConfiguration)) {
             $indexingConfigurationList = array($indexingConfiguration);
         } else {
             $indexingConfigurationList = $this->getIndexingConfigurationsByItem($itemType, $itemUid, $rootPageId);
         }
         $solrConfiguration = Util::getSolrConfigurationFromPageId($rootPageId);
         // make a backup of the current item
         $baseItem = $item;
         foreach ($indexingConfigurationList as $indexingConfigurationCurrent) {
             $item = $baseItem;
             $item['indexing_configuration'] = $indexingConfigurationCurrent;
             $addItemToQueue = TRUE;
             // Ensure additionalWhereClause is applied.
             if (!empty($solrConfiguration['index.']['queue.'][$item['indexing_configuration'] . '.']['additionalWhereClause'])) {
                 $indexingConfigurationCheckRecord = BackendUtility::getRecord($itemType, $itemUid, 'pid' . $additionalRecordFields, ' AND ' . $solrConfiguration['index.']['queue.'][$item['indexing_configuration'] . '.']['additionalWhereClause']);
                 if (empty($indexingConfigurationCheckRecord)) {
                     // item does not match the indexing configuration's additionalWhereClause
                     $addItemToQueue = FALSE;
                 }
             }
             if ($addItemToQueue) {
                 $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_solr_indexqueue_item', $item);
             }
         }
     }
 }