Skip to content

Commit

Permalink
[TASK] Use proper label shortcut method in adminpanel and feedit
Browse files Browse the repository at this point in the history
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 <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
  • Loading branch information
bmack committed Aug 20, 2018
1 parent 42f05e8 commit 963eb27
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
25 changes: 10 additions & 15 deletions typo3/sysext/adminpanel/Classes/Service/EditToolbarService.php
Expand Up @@ -69,7 +69,7 @@ public function createToolbar(): string
'returnUrl' => $returnUrl,
]
);
$title = $this->extGetLL('edit_recordHistory');
$title = $this->getLabel('edit_recordHistory');
$output[] = '<a class="' .
$classes .
'" href="' .
Expand All @@ -91,7 +91,7 @@ public function createToolbar(): string
}
$link = (string)$uriBuilder->buildUriFromRoute($moduleName, $linkParameters);
$icon = $iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render();
$title = $this->extGetLL('edit_newContentElement');
$title = $this->getLabel('edit_newContentElement');
$output[] = '<a class="' .
$classes .
'" href="' .
Expand All @@ -114,7 +114,7 @@ public function createToolbar(): string
]
);
$icon = $iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL)->render();
$title = $this->extGetLL('edit_move_page');
$title = $this->getLabel('edit_move_page');
$output[] = '<a class="' .
$classes .
'" href="' .
Expand All @@ -137,7 +137,7 @@ public function createToolbar(): string
]
);
$icon = $iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render();
$title = $this->extGetLL('edit_newPage');
$title = $this->getLabel('edit_newPage');
$output[] = '<a class="' .
$classes .
'" href="' .
Expand All @@ -160,7 +160,7 @@ public function createToolbar(): string
]
);
$icon = $iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render();
$title = $this->extGetLL('edit_editPageProperties');
$title = $this->getLabel('edit_editPageProperties');
$output[] = '<a class="' .
$classes .
'" href="' .
Expand Down Expand Up @@ -205,7 +205,7 @@ public function createToolbar(): string
);
$icon = $iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL)
->render();
$title = $this->extGetLL('edit_editPageOverlay');
$title = $this->getLabel('edit_editPageOverlay');
$output[] = '<a class="' .
$classes .
'" href="' .
Expand All @@ -228,7 +228,7 @@ public function createToolbar(): string
]
);
$icon = $iconFactory->getIcon('actions-system-list-open', Icon::SIZE_SMALL)->render();
$title = $this->extGetLL('edit_db_list');
$title = $this->getLabel('edit_db_list');
$output[] = '<a class="' .
$classes .
'" href="' .
Expand All @@ -248,17 +248,12 @@ public function createToolbar(): string
/**
* Translate given key
*
* @param string $key Key for a label in the $LOCAL_LANG array of "sysext/lang/Resources/Private/Language/locallang_tsfe.xlf
* @param bool $convertWithHtmlspecialchars If TRUE the language-label will be sent through htmlspecialchars
* @param string $key Key for a label in the $LOCAL_LANG array of "sysext/core/Resources/Private/Language/locallang_tsfe.xlf
* @return string The value for the $key
*/
protected function extGetLL($key, $convertWithHtmlspecialchars = true): ?string
protected function getLabel($key): ?string
{
$labelStr = $this->getLanguageService()->getLL($key);
if ($convertWithHtmlspecialchars) {
$labelStr = htmlspecialchars($labelStr, ENT_QUOTES | ENT_HTML5);
}
return $labelStr;
return htmlspecialchars($this->getLanguageService()->getLL($key), ENT_QUOTES | ENT_HTML5);
}

/**
Expand Down
46 changes: 38 additions & 8 deletions typo3/sysext/feedit/Classes/FrontendEditPanel.php
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -102,14 +103,14 @@ public function editPanel($content, array $conf, $currentRecord = '', array $dat
$panel .= $editToolbarService->createToolbar();
}
if (isset($allow['edit'])) {
$icon = '<span title="' . $this->backendUser->extGetLL('p_editRecord') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render('inline') . '</span>';
$icon = '<span title="' . $this->getLabel('p_editRecord') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render('inline') . '</span>';
$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 = '<span title="' . $this->backendUser->extGetLL('p_moveUp') . '">' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render('inline') . '</span>';
$icon = '<span title="' . $this->getLabel('p_moveUp') . '">' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render('inline') . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'up');
$icon = '<span title="' . $this->backendUser->extGetLL('p_moveDown') . '">' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render('inline') . '</span>';
$icon = '<span title="' . $this->getLabel('p_moveDown') . '">' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render('inline') . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'down');
}
// Hiding in workspaces because implementation is incomplete
Expand All @@ -120,17 +121,17 @@ public function editPanel($content, array $conf, $currentRecord = '', array $dat
$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 = '<span title="' . $this->backendUser->extGetLL('p_newSubpage') . '">'
$icon = '<span title="' . $this->getLabel('p_newSubpage') . '">'
. $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)->render('inline')
. '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '');
} else {
$icon = '<span title="' . $this->backendUser->extGetLL('p_newRecordAfter') . '">'
$icon = '<span title="' . $this->getLabel('p_newRecordAfter') . '">'
. $this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL)->render('inline')
. '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '', $newUID);
Expand All @@ -139,10 +140,10 @@ public function editPanel($content, array $conf, $currentRecord = '', array $dat
// 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 = '<span title="' . $this->backendUser->extGetLL('p_delete') . '">'
$icon = '<span title="' . $this->getLabel('p_delete') . '">'
. $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render('inline')
. '</span>';
$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.']);
Expand Down Expand Up @@ -329,4 +330,33 @@ protected function isDisabled($table, array $row)

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'];
}
}

0 comments on commit 963eb27

Please sign in to comment.