From a081c86bae81b2f9804ecae17d01c6564657966f Mon Sep 17 00:00:00 2001 From: Fabian Galinski <fabian@sgalinski.de> Date: Thu, 14 Sep 2017 18:37:57 +0200 Subject: [PATCH] [TASK] Fixing the validation error since TYPO3 8 and adapations to the new TypoScript config. --- Classes/Form/Element/RichTextElement.php | 44 +++++++++++++++++------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/Classes/Form/Element/RichTextElement.php b/Classes/Form/Element/RichTextElement.php index 035c716..09935d7 100644 --- a/Classes/Form/Element/RichTextElement.php +++ b/Classes/Form/Element/RichTextElement.php @@ -18,6 +18,7 @@ use SGalinski\Tinymce\Loader; use SGalinski\Tinymce4Rte\Extension\Typo3Image; use SGalinski\Tinymce4Rte\Extension\Typo3Link; use SGalinski\Tinymce4Rte\RteHtmlAreaApi; +use SGalinski\Tinymce4Rte\Utility\VersionUtility; use TYPO3\CMS\Backend\Form\Element\AbstractFormElement; use TYPO3\CMS\Backend\Form\InlineStackProcessor; use TYPO3\CMS\Backend\Utility\BackendUtility; @@ -338,6 +339,16 @@ class RichTextElement extends AbstractFormElement { $value = $this->transformDatabaseContentToEditor($this->data['parameterArray']['itemFormElValue']); + // Remove this empty data attribute, otherwise an error will throw in TYPO3 8.7. + $validationResults = $this->getValidationDataAsDataAttribute( + $this->data['parameterArray']['fieldConf']['config'] + ); + if (VersionUtility::isVersion870OrHigher() && + trim($validationResults) === 'data-formengine-validation-rules="[]"' + ) { + $validationResults = ''; + } + $result = array(); // The hidden field tells the DataHandler that processing should be done on this value. $result[] = '<input type="hidden" name="' . htmlspecialchars($triggerFieldName) . '" value="RTE" />'; @@ -345,7 +356,7 @@ class RichTextElement extends AbstractFormElement { // $result[] = $this->getLanguageService()->sL('LLL:EXT:tinymce4_rte/Resources/Private/Language/locallang.xlf:Please wait'); // $result[] = '</div>'; $result[] = '<div id="editorWrap' . $this->domIdentifier . '" class="editorWrap" style="width:' . $editorWrapWidth . '; height:100%;">'; - $result[] = '<textarea ' . $this->getValidationDataAsDataAttribute($this->data['parameterArray']['fieldConf']['config']) . ' id="RTEarea' . $this->domIdentifier . '" class="tinymce4_rte" name="' . htmlspecialchars($itemFormElementName) . '" rows="0" cols="0" style="' . htmlspecialchars($rteDivStyle) . '">'; + $result[] = '<textarea ' . $validationResults . ' id="RTEarea' . $this->domIdentifier . '" class="tinymce4_rte" name="' . htmlspecialchars($itemFormElementName) . '" rows="0" cols="0" style="' . htmlspecialchars($rteDivStyle) . '">'; $result[] = htmlspecialchars($value); $result[] = '</textarea>'; $result[] = '</div>'; @@ -359,7 +370,6 @@ class RichTextElement extends AbstractFormElement { * @return void */ protected function enableRegisteredPlugins() { - // @todo repair this $plugins = [ 'TYPO3Image' => [ 'objectReference' => Typo3Image::class, @@ -592,18 +602,28 @@ class RichTextElement extends AbstractFormElement { /** @var Loader $tinyMCE */ $tinyMCE = GeneralUtility::makeInstance(Loader::class); $tinyMCE->loadConfiguration($this->vanillaRteTsConfig['properties']['default.']['tinymceConfiguration']); - if ($this->vanillaRteTsConfig['properties']['default.']['contentCSS'] !== '') { - $contentCssArray = is_array($this->vanillaRteTsConfig['properties']['default.']['contentCSS.']) ? $this->vanillaRteTsConfig['properties']['default.']['contentCSS.'] : (array)$this->vanillaRteTsConfig['properties']['default.']['contentCSS']; - if (!empty($contentCssArray)) { - $contentCssFileArray = array(); - foreach ($contentCssArray as $contentCssKey => $contentCssFile) { - $contentCssFileAbs = GeneralUtility::getFileAbsFileName(trim($contentCssFile)); - if (is_file($contentCssFileAbs)) { - $contentCssFileArray[] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . PathUtility::stripPathSitePrefix($contentCssFileAbs) . '?' . filemtime($contentCssFileAbs); - } + + $contentCssArray = []; + if (VersionUtility::isVersion870OrHigher()) { + $contentCssArray = is_array($this->vanillaRteTsConfig['properties']['default.']['contentCSS.']) ? + $this->vanillaRteTsConfig['properties']['default.']['contentCSS.'] : []; + } else { + if ($this->vanillaRteTsConfig['properties']['default.']['contentCSS'] !== '') { + $contentCssArray = is_array($this->vanillaRteTsConfig['properties']['default.']['contentCSS.']) ? + $this->vanillaRteTsConfig['properties']['default.']['contentCSS.'] : + (array) $this->vanillaRteTsConfig['properties']['default.']['contentCSS']; + } + } + + if (!empty($contentCssArray)) { + $contentCssFileArray = []; + foreach ($contentCssArray as $contentCssKey => $contentCssFile) { + $contentCssFileAbs = GeneralUtility::getFileAbsFileName(trim($contentCssFile)); + if (is_file($contentCssFileAbs)) { + $contentCssFileArray[] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . PathUtility::stripPathSitePrefix($contentCssFileAbs) . '?' . filemtime($contentCssFileAbs); } - $tinyMCE->addConfigurationOption('content_css', implode(',', $contentCssFileArray)); } + $tinyMCE->addConfigurationOption('content_css', implode(',', $contentCssFileArray)); } $tinyMCE->addConfigurationOption( -- GitLab