TYPO3 CMS  TYPO3_8-7
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 
24 
34 {
40  public function render()
41  {
42  $languageService = $this->getLanguageService();
43  $backendUser = $this->getBackendUserAuthentication();
44 
45  $table = $this->data['tableName'];
46  $row = $this->data['databaseRow'];
47 
48  $options = $this->data;
49  if (empty($this->data['fieldListToRender'])) {
50  $options['renderType'] = 'fullRecordContainer';
51  } else {
52  $options['renderType'] = 'listOfFieldsContainer';
53  }
54  $result = $this->nodeFactory->create($options)->render();
55 
56  $childHtml = $result['html'];
57 
58  $recordPath = '';
59  // @todo: what is this >= 0 check for? wsol cases?!
60  if ($this->data['effectivePid'] >= 0) {
61  $permissionsClause = $backendUser->getPagePermsClause(1);
62  $recordPath = BackendUtility::getRecordPath($this->data['effectivePid'], $permissionsClause, 15);
63  }
64 
65  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
66  $icon = '<span title="' . htmlspecialchars($recordPath) . '">' . $iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
67 
68  // @todo: Could this be done in a more clever way? Does it work at all?
69  $tableTitle = $languageService->sL($this->data['processedTca']['ctrl']['title']);
70 
71  if ($this->data['command'] === 'new') {
72  $newOrUid = ' <span class="typo3-TCEforms-newToken">' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.new')) . '</span>';
73 
74  // @todo: There is quite some stuff do to for WS overlays ...
75  $workspacedPageRecord = BackendUtility::getRecordWSOL('pages', $this->data['effectivePid'], 'title');
76  $pageTitle = BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
77  if ($table === 'pages') {
78  $label = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.createNewPage'));
79  $pageTitle = sprintf($label, $tableTitle);
80  } else {
81  $label = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.createNewRecord'));
82  if ($this->data['effectivePid'] === 0) {
83  $label = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.createNewRecordRootLevel'));
84  }
85  $pageTitle = sprintf($label, $tableTitle, $pageTitle);
86  }
87  } else {
88  $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid']);
89  $newOrUid = ' <span class="typo3-TCEforms-recUid">[' . htmlspecialchars($row['uid']) . ']</span>';
90 
91  // @todo: getRecordTitlePrep applies an htmlspecialchars here
92  $recordLabel = BackendUtility::getRecordTitlePrep($this->data['recordTitle']);
93  if ($table === 'pages') {
94  $label = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.editPage'));
95  $pageTitle = sprintf($label, $tableTitle, $recordLabel);
96  } else {
97  $label = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.editRecord'));
98  $workspacedPageRecord = BackendUtility::getRecordWSOL('pages', $row['pid'], 'uid,title');
99  $pageTitle = BackendUtility::getRecordTitle('pages', $workspacedPageRecord, true, false);
100  if (empty($recordLabel)) {
101  $label = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.editRecordNoTitle'));
102  }
103  if ($this->data['effectivePid'] === 0) {
104  $label = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.editRecordRootLevel'));
105  }
106  if (!empty($recordLabel)) {
107  // Use record title and prepend an edit label.
108  $pageTitle = sprintf($label, $tableTitle, $recordLabel, $pageTitle);
109  } else {
110  // Leave out the record title since it is not set.
111  $pageTitle = sprintf($label, $tableTitle, $pageTitle);
112  }
113  }
114  }
115 
116  $view = GeneralUtility::makeInstance(StandaloneView::class);
117  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
118  'EXT:backend/Resources/Private/Templates/OuterWrapContainer.html'
119  ));
120 
121  $descriptionColumn = !empty($this->data['processedTca']['ctrl']['descriptionColumn'])
122  ? $this->data['processedTca']['ctrl']['descriptionColumn'] : null;
123  if ($descriptionColumn !== null) {
124  $view->assign('recordDescription', $this->data['databaseRow'][$descriptionColumn]);
125  }
126  $readOnlyRecord = !empty($this->data['processedTca']['ctrl']['readOnly'])
127  ? (bool)$this->data['processedTca']['ctrl']['readOnly'] : null;
128  if ($readOnlyRecord === true) {
129  $view->assign('recordReadonly', true);
130  }
131  $fieldInformationResult = $this->renderFieldInformation();
132  $fieldInformationHtml = $fieldInformationResult['html'];
133  $result = $this->mergeChildReturnIntoExistingResult($result, $fieldInformationResult, false);
134 
135  $fieldWizardResult = $this->renderFieldWizard();
136  $fieldWizardHtml = $fieldWizardResult['html'];
137  $result = $this->mergeChildReturnIntoExistingResult($result, $fieldWizardResult, false);
138 
139  $view->assignMultiple([
140  'pageTitle' => $pageTitle,
141  'fieldInformationHtml' => $fieldInformationHtml,
142  'fieldWizardHtml' => $fieldWizardHtml,
143  'childHtml' => $childHtml,
144  'icon' => $icon,
145  'tableTitle' => $tableTitle,
146  'newOrUid' => $newOrUid
147  ]);
148  $result['html'] = $view->render();
149  return $result;
150  }
151 
155  protected function getLanguageService()
156  {
157  return $GLOBALS['LANG'];
158  }
159 
163  protected function getBackendUserAuthentication()
164  {
165  return $GLOBALS['BE_USER'];
166  }
167 }
static getRecordWSOL( $table, $uid, $fields=' *', $where='', $useDeleteClause=true, $unsetMovePointers=false)
static wrapClickMenuOnIcon( $content, $table, $uid=0, $context='', $_addParams='', $_enDisItems='', $returnTagParameters=false)
static getFileAbsFileName($filename, $_=null, $_2=null)
static makeInstance($className,... $constructorArguments)
static getRecordTitle($table, $row, $prep=false, $forceResult=true)
static getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)
static getRecordTitlePrep($title, $titleLength=0)
mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']