TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Tables.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Recycler\Domain\Model;
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  foreach (RecyclerUtility::getModifyableTables() as $tableName) {
40  $deletedField = RecyclerUtility::getDeletedField($tableName);
41  if ($deletedField) {
42  // Determine whether the table has deleted records:
43  $queryBuilder = $connection->getQueryBuilderForTable($tableName);
44  $queryBuilder->getRestrictions()->removeAll();
45 
46  $deletedCount = $queryBuilder->count('uid')
47  ->from($tableName)
48  ->where(
49  $queryBuilder->expr()->neq(
50  $deletedField,
51  $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
52  )
53  )
54  ->execute()
55  ->fetchColumn();
56 
57  if ($deletedCount) {
58  /* @var $deletedDataObject DeletedRecords */
59  $deletedDataObject = GeneralUtility::makeInstance(DeletedRecords::class);
60  $deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows();
61  if (isset($deletedData[$tableName])) {
62  if ($deletedRecordsInTable = count($deletedData[$tableName])) {
63  $deletedRecordsTotal += $deletedRecordsInTable;
64  $tables[] = [
65  $tableName,
66  $deletedRecordsInTable,
67  $lang->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'])
68  ];
69  }
70  }
71  }
72  }
73  }
74  $jsonArray = $tables;
75  array_unshift($jsonArray, [
76  '',
77  $deletedRecordsTotal,
78  $lang->sL('LLL:EXT:recycler/mod1/locallang.xlf:label_allrecordtypes')
79  ]);
80  return $jsonArray;
81  }
82 
88  protected function getLanguageService()
89  {
90  return $GLOBALS['LANG'];
91  }
92 }
getTables($startUid, $depth=0)
Definition: Tables.php:33
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)