/** * Load all deleted rows from $table * If table is not set, it iterates the TCA tables * * @param int $id UID from selected page * @param string $table Tablename * @param int $depth How many levels recursive * @param string $limit MySQL LIMIT * @param string $filter Filter text * @return DeletedRecords */ public function loadData($id, $table, $depth, $limit = '', $filter = '') { // set the limit $this->limit = trim($limit); if ($table) { if (in_array($table, RecyclerUtility::getModifyableTables())) { $this->table[] = $table; $this->setData($id, $table, $depth, $GLOBALS['TCA'][$table]['ctrl'], $filter); } } else { foreach ($GLOBALS['TCA'] as $tableKey => $tableValue) { // only go into this table if the limit allows it if ($this->limit !== '') { $parts = GeneralUtility::trimExplode(',', $this->limit); // abort loop if LIMIT 0,0 if ((int) $parts[0] === 0 && (int) $parts[1] === 0) { break; } } $this->table[] = $tableKey; $this->setData($id, $tableKey, $depth, $tableValue['ctrl'], $filter); } } return $this; }
/** * Get tables for menu example * * @param int $startUid UID from selected page * @param int $depth How many levels recursive * @return string The tables to be displayed */ public function getTables($startUid, $depth = 0) { $deletedRecordsTotal = 0; $lang = $this->getLanguageService(); $tables = array(); foreach (RecyclerUtility::getModifyableTables() as $tableName) { $deletedField = RecyclerUtility::getDeletedField($tableName); if ($deletedField) { // Determine whether the table has deleted records: $deletedCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', $tableName, $deletedField . '<>0'); if ($deletedCount) { /* @var $deletedDataObject \TYPO3\CMS\Recycler\Domain\Model\DeletedRecords */ $deletedDataObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Recycler\Domain\Model\DeletedRecords::class); $deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows(); if (isset($deletedData[$tableName])) { if ($deletedRecordsInTable = count($deletedData[$tableName])) { $deletedRecordsTotal += $deletedRecordsInTable; $tables[] = array($tableName, $deletedRecordsInTable, RecyclerUtility::getUtf8String($lang->sL($GLOBALS['TCA'][$tableName]['ctrl']['title']))); } } } } } $jsonArray = $tables; array_unshift($jsonArray, array('', $deletedRecordsTotal, $lang->sL('LLL:EXT:recycler/mod1/locallang.xlf:label_allrecordtypes'))); return $jsonArray; }
/** * Get tables for menu example * * @param int $startUid UID from selected page * @param int $depth How many levels recursive * @return string The tables to be displayed */ public function getTables($startUid, $depth = 0) { $deletedRecordsTotal = 0; $lang = $this->getLanguageService(); $tables = array(); $connection = GeneralUtility::makeInstance(ConnectionPool::class); foreach (RecyclerUtility::getModifyableTables() as $tableName) { $deletedField = RecyclerUtility::getDeletedField($tableName); if ($deletedField) { // Determine whether the table has deleted records: $queryBuilder = $connection->getQueryBuilderForTable($tableName); $queryBuilder->getQueryContext()->setContext(QueryContextType::UNRESTRICTED); $deletedCount = $queryBuilder->count('uid')->from($tableName)->where($queryBuilder->expr()->neq($deletedField, 0))->execute()->fetchColumn(); if ($deletedCount) { /* @var $deletedDataObject DeletedRecords */ $deletedDataObject = GeneralUtility::makeInstance(DeletedRecords::class); $deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows(); if (isset($deletedData[$tableName])) { if ($deletedRecordsInTable = count($deletedData[$tableName])) { $deletedRecordsTotal += $deletedRecordsInTable; $tables[] = array($tableName, $deletedRecordsInTable, $lang->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'])); } } } } } $jsonArray = $tables; array_unshift($jsonArray, array('', $deletedRecordsTotal, $lang->sL('LLL:EXT:recycler/mod1/locallang.xlf:label_allrecordtypes'))); return $jsonArray; }