Exemplo n.º 1
0
 /**
  * Returns some additional information about indexing progress, shown in
  * the scheduler's task overview list.
  *
  * @return string Information to display
  */
 public function getAdditionalInformation()
 {
     $message = 'Site: ' . $this->site->getLabel();
     $failedItemsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'tx_solr_indexqueue_item', 'root = ' . $this->site->getRootPageId() . ' AND errors != \'\'');
     if ($failedItemsCount) {
         $message .= ' Failures: ' . $failedItemsCount;
     }
     return $message;
 }
Exemplo n.º 2
0
 /**
  * Builds the SELECT part of the Index Queue initialization query.
  *
  */
 protected function buildSelectStatement()
 {
     $changedField = $GLOBALS['TCA'][$this->type]['ctrl']['tstamp'];
     if (!empty($GLOBALS['TCA'][$this->type]['ctrl']['enablecolumns']['starttime'])) {
         $changedField = 'GREATEST(' . $GLOBALS['TCA'][$this->type]['ctrl']['enablecolumns']['starttime'] . ',' . $GLOBALS['TCA'][$this->type]['ctrl']['tstamp'] . ')';
     }
     $select = 'SELECT ' . '\'' . $this->site->getRootPageId() . '\' as root, ' . '\'' . $this->type . '\' AS item_type, ' . 'uid AS item_uid, ' . '\'' . $this->indexingConfigurationName . '\' as indexing_configuration, ' . $this->getIndexingPriority() . ' AS indexing_priority, ' . $changedField . ' AS changed';
     return $select;
 }
 /**
  * @return void
  */
 protected function resolveSite()
 {
     $this->site = $this->moduleData->getSite();
     if (!$this->site instanceof Site) {
         $this->initializeSiteFromFirstAvailableAndStoreInModuleData();
     }
     $rootPageId = $this->site instanceof Site ? $this->site->getRootPageId() : 0;
     if ($rootPageId > 0 && !Util::pageExists($rootPageId)) {
         $this->initializeSiteFromFirstAvailableAndStoreInModuleData();
     }
 }
Exemplo n.º 4
0
 /**
  * Gets the indexing progress.
  *
  * @return float Indexing progress as a two decimal precision float. f.e. 44.87
  */
 public function getProgress()
 {
     $itemsIndexedPercentage = 0.0;
     $totalItemsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'tx_solr_indexqueue_item', 'root = ' . $this->site->getRootPageId());
     $remainingItemsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'tx_solr_indexqueue_item', 'changed > indexed AND root = ' . $this->site->getRootPageId());
     $itemsIndexedCount = $totalItemsCount - $remainingItemsCount;
     if ($totalItemsCount > 0) {
         $itemsIndexedPercentage = $itemsIndexedCount * 100 / $totalItemsCount;
         $itemsIndexedPercentage = round($itemsIndexedPercentage, 2);
     }
     return $itemsIndexedPercentage;
 }
 /**
  * Builds a map of indexing configuration names to tables to to index.
  *
  * @return array Indexing configuration to database table map
  */
 protected function getIndexQueueConfigurationTableMap()
 {
     $indexingTableMap = array();
     $solrConfiguration = Util::getSolrConfigurationFromPageId($this->site->getRootPageId());
     foreach ($solrConfiguration['index.']['queue.'] as $name => $configuration) {
         if (is_array($configuration)) {
             $name = substr($name, 0, -1);
             if ($solrConfiguration['index.']['queue.'][$name]) {
                 $table = $name;
                 if ($solrConfiguration['index.']['queue.'][$name . '.']['table']) {
                     $table = $solrConfiguration['index.']['queue.'][$name . '.']['table'];
                 }
                 $indexingTableMap[$name] = $table;
             }
         }
     }
     return $indexingTableMap;
 }
 /**
  * Initializes the controller before invoking an action method.
  *
  * @return void
  */
 protected function initializeAction()
 {
     $this->site = $this->moduleData->getSite();
     if (!$this->site instanceof Site) {
         $this->initializeSiteFromFirstAvailableAndStoreInModuleData();
     }
     $rootPageId = $this->site->getRootPageId();
     if ($rootPageId > 0 && !Util::pageExists($rootPageId)) {
         $this->initializeSiteFromFirstAvailableAndStoreInModuleData();
     }
     try {
         $moduleName = $this->request->getArgument('module');
         if ($this->moduleManager->isRegisteredModule($moduleName)) {
             $this->activeModuleName = $moduleName;
             $this->activeModule = $this->moduleManager->getModule($moduleName);
         }
     } catch (NoSuchArgumentException $e) {
         $this->activeModule = $this->moduleManager->getModule($this->activeModuleName);
     }
     $this->moduleManager->sortModules();
     $this->modules = $this->moduleManager->getModules();
 }
Exemplo n.º 7
0
 /**
  * Gets all connection configurations for a given site.
  *
  * @param Site $site A TYPO3 site
  * @return array An array of Solr connection configurations for a site
  */
 public function getConfigurationsBySite(Site $site)
 {
     $solrConfigurations = array();
     $allConfigurations = $this->getAllConfigurations();
     foreach ($allConfigurations as $configuration) {
         if ($configuration['rootPageUid'] == $site->getRootPageId()) {
             $solrConfigurations[] = $configuration;
         }
     }
     return $solrConfigurations;
 }
Exemplo n.º 8
0
 /**
  * Gets $limit number of items to index for a particular $site.
  *
  * @param Site $site TYPO3 site
  * @param integer $limit Number of items to get from the queue
  * @return Item[] Items to index to the given solr server
  */
 public function getItemsToIndex(Site $site, $limit = 50)
 {
     $itemsToIndex = array();
     // determine which items to index with this run
     $indexQueueItemRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_solr_indexqueue_item', 'root = ' . $site->getRootPageId() . ' AND changed > indexed' . ' AND changed <= ' . time() . ' AND errors = \'\'', '', 'indexing_priority DESC, changed DESC, uid DESC', intval($limit));
     if (!empty($indexQueueItemRecords)) {
         // convert queued records to index queue item objects
         $itemsToIndex = $this->getIndexQueueItemObjectsFromRecords($indexQueueItemRecords);
     }
     return $itemsToIndex;
 }
Exemplo n.º 9
0
 /**
  * Creates a dropdown selector of available TYPO3 sites with Solr
  * configured.
  *
  * @param string $selectorName Name to be used in the select's name attribute
  * @param Site $selectedSite Optional, currently selected site
  * @return string Site selector HTML code
  * @todo Extract into own class like indexing configuration selector
  */
 public static function getAvailableSitesSelector($selectorName, Site $selectedSite = null)
 {
     $sites = self::getAvailableSites();
     $selector = '<select name="' . $selectorName . '">';
     foreach ($sites as $site) {
         $selectedAttribute = '';
         if ($selectedSite !== null && $site->getRootPageId() == $selectedSite->getRootPageId()) {
             $selectedAttribute = ' selected="selected"';
         }
         $selector .= '<option value="' . $site->getRootPageId() . '"' . $selectedAttribute . '>' . $site->getLabel() . '</option>';
     }
     $selector .= '</select>';
     return $selector;
 }