69 $this->cObj = GeneralUtility::makeInstance(\
TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
70 $this->cObj->start([]);
71 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
89 public function editPanel($content, array $conf, $currentRecord =
'', array $dataArr = [], $table =
'', array $allow = [], $newUID = 0, array $hiddenFields = [])
91 $hiddenFieldString =
'';
94 $this->frontendController->set_no_cache(
'Frontend edit panel is shown',
true);
96 $formName =
'TSFE_EDIT_FORM_' . substr($this->frontendController->uniqueHash(), 0, 4);
97 $formTag =
'<form name="' . $formName .
'" id ="' . $formName .
'" action="' . htmlspecialchars(GeneralUtility::getIndpEnv(
'REQUEST_URI')) .
'" method="post" enctype="multipart/form-data" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
98 $sortField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'sortby'];
99 $labelField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'label'];
100 $hideField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'];
103 if (isset($allow[
'toolbar'])) {
104 $editToolbarService = GeneralUtility::makeInstance(EditToolbarService::class);
105 $panel .= $editToolbarService->createToolbar();
107 if (isset($allow[
'edit'])) {
108 $icon =
'<span title="' . $this->
getLabel(
'p_editRecord') .
'">' . $this->iconFactory->getIcon(
'actions-document-open',
Icon::SIZE_SMALL)->render(
'inline') .
'</span>';
109 $panel .= $this->
editPanelLinkWrap($icon, $formName,
'edit', $dataArr[
'_LOCALIZED_UID'] ? $table .
':' . $dataArr[
'_LOCALIZED_UID'] : $currentRecord);
112 if (isset($allow[
'move']) && $sortField && $this->backendUser->workspace === 0) {
113 $icon =
'<span title="' . $this->
getLabel(
'p_moveUp') .
'">' . $this->iconFactory->getIcon(
'actions-move-up',
Icon::SIZE_SMALL)->render(
'inline') .
'</span>';
115 $icon =
'<span title="' . $this->
getLabel(
'p_moveDown') .
'">' . $this->iconFactory->getIcon(
'actions-move-down',
Icon::SIZE_SMALL)->render(
'inline') .
'</span>';
120 if (isset($allow[
'hide']) && $hideField && $this->backendUser->workspace === 0 && !$dataArr[
'_LOCALIZED_UID']) {
121 if ($dataArr[$hideField]) {
122 $icon = $this->iconFactory->getIcon(
'actions-edit-unhide',
Icon::SIZE_SMALL)->render(
'inline');
125 $icon = $this->iconFactory->getIcon(
'actions-edit-hide',
Icon::SIZE_SMALL)->render(
'inline');
129 if (isset($allow[
'new'])) {
130 if ($table ===
'pages') {
131 $icon =
'<span title="' . $this->
getLabel(
'p_newSubpage') .
'">'
132 . $this->iconFactory->getIcon(
'actions-page-new',
Icon::SIZE_SMALL)->render(
'inline')
136 $icon =
'<span title="' . $this->
getLabel(
'p_newRecordAfter') .
'">'
137 . $this->iconFactory->getIcon(
'actions-document-new',
Icon::SIZE_SMALL)->render(
'inline')
139 $panel .= $this->
editPanelLinkWrap($icon, $formName,
'new', $currentRecord,
'', $newUID);
144 if (isset($allow[
'delete']) && $this->backendUser->workspace === 0 && !$dataArr[
'_LOCALIZED_UID']) {
145 $icon =
'<span title="' . $this->
getLabel(
'p_delete') .
'">'
146 . $this->iconFactory->getIcon(
'actions-edit-delete',
Icon::SIZE_SMALL)->render(
'inline')
151 $labelTxt = $this->cObj->stdWrap($conf[
'label'], $conf[
'label.']);
152 foreach ((array)$hiddenFields as $name => $value) {
153 $hiddenFieldString .=
'<input type="hidden" name="TSFE_EDIT[' . htmlspecialchars($name) .
']" value="' . htmlspecialchars($value) .
'"/>' . LF;
156 $panel =
'<!-- BE_USER Edit Panel: -->
157 ' . $formTag . $hiddenFieldString .
'
158 <input type="hidden" name="TSFE_EDIT[cmd]" value="" />
159 <input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord .
'" />
160 <div class="typo3-editPanel">'
161 .
'<div class="typo3-editPanel-btn-group">'
164 ($labelTxt ?
'<div class="typo3-editPanel-label">' . sprintf($labelTxt, htmlspecialchars(GeneralUtility::fixed_lgd_cs($dataArr[$labelField], 50))) .
'</div>' :
'') .
'
169 if ($conf[
'innerWrap']) {
170 $panel = $this->cObj->wrap($panel, $conf[
'innerWrap']);
172 if ($conf[
'innerWrap.']) {
173 $panel = $this->cObj->stdWrap($panel, $conf[
'innerWrap.']);
177 if ($conf[
'outerWrap']) {
178 $panel = $this->cObj->wrap($panel, $conf[
'outerWrap']);
180 if ($conf[
'outerWrap.']) {
181 $panel = $this->cObj->stdWrap($panel, $conf[
'outerWrap.']);
183 if ($conf[
'printBeforeContent']) {
184 $finalOut = $panel . $content;
186 $finalOut = $content . $panel;
189 $hidden = $this->
isDisabled($table, $dataArr) ?
' typo3-feedit-element-hidden' :
'';
190 $outerWrapConfig = $conf[
'stdWrap.'] ?? [
'wrap' =>
'<div class="typo3-feedit-element' . $hidden .
'">|</div>'];
191 $finalOut = $this->cObj->stdWrap($finalOut, $outerWrapConfig);
211 public function editIcons($content, $params, array $conf = [], $currentRecord =
'', array $dataArr = [], $addUrlParamStr =
'', $table, $editUid, $fieldList)
214 $this->frontendController->set_no_cache(
'Display frontend edit icons',
true);
215 $iconTitle = $this->cObj->stdWrap($conf[
'iconTitle'], $conf[
'iconTitle.']);
216 $iconImg =
'<span title="' . htmlspecialchars($iconTitle, ENT_COMPAT,
'UTF-8',
false) .
'" style="' . ($conf[
'styleAttribute'] ? htmlspecialchars($conf[
'styleAttribute']) :
'') .
'">'
217 . $this->iconFactory->getIcon(
'actions-document-open', Icon::SIZE_SMALL)->render(
'inline')
219 $noView = GeneralUtility::_GP(
'ADMCMD_view') ? 1 : 0;
221 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
222 $url = (string)$uriBuilder->buildUriFromRoute(
225 'edit[' . $table .
'][' . $editUid .
']' =>
'edit',
226 'columnsOnly' => $fieldList,
232 if ($conf[
'beforeLastTag'] < 0) {
233 $content = $icon . $content;
234 } elseif ($conf[
'beforeLastTag'] > 0) {
235 $cBuf = rtrim($content);
237 while ($secureCount && substr($cBuf, -1) ===
'>' && substr($cBuf, -4) !==
'</a>') {
238 $cBuf = rtrim(preg_replace(
'/<[^<]*>$/',
'', $cBuf));
241 $content = strlen($cBuf) && $secureCount ? substr($content, 0, strlen($cBuf)) . $icon . substr($content, strlen($cBuf)) : ($content = $icon . $content);
260 protected function editPanelLinkWrap($string, $formName, $cmd, $currentRecord =
'', $confirm =
'', $nPid =
'')
262 $noView = GeneralUtility::_GP(
'ADMCMD_view') ? 1 : 0;
264 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
265 if ($cmd ===
'edit') {
266 $rParts = explode(
':', $currentRecord);
267 $out = $this->
editPanelLinkWrap_doWrap($string, (
string)$uriBuilder->buildUriFromRoute(
'record_edit', [
'edit[' . $rParts[0] .
'][' . $rParts[1] .
']' =>
'edit',
'noView' => $noView,
'feEdit' => 1]), $currentRecord);
268 } elseif ($cmd ===
'new') {
269 $rParts = explode(
':', $currentRecord);
270 if ($rParts[0] ===
'pages') {
271 $out = $this->
editPanelLinkWrap_doWrap($string, (
string)$uriBuilder->buildUriFromRoute(
'db_new', [
'id' => $rParts[1],
'pagesOnly' => 1]), $currentRecord);
276 $out = $this->
editPanelLinkWrap_doWrap($string, (
string)$uriBuilder->buildUriFromRoute(
'record_edit', [
'edit[' . $rParts[0] .
'][' . $nPid .
']' =>
'new',
'noView' => $noView]), $currentRecord);
281 $cf1 =
'if (confirm(' . GeneralUtility::quoteJSvalue($confirm) .
')) {';
286 $out =
'<a href="#" class="typo3-editPanel-btn typo3-editPanel-btn-default" onclick="' . htmlspecialchars($cf1 .
'document.' . $formName .
'[\'TSFE_EDIT[cmd]\'].value=\'' . $cmd .
'\'; document.
' . $formName . '.submit();
' . $cf2 . ' return false;
') . '">' . $string . '</a>';
300 protected function editPanelLinkWrap_doWrap($string, $url, $additionalClasses = '')
302 $width = MathUtility::forceIntegerInRange($this->backendUser->getTSConfig()['options.']['feedit.']['popupWidth'] ?? 690, 690, 5000, 690);
303 $height = MathUtility::forceIntegerInRange($this->backendUser->getTSConfig()['options.']['feedit.']['popupHeight'] ?? 500, 500, 5000, 500);
304 $onclick = 'vHWin=window.open(' . GeneralUtility::quoteJSvalue($url . '&returnUrl=' . rawurlencode(PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Public/Html/Close.html')))) . ',\'FEquickEditWindow\',\'width=' . $width . ',height=' . $height . ',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;';
305 return '<a href="#
" class="typo3-
editPanel-btn typo3-
editPanel-btn-
default frontEndEditIconLinks
' . htmlspecialchars($additionalClasses) . '" onclick="' . htmlspecialchars($onclick) . '">' . $string . '</a>';
315 protected function isDisabled($table, array $row)
319 $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] &&
320 $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']] ||
321 $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group'] &&
322 $this->frontendController->simUserGroup &&
323 $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['fe_group']] == $this->frontendController->simUserGroup ||
324 $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime'] &&
325 $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME'] ||
326 $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime'] &&
327 $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] &&
328 $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME']
346 protected function getLabel(string $key): string
348 if (!is_array($GLOBALS['LOCAL_LANG'])) {
349 $this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_tsfe.xlf');
350 if (!is_array($GLOBALS['LOCAL_LANG'])) {
351 $GLOBALS['LOCAL_LANG'] = [];
354 return htmlspecialchars($this->getLanguageService()->getLL($key));
360 protected function getLanguageService(): LanguageService
362 return $GLOBALS['LANG'];