Skip to content
Snippets Groups Projects

Typo3v8compatibility

Merged Fabian Galinski requested to merge typo3v8compatibility into master
1 file
+ 2
1
Compare changes
  • Side-by-side
  • Inline
@@ -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;
@@ -274,6 +275,10 @@ class RichTextElement extends AbstractFormElement {
$html = $this->getMainHtml();
if (isset($parameterArray['fieldConf']['config']['wizards']['RTE'])) {
unset($parameterArray['fieldConf']['config']['wizards']['RTE']);
}
$this->resultArray['html'] = $this->renderWizards(
array($html),
$parameterArray['fieldConf']['config']['wizards'],
@@ -298,36 +303,21 @@ class RichTextElement extends AbstractFormElement {
$backendUser = $this->getBackendUserAuthentication();
if ($this->isInFullScreenMode()) {
$width = '100%';
$height = '100%';
$paddingRight = '0px';
$editorWrapWidth = '100%';
} else {
$options = $backendUser->userTS['options.'];
$width = 530 + (isset($options['RTELargeWidthIncrement']) ? (int) $options['RTELargeWidthIncrement'] : 150);
/** @var InlineStackProcessor $inlineStackProcessor */
$inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
$inlineStackProcessor->initializeByGivenStructure($this->data['inlineStructure']);
$inlineStructureDepth = $inlineStackProcessor->getStructureDepth();
$width -= $inlineStructureDepth > 0 ? ($inlineStructureDepth + 1) * 12 : 0;
$widthOverride = isset($backendUser->uc['rteWidth']) && trim($backendUser->uc['rteWidth']) ?: trim($this->processedRteConfiguration['RTEWidthOverride']);
if ($widthOverride) {
if (strstr($widthOverride, '%')) {
if ($this->client['browser'] !== 'msie') {
$width = (int) $widthOverride > 0 ? (int) $widthOverride : '100%';
}
} else {
$width = (int) $widthOverride > 0 ? (int) $widthOverride : $width;
}
}
$width = strstr($width, '%') ? $width : $width . 'px';
$height = 380 + (isset($options['RTELargeHeightIncrement']) ? (int) $options['RTELargeHeightIncrement'] : 0);
$heightOverride = isset($backendUser->uc['rteHeight']) && (int) $backendUser->uc['rteHeight'] ?: (int) $this->processedRteConfiguration['RTEHeightOverride'];
$height = $heightOverride > 0 ? $heightOverride . 'px' : $height . 'px';
$paddingRight = '2';
$editorWrapWidth = '99%';
}
$rteDivStyle = 'position:relative; left:0px; top:0px; height:' . $height . '; width:' . $width . '; border: 1px solid black; padding: 2 ' . $paddingRight . ' 2 2;';
$rteDivStyle = 'position:relative; left:0px; top:0px; height:' . $height . '; width: 100%;' . '; border: 1px solid black; padding: 2 ' . $paddingRight . ' 2 2;';
$itemFormElementName = $this->data['parameterArray']['itemFormElName'];
@@ -338,14 +328,28 @@ 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();
// next line is required to fix the scrolling toolbar elements in the tinymce
// also fixes the fullscreen dialog
$result[] = '<style>body{position:relative;}div.mce-fullscreen{top: 65px;}</style>';
// The hidden field tells the DataHandler that processing should be done on this value.
$result[] = '<input type="hidden" name="' . htmlspecialchars($triggerFieldName) . '" value="RTE" />';
// $result[] = '<div id="pleasewait' . $this->domIdentifier . '" class="pleasewait" style="display: block;" >';
// $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>';
@@ -591,18 +595,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(
@@ -626,12 +640,18 @@ class RichTextElement extends AbstractFormElement {
* @return string RTE initialization inline JavaScript code
*/
protected function getRteInitJsCode() {
$ajaxPingJavaScriptCode = '(function($) {
$(document).ready(function() {
$.get(TYPO3.settings.ajaxUrls[\'tinymce4_rte::ajaxPing\']);
});
})(TYPO3.jQuery);';
return 'if (typeof RTEarea === "undefined") {
RTEarea = new Object();
RTEarea[0] = new Object();
RTEarea[0].version = "' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tinymce4_rte']['version'] . '";
RTEarea[0].editorUrl = "' . ExtensionManagementUtility::extRelPath('tinymce4_rte') . '";
}';
}' . $ajaxPingJavaScriptCode;
}
/**
Loading