‪TYPO3CMS  10.4
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 
26 
36 {
42  public function ‪render()
43  {
44  $languageService = $this->‪getLanguageService();
45  $backendUser = $this->‪getBackendUserAuthentication();
46 
47  $table = $this->data['tableName'];
48  $row = $this->data['databaseRow'];
49 
50  $options = ‪$this->data;
51  if (empty($this->data['fieldListToRender'])) {
52  $options['renderType'] = 'fullRecordContainer';
53  } else {
54  $options['renderType'] = 'listOfFieldsContainer';
55  }
56  $result = $this->nodeFactory->create($options)->render();
57 
58  $childHtml = $result['html'];
59 
60  $recordPath = '';
61  // @todo: what is this >= 0 check for? wsol cases?!
62  if ($this->data['effectivePid'] >= 0) {
63  $permissionsClause = $backendUser->getPagePermsClause(‪Permission::PAGE_SHOW);
64  $recordPath = ‪BackendUtility::getRecordPath($this->data['effectivePid'], $permissionsClause, 15);
65  }
66 
67  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
68  $icon = '<span title="' . htmlspecialchars($recordPath) . '">' . $iconFactory->getIconForRecord($table, $row, ‪Icon::SIZE_SMALL)->render() . '</span>';
69 
70  // @todo: Could this be done in a more clever way? Does it work at all?
71  $tableTitle = $languageService->sL($this->data['processedTca']['ctrl']['title']);
72 
73  if ($this->data['command'] === 'new') {
74  $newOrUid = ' <span class="typo3-TCEforms-newToken">' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.new')) . '</span>';
75 
76  // @todo: There is quite some stuff do to for WS overlays ...
77  $workspacedPageRecord = ‪BackendUtility::getRecordWSOL('pages', $this->data['effectivePid'], 'title');
78  $pageTitle = ‪BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
79  if ($table === 'pages') {
80  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewPage'));
81  $pageTitle = sprintf($label, $tableTitle);
82  } else {
83  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewRecord'));
84  if ($this->data['effectivePid'] === 0) {
85  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewRecordRootLevel'));
86  }
87  $pageTitle = sprintf($label, $tableTitle, $pageTitle);
88  }
89  } else {
90  $icon = ‪BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid']);
91  $newOrUid = ' <span class="typo3-TCEforms-recUid">[' . htmlspecialchars($row['uid']) . ']</span>';
92 
93  // @todo: getRecordTitlePrep applies an htmlspecialchars here
94  $recordLabel = ‪BackendUtility::getRecordTitlePrep($this->data['recordTitle']);
95  if ($table === 'pages') {
96  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editPage'));
97  $pageTitle = sprintf($label, $tableTitle, $recordLabel);
98  } else {
99  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecord'));
100  $workspacedPageRecord = ‪BackendUtility::getRecordWSOL('pages', $row['pid'], 'uid,title');
101  $pageTitle = ‪BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
102  if (empty($recordLabel)) {
103  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecordNoTitle'));
104  }
105  if ($this->data['effectivePid'] === 0) {
106  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecordRootLevel'));
107  }
108  if (!empty($recordLabel)) {
109  // Use record title and prepend an edit label.
110  $pageTitle = sprintf($label, $tableTitle, $recordLabel, $pageTitle);
111  } else {
112  // Leave out the record title since it is not set.
113  $pageTitle = sprintf($label, $tableTitle, $pageTitle);
114  }
115  }
116  }
117 
118  $view = GeneralUtility::makeInstance(StandaloneView::class);
119  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
120  'EXT:backend/Resources/Private/Templates/OuterWrapContainer.html'
121  ));
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  'tableTitle' => $tableTitle,
148  'newOrUid' => $newOrUid,
149  'isNewRecord' => $this->data['command'] === 'new'
150  ]);
151  $result['html'] = $view->render();
152  return $result;
153  }
154 
158  protected function ‪getLanguageService()
159  {
160  return ‪$GLOBALS['LANG'];
161  }
162 
166  protected function ‪getBackendUserAuthentication()
167  {
168  return ‪$GLOBALS['BE_USER'];
169  }
170 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Backend\Form\AbstractNode\mergeChildReturnIntoExistingResult
‪array mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
Definition: AbstractNode.php:116
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\render
‪array render()
Definition: OuterWrapContainer.php:42
‪TYPO3\CMS\Backend\Form\Container
Definition: AbstractContainer.php:16
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:24
‪TYPO3\CMS\Backend\Utility\BackendUtility\wrapClickMenuOnIcon
‪static string wrapClickMenuOnIcon( $content, $table, $uid=0, $context='', $_addParams='', $_enDisItems='', $returnTagParameters=false)
Definition: BackendUtility.php:2510
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitlePrep
‪static string getRecordTitlePrep($title, $titleLength=0)
Definition: BackendUtility.php:1614
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:42
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:28
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitle
‪static string getRecordTitle($table, $row, $prep=false, $forceResult=true)
Definition: BackendUtility.php:1541
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:33
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordWSOL
‪static array getRecordWSOL( $table, $uid, $fields=' *', $where='', $useDeleteClause=true, $unsetMovePointers=false)
Definition: BackendUtility.php:139
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderFieldInformation
‪array renderFieldInformation()
Definition: AbstractContainer.php:34
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer
Definition: OuterWrapContainer.php:36
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordPath
‪static mixed getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)
Definition: BackendUtility.php:546
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderFieldWizard
‪array renderFieldWizard()
Definition: AbstractContainer.php:68
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\getLanguageService
‪LanguageService getLanguageService()
Definition: OuterWrapContainer.php:158
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\getBackendUserAuthentication
‪BackendUserAuthentication getBackendUserAuthentication()
Definition: OuterWrapContainer.php:166