‪TYPO3CMS  9.5
ElementInformationController.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 use Doctrine\DBAL\Connection;
19 use Psr\Http\Message\ResponseInterface;
20 use Psr\Http\Message\ServerRequestInterface;
37 
43 {
46 
50  private ‪$deprecatedPublicMethods = [
51  'getLabelForTableColumn' => 'Using ElementInformationController::getLabelForTableColumn() is deprecated and will not be possible anymore in TYPO3 v10.0.',
52  ];
53 
60  'table' => 'Using $table of class ElementInformationController from the outside is discouraged, as this variable is only used for internal storage.',
61  'uid' => 'Using $uid of class ElementInformationController from the outside is discouraged, as this variable is only used for internal storage.',
62  'access' => 'Using $access of class ElementInformationController from the outside is discouraged, as this variable is only used for internal storage.',
63  'type' => 'Using $type of class ElementInformationController from the outside is discouraged, as this variable is only used for internal storage.',
64  'pageInfo' => 'Using $pageInfo of class ElementInformationController from the outside is discouraged, as this variable is only used for internal storage.',
65  ];
66 
72  protected ‪$table;
73 
79  protected ‪$uid;
80 
84  protected ‪$permsClause;
85 
89  protected ‪$access = false;
90 
98  protected ‪$type = '';
99 
103  protected ‪$moduleTemplate;
104 
111  protected ‪$pageInfo;
112 
118  protected ‪$row;
119 
123  protected ‪$fileObject;
124 
128  protected ‪$folderObject;
129 
133  protected ‪$iconFactory;
134 
138  public function ‪__construct()
139  {
140  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
141  ‪$GLOBALS['SOBE'] = $this;
142 
143  // @deprecated since TYPO3 v9, will be obsolete in TYPO3 v10.0 with removal of init()
144  $request = ‪$GLOBALS['TYPO3_REQUEST'];
145  // @deprecated since TYPO3 v9, will be moved out of __construct() in TYPO3 v10.0
146  $this->‪init($request);
147  }
148 
156  public function ‪mainAction(ServerRequestInterface $request): ResponseInterface
157  {
158  $this->‪main($request);
159  return new ‪HtmlResponse($this->moduleTemplate->renderContent());
160  }
161 
168  public function ‪init(ServerRequestInterface $request = null): void
169  {
170  if ($request === null) {
171  // Missing argument? This method must have been called from outside.
172  // Method will be protected and $request mandatory in TYPO3 v10.0, giving core freedom to move stuff around
173  // New v10 signature: "protected function init(ServerRequestInterface $request): void"
174  // @deprecated since TYPO3 v9, method argument $request will be set to mandatory
175  trigger_error('ElementInformationController->init() will be set to protected in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED);
176  $request = ‪$GLOBALS['TYPO3_REQUEST'];
177  }
178 
179  $queryParams = $request->getQueryParams();
180 
181  $this->table = $queryParams['table'] ?? null;
182  $this->uid = $queryParams['uid'] ?? null;
183 
184  $this->permsClause = $this->‪getBackendUser()->‪getPagePermsClause(‪Permission::PAGE_SHOW);
185  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
186  $this->moduleTemplate->getDocHeaderComponent()->disable();
187 
188  if (isset(‪$GLOBALS['TCA'][$this->table])) {
189  $this->‪initDatabaseRecord();
190  } elseif ($this->table === '_FILE' || $this->table === '_FOLDER' || $this->table === 'sys_file') {
191  $this->‪initFileOrFolderRecord();
192  }
193  }
194 
198  protected function ‪initDatabaseRecord()
199  {
200  $this->type = 'db';
201  $this->uid = (int)$this->uid;
202 
203  // Check permissions and uid value:
204  if ($this->uid && $this->‪getBackendUser()->‪check('tables_select', $this->table)) {
205  if ((string)$this->table === 'pages') {
206  $this->pageInfo = ‪BackendUtility::readPageAccess($this->uid, $this->permsClause);
207  $this->access = is_array($this->pageInfo);
208  $this->row = ‪$this->pageInfo;
209  } else {
210  $this->row = ‪BackendUtility::getRecordWSOL($this->table, $this->uid);
211  if ($this->row) {
212  // Find the correct "pid" when a versionized record is given, otherwise "pid = -1" always fails
213  if (!empty($this->row['t3ver_oid'])) {
214  $t3OrigRow = ‪BackendUtility::getRecord($this->table, (int)$this->row['t3ver_oid']);
215  $this->pageInfo = ‪BackendUtility::readPageAccess((int)$t3OrigRow['pid'], $this->permsClause);
216  } else {
217  $this->pageInfo = ‪BackendUtility::readPageAccess($this->row['pid'], $this->permsClause);
218  }
219  $this->access = is_array($this->pageInfo);
220  }
221  }
222  }
223  }
224 
228  protected function ‪initFileOrFolderRecord()
229  {
230  $fileOrFolderObject = ‪ResourceFactory::getInstance()->‪retrieveFileOrFolderObject($this->uid);
231 
232  if ($fileOrFolderObject instanceof Folder) {
233  $this->folderObject = $fileOrFolderObject;
234  $this->access = $this->folderObject->‪checkActionPermission('read');
235  $this->type = 'folder';
236  } elseif ($fileOrFolderObject instanceof File) {
237  $this->fileObject = $fileOrFolderObject;
238  $this->access = $this->fileObject->checkActionPermission('read');
239  $this->type = 'file';
240  $this->table = 'sys_file';
241 
242  try {
243  $this->row = ‪BackendUtility::getRecordWSOL($this->table, $fileOrFolderObject->getUid());
244  } catch (\‪Exception $e) {
245  $this->row = [];
246  }
247  }
248  }
249 
256  public function ‪main(ServerRequestInterface $request = null): void
257  {
258  if ($request === null) {
259  // Missing argument? This method must have been called from outside.
260  // @deprecated since TYPO3 v9, method argument $request will be set to mandatory
261  trigger_error('ElementInformationController->main() will be set to protected in TYPO3 v10.0. Do not call from other extension.', E_USER_DEPRECATED);
262  $request = ‪$GLOBALS['TYPO3_REQUEST'];
263  }
264 
265  $content = '';
266 
267  // Rendering of the output via fluid
268  $view = GeneralUtility::makeInstance(StandaloneView::class);
269  $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates')]);
270  $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials')]);
271  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
272  'EXT:backend/Resources/Private/Templates/ContentElement/ElementInformation.html'
273  ));
274 
275  if ($this->access) {
276  // render type by user func
277  $typeRendered = false;
278  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] ?? [] as $className) {
279  $typeRenderObj = GeneralUtility::makeInstance($className);
280  if (is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render')) {
281  if ($typeRenderObj->isValid($this->type, $this)) {
282  $content .= $typeRenderObj->render($this->type, $this);
283  $typeRendered = true;
284  break;
285  }
286  }
287  }
288 
289  if (!$typeRendered) {
290  $view->assign('accessAllowed', true);
291  $view->assignMultiple($this->‪getPageTitle());
292  $view->assignMultiple($this->‪getPreview());
293  $view->assignMultiple($this->‪getPropertiesForTable());
294  $view->assignMultiple($this->‪getReferences($request));
295  $view->assign('returnUrl', GeneralUtility::sanitizeLocalUrl($request->getQueryParams()['returnUrl']));
296  $view->assign('maxTitleLength', $this->‪getBackendUser()->uc['titleLen'] ?? 20);
297  $content .= $view->render();
298  }
299  } else {
300  $content .= $view->render();
301  }
302 
303  $this->moduleTemplate->setContent($content);
304  }
305 
311  protected function ‪getPageTitle(): array
312  {
313  $pageTitle = [
314  'title' => ‪BackendUtility::getRecordTitle($this->table, $this->row, false)
315  ];
316  if ($this->type === 'folder') {
317  $pageTitle['table'] = $this->‪getLanguageService()->‪sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:folder');
318  $pageTitle['icon'] = $this->iconFactory->getIconForResource($this->folderObject, ‪Icon::SIZE_SMALL)->render();
319  } elseif ($this->type === 'file') {
320  $pageTitle['table'] = $this->‪getLanguageService()->‪sL(‪$GLOBALS['TCA'][$this->table]['ctrl']['title']);
321  $pageTitle['icon'] = $this->iconFactory->getIconForResource($this->fileObject, ‪Icon::SIZE_SMALL)->render();
322  } else {
323  $pageTitle['table'] = $this->‪getLanguageService()->‪sL(‪$GLOBALS['TCA'][$this->table]['ctrl']['title']);
324  $pageTitle['icon'] = $this->iconFactory->getIconForRecord($this->table, $this->row, ‪Icon::SIZE_SMALL);
325  }
326  $this->moduleTemplate->setTitle($pageTitle['table'] . ': ' . $pageTitle['title']);
327  return $pageTitle;
328  }
329 
335  protected function ‪getPreview(): array
336  {
337  $preview = [];
338  // Perhaps @todo in future: Also display preview for records - without fileObject
339  if (!$this->fileObject) {
340  return $preview;
341  }
342 
343  // check if file is marked as missing
344  if ($this->fileObject->isMissing()) {
345  $preview['missingFile'] = $this->fileObject->getName();
346  } else {
348  ‪$rendererRegistry = GeneralUtility::makeInstance(\‪TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::class);
349  $fileRenderer = ‪$rendererRegistry->getRenderer($this->fileObject);
350  $fileExtension = $this->fileObject->getExtension();
351  $preview['url'] = $this->fileObject->getPublicUrl(true);
352 
353  $width = '590m';
354  $heigth = '400m';
355 
356  // Check if there is a FileRenderer
357  if ($fileRenderer !== null) {
358  $preview['fileRenderer'] = $fileRenderer->render(
359  $this->fileObject,
360  $width,
361  $heigth,
362  [],
363  true
364  );
365 
366  // else check if we can create an Image preview
367  } elseif (GeneralUtility::inList(‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
368  $preview['fileObject'] = ‪$this->fileObject;
369  $preview['width'] = $width;
370  $preview['heigth'] = $heigth;
371  }
372  }
373  return $preview;
374  }
375 
381  protected function ‪getPropertiesForTable(): array
382  {
383  $propertiesForTable = [];
384  $lang = $this->‪getLanguageService();
385 
386  $extraFields = [
387  'uid' => htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:show_item.php.uid'))
388  ];
389 
390  if (in_array($this->type, ['folder', 'file'], true)) {
391  if ($this->type === 'file') {
392  $extraFields['creation_date'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.creationDate'));
393  $extraFields['modification_date'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.timestamp'));
394  if ($this->fileObject->getType() === ‪AbstractFile::FILETYPE_IMAGE) {
395  $extraFields['width'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.width'));
396  $extraFields['height'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.height'));
397  }
398  }
399  $extraFields['storage'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file.storage'));
400  $extraFields['folder'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:folder'));
401  } else {
402  $extraFields['crdate'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.creationDate'));
403  $extraFields['cruser_id'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.creationUserId'));
404  $extraFields['tstamp'] = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.timestamp'));
405 
406  // check if the special fields are defined in the TCA ctrl section of the table
407  foreach ($extraFields as $fieldName => $fieldLabel) {
408  if (isset(‪$GLOBALS['TCA'][$this->table]['ctrl'][$fieldName])) {
409  $extraFields[‪$GLOBALS['TCA'][‪$this->table]['ctrl'][$fieldName]] = $fieldLabel;
410  } elseif ($fieldName !== 'uid') {
411  unset($extraFields[$fieldName]);
412  }
413  }
414  }
415 
416  foreach ($extraFields as $name => $fieldLabel) {
417  $rowValue = '';
418  $thisRow = [];
419  if (!isset($this->row[$name])) {
420  $resourceObject = $this->fileObject ?: ‪$this->folderObject;
421  if ($name === 'storage') {
422  $rowValue = $resourceObject->‪getStorage()->‪getName();
423  } elseif ($name === 'folder') {
424  $rowValue = $resourceObject->getParentFolder()->getReadablePath();
425  } elseif ($name === 'width') {
426  $rowValue = $this->fileObject->getProperty('width') . 'px';
427  } elseif ($name === 'height') {
428  $rowValue = $this->fileObject->getProperty('height') . 'px';
429  }
430  } elseif ($name === 'creation_date' || $name === 'modification_date' || $name === 'tstamp' || $name === 'crdate') {
431  $rowValue = ‪BackendUtility::datetime($this->row[$name]);
432  } else {
433  $rowValue = ‪BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
434  }
435  $thisRow['value'] = $rowValue;
436  $thisRow['fieldLabel'] = rtrim($fieldLabel, ':');
437  // show the backend username who created the issue
438  if ($name === 'cruser_id' && $rowValue) {
439  $creatorRecord = ‪BackendUtility::getRecord('be_users', $rowValue);
440  if ($creatorRecord) {
442  $avatar = GeneralUtility::makeInstance(Avatar::class);
443  $creatorRecord['icon'] = $avatar->render($creatorRecord);
444  $thisRow['creatorRecord'] = $creatorRecord;
445  $thisRow['value'] = '';
446  }
447  }
448  $propertiesForTable['extraFields'][] = $thisRow;
449  }
450 
451  // Traverse the list of fields to display for the record:
452  $fieldList = GeneralUtility::trimExplode(',', ‪$GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], true);
453  foreach ($fieldList as $name) {
454  $thisRow = [];
455  $name = trim($name);
456  ‪$uid = $this->row['uid'];
457 
458  if (!isset(‪$GLOBALS['TCA'][$this->table]['columns'][$name])) {
459  continue;
460  }
461 
462  // Storage is already handled above
463  if ($this->type === 'file' && $name === 'storage') {
464  continue;
465  }
466 
467  // format file size as bytes/kilobytes/megabytes
468  if ($this->type === 'file' && $name === 'size') {
469  $this->row[$name] = GeneralUtility::formatSize($this->row[$name], htmlspecialchars($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:byteSizeUnits')));
470  }
471 
472  $isExcluded = !(!‪$GLOBALS['TCA'][‪$this->table]['columns'][$name]['exclude'] || $this->‪getBackendUser()->‪check('non_exclude_fields', $this->table . ':' . $name));
473  if ($isExcluded) {
474  continue;
475  }
476 
477  $thisRow['fieldValue'] = ‪BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, false, ‪$uid);
478  $thisRow['fieldLabel'] = htmlspecialchars($lang->sL(‪BackendUtility::getItemLabel($this->table, $name)));
479  $propertiesForTable['fields'][] = $thisRow;
480  }
481  return $propertiesForTable;
482  }
483 
490  protected function ‪getReferences(ServerRequestInterface $request): array
491  {
492  $references = [];
493  switch ($this->type) {
494  case 'db': {
495  $references['refLines'] = $this->‪makeRef($this->table, $this->row['uid'], $request);
496  $references['refFromLines'] = $this->‪makeRefFrom($this->table, $this->row['uid'], $request);
497  break;
498  }
499 
500  case 'file': {
501  if ($this->fileObject && $this->fileObject->isIndexed()) {
502  $references['refLines'] = $this->‪makeRef('_FILE', $this->fileObject, $request);
503  }
504  break;
505  }
506  }
507  return $references;
508  }
509 
517  protected function ‪getLabelForTableColumn($tableName, $fieldName)
518  {
519  if (‪$GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== null) {
520  $field = $this->‪getLanguageService()->‪sL(‪$GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
521  if (trim($field) === '') {
522  $field = $fieldName;
523  }
524  } else {
525  $field = $fieldName;
526  }
527  return $field;
528  }
529 
538  protected function ‪getRecordActions(‪$table, ‪$uid, ServerRequestInterface $request): array
539  {
540  if (‪$table === '' || ‪$uid < 0) {
541  return [];
542  }
543 
544  $actions = [];
545  // Edit button
546  $urlParameters = [
547  'edit' => [
548  ‪$table => [
549  ‪$uid => 'edit'
550  ]
551  ],
552  'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
553  ];
555  $uriBuilder = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\UriBuilder::class);
556  $actions['recordEditUrl'] = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
557 
558  // History button
559  $urlParameters = [
560  'element' => ‪$table . ':' . ‪$uid,
561  'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
562  ];
563  $actions['recordHistoryUrl'] = (string)$uriBuilder->buildUriFromRoute('record_history', $urlParameters);
564 
565  if (‪$table === 'pages') {
566  // Recordlist button
567  $actions['webListUrl'] = (string)$uriBuilder->buildUriFromRoute('web_list', ['id' => ‪$uid, 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()]);
568 
569  // View page button
571  }
572 
573  return $actions;
574  }
575 
584  protected function ‪makeRef(‪$table, $ref, ServerRequestInterface $request)
585  {
586  $refLines = [];
587  $lang = $this->‪getLanguageService();
588  // Files reside in sys_file table
589  if (‪$table === '_FILE') {
590  $selectTable = 'sys_file';
591  $selectUid = $ref->getUid();
592  } else {
593  $selectTable = ‪$table;
594  $selectUid = $ref;
595  }
597  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
598  ->getQueryBuilderForTable('sys_refindex');
599 
600  $predicates = [
601  $queryBuilder->expr()->eq(
602  'ref_table',
603  $queryBuilder->createNamedParameter($selectTable, \PDO::PARAM_STR)
604  ),
605  $queryBuilder->expr()->eq(
606  'ref_uid',
607  $queryBuilder->createNamedParameter($selectUid, \PDO::PARAM_INT)
608  ),
609  $queryBuilder->expr()->eq(
610  'deleted',
611  $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
612  )
613  ];
614 
615  $backendUser = $this->‪getBackendUser();
616  if (!$backendUser->isAdmin()) {
617  $allowedSelectTables = GeneralUtility::trimExplode(',', $backendUser->groupData['tables_select']);
618  $predicates[] = $queryBuilder->expr()->in(
619  'tablename',
620  $queryBuilder->createNamedParameter($allowedSelectTables, Connection::PARAM_STR_ARRAY)
621  );
622  }
623 
624  $rows = $queryBuilder
625  ->select('*')
626  ->from('sys_refindex')
627  ->where(...$predicates)
628  ->execute()
629  ->fetchAll();
630 
631  // Compile information for title tag:
632  foreach ($rows as ‪$row) {
633  if (‪$row['tablename'] === 'sys_file_reference') {
635  if (‪$row['tablename'] === null || ‪$row['recuid'] === null) {
636  return;
637  }
638  }
639 
640  $line = [];
641  $record = ‪BackendUtility::getRecord(‪$row['tablename'], ‪$row['recuid']);
642  if ($record) {
643  ‪BackendUtility::fixVersioningPid(‪$row['tablename'], $record);
644  if (!$this->‪canAccessPage($row['tablename'], $record)) {
645  continue;
646  }
647  $parentRecord = ‪BackendUtility::getRecord('pages', $record['pid']);
648  $parentRecordTitle = is_array($parentRecord)
649  ? ‪BackendUtility::getRecordTitle('pages', $parentRecord)
650  : '';
651  $urlParameters = [
652  'edit' => [
653  ‪$row['tablename'] => [
654  ‪$row['recuid'] => 'edit'
655  ]
656  ],
657  'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
658  ];
660  $uriBuilder = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\UriBuilder::class);
661  $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
662  $line['url'] = $url;
663  $line['icon'] = $this->iconFactory->getIconForRecord(‪$row['tablename'], $record, ‪Icon::SIZE_SMALL)->render();
664  $line['row'] = ‪$row;
665  $line['record'] = $record;
666  $line['recordTitle'] = ‪BackendUtility::getRecordTitle(‪$row['tablename'], $record, false, true);
667  $line['parentRecordTitle'] = $parentRecordTitle;
668  $line['title'] = $lang->sL(‪$GLOBALS['TCA'][‪$row['tablename']]['ctrl']['title']);
669  $line['labelForTableColumn'] = $this->‪getLabelForTableColumn($row['tablename'], ‪$row['field']);
670  $line['path'] = ‪BackendUtility::getRecordPath($record['pid'], '', 0, 0);
671  $line['actions'] = $this->‪getRecordActions($row['tablename'], ‪$row['recuid'], $request);
672  } else {
673  $line['row'] = ‪$row;
674  $line['title'] = $lang->sL(‪$GLOBALS['TCA'][‪$row['tablename']]['ctrl']['title']) ?: ‪$row['tablename'];
675  $line['labelForTableColumn'] = $this->‪getLabelForTableColumn($row['tablename'], ‪$row['field']);
676  }
677  $refLines[] = $line;
678  }
679  return $refLines;
680  }
681 
690  protected function ‪makeRefFrom(‪$table, $ref, ServerRequestInterface $request): array
691  {
692  $refFromLines = [];
693  $lang = $this->‪getLanguageService();
694 
696  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
697  ->getQueryBuilderForTable('sys_refindex');
698 
699  $predicates = [
700  $queryBuilder->expr()->eq(
701  'tablename',
702  $queryBuilder->createNamedParameter(‪$table, \PDO::PARAM_STR)
703  ),
704  $queryBuilder->expr()->eq(
705  'recuid',
706  $queryBuilder->createNamedParameter($ref, \PDO::PARAM_INT)
707  )
708  ];
709 
710  $backendUser = $this->‪getBackendUser();
711  if (!$backendUser->isAdmin()) {
712  $allowedSelectTables = GeneralUtility::trimExplode(',', $backendUser->groupData['tables_select']);
713  $predicates[] = $queryBuilder->expr()->in(
714  'ref_table',
715  $queryBuilder->createNamedParameter($allowedSelectTables, Connection::PARAM_STR_ARRAY)
716  );
717  }
718 
719  $rows = $queryBuilder
720  ->select('*')
721  ->from('sys_refindex')
722  ->where(...$predicates)
723  ->execute()
724  ->fetchAll();
725 
726  // Compile information for title tag:
727  foreach ($rows as ‪$row) {
728  $line = [];
729  $record = ‪BackendUtility::getRecord(‪$row['ref_table'], ‪$row['ref_uid']);
730  if ($record) {
731  ‪BackendUtility::fixVersioningPid(‪$row['ref_table'], $record);
732  if (!$this->‪canAccessPage($row['ref_table'], $record)) {
733  continue;
734  }
735  $urlParameters = [
736  'edit' => [
737  ‪$row['ref_table'] => [
738  ‪$row['ref_uid'] => 'edit'
739  ]
740  ],
741  'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
742  ];
744  $uriBuilder = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\UriBuilder::class);
745  $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
746  $line['url'] = $url;
747  $line['icon'] = $this->iconFactory->getIconForRecord(‪$row['tablename'], $record, ‪Icon::SIZE_SMALL)->render();
748  $line['row'] = ‪$row;
749  $line['record'] = $record;
750  $line['recordTitle'] = ‪BackendUtility::getRecordTitle(‪$row['ref_table'], $record, false, true);
751  $line['title'] = $lang->sL(‪$GLOBALS['TCA'][‪$row['ref_table']]['ctrl']['title']);
752  $line['labelForTableColumn'] = $this->‪getLabelForTableColumn(‪$table, $row['field']);
753  $line['path'] = ‪BackendUtility::getRecordPath($record['pid'], '', 0, 0);
754  $line['actions'] = $this->‪getRecordActions($row['ref_table'], ‪$row['ref_uid'], $request);
755  } else {
756  $line['row'] = ‪$row;
757  $line['title'] = $lang->sL(‪$GLOBALS['TCA'][‪$row['ref_table']]['ctrl']['title']);
758  $line['labelForTableColumn'] = $this->‪getLabelForTableColumn(‪$table, $row['field']);
759  }
760  $refFromLines[] = $line;
761  }
762  return $refFromLines;
763  }
764 
771  protected function ‪transformFileReferenceToRecordReference(array $referenceRecord)
772  {
774  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
775  ->getQueryBuilderForTable('sys_file_reference');
776  $queryBuilder->getRestrictions()->removeAll();
777  $fileReference = $queryBuilder
778  ->select('*')
779  ->from('sys_file_reference')
780  ->where(
781  $queryBuilder->expr()->eq(
782  'uid',
783  $queryBuilder->createNamedParameter($referenceRecord['recuid'], \PDO::PARAM_INT)
784  )
785  )
786  ->execute()
787  ->fetch();
788 
789  return [
790  'recuid' => $fileReference['uid_foreign'],
791  'tablename' => $fileReference['tablenames'],
792  'field' => $fileReference['fieldname'],
793  'flexpointer' => '',
794  'softref_key' => '',
795  'sorting' => $fileReference['sorting_foreign']
796  ];
797  }
798 
804  protected function ‪canAccessPage(string $tableName, array $record): bool
805  {
806  $recordPid = (int)($tableName === 'pages' ? $record['uid'] : $record['pid']);
807  return $this->‪getBackendUser()->‪isInWebMount($tableName === 'pages' ? $record : $record['pid'])
808  || $recordPid === 0 && !empty(‪$GLOBALS['TCA'][$tableName]['ctrl']['security']['ignoreRootLevelRestriction']);
809  }
810 
816  protected function ‪getLanguageService()
817  {
818  return ‪$GLOBALS['LANG'];
819  }
820 
826  protected function ‪getBackendUser()
827  {
828  return ‪$GLOBALS['BE_USER'];
829  }
830 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$moduleTemplate
‪ModuleTemplate $moduleTemplate
Definition: ElementInformationController.php:93
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\getPropertiesForTable
‪array getPropertiesForTable()
Definition: ElementInformationController.php:366
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$permsClause
‪string $permsClause
Definition: ElementInformationController.php:77
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getPagePermsClause
‪string getPagePermsClause($perms)
Definition: BackendUserAuthentication.php:523
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\mainAction
‪ResponseInterface mainAction(ServerRequestInterface $request)
Definition: ElementInformationController.php:141
‪TYPO3\CMS\Backend\Utility\BackendUtility\datetime
‪static string datetime($value)
Definition: BackendUtility.php:1190
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$row
‪array $row
Definition: ElementInformationController.php:106
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\getPreview
‪array getPreview()
Definition: ElementInformationController.php:320
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\getPageTitle
‪array getPageTitle()
Definition: ElementInformationController.php:296
‪TYPO3
‪TYPO3\CMS\Backend\Backend\Avatar\Avatar
Definition: Avatar.php:33
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\makeRef
‪array makeRef($table, $ref, ServerRequestInterface $request)
Definition: ElementInformationController.php:569
‪TYPO3\CMS\Backend\Exception
Definition: Exception.php:23
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\transformFileReferenceToRecordReference
‪array transformFileReferenceToRecordReference(array $referenceRecord)
Definition: ElementInformationController.php:756
‪TYPO3\CMS\Backend\Controller\ContentElement
Definition: ElementHistoryController.php:2
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\check
‪bool check($type, $value)
Definition: BackendUserAuthentication.php:648
‪TYPO3\CMS\Backend\Utility\BackendUtility\getItemLabel
‪static string getItemLabel($table, $col)
Definition: BackendUtility.php:1791
‪TYPO3\CMS\Core\Resource\ResourceFactory\getInstance
‪static ResourceFactory getInstance()
Definition: ResourceFactory.php:39
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController
Definition: ElementInformationController.php:43
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:158
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\getLabelForTableColumn
‪string getLabelForTableColumn($tableName, $fieldName)
Definition: ElementInformationController.php:502
‪TYPO3\CMS\Backend\Utility\BackendUtility\BEgetRootLine
‪static array BEgetRootLine($uid, $clause='', $workspaceOL=false, array $additionalFields=[])
Definition: BackendUtility.php:374
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\getBackendUser
‪TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser()
Definition: ElementInformationController.php:811
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\canAccessPage
‪bool canAccessPage(string $tableName, array $record)
Definition: ElementInformationController.php:789
‪TYPO3\CMS\Core\Resource\AbstractFile\FILETYPE_IMAGE
‪const FILETYPE_IMAGE
Definition: AbstractFile.php:76
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:40
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:23
‪TYPO3\CMS\Core\Resource\Folder\getStorage
‪ResourceStorage getStorage()
Definition: Folder.php:146
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$table
‪string $table
Definition: ElementInformationController.php:67
‪TYPO3\CMS\Backend\Utility\BackendUtility\fixVersioningPid
‪static fixVersioningPid($table, &$rr, $ignoreWorkspaceMatch=false)
Definition: BackendUtility.php:3986
‪TYPO3\CMS\Core\Resource\AbstractFile
Definition: AbstractFile.php:24
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\makeRefFrom
‪array makeRefFrom($table, $ref, ServerRequestInterface $request)
Definition: ElementInformationController.php:675
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:34
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:33
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:23
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitle
‪static string getRecordTitle($table, $row, $prep=false, $forceResult=true)
Definition: BackendUtility.php:1811
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\initFileOrFolderRecord
‪initFileOrFolderRecord()
Definition: ElementInformationController.php:213
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$fileObject
‪TYPO3 CMS Core Resource File $fileObject
Definition: ElementInformationController.php:110
‪TYPO3\CMS\Backend\Utility\BackendUtility\getProcessedValueExtra
‪static string getProcessedValueExtra( $table, $fN, $fV, $fixed_lgd_chars=0, $uid=0, $forceResult=true, $pid=0)
Definition: BackendUtility.php:2362
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:32
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$type
‪string $type
Definition: ElementInformationController.php:89
‪TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait
Definition: PublicMethodDeprecationTrait.php:68
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordWSOL
‪static array getRecordWSOL( $table, $uid, $fields=' *', $where='', $useDeleteClause=true, $unsetMovePointers=false)
Definition: BackendUtility.php:174
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$iconFactory
‪IconFactory $iconFactory
Definition: ElementInformationController.php:118
‪TYPO3\CMS\Core\Resource\File\checkActionPermission
‪bool checkActionPermission($action)
Definition: File.php:262
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:130
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\initDatabaseRecord
‪initDatabaseRecord()
Definition: ElementInformationController.php:183
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$access
‪bool $access
Definition: ElementInformationController.php:81
‪TYPO3\CMS\Backend\Utility\BackendUtility\viewOnClick
‪static string viewOnClick( $pageUid, $backPath='', $rootLine=null, $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=true)
Definition: BackendUtility.php:2616
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\__construct
‪__construct()
Definition: ElementInformationController.php:123
‪TYPO3\CMS\Backend\Utility\BackendUtility\getProcessedValue
‪static string null getProcessedValue( $table, $col, $value, $fixed_lgd_chars=0, $defaultPassthrough=false, $noRecordLookup=false, $uid=0, $forceResult=true, $pid=0)
Definition: BackendUtility.php:1933
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\getReferences
‪array getReferences(ServerRequestInterface $request)
Definition: ElementInformationController.php:475
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\getLanguageService
‪TYPO3 CMS Core Localization LanguageService getLanguageService()
Definition: ElementInformationController.php:801
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$uid
‪int $uid
Definition: ElementInformationController.php:73
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$deprecatedPublicProperties
‪array $deprecatedPublicProperties
Definition: ElementInformationController.php:55
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$folderObject
‪Folder $folderObject
Definition: ElementInformationController.php:114
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\init
‪init(ServerRequestInterface $request=null)
Definition: ElementInformationController.php:153
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\main
‪main(ServerRequestInterface $request=null)
Definition: ElementInformationController.php:241
‪TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait
Definition: PublicPropertyDeprecationTrait.php:66
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\getRecordActions
‪array getRecordActions($table, $uid, ServerRequestInterface $request)
Definition: ElementInformationController.php:523
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordPath
‪static mixed getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)
Definition: BackendUtility.php:572
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$pageInfo
‪array $pageInfo
Definition: ElementInformationController.php:100
‪$rendererRegistry
‪$rendererRegistry
Definition: ext_localconf.php:120
‪TYPO3\CMS\Backend\Controller\ContentElement\ElementInformationController\$deprecatedPublicMethods
‪array $deprecatedPublicMethods
Definition: ElementInformationController.php:47
‪TYPO3\CMS\Core\Resource\ResourceFactory\retrieveFileOrFolderObject
‪File Folder null retrieveFileOrFolderObject($input)
Definition: ResourceFactory.php:491
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:25
‪TYPO3\CMS\Backend\Utility\BackendUtility\readPageAccess
‪static array bool readPageAccess($id, $perms_clause)
Definition: BackendUtility.php:635
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\isInWebMount
‪int null isInWebMount($idOrRow, $readPerms='', $exitOnError=0)
Definition: BackendUserAuthentication.php:353
‪TYPO3\CMS\Core\Resource\ResourceStorage\getName
‪string getName()
Definition: ResourceStorage.php:261