From 71694bdc83a705aacd602bc9d36435aecde14cf3 Mon Sep 17 00:00:00 2001 From: "J. Peter M. Schuler" Date: Mon, 7 Aug 2023 10:39:25 +0200 Subject: [PATCH] [FEATURE] refactor LinkBrowserController fix from #510 providing new for >=11 and retaining old solution for <=10 fixes #510, fixes #502, rels #503, rels #507, rels #508 --- .../Backend/LinkBrowserController.php | 22 +------------------ .../Core/Page/JavaScriptModuleInstruction.php | 4 +++- Resources/Public/JavaScript/ParentWindow.js | 20 +++++++++++++++++ ext_localconf.php | 3 +++ 4 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 Resources/Public/JavaScript/ParentWindow.js diff --git a/Classes/Controller/Backend/LinkBrowserController.php b/Classes/Controller/Backend/LinkBrowserController.php index 0e762a49d..22fcabf12 100644 --- a/Classes/Controller/Backend/LinkBrowserController.php +++ b/Classes/Controller/Backend/LinkBrowserController.php @@ -15,28 +15,8 @@ class LinkBrowserController extends CoreLinkBrowserController protected function initDocumentTemplate() { parent::initDocumentTemplate(); -<<<<<<< HEAD - -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> b596a8ab ([LINT] remove code sniff errors) $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addRequireJsConfiguration( -======= - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addRequireJsConfiguration( ->>>>>>> 885d9325 ([BUGFIX] fixes #502) -======= - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - $pageRenderer->addRequireJsConfiguration( ->>>>>>> 541a3b72 (correct whitespaces) - [ - 'map' => [ - '*' => ['TYPO3/CMS/Backend/FormEngineLinkBrowserAdapter' => PathUtility::getRelativePathTo(ExtensionManagementUtility::extPath('templavoilaplus')) . '/Resources/Public/JavaScript/FormEngineLinkBrowserAdapter'] - ] - ] - ); + $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 adb246f28..27e45eada 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;