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