Commit 9ca09310 authored by Michael Oehlhof's avatar Michael Oehlhof Committed by Wouter Wolters
Browse files

[TASK] Clipboard: Use new modal confirmation dialog for "Delete Elements"

Clipboard: Use new modal confirmation dialog for the menu item
"Delete Elements"

Resolves: #72350
Releases: master, 7.6
Change-Id: Icb4a9c428802af4bc09152010b264c1c02b2eb74
Reviewed-on: https://review.typo3.org/45997

Reviewed-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
parent 6cb7299f
......@@ -249,12 +249,13 @@ class Clipboard
*/
public function printClipboard()
{
$languageService = $this->getLanguageService();
$out = array();
$elementCount = count($this->elFromTable($this->fileMode ? '_FILE' : ''));
// Copymode Selector menu
$copymodeUrl = GeneralUtility::linkThisScript();
$moveLabel = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_misc.xlf:moveElements'));
$copyLabel = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_misc.xlf:copyElements'));
$moveLabel = htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_misc.xlf:moveElements'));
$copyLabel = htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_misc.xlf:copyElements'));
$copymodeSelector = '
<div class="btn-group">
......@@ -279,7 +280,7 @@ class Clipboard
// Import / Export link:
if (ExtensionManagementUtility::isLoaded('impexp')) {
$url = BackendUtility::getModuleUrl('xMOD_tximpexp', $this->exportClipElementParameters());
$optionArray[] = '<li><a href="#" onclick="' . htmlspecialchars(('window.location.href=' . GeneralUtility::quoteJSvalue($url) . ';')) . '">' . $this->clLabel('export', 'rm') . '</a></li>';
$optionArray[] = '<li><a href="' . htmlspecialchars($url) . '">' . $this->clLabel('export', 'rm') . '</a></li>';
}
// Edit:
if (!$this->fileMode) {
......@@ -287,20 +288,34 @@ class Clipboard
}
// Delete referenced elements:
$confirmationCheck = false;
if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) {
$js = '
if (confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:mess.deleteClip'), $elementCount)) . ')){
window.location.href=' . GeneralUtility::quoteJSvalue($this->deleteUrl(0, ($this->fileMode ? 1 : 0)) . '&redirect=') . '+top.rawurlencode(window.location.href);
}
';
} else {
$js = ' window.location.href=' . GeneralUtility::quoteJSvalue($this->deleteUrl(0, ($this->fileMode ? 1 : 0)) . '&redirect=') . '+top.rawurlencode(window.location.href); ';
$confirmationCheck = true;
}
$optionArray[] = '<li><a href="#" onclick="' . htmlspecialchars($js) . '">' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.clipboard.delete_elements', true) . '</a></li>';
$confirmationMessage = sprintf(
$languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.deleteClip'),
$elementCount
);
$title = $languageService
->sL('LLL:EXT:lang/locallang_core.xlf:labels.clipboard.delete_elements');
$returnUrl = $this->deleteUrl(1, ($this->fileMode ? 1 : 0));
$btnOkText = $languageService
->sL('LLL:EXT:lang/locallang_alt_doc.xlf:buttons.confirm.delete_elements.yes');
$btnCancelText = $languageService
->sL('LLL:EXT:lang/locallang_alt_doc.xlf:buttons.confirm.delete_elements.no');
$optionArray[] = '<li><a'
. (($confirmationCheck) ? ' class="t3js-modal-trigger"' : '')
. ' href="' . htmlspecialchars($returnUrl) . '"'
. ' data-severity="warning"'
. ' data-button-close-text="' . htmlspecialchars($btnCancelText) . '"'
. ' data-button-ok-text="' . htmlspecialchars($btnOkText) . '"'
. ' data-content="' . htmlspecialchars($confirmationMessage) . '"'
. ' data-title="' . htmlspecialchars($title) . '">'
. htmlspecialchars($title) . '</a></li>';
// Clear clipboard
$optionArray[] = '<li><a href="#" onclick="' . htmlspecialchars('window.location.href=' . GeneralUtility::quoteJSvalue($removeAllUrl . '#clip_head')) . '">' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.clipboard.clear_clipboard', true) . '</a></li>';
$deleteLink = '<a class="btn btn-danger" href="' . htmlspecialchars($removeAllUrl) . '#clip_head" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:buttons.clear', true) . '">' . $this->iconFactory->getIcon('actions-document-close', Icon::SIZE_SMALL)->render(SvgIconProvider::MARKUP_IDENTIFIER_INLINE) . '</a>';
$optionArray[] = '<li><a href="' . htmlspecialchars($removeAllUrl) . '#clip_head">' . $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.clipboard.clear_clipboard', true) . '</a></li>';
$deleteLink = '<a class="btn btn-danger" href="' . htmlspecialchars($removeAllUrl) . '#clip_head" title="' . $languageService->sL('LLL:EXT:lang/locallang_core.xlf:buttons.clear', true) . '">' . $this->iconFactory->getIcon('actions-document-close', Icon::SIZE_SMALL)->render(SvgIconProvider::MARKUP_IDENTIFIER_INLINE) . '</a>';
// menuSelector
$menuSelector = '
......
......@@ -72,6 +72,12 @@
<trans-unit id="label.confirm.delete_record.content">
<source>Are you sure you want to delete this record?</source>
</trans-unit>
<trans-unit id="buttons.confirm.delete_elements.no">
<source>Cancel</source>
</trans-unit>
<trans-unit id="buttons.confirm.delete_elements.yes">
<source>Yes, delete these elements</source>
</trans-unit>
</body>
</file>
</xliff>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment