Commit c2cb3e87 authored by Philipp Parzer's avatar Philipp Parzer Committed by Daniel Goerz
Browse files

[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
Releases: master
Change-Id: I3c3ae34f7514128cb164a5edc8ed028a86af1238
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60752

Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Tested-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
parent 792dae2e
......@@ -437,7 +437,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
*/
......@@ -467,6 +467,7 @@ class InlineControlContainer extends AbstractContainer
$objectPrefix = $currentStructureDomObjectIdPrefix . '-' . $foreign_table;
$mode = 'db';
$showUpload = false;
$showByUrl = false;
$elementBrowserEnabled = true;
if (!empty($inlineConfiguration['appearance']['createNewRelationLinkTitle'])) {
$createNewRelationText = htmlspecialchars($languageService->sL($inlineConfiguration['appearance']['createNewRelationLinkTitle']));
......@@ -479,10 +480,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'];
}
......@@ -511,7 +516,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'],
......@@ -521,8 +526,9 @@ class InlineControlContainer extends AbstractContainer
$folder instanceof Folder
&& $folder->getStorage()->checkUserActionPermission('add', 'File')
) {
$maxFileSize = GeneralUtility::getMaxUploadFileSize() * 1024;
$item .= ' <a href="#" class="btn btn-default t3js-drag-uploader inlineNewFileUploadButton"
if ($showUpload) {
$maxFileSize = GeneralUtility::getMaxUploadFileSize() * 1024;
$item .= ' <a href="#" class="btn btn-default t3js-drag-uploader inlineNewFileUploadButton"
' . $buttonStyle . '
data-dropzone-target="#' . htmlspecialchars(StringUtility::escapeCssSelector($currentStructureDomObjectIdPrefix)) . '"
data-insert-dropzone-before="1"
......@@ -531,12 +537,13 @@ class InlineControlContainer extends AbstractContainer
data-target-folder="' . htmlspecialchars($folder->getCombinedIdentifier()) . '"
data-max-file-size="' . htmlspecialchars($maxFileSize) . '"
>';
$item .= $this->iconFactory->getIcon('actions-upload', Icon::SIZE_SMALL)->render() . ' ';
$item .= htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:file_upload.select-and-submit'));
$item .= '</a>';
$item .= $this->iconFactory->getIcon('actions-upload', Icon::SIZE_SMALL)->render() . ' ';
$item .= htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:file_upload.select-and-submit'));
$item .= '</a>';
$this->requireJsModules[] = ['TYPO3/CMS/Backend/DragUploader' => 'function(dragUploader){dragUploader.initialize()}'];
if (!empty($onlineMediaAllowed)) {
$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'] . '"';
......
.. include:: ../../Includes.txt
===========================================================================================
Feature: #84250 - Separately enable / disable "Add media by URL" and "Select & upload files"
===========================================================================================
See :issue:`84250`
Description
===========
A new appearance property "fileByUrlAllowed" is used to separately enable / disable the buttons "Add media by URL" and "Select & upload files".
* `fileUploadAllowed = false` now only hides the button "Select & upload files".
* `fileByUrlAllowed = false` now hides the button "Add media by URL".
If "elementBrowserType" is set to "file" both values are true by default.
Example
.. codeblock:: php
$GLOBALS['TCA']['pages']['columns']['media']['config']['appearance'] = [
'fileUploadAllowed' => false,
'fileByUrlAllowed' => false,
];
This will suppress both buttons and only leave "Create new relation".
Impact
======
Users have to use the new appearance property "fileByUrlAllowed" to hide the button "Add media by URL"
.. index:: Backend, TCA, ext:backend
\ No newline at end of file
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