diff --git a/src/Resources/contao/classes/DataContainer.php b/src/Resources/contao/classes/DataContainer.php index 8b5f9cf07f..580885a43d 100644 --- a/src/Resources/contao/classes/DataContainer.php +++ b/src/Resources/contao/classes/DataContainer.php @@ -113,7 +113,14 @@ abstract class DataContainer extends \Backend protected $blnUploadable = false; /** - * @var \Closure + * DCA Picker instance + * @var PickerInterface + */ + protected $objPicker; + + /** + * Callback to convert DCA value to picker value + * @var callable */ protected $objPickerCallback; @@ -557,17 +564,26 @@ protected function row($strPalette=null) { list ($file, $type) = explode('|', $arrData['eval']['rte'], 2); + $fileBrowserTypes = []; + $pickerBuilder = \System::getContainer()->get('contao.picker.builder'); + foreach (['file' => 'image', 'link' => 'file'] as $context => $type) { + if ($pickerBuilder->supportsContext($context)) { + $fileBrowserTypes[] = $type; + } + } + /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_' . $file); $objTemplate->selector = 'ctrl_' . $this->strInputName; $objTemplate->type = $type; + $objTemplate->fileBrowserTypes = $fileBrowserTypes; // Deprecated since Contao 4.0, to be removed in Contao 5.0 $objTemplate->language = \Backend::getTinyMceLanguage(); $updateMode = $objTemplate->parse(); - unset($file, $type); + unset($file, $type, $pickerBuilder); } // Handle multi-select fields in "override all" mode @@ -907,6 +923,7 @@ public function initPicker(PickerInterface $picker) $attributes = $provider->getDcaAttributes($picker->getConfig()); + $this->objPicker = $picker; $this->strPickerFieldType = $attributes['fieldType']; $this->objPickerCallback = function ($value) use ($picker, $provider) { return $provider->convertDcaValue($picker->getConfig(), $value); diff --git a/src/Resources/contao/templates/backend/be_tinyFlash.html5 b/src/Resources/contao/templates/backend/be_tinyFlash.html5 index a62e0f9250..1b282c8fe8 100644 --- a/src/Resources/contao/templates/backend/be_tinyFlash.html5 +++ b/src/Resources/contao/templates/backend/be_tinyFlash.html5 @@ -3,16 +3,6 @@ namespace Contao; if ($GLOBALS['TL_CONFIG']['useRTE']): - $builder = \System::getContainer()->get('contao.picker.builder'); - $pickerTypes = []; - - if ($builder->supportsContext('file')) { - $pickerTypes[] = 'image'; - } - - if ($builder->supportsContext('link')) { - $pickerTypes[] = 'file'; - } ?> @@ -35,7 +25,9 @@ setTimeout(function() { } editor.on('focus', function(){ Backend.getScrollOffset(); }); }, - file_browser_callback_types: , + fileBrowserTypes)): ?> + file_browser_callback_types: fileBrowserTypes) ?>, + file_browser_callback: function(field_name, url, type, win) { Backend.openModalBrowser(field_name, url, type, win); }, diff --git a/src/Resources/contao/templates/backend/be_tinyMCE.html5 b/src/Resources/contao/templates/backend/be_tinyMCE.html5 index 9cffa2288f..ba4452c3e0 100644 --- a/src/Resources/contao/templates/backend/be_tinyMCE.html5 +++ b/src/Resources/contao/templates/backend/be_tinyMCE.html5 @@ -3,16 +3,6 @@ namespace Contao; if ($GLOBALS['TL_CONFIG']['useRTE']): - $builder = \System::getContainer()->get('contao.picker.builder'); - $pickerTypes = []; - - if ($builder->supportsContext('file')) { - $pickerTypes[] = 'image'; - } - - if ($builder->supportsContext('link')) { - $pickerTypes[] = 'file'; - } ?> @@ -34,7 +24,9 @@ setTimeout(function() { } editor.on('focus', function(){ Backend.getScrollOffset(); }); }, - file_browser_callback_types: , + fileBrowserTypes)): ?> + file_browser_callback_types: fileBrowserTypes) ?>, + file_browser_callback: function(field_name, url, type, win) { Backend.openModalBrowser(field_name, url, type, win); }, diff --git a/src/Resources/contao/templates/backend/be_tinyNews.html5 b/src/Resources/contao/templates/backend/be_tinyNews.html5 index c77a09ed44..0db64c423a 100644 --- a/src/Resources/contao/templates/backend/be_tinyNews.html5 +++ b/src/Resources/contao/templates/backend/be_tinyNews.html5 @@ -3,16 +3,6 @@ namespace Contao; if ($GLOBALS['TL_CONFIG']['useRTE']): - $builder = \System::getContainer()->get('contao.picker.builder'); - $pickerTypes = []; - - if ($builder->supportsContext('file')) { - $pickerTypes[] = 'image'; - } - - if ($builder->supportsContext('link')) { - $pickerTypes[] = 'file'; - } ?> @@ -34,7 +24,9 @@ setTimeout(function() { } editor.on('focus', function(){ Backend.getScrollOffset(); }); }, - file_browser_callback_types: , + fileBrowserTypes)): ?> + file_browser_callback_types: fileBrowserTypes) ?>, + file_browser_callback: function(field_name, url, type, win) { Backend.openModalBrowser(field_name, url, type, win); },