Skip to content

Commit

Permalink
[FEATURE] refactor LinkBrowserController fix from T3Voila#510
Browse files Browse the repository at this point in the history
providing new for >=11 and retaining old solution for <=10

fixes T3Voila#510, fixes T3Voila#502, rels T3Voila#503, rels T3Voila#507, rels T3Voila#508
  • Loading branch information
jpmschuler committed Sep 20, 2023
1 parent 1f62bc1 commit 71694bd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
22 changes: 1 addition & 21 deletions Classes/Controller/Backend/LinkBrowserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
4 changes: 3 additions & 1 deletion Classes/Core/Page/JavaScriptModuleInstruction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
20 changes: 20 additions & 0 deletions Resources/Public/JavaScript/ParentWindow.js
Original file line number Diff line number Diff line change
@@ -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();
}
});
3 changes: 3 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 71694bd

Please sign in to comment.