‪TYPO3CMS  9.5
OuterWrapContainer.php
Go to the documentation of this file.
1 <?php
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 
25 
35 {
41  public function ‪render()
42  {
43  $languageService = $this->‪getLanguageService();
44  $backendUser = $this->‪getBackendUserAuthentication();
45 
46  $table = $this->data['tableName'];
47  $row = $this->data['databaseRow'];
48 
49  $options = ‪$this->data;
50  if (empty($this->data['fieldListToRender'])) {
51  $options['renderType'] = 'fullRecordContainer';
52  } else {
53  $options['renderType'] = 'listOfFieldsContainer';
54  }
55  $result = $this->nodeFactory->create($options)->render();
56 
57  $childHtml = $result['html'];
58 
59  $recordPath = '';
60  // @todo: what is this >= 0 check for? wsol cases?!
61  if ($this->data['effectivePid'] >= 0) {
62  $permissionsClause = $backendUser->getPagePermsClause(‪Permission::PAGE_SHOW);
63  $recordPath = ‪BackendUtility::getRecordPath($this->data['effectivePid'], $permissionsClause, 15);
64  }
65 
66  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
67  $icon = '<span title="' . htmlspecialchars($recordPath) . '">' . $iconFactory->getIconForRecord($table, $row, ‪Icon::SIZE_SMALL)->render() . '</span>';
68 
69  // @todo: Could this be done in a more clever way? Does it work at all?
70  $tableTitle = $languageService->sL($this->data['processedTca']['ctrl']['title']);
71 
72  if ($this->data['command'] === 'new') {
73  $newOrUid = ' <span class="typo3-TCEforms-newToken">' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.new')) . '</span>';
74 
75  // @todo: There is quite some stuff do to for WS overlays ...
76  $workspacedPageRecord = ‪BackendUtility::getRecordWSOL('pages', $this->data['effectivePid'], 'title');
77  $pageTitle = ‪BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
78  if ($table === 'pages') {
79  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewPage'));
80  $pageTitle = sprintf($label, $tableTitle);
81  } else {
82  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewRecord'));
83  if ($this->data['effectivePid'] === 0) {
84  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.createNewRecordRootLevel'));
85  }
86  $pageTitle = sprintf($label, $tableTitle, $pageTitle);
87  }
88  } else {
89  $icon = ‪BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid']);
90  $newOrUid = ' <span class="typo3-TCEforms-recUid">[' . htmlspecialchars($row['uid']) . ']</span>';
91 
92  // @todo: getRecordTitlePrep applies an htmlspecialchars here
93  $recordLabel = ‪BackendUtility::getRecordTitlePrep($this->data['recordTitle']);
94  if ($table === 'pages') {
95  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editPage'));
96  $pageTitle = sprintf($label, $tableTitle, $recordLabel);
97  } else {
98  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecord'));
99  $workspacedPageRecord = ‪BackendUtility::getRecordWSOL('pages', $row['pid'], 'uid,title');
100  $pageTitle = ‪BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
101  if (empty($recordLabel)) {
102  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecordNoTitle'));
103  }
104  if ($this->data['effectivePid'] === 0) {
105  $label = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecordRootLevel'));
106  }
107  if (!empty($recordLabel)) {
108  // Use record title and prepend an edit label.
109  $pageTitle = sprintf($label, $tableTitle, $recordLabel, $pageTitle);
110  } else {
111  // Leave out the record title since it is not set.
112  $pageTitle = sprintf($label, $tableTitle, $pageTitle);
113  }
114  }
115  }
116 
117  $view = GeneralUtility::makeInstance(StandaloneView::class);
118  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
119  'EXT:backend/Resources/Private/Templates/OuterWrapContainer.html'
120  ));
121 
122  $descriptionColumn = !empty($this->data['processedTca']['ctrl']['descriptionColumn'])
123  ? $this->data['processedTca']['ctrl']['descriptionColumn'] : null;
124  if ($descriptionColumn !== null) {
125  $view->assign('recordDescription', $this->data['databaseRow'][$descriptionColumn]);
126  }
127  $readOnlyRecord = !empty($this->data['processedTca']['ctrl']['readOnly'])
128  ? (bool)$this->data['processedTca']['ctrl']['readOnly'] : null;
129  if ($readOnlyRecord === true) {
130  $view->assign('recordReadonly', true);
131  }
132  $fieldInformationResult = $this->‪renderFieldInformation();
133  $fieldInformationHtml = $fieldInformationResult['html'];
134  $result = $this->‪mergeChildReturnIntoExistingResult($result, $fieldInformationResult, false);
135 
136  $fieldWizardResult = $this->‪renderFieldWizard();
137  $fieldWizardHtml = $fieldWizardResult['html'];
138  $result = $this->‪mergeChildReturnIntoExistingResult($result, $fieldWizardResult, false);
139 
140  $view->assignMultiple([
141  'pageTitle' => $pageTitle,
142  'fieldInformationHtml' => $fieldInformationHtml,
143  'fieldWizardHtml' => $fieldWizardHtml,
144  'childHtml' => $childHtml,
145  'icon' => $icon,
146  'tableTitle' => $tableTitle,
147  'newOrUid' => $newOrUid,
148  'isNewRecord' => $this->data['command'] === 'new'
149  ]);
150  $result['html'] = $view->render();
151  return $result;
152  }
153 
157  protected function ‪getLanguageService()
158  {
159  return ‪$GLOBALS['LANG'];
160  }
161 
165  protected function ‪getBackendUserAuthentication()
166  {
167  return ‪$GLOBALS['BE_USER'];
168  }
169 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Backend\Form\AbstractNode\mergeChildReturnIntoExistingResult
‪array mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
Definition: AbstractNode.php:115
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\render
‪array render()
Definition: OuterWrapContainer.php:41
‪TYPO3\CMS\Backend\Form\Container
Definition: AbstractContainer.php:2
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:23
‪TYPO3\CMS\Backend\Utility\BackendUtility\wrapClickMenuOnIcon
‪static string wrapClickMenuOnIcon( $content, $table, $uid=0, $context='', $_addParams='', $_enDisItems='', $returnTagParameters=false)
Definition: BackendUtility.php:2759
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitlePrep
‪static string getRecordTitlePrep($title, $titleLength=0)
Definition: BackendUtility.php:1883
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:40
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:27
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitle
‪static string getRecordTitle($table, $row, $prep=false, $forceResult=true)
Definition: BackendUtility.php:1811
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:32
‪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\Form\Container\AbstractContainer\renderFieldInformation
‪array renderFieldInformation()
Definition: AbstractContainer.php:33
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer
Definition: OuterWrapContainer.php:35
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪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\Form\Container\AbstractContainer\renderFieldWizard
‪array renderFieldWizard()
Definition: AbstractContainer.php:67
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\getLanguageService
‪LanguageService getLanguageService()
Definition: OuterWrapContainer.php:157
‪TYPO3\CMS\Backend\Form\Container\OuterWrapContainer\getBackendUserAuthentication
‪BackendUserAuthentication getBackendUserAuthentication()
Definition: OuterWrapContainer.php:165