TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
DeletedRecordsController.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Recycler\Controller;
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 
23 
28 {
32  protected $runtimeCache = null;
33 
37  protected $tce;
38 
39  public function __construct()
40  {
41  $this->runtimeCache = $this->getMemoryCache();
42  $this->tce = GeneralUtility::makeInstance(DataHandler::class);
43  }
44 
52  public function transform($deletedRowsArray, $totalDeleted)
53  {
54  $total = 0;
55  $jsonArray = [
56  'rows' => []
57  ];
58 
59  if (is_array($deletedRowsArray)) {
60  $lang = $this->getLanguageService();
61  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
62 
63  foreach ($deletedRowsArray as $table => $rows) {
64  $total += count($deletedRowsArray[$table]);
65  foreach ($rows as $row) {
66  $pageTitle = $this->getPageTitle((int)$row['pid']);
67  $backendUser = BackendUtility::getRecord('be_users', $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']], 'username', '', false);
68  $jsonArray['rows'][] = [
69  'uid' => $row['uid'],
70  'pid' => $row['pid'],
71  'icon' => $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render(),
72  'pageTitle' => $pageTitle,
73  'table' => $table,
74  'crdate' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['crdate']]),
75  'tstamp' => BackendUtility::datetime($row[$GLOBALS['TCA'][$table]['ctrl']['tstamp']]),
76  'owner' => htmlspecialchars($backendUser['username']),
77  'owner_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']],
78  'tableTitle' => $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']),
79  'title' => htmlspecialchars(BackendUtility::getRecordTitle($table, $row)),
80  'path' => RecyclerUtility::getRecordPath($row['pid']),
81  'isParentDeleted' => $table === 'pages' ? RecyclerUtility::isParentPageDeleted($row['pid']) : false
82  ];
83  }
84  }
85  }
86  $jsonArray['total'] = $totalDeleted;
87  return $jsonArray;
88  }
89 
96  protected function getPageTitle($pageId)
97  {
98  $cacheId = 'recycler-pagetitle-' . $pageId;
99  if ($this->runtimeCache->has($cacheId)) {
100  $pageTitle = $this->runtimeCache->get($cacheId);
101  } else {
102  if ($pageId === 0) {
103  $pageTitle = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
104  } else {
105  $recordInfo = $this->tce->recordInfo('pages', $pageId, 'title');
106  $pageTitle = $recordInfo['title'];
107  }
108  $this->runtimeCache->set($cacheId, $pageTitle);
109  }
110  return $pageTitle;
111  }
112 
118  protected function getLanguageService()
119  {
120  return $GLOBALS['LANG'];
121  }
122 
128  protected function getCacheManager()
129  {
130  return GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class);
131  }
132 
138  protected function getMemoryCache()
139  {
140  return $this->getCacheManager()->getCache('cache_runtime');
141  }
142 }
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']
static makeInstance($className,...$constructorArguments)
static getRecordPath($uid, $clause= '', $titleLimit=1000, $fullTitleLimit=0)