TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
OuterWrapContainer.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Form\Container;
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'], 1, '', '+copy,info,edit,view');
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  $title = $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.recordInformation');
125  $content = $this->data['databaseRow'][$descriptionColumn];
126  $view->assignMultiple([
127  'infoBoxMessageTitle' => $title,
128  'infoBoxMessage' => $content
129  ]);
130  }
131 
132  $view->assignMultiple([
133  'pageTitle' => $pageTitle,
134  'childHtml' => $childHtml,
135  'icon' => $icon,
136  'tableTitle' => $tableTitle,
137  'newOrUid' => $newOrUid
138  ]);
139  $result['html'] = $view->render();
140  return $result;
141  }
142 
146  protected function getLanguageService()
147  {
148  return $GLOBALS['LANG'];
149  }
150 
154  protected function getBackendUserAuthentication()
155  {
156  return $GLOBALS['BE_USER'];
157  }
158 }
static getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)
static getRecordWSOL($table, $uid, $fields= '*', $where= '', $useDeleteClause=true, $unsetMovePointers=false)
static getRecordTitle($table, $row, $prep=false, $forceResult=true)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)
static wrapClickMenuOnIcon($content, $table, $uid=0, $listFrame=true, $addParams= '', $enDisItems= '', $returnTagParameters=false)
static getFileAbsFileName($filename, $_=null, $_2=null)