From 7658f63b284e1ed66b8acdec81f47cb7e1aa3ebe Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Mon, 20 Aug 2018 09:02:59 +0200 Subject: [PATCH] [TASK] Use proper label shortcut method in adminpanel and feedit The legacy naming for the shorthand method "extGetLL" was moved to "getLabel" for both the edit toolbar and the EXT:feedit panel. Resolves: #85905 Releases: master Change-Id: I4fdad2127d40cc2850237311f3bc3f56c85ca394 Reviewed-on: https://review.typo3.org/57964 Tested-by: TYPO3com Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn Reviewed-by: Anja Leichsenring Tested-by: Anja Leichsenring Reviewed-by: Benni Mack Tested-by: Benni Mack --- Classes/FrontendEditPanel.php | 46 +++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/Classes/FrontendEditPanel.php b/Classes/FrontendEditPanel.php index 1aea7fa..921a72d 100644 --- a/Classes/FrontendEditPanel.php +++ b/Classes/FrontendEditPanel.php @@ -17,6 +17,7 @@ use TYPO3\CMS\Adminpanel\Service\EditToolbarService; use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -102,14 +103,14 @@ class FrontendEditPanel $panel .= $editToolbarService->createToolbar(); } if (isset($allow['edit'])) { - $icon = '' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render('inline') . ''; + $icon = '' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render('inline') . ''; $panel .= $this->editPanelLinkWrap($icon, $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord); } // Hiding in workspaces because implementation is incomplete if (isset($allow['move']) && $sortField && $this->backendUser->workspace === 0) { - $icon = '' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render('inline') . ''; + $icon = '' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render('inline') . ''; $panel .= $this->editPanelLinkWrap($icon, $formName, 'up'); - $icon = '' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render('inline') . ''; + $icon = '' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render('inline') . ''; $panel .= $this->editPanelLinkWrap($icon, $formName, 'down'); } // Hiding in workspaces because implementation is incomplete @@ -120,17 +121,17 @@ class FrontendEditPanel $panel .= $this->editPanelLinkWrap($icon, $formName, 'unhide'); } else { $icon = $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render('inline'); - $panel .= $this->editPanelLinkWrap($icon, $formName, 'hide', '', $this->backendUser->extGetLL('p_hideConfirm')); + $panel .= $this->editPanelLinkWrap($icon, $formName, 'hide', '', $this->getLabel('p_hideConfirm')); } } if (isset($allow['new'])) { if ($table === 'pages') { - $icon = '' + $icon = '' . $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render('inline') . ''; $panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, ''); } else { - $icon = '' + $icon = '' . $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render('inline') . ''; $panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '', $newUID); @@ -139,10 +140,10 @@ class FrontendEditPanel // Hiding in workspaces because implementation is incomplete // Hiding for localizations because it is unknown what should be the function in that case if (isset($allow['delete']) && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) { - $icon = '' + $icon = '' . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render('inline') . ''; - $panel .= $this->editPanelLinkWrap($icon, $formName, 'delete', '', $this->backendUser->extGetLL('p_deleteConfirm')); + $panel .= $this->editPanelLinkWrap($icon, $formName, 'delete', '', $this->getLabel('p_deleteConfirm')); } // Final $labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']); @@ -329,4 +330,33 @@ class FrontendEditPanel return $status; } + + /** + * Returns the label for key. If a translation for the language set in $this->uc['lang'] + * is found that is returned, otherwise the default value. + * If the global variable $LOCAL_LANG is NOT an array (yet) then this function loads + * the global $LOCAL_LANG array with the content of "EXT:core/Resources/Private/Language/locallang_tsfe.xlf" + * such that the values therein can be used for labels in the Admin Panel + * + * @param string $key Key for a label in the $GLOBALS['LOCAL_LANG'] array of "EXT:core/Resources/Private/Language/locallang_tsfe.xlf + * @return string The value for the $key + */ + protected function getLabel(string $key): string + { + if (!is_array($GLOBALS['LOCAL_LANG'])) { + $this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_tsfe.xlf'); + if (!is_array($GLOBALS['LOCAL_LANG'])) { + $GLOBALS['LOCAL_LANG'] = []; + } + } + return htmlspecialchars($this->getLanguageService()->getLL($key)); + } + + /** + * @return LanguageService + */ + protected function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } }