‪TYPO3CMS  ‪main
OuterWrapContainer.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
20 use TYPO3\CMS\Core\Imaging\IconSize;
23 
33 {
34  public function ‪__construct(
35  private readonly ‪IconFactory $iconFactory,
36  ) {}
37 
43  public function ‪render(): array
44  {
45  $languageService = $this->‪getLanguageService();
46  $backendUser = $this->‪getBackendUserAuthentication();
47 
48  $table = $this->data['tableName'];
49  $row = $this->data['databaseRow'];
50 
51  $options = ‪$this->data;
52  if (empty($this->data['fieldListToRender'])) {
53  $options['renderType'] = 'fullRecordContainer';
54  } else {
55  $options['renderType'] = 'listOfFieldsContainer';
56  }
57  $result = $this->nodeFactory->create($options)->render();
58 
59  $childHtml = $result['html'];
60 
61  $recordPath = '';
62  // @todo: what is this >= 0 check for? wsol cases?!
63  if ($this->data['effectivePid'] >= 0) {
64  $permissionsClause = $backendUser->getPagePermsClause(‪Permission::PAGE_SHOW);
65  $recordPath = BackendUtility::getRecordPath($this->data['effectivePid'], $permissionsClause, 15);
66  }
67 
68  $icon = $this->iconFactory
69  ->getIconForRecord($table, $row, IconSize::SMALL)
70  ->setTitle($recordPath)
71  ->render();
72 
73  // @todo: Could this be done in a more clever way? Does it work at all?
74  $tableTitle = $languageService->sL($this->data['processedTca']['ctrl']['title']);
75 
76  if ($this->data['command'] === 'new') {
77  $newOrUid = ' <span class="typo3-TCEforms-newToken">' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.new')) . '</span>';
78 
79  // @todo: There is quite some stuff do to for WS overlays ...
80  $workspacedPageRecord = BackendUtility::getRecordWSOL('pages', $this->data['effectivePid'], 'title');
81  $pageTitle = BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
82  if ($table === 'pages') {
83  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewPage'));
84  $pageTitle = sprintf($label, $tableTitle);
85  } else {
86  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewRecord'));
87  if ($this->data['effectivePid'] === 0) {
88  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewRecordRootLevel'));
89  }
90  $pageTitle = sprintf($label, $tableTitle, $pageTitle);
91  }
92  } else {
93  $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid']);
94  $newOrUid = ' <span class="typo3-TCEforms-recUid">[' . htmlspecialchars($row['uid']) . ']</span>';
95 
96  // @todo: getRecordTitlePrep applies an htmlspecialchars here
97  $recordLabel = BackendUtility::getRecordTitlePrep($this->data['recordTitle']);
98  if ($table === 'pages') {
99  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editPage'));
100  $pageTitle = sprintf($label, $tableTitle, $recordLabel);
101  } else {
102  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecord'));
103  $workspacedPageRecord = BackendUtility::getRecordWSOL('pages', $row['pid'], 'uid,title');
104  $pageTitle = BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
105  if (empty($recordLabel)) {
106  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecordNoTitle'));
107  }
108  if ($this->data['effectivePid'] === 0) {
109  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecordRootLevel'));
110  }
111  if (!empty($recordLabel)) {
112  // Use record title and prepend an edit label.
113  $pageTitle = sprintf($label, $tableTitle, $recordLabel, $pageTitle);
114  } else {
115  // Leave out the record title since it is not set.
116  $pageTitle = sprintf($label, $tableTitle, $pageTitle);
117  }
118  }
119  }
120 
121  $view = $this->backendViewFactory->create($this->data['request']);
122 
123  $descriptionColumn = !empty($this->data['processedTca']['ctrl']['descriptionColumn'])
124  ? $this->data['processedTca']['ctrl']['descriptionColumn'] : null;
125  if ($descriptionColumn !== null) {
126  $view->assign('recordDescription', $this->data['databaseRow'][$descriptionColumn]);
127  }
128  $readOnlyRecord = !empty($this->data['processedTca']['ctrl']['readOnly'])
129  ? (bool)$this->data['processedTca']['ctrl']['readOnly'] : null;
130  if ($readOnlyRecord === true) {
131  $view->assign('recordReadonly', true);
132  }
133  $fieldInformationResult = $this->‪renderFieldInformation();
134  $fieldInformationHtml = $fieldInformationResult['html'];
135  $result = $this->‪mergeChildReturnIntoExistingResult($result, $fieldInformationResult, false);
136 
137  $fieldWizardResult = $this->‪renderFieldWizard();
138  $fieldWizardHtml = $fieldWizardResult['html'];
139  $result = $this->‪mergeChildReturnIntoExistingResult($result, $fieldWizardResult, false);
140 
141  $view->assignMultiple([
142  'pageTitle' => $pageTitle,
143  'fieldInformationHtml' => $fieldInformationHtml,
144  'fieldWizardHtml' => $fieldWizardHtml,
145  'childHtml' => $childHtml,
146  'icon' => $icon,
147  'tableName' => $backendUser->shallDisplayDebugInformation() ? $table : '',
148  'tableTitle' => $tableTitle,
149  'newOrUid' => $newOrUid,
150  'isNewRecord' => $this->data['command'] === 'new',
151  ]);
152  $result['html'] = $view->render('Form/OuterWrapContainer');
153  return $result;
154  }
155 
157  {
158  return ‪$GLOBALS['LANG'];
159  }
160 
161 }
‪TYPO3\CMS\Backend\Form\AbstractNode\mergeChildReturnIntoExistingResult
‪array mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
Definition: AbstractNode.php:104
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\render
‪array render()
Definition: OuterWrapContainer.php:43
‪TYPO3\CMS\Backend\Form\Container
Definition: AbstractContainer.php:16
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\getLanguageService
‪getLanguageService()
Definition: OuterWrapContainer.php:156
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:26
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\getBackendUserAuthentication
‪getBackendUserAuthentication()
Definition: AbstractContainer.php:149
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:35
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:29
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:35
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\__construct
‪__construct(private readonly IconFactory $iconFactory,)
Definition: OuterWrapContainer.php:34
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderFieldInformation
‪array renderFieldInformation()
Definition: AbstractContainer.php:52
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer
Definition: OuterWrapContainer.php:33
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderFieldWizard
‪array renderFieldWizard()
Definition: AbstractContainer.php:86