/**
  * Calendarize indexer for ke_search
  *
  * @param array $indexerConfig Configuration from TYPO3 Backend
  * @param \tx_kesearch_indexer $indexerObject Reference to indexer class.
  * @return string|null
  */
 public function customIndexer(&$indexerConfig, &$indexerObject)
 {
     if ($indexerConfig['type'] !== 'calendarize') {
         return null;
     }
     /** @var \HDNET\Calendarize\Domain\Repository\IndexRepository $indexRepository */
     $indexRepository = HelperUtility::create('HDNET\\Calendarize\\Domain\\Repository\\IndexRepository');
     // @todo select only $indexerConfig['storagepid']
     $indexObjects = $indexRepository->findList()->toArray();
     foreach ($indexObjects as $index) {
         /** @var $index Index */
         /** @var KeSearchIndexInterface $originalObject */
         $originalObject = $index->getOriginalObject();
         if (!$originalObject instanceof KeSearchIndexInterface) {
             continue;
         }
         $title = strip_tags($originalObject->getKeSearchTitle($index));
         $abstract = strip_tags($originalObject->getKeSearchAbstract($index));
         $content = strip_tags($originalObject->getKeSearchContent($index));
         $fullContent = $title . "\n" . $abstract . "\n" . $content;
         // @todo Add year and month information
         $additionalFields = [];
         $indexerObject->storeInIndex($indexerConfig['storagepid'], $title, 'calendarize', $indexerConfig['targetpid'], $fullContent, '', '&tx_calendarize_calendar[index]=' . $index->getUid(), $abstract, 0, 0, 0, '', false, $additionalFields);
     }
     return '<p><b>Custom Indexer "' . $indexerConfig['title'] . '": ' . sizeof($indexObjects) . ' elements have been indexed.</b></p>';
 }
 /**
  * Handle the index ID to alias convert
  *
  * @param $value
  *
  * @return string
  */
 protected function id2alias($value)
 {
     $databaseConnection = HelperUtility::getDatabaseConnection();
     $row = $databaseConnection->exec_SELECTgetSingleRow('value_alias', 'tx_realurl_uniqalias', 'tablename=' . $databaseConnection->fullQuoteStr(IndexerService::TABLE_NAME, IndexerService::TABLE_NAME) . ' AND value_id=' . (int) $value);
     if (isset($row['value_alias'])) {
         return $row['value_alias'];
     }
     /** @var IndexRepository $indexRepository */
     $indexRepository = HelperUtility::create('HDNET\\Calendarize\\Domain\\Repository\\IndexRepository');
     $index = $indexRepository->findByUid($value);
     if (!$index instanceof Index) {
         $alias = 'idx-' . $value;
     } else {
         $originalObject = $index->getOriginalObject();
         if (!$originalObject instanceof RealUrlInterface) {
             $alias = 'idx-' . $value;
         } else {
             $alias = $this->generateRealUrl($originalObject->getRealUrlAliasBase(), $index);
         }
     }
     $databaseConnection = HelperUtility::getDatabaseConnection();
     $entry = ['tstamp' => time(), 'tablename' => IndexerService::TABLE_NAME, 'field_alias' => 'title', 'field_id' => 'uid', 'value_alias' => $alias, 'value_id' => $value];
     $databaseConnection->exec_INSERTquery('tx_realurl_uniqalias', $entry);
     return $alias;
 }
 /**
  * Build the configuration handler
  *
  * @param Configuration $configuration
  *
  * @return bool|AbstractTimeTable
  */
 protected function buildConfigurationHandler(Configuration $configuration)
 {
     $handler = 'HDNET\\Calendarize\\Service\\TimeTable\\' . ucfirst($configuration->getType()) . 'TimeTable';
     if (!class_exists($handler)) {
         return false;
     }
     return HelperUtility::create($handler);
 }
 /**
  * Run the delete action
  *
  * @param string      $table
  * @param int         $id
  * @param             $recordToDelete
  * @param             $recordWasDeleted
  * @param DataHandler $dataHandler
  */
 public function processCmdmap_deleteAction($table, $id, $recordToDelete, &$recordWasDeleted, DataHandler $dataHandler)
 {
     $register = Register::getRegister();
     foreach ($register as $key => $configuration) {
         if ($configuration['tableName'] == $table) {
             $indexer = HelperUtility::create('HDNET\\Calendarize\\Service\\IndexerService');
             $dataHandler->deleteEl($table, $id);
             $recordWasDeleted = TRUE;
             $indexer->reindex($key, $table, $id);
         }
     }
 }
Example #5
0
 /**
  * Set ids by general
  *
  * @signalClass \HDNET\Calendarize\Domain\Repository\IndexRepository
  * @signalName getDefaultConstraints
  *
  * @param array $indexIds
  * @param array $indexTypes
  * @param array $contentRecord
  *
  * @return array
  */
 public function setIdsByGeneral(array $indexIds, array $indexTypes, array $contentRecord)
 {
     $databaseConnection = HelperUtility::getDatabaseConnection();
     $rows = $databaseConnection->exec_SELECTgetRows('uid_local', 'sys_category_record_mm', 'tablenames="tt_content" AND uid_foreign=' . $contentRecord['uid']);
     $categoryIds = [];
     foreach ($rows as $row) {
         $categoryIds[] = (int) $row['uid_local'];
     }
     if (empty($categoryIds)) {
         return ['indexIds' => $indexIds, 'indexTypes' => $indexTypes, 'contentRecord' => $contentRecord];
     }
     $rows = $databaseConnection->exec_SELECTgetRows('uid_foreign', 'sys_category_record_mm', 'tablenames="tx_calendarize_domain_model_event" AND uid_local IN (' . implode(',', $categoryIds) . ')');
     foreach ($rows as $row) {
         $indexIds[] = (int) $row['uid_foreign'];
     }
     return ['indexIds' => $indexIds, 'indexTypes' => $indexTypes, 'contentRecord' => $contentRecord];
 }
 /**
  * Modify the given times via the configuration
  *
  * @param array         $times
  * @param Configuration $configuration
  *
  * @return void
  */
 public function handleConfiguration(array &$times, Configuration $configuration)
 {
     $url = $configuration->getExternalIcsUrl();
     if (!GeneralUtility::isValidUrl($url)) {
         HelperUtility::createFlashMessage('Configuration with invalid ICS URL: ' . $url, 'Index ICS URL', FlashMessage::ERROR);
         return;
     }
     $events = $this->icsReaderService->toArray($url);
     foreach ($events as $event) {
         /** @var $event ICalEvent */
         $startTime = DateTimeUtility::getDaySecondsOfDateTime($event->getStart());
         $endTime = DateTimeUtility::getDaySecondsOfDateTime($event->getEnd());
         if ($endTime === self::DAY_END) {
             $endTime = 0;
         }
         $entry = ['pid' => 0, 'start_date' => $event->getStart(), 'end_date' => $event->getEnd() ?: $event->getStart(), 'start_time' => $startTime, 'end_time' => $endTime, 'all_day' => $endTime === 0];
         $times[] = $entry;
     }
 }
 /**
  * Process the reindex after all operations
  *
  * @param DataHandler $dataHandler
  *
  * @return void
  */
 public function processDatamap_afterAllOperations(DataHandler $dataHandler)
 {
     if (!$this->indexItems) {
         return;
     }
     $register = Register::getRegister();
     /** @var \HDNET\Calendarize\Service\IndexerService $indexer */
     $indexer = HelperUtility::create('HDNET\\Calendarize\\Service\\IndexerService');
     foreach ($register as $key => $configuration) {
         foreach ($this->indexItems as $table => $identifiers) {
             if ($table === $configuration['tableName']) {
                 foreach ($identifiers as $uid) {
                     $indexer->reindex($key, $table, $uid);
                 }
             }
         }
     }
     $this->indexItems = array();
 }
Example #8
0
 /**
  * Remove index Items of configurations that are not valid anymore
  *
  * @return bool
  */
 protected function removeInvalidConfigurationIndex()
 {
     $validKeys = array_keys(Register::getRegister());
     $databaseConnection = HelperUtility::getDatabaseConnection();
     if ($validKeys) {
         foreach ($validKeys as $key => $value) {
             $validKeys[$key] = $databaseConnection->fullQuoteStr($value, IndexerService::TABLE_NAME);
         }
         return (bool) $databaseConnection->exec_DELETEquery(self::TABLE_NAME, 'unique_register_key NOT IN (' . implode(',', $validKeys) . ')');
     }
     return (bool) $databaseConnection->exec_TRUNCATEquery(self::TABLE_NAME);
 }
Example #9
0
 /**
  * Get the default constraint for the queries
  *
  * @param QueryInterface $query
  *
  * @return array
  */
 protected function getDefaultConstraints(QueryInterface $query)
 {
     $constraints = [];
     $constraints[] = $query->in('uniqueRegisterKey', $this->indexTypes);
     $storagePages = $this->getStoragePageIds();
     if (!empty($storagePages)) {
         $constraints[] = $query->in('pid', $storagePages);
     }
     $arguments = ['indexIds' => [], 'indexTypes' => $this->indexTypes, 'contentRecord' => $this->contentRecord];
     $signalSlotDispatcher = HelperUtility::getSignalSlotDispatcher();
     $arguments = $signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__, $arguments);
     if ($arguments['indexIds']) {
         $constraints[] = $query->in('foreign_uid', $arguments['indexIds']);
     }
     return $constraints;
 }
Example #10
0
 /**
  * Get the original record by configuration
  *
  * @param $configuration
  * @param $uid
  *
  * @return object
  */
 protected function getOriginalRecordByConfiguration($configuration, $uid)
 {
     $query = HelperUtility::getQuery($configuration['modelName']);
     $query->getQuerySettings()->setRespectStoragePage(FALSE);
     $query->matching($query->equals('uid', $uid));
     return $query->execute()->getFirst();
 }
Example #11
0
 /**
  * Get the default constraint for the queries
  *
  * @param QueryInterface $query
  *
  * @return array
  */
 protected function getDefaultConstraints(QueryInterface $query)
 {
     $constraints = array();
     $constraints[] = $query->in('uniqueRegisterKey', $this->indexTypes);
     // storage page selection
     // @todo please check core API functions again
     /** @var ConfigurationManagerInterface $configuratioManager */
     $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
     $frameworkConfiguration = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
     $storagePages = isset($frameworkConfiguration['persistence']['storagePid']) ? GeneralUtility::intExplode(',', $frameworkConfiguration['persistence']['storagePid']) : array();
     if (!empty($storagePages)) {
         $constraints[] = $query->in('pid', $storagePages);
     }
     $arguments = array('indexIds' => array(), 'indexTypes' => $this->indexTypes, 'contentRecord' => $this->contentRecord);
     $signalSlotDispatcher = HelperUtility::getSignalSlotDispatcher();
     $arguments = $signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__, $arguments);
     if ($arguments['indexIds']) {
         $constraints[] = $query->in('foreign_uid', $arguments['indexIds']);
     }
     return $constraints;
 }
Example #12
0
 /**
  * Get the next events
  *
  * @param string $table
  * @param int    $uid
  * @param int    $limit
  *
  * @return array|NULL
  */
 protected function getNextEvents($table, $uid, $limit = 5)
 {
     $databaseConnection = HelperUtility::getDatabaseConnection();
     return $databaseConnection->exec_SELECTgetRows('*', IndexerService::TABLE_NAME, 'start_date > ' . time() . ' AND foreign_table=' . $databaseConnection->fullQuoteStr($table, IndexerService::TABLE_NAME) . ' AND foreign_uid=' . (int) $uid, '', 'start_date ASC, start_time ASC', $limit);
 }
Example #13
0
 /**
  * Store to the DB
  */
 protected function persist()
 {
     /** @var $persist PersistenceManager */
     $persist = HelperUtility::create('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
     $persist->persistAll();
 }
Example #14
0
 /**
  * Get the user record
  *
  * @param string $userName
  *
  * @return array|FALSE|NULL
  */
 protected function getUserRow($userName)
 {
     $dbConnection = HelperUtility::getDatabaseConnection();
     $where = 'username = '******'fe_users') . BackendUtility::deleteClause($this->tableName) . BackendUtility::BEenableFields($this->tableName);
     return $dbConnection->exec_SELECTgetSingleRow('*', 'fe_users', $where);
 }