Commit a081c86b authored by Fabian Galinski's avatar Fabian Galinski 😾
Browse files

[TASK] Fixing the validation error since TYPO3 8 and adapations to the new TypoScript config.

parent a64502c3
......@@ -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(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment