‪TYPO3CMS  ‪main
RecordsOverview.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
24 use TYPO3\CMS\Core\Imaging\IconSize;
28 
34 {
35  public function ‪__construct(
36  private readonly ‪IconFactory $iconFactory,
37  ) {}
38 
42  public function ‪render(): array
43  {
44  $languageService = $this->‪getLanguageService();
45  $backendUser = $this->‪getBackendUserAuthentication();
46  $result = $this->‪initializeResultArray();
47 
48  $parameterArray = $this->data['parameterArray'];
49  $selectedItems = $parameterArray['itemFormElValue'];
50  $maxTitleLength = (int)$backendUser->uc['titleLen'];
51 
52  $recordsOverviewHtml = [];
53  foreach ($selectedItems as $selectedItem) {
54  $title = (string)$selectedItem['title'];
55  if (empty($title)) {
56  $title = '[' . $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title') . ']';
57  }
58  $shortenedTitle = ‪GeneralUtility::fixed_lgd_cs($title, $maxTitleLength);
59  $linkedIcon = BackendUtility::wrapClickMenuOnIcon(
60  $this->iconFactory->getIconForRecord($selectedItem['table'], $selectedItem['row'], IconSize::SMALL)->render(),
61  $selectedItem['table'],
62  $selectedItem['uid']
63  );
64  $linkedTitle = BackendUtility::wrapClickMenuOnIcon(
65  htmlspecialchars($shortenedTitle),
66  $selectedItem['table'],
67  $selectedItem['uid']
68  );
69  $pathToContainingPage = BackendUtility::getRecordPath($selectedItem['row']['pid'], $this->‪getBackendUserAuthentication()->getPagePermsClause(‪Permission::PAGE_SHOW), 0);
70 
71  $recordsOverviewHtml[] = '<tr>';
72  $recordsOverviewHtml[] = '<td class="col-icon">';
73  $recordsOverviewHtml[] = $linkedIcon;
74  $recordsOverviewHtml[] = '</td>';
75  $recordsOverviewHtml[] = '<td class="col-title">';
76  $recordsOverviewHtml[] = $linkedTitle;
77  $recordsOverviewHtml[] = '<span class="text-body-secondary">';
78  $recordsOverviewHtml[] = ' [' . $selectedItem['uid'] . ']';
79  $recordsOverviewHtml[] = ' ' . htmlspecialchars($pathToContainingPage);
80  $recordsOverviewHtml[] = '</span>';
81  $recordsOverviewHtml[] = '</td>';
82  $recordsOverviewHtml[] = '</tr>';
83  }
84 
85  $html = [];
86  if (!empty($recordsOverviewHtml)) {
87  $html[] = '<div class="table-fit mt-1 mb-0">';
88  $html[] = '<table class="table">';
89  $html[] = '<tbody>';
90  $html[] = implode(LF, $recordsOverviewHtml);
91  $html[] = '</tbody>';
92  $html[] = '</table>';
93  $html[] = '</div>';
94  }
95 
96  $result['html'] = implode(LF, $html);
97  return $result;
98  }
99 
101  {
102  return ‪$GLOBALS['BE_USER'];
103  }
104 
106  {
107  return ‪$GLOBALS['LANG'];
108  }
109 }
‪TYPO3\CMS\Core\Utility\GeneralUtility\fixed_lgd_cs
‪static string fixed_lgd_cs(string $string, int $chars, string $appendString='...')
Definition: GeneralUtility.php:92
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Backend\Form\FieldWizard\RecordsOverview\__construct
‪__construct(private readonly IconFactory $iconFactory,)
Definition: RecordsOverview.php:35
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:26
‪TYPO3\CMS\Backend\Form\FieldWizard
Definition: DefaultLanguageDifferences.php:18
‪TYPO3\CMS\Backend\Form\FieldWizard\RecordsOverview\render
‪render()
Definition: RecordsOverview.php:42
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:35
‪TYPO3\CMS\Backend\Form\FieldWizard\RecordsOverview
Definition: RecordsOverview.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Form\FieldWizard\RecordsOverview\getBackendUserAuthentication
‪getBackendUserAuthentication()
Definition: RecordsOverview.php:100
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Backend\Form\FieldWizard\RecordsOverview\getLanguageService
‪getLanguageService()
Definition: RecordsOverview.php:105
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪initializeResultArray()
Definition: AbstractNode.php:77