From e650ac927e012ff2e816948f3805e508325548b5 Mon Sep 17 00:00:00 2001 From: Lorenz Ulrich Date: Tue, 28 Jan 2020 17:32:30 +0100 Subject: [PATCH] [FEATURE] Separately enable / disable "Add media by URL" and "Select & upload files" A new appearance property "fileByUrlAllowed" is used to separately enable / disable the buttons "Add media by URL" and "Select & upload files". fileUploadAllowed = 0 now only hides the button "Select & upload files" fileByUrlAllowed = 0 now hides the button "Add media by URL" if "elementBrowserType" is set to "file" both values are true by default Resolves: #84250 --- .../Form/Container/InlineControlContainer.php | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php b/typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php index 82aaf7786b..4b93855c76 100644 --- a/typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php +++ b/typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php @@ -427,7 +427,7 @@ class InlineControlContainer extends AbstractContainer * Wraps a text with an anchor and returns the HTML representation. * * @param string $text The text to be wrapped by an anchor - * @param string $link The link to be used in the anchor + * @param string $link The link to be used in the anchor * @param array $attributes Array of attributes to be used in the anchor * @return string The wrapped text as HTML representation */ @@ -463,6 +463,7 @@ class InlineControlContainer extends AbstractContainer $nameObject = $currentStructureDomObjectIdPrefix; $mode = 'db'; $showUpload = false; + $showByUrl = false; $elementBrowserEnabled = true; if (!empty($inlineConfiguration['appearance']['createNewRelationLinkTitle'])) { $createNewRelationText = htmlspecialchars($languageService->sL($inlineConfiguration['appearance']['createNewRelationLinkTitle'])); @@ -475,10 +476,14 @@ class InlineControlContainer extends AbstractContainer } if ($mode === 'file') { $showUpload = true; + $showByUrl = true; } if (isset($inlineConfiguration['appearance']['fileUploadAllowed'])) { $showUpload = (bool)$inlineConfiguration['appearance']['fileUploadAllowed']; } + if (isset($inlineConfiguration['appearance']['fileByUrlAllowed'])) { + $showByUrl = (bool)$inlineConfiguration['appearance']['fileByUrlAllowed']; + } if (isset($groupFieldConfiguration['appearance']['elementBrowserAllowed'])) { $allowed = $groupFieldConfiguration['appearance']['elementBrowserAllowed']; } @@ -509,7 +514,7 @@ class InlineControlContainer extends AbstractContainer if (!empty($allowedArray)) { $onlineMediaAllowed = array_intersect($allowedArray, $onlineMediaAllowed); } - if ($showUpload && $isDirectFileUploadEnabled) { + if (($showUpload || $showByUrl) && $isDirectFileUploadEnabled) { $folder = $backendUser->getDefaultUploadFolder( $this->data['parentPageRow']['uid'], $this->data['tableName'], @@ -519,22 +524,24 @@ class InlineControlContainer extends AbstractContainer $folder instanceof Folder && $folder->getStorage()->checkUserActionPermission('add', 'File') ) { - $maxFileSize = GeneralUtility::getMaxUploadFileSize() * 1024; - $item .= ' '; - $item .= $this->iconFactory->getIcon('actions-upload', Icon::SIZE_SMALL)->render() . ' '; - $item .= htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:file_upload.select-and-submit')); - $item .= ''; - - $this->requireJsModules[] = ['TYPO3/CMS/Backend/DragUploader' => 'function(dragUploader){dragUploader.initialize()}']; - if (!empty($onlineMediaAllowed)) { + if ($showUpload) { + $maxFileSize = GeneralUtility::getMaxUploadFileSize() * 1024; + $item .= ' '; + $item .= $this->iconFactory->getIcon('actions-upload', Icon::SIZE_SMALL)->render() . ' '; + $item .= htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:file_upload.select-and-submit')); + $item .= ''; + + $this->requireJsModules[] = ['TYPO3/CMS/Backend/DragUploader' => 'function(dragUploader){dragUploader.initialize()}']; + } + if (!empty($onlineMediaAllowed) && $showByUrl) { $buttonStyle = ''; if (isset($inlineConfiguration['inline']['inlineOnlineMediaAddButtonStyle'])) { $buttonStyle = ' style="' . $inlineConfiguration['inline']['inlineOnlineMediaAddButtonStyle'] . '"'; -- 2.17.1