/** * 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; }
/** * 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]; }
/** * 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); }
/** * 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); }
/** * 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); }