TYPO3 CMS  TYPO3_8-7
Tables.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
24 class Tables
25 {
33  public function getTables($startUid, $depth = 0)
34  {
35  $deletedRecordsTotal = 0;
36  $lang = $this->getLanguageService();
37  $tables = [];
38  $connection = GeneralUtility::makeInstance(ConnectionPool::class);
39 
40  foreach (RecyclerUtility::getModifyableTables() as $tableName) {
41  $deletedField = RecyclerUtility::getDeletedField($tableName);
42  if ($deletedField) {
43  // Determine whether the table has deleted records:
44  $queryBuilder = $connection->getQueryBuilderForTable($tableName);
45  $queryBuilder->getRestrictions()->removeAll();
46 
47  $deletedCount = $queryBuilder->count('uid')
48  ->from($tableName)
49  ->where(
50  $queryBuilder->expr()->neq(
51  $deletedField,
52  $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
53  )
54  )
55  ->execute()
56  ->fetchColumn();
57 
58  if ($deletedCount) {
59  /* @var $deletedDataObject DeletedRecords */
60  $deletedDataObject = GeneralUtility::makeInstance(DeletedRecords::class);
61  $deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows();
62  if (isset($deletedData[$tableName])) {
63  if ($deletedRecordsInTable = count($deletedData[$tableName])) {
64  $deletedRecordsTotal += $deletedRecordsInTable;
65  $tables[] = [
66  $tableName,
67  $deletedRecordsInTable,
68  $lang->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'] ?? $tableName)
69  ];
70  }
71  }
72  }
73  }
74  }
75  $jsonArray = $tables;
76  array_unshift($jsonArray, [
77  '',
78  $deletedRecordsTotal,
79  $lang->sL('LLL:EXT:recycler/Resources/Private/Language/locallang.xlf:label_allrecordtypes')
80  ]);
81  return $jsonArray;
82  }
83 
89  protected function getLanguageService()
90  {
91  return $GLOBALS['LANG'];
92  }
93 }
getTables($startUid, $depth=0)
Definition: Tables.php:33
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']