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