‪TYPO3CMS  9.5
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 
25 class ‪Tables
26 {
34  public function ‪getTables($startUid, $depth = 0)
35  {
36  $deletedRecordsTotal = 0;
37  $lang = $this->‪getLanguageService();
38  $tables = [];
39  $connection = GeneralUtility::makeInstance(ConnectionPool::class);
40 
41  foreach (‪RecyclerUtility::getModifyableTables() as $tableName) {
42  $deletedField = ‪RecyclerUtility::getDeletedField($tableName);
43  if ($deletedField) {
44  // Determine whether the table has deleted records:
45  $queryBuilder = $connection->getQueryBuilderForTable($tableName);
46  $queryBuilder->getRestrictions()->removeAll();
47 
48  $deletedCount = $queryBuilder->count('uid')
49  ->from($tableName)
50  ->where(
51  $queryBuilder->expr()->neq(
52  $deletedField,
53  $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
54  )
55  )
56  ->execute()
57  ->fetchColumn();
58 
59  if ($deletedCount) {
60  /* @var DeletedRecords $deletedDataObject */
61  $deletedDataObject = GeneralUtility::makeInstance(DeletedRecords::class);
62  $deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows();
63  if (isset($deletedData[$tableName])) {
64  if ($deletedRecordsInTable = count($deletedData[$tableName])) {
65  $deletedRecordsTotal += $deletedRecordsInTable;
66  $tables[] = [
67  $tableName,
68  $deletedRecordsInTable,
69  $lang->sL(‪$GLOBALS['TCA'][$tableName]['ctrl']['title'] ?? $tableName)
70  ];
71  }
72  }
73  }
74  }
75  }
76  $jsonArray = $tables;
77  array_unshift($jsonArray, [
78  '',
79  $deletedRecordsTotal,
80  $lang->sL('LLL:EXT:recycler/Resources/Private/Language/locallang.xlf:label_allrecordtypes')
81  ]);
82  return $jsonArray;
83  }
84 
90  protected function ‪getLanguageService()
91  {
92  return ‪$GLOBALS['LANG'];
93  }
94 }
‪TYPO3\CMS\Recycler\Domain\Model\Tables\getTables
‪array getTables($startUid, $depth=0)
Definition: Tables.php:34
‪TYPO3\CMS\Recycler\Domain\Model\Tables
Definition: Tables.php:26
‪TYPO3\CMS\Recycler\Domain\Model\Tables\getLanguageService
‪TYPO3 CMS Core Localization LanguageService getLanguageService()
Definition: Tables.php:90
‪TYPO3\CMS\Recycler\Utility\RecyclerUtility\getDeletedField
‪static string getDeletedField($tableName)
Definition: RecyclerUtility.php:127
‪TYPO3\CMS\Recycler\Utility\RecyclerUtility\getModifyableTables
‪static getModifyableTables()
Definition: RecyclerUtility.php:220
‪TYPO3\CMS\Recycler\Utility\RecyclerUtility
Definition: RecyclerUtility.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Recycler\Domain\Model
Definition: DeletedRecords.php:2
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45