diff --git a/Classes/FrontendEditAssetLoader.php b/Classes/FrontendEditAssetLoader.php new file mode 100644 index 0000000..1d4a889 --- /dev/null +++ b/Classes/FrontendEditAssetLoader.php @@ -0,0 +1,65 @@ +getLanguageService(); + $coreLabels = [ + 'csh_tooltip_loading' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:csh_tooltip_loading') + ]; + $generatedLabels = []; + $generatedLabels['core'] = $coreLabels; + $code = 'TYPO3.LLL = ' . json_encode($generatedLabels) . ';'; + $filePath = 'typo3temp/assets/js/backend-' . sha1($code) . '.js'; + if (!file_exists(PATH_site . $filePath)) { + // writeFileToTypo3tempDir() returns NULL on success (please double-read!) + $error = GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filePath, $code); + if ($error !== null) { + throw new \RuntimeException('Locallang JS file could not be written to ' . $filePath . '. Reason: ' . $error, 1446118286); + } + } + $pageRenderer->addJsFile('../' . $filePath); + } + } + + /** + * Returns LanguageService + * + * @return \TYPO3\CMS\Lang\LanguageService + */ + protected function getLanguageService() + { + return $GLOBALS['LANG']; + } +} diff --git a/ext_localconf.php b/ext_localconf.php index 943ffcd..b356fa8 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -3,3 +3,12 @@ defined('TYPO3_MODE') or die(); // Register the edit panel view. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = \TYPO3\CMS\Feedit\FrontendEditPanel::class; + +if (TYPO3_MODE === 'FE') { + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect( + \TYPO3\CMS\Backend\Controller\EditDocumentController::class, + 'initAfter', + \TYPO3\CMS\Feedit\FrontendEditAssetLoader::class, + 'attachAssets' + ); +}