TYPO3 CMS  TYPO3_8-7
DeletedRecordsController.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 
24 
29 {
33  protected $runtimeCache = null;
34 
38  protected $tce;
39 
40  public function __construct()
41  {
42  $this->runtimeCache = $this->getMemoryCache();
43  $this->tce = GeneralUtility::makeInstance(DataHandler::class);
44  }
45 
52  public function transform($deletedRowsArray)
53  {
54  $jsonArray = [
55  'rows' => []
56  ];
57 
58  if (is_array($deletedRowsArray)) {
59  $lang = $this->getLanguageService();
60  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
61 
62  foreach ($deletedRowsArray as $table => $rows) {
63  foreach ($rows as $row) {
64  $pageTitle = $this->getPageTitle((int)$row['pid']);
65  $backendUser = BackendUtility::getRecord('be_users', $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'username', '', false);
66  $jsonArray['rows'][] = [
67  'uid' => $row['uid'],
68  'pid' => $row['pid'],
69  'icon' => $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render(),
70  'pageTitle' => $pageTitle,
71  'table' => $table,
72  'crdate' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]),
73  'tstamp' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]),
74  'owner' => htmlspecialchars($backendUser['username']),
75  'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']],
76  'tableTitle' => $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']),
77  'title' => htmlspecialchars(BackendUtility::getRecordTitle($table, $row)),
78  'path' => RecyclerUtility::getRecordPath($row['pid']),
79  'isParentDeleted' => $table === 'pages' ? RecyclerUtility::isParentPageDeleted($row['pid']) : false
80  ];
81  }
82  }
83  }
84  return $jsonArray;
85  }
86 
93  protected function getPageTitle($pageId)
94  {
95  $cacheId = 'recycler-pagetitle-' . $pageId;
96  if ($this->runtimeCache->has($cacheId)) {
97  $pageTitle = $this->runtimeCache->get($cacheId);
98  } else {
99  if ($pageId === 0) {
100  $pageTitle = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
101  } else {
102  $recordInfo = $this->tce->recordInfo('pages', $pageId, 'title');
103  $pageTitle = $recordInfo['title'];
104  }
105  $this->runtimeCache->set($cacheId, $pageTitle);
106  }
107  return $pageTitle;
108  }
109 
115  protected function getLanguageService()
116  {
117  return $GLOBALS['LANG'];
118  }
119 
125  protected function getCacheManager()
126  {
127  return GeneralUtility::makeInstance(CacheManager::class);
128  }
129 
135  protected function getMemoryCache()
136  {
137  return $this->getCacheManager()->getCache('cache_runtime');
138  }
139 }
static getRecordPath($uid, $clause='', $titleLimit=1000, $fullTitleLimit=0)
static makeInstance($className,... $constructorArguments)
static getRecordTitle($table, $row, $prep=false, $forceResult=true)
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']