diff --git a/Classes/Controller/Backend/LinkBrowserController.php b/Classes/Controller/Backend/LinkBrowserController.php index fd8850d01..936197aeb 100644 --- a/Classes/Controller/Backend/LinkBrowserController.php +++ b/Classes/Controller/Backend/LinkBrowserController.php @@ -16,12 +16,21 @@ protected function initDocumentTemplate() { parent::initDocumentTemplate(); $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addRequireJsConfiguration( - [ - 'map' => [ - '*' => ['TYPO3/CMS/Backend/FormEngineLinkBrowserAdapter' => PathUtility::getRelativePathTo(ExtensionManagementUtility::extPath('templavoilaplus')) . '/Resources/Public/JavaScript/FormEngineLinkBrowserAdapter'] + if (version_compare(TYPO3_version, '10.4', '<=')) { + $pageRenderer->addRequireJsConfiguration( + [ + 'map' => [ + '*' => [ + 'TYPO3/CMS/Backend/FormEngineLinkBrowserAdapter' => PathUtility::getRelativePathTo( + ExtensionManagementUtility::extPath('templavoilaplus') + ) . + '/Resources/Public/JavaScript/FormEngineLinkBrowserAdapter' + ] + ] ] - ] - ); + ); + } else { + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Templavoilaplus/ParentWindow'); + } } } diff --git a/Classes/Core/Page/JavaScriptModuleInstruction.php b/Classes/Core/Page/JavaScriptModuleInstruction.php index 750b38733..d44f4e52f 100644 --- a/Classes/Core/Page/JavaScriptModuleInstruction.php +++ b/Classes/Core/Page/JavaScriptModuleInstruction.php @@ -36,7 +36,9 @@ class JavaScriptModuleInstruction extends CoreJavaScriptModuleInstruction */ public function __construct(string $name, int $flags) { - $name = preg_replace($this->pattern, $this->replace, $name); + if (version_compare(TYPO3_version, '10.4', '<=')) { + $name = preg_replace($this->pattern, $this->replace, $name); + } parent::__construct($name, $flags); } } diff --git a/Resources/Public/JavaScript/ParentWindow.js b/Resources/Public/JavaScript/ParentWindow.js new file mode 100644 index 000000000..3f1134f31 --- /dev/null +++ b/Resources/Public/JavaScript/ParentWindow.js @@ -0,0 +1,20 @@ +define([ + 'TYPO3/CMS/Backend/FormEngineLinkBrowserAdapter' +], function(FormEngineLinkBrowserAdapter, ElementBrowser) { + const FormEngineLinkBrowserAdapterParentFunction = FormEngineLinkBrowserAdapter.getParent; + const getParent = () => { + if ( + typeof window.parent !== 'undefined' && + typeof window.parent.document.list_frame !== 'undefined' && + window.parent.frames.list_frame.parent.document.querySelector('.t3js-modal-iframe') !== null && + window.parent.frames.list_frame.parent.document.querySelectorAll('.t3js-modal-iframe').length > 1 + ) { + return window.parent.frames.list_frame.parent.document.querySelector('.t3js-modal-iframe').contentWindow; + } + return null; + } + + FormEngineLinkBrowserAdapter.getParent = () => { + return getParent() || FormEngineLinkBrowserAdapterParentFunction(); + } +}); diff --git a/ext_localconf.php b/ext_localconf.php index 68dda559d..f7057364d 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -8,6 +8,9 @@ $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class]['className'] = \Tvp\TemplaVoilaPlus\Configuration\FlexForm\FlexFormTools8::class; +$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Backend\Controller\LinkBrowserController::class]['className'] + = Tvp\TemplaVoilaPlus\Controller\Backend\LinkBrowserController::class; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Core\Page\JavaScriptModuleInstruction::class]['className'] = Tvp\TemplaVoilaPlus\Core\Page\JavaScriptModuleInstruction::class;