Commit 495e4f92 authored by Fabian Galinski's avatar Fabian Galinski

[FEATURE] Compatibility for TYPO3 8.7

parent 5604b2bb
......@@ -5,7 +5,7 @@ namespace SGalinski\Tinymce;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (http://www.sgalinski.de)
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
......@@ -31,6 +31,7 @@ use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Lang\LanguageService;
use TYPO3\CMS\Core\Localization\Locales;
/**
* tinyMCE initialisation class
......@@ -88,7 +89,9 @@ class Loader {
/**
* @param string $configuration file reference or configuration string (defaults to basic configuration)
* @param boolean $forceLanguage set this to true if you want to force your language set by the configuration
*
* @return void
* @throws \InvalidArgumentException
*/
public function loadConfiguration($configuration = '', $forceLanguage = FALSE) {
self::$init = FALSE;
......@@ -102,6 +105,7 @@ class Loader {
* Calculates and sets the current language
*
* @return void
* @throws \InvalidArgumentException
*/
protected function setLanguage() {
/** @var $languageInstance LanguageService */
......@@ -116,9 +120,8 @@ class Loader {
}
// language conversion from TLD to iso631
/** @var $locales \TYPO3\CMS\Core\Localization\Locales */
$locales = GeneralUtility::makeInstance('TYPO3\CMS\Core\Localization\Locales');
$locales->initialize();
$locales = GeneralUtility::makeInstance(Locales::class);
Locales::initialize();
$isoArray = (array) $locales->getIsoMapping();
if (array_key_exists($languageKey, $isoArray)) {
......@@ -146,8 +149,9 @@ class Loader {
* issue.
*
* @return string
* @throws \UnexpectedValueException
*/
protected function getConfiguration() {
protected function getConfiguration(): string {
$configuration = $this->tinymceConfiguration['preJS'];
$configuration .= '
var SG = SG || {};
......@@ -224,7 +228,7 @@ class Loader {
*
* @return string
*/
public function getJS() {
public function getJS(): string {
$output = '';
if (!self::$init) {
self::$init = TRUE;
......@@ -284,9 +288,11 @@ class Loader {
* Loads the required javascript via the require.js
*
* @return array
* @throws \BadFunctionCallException
* @throws \UnexpectedValueException
* @see \SGalinski\Tinymce4Rte\Form\Element\RichTextElement->loadRequireModulesForRTE
*/
public function loadJsViaRequireJS() {
public function loadJsViaRequireJS(): array {
if (self::$init) {
return [];
}
......@@ -326,7 +332,7 @@ class Loader {
* @param string $configuration file reference or configuration string
* @return array
*/
protected function prepareTinyMCEConfiguration($configuration) {
protected function prepareTinyMCEConfiguration($configuration): array {
$configurationArray = [];
// try to resolve a potential TYPO3 file path
......@@ -386,7 +392,7 @@ class Loader {
* @param string $configuration
* @return string
*/
protected function replaceTypo3Paths($configuration) {
protected function replaceTypo3Paths($configuration): string {
$replacementFunction = function ($value) {
// getPath should be used, but this causes a php exception with PHP 5.3 as $this isn't set there
return '\'' . GeneralUtility::getIndpEnv('TYPO3_SITE_URL') .
......@@ -402,9 +408,11 @@ class Loader {
*
* @param string $relativePath
* @param bool $returnWithDomain
*
* @return string
* @throws \UnexpectedValueException
*/
protected function getPath($relativePath, $returnWithDomain = FALSE) {
protected function getPath($relativePath, $returnWithDomain = FALSE): string {
$finalPath = $absolutePath = GeneralUtility::getFileAbsFileName($relativePath);
if ($returnWithDomain) {
$finalPath = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . str_replace(PATH_site, '', $absolutePath);
......@@ -412,5 +420,3 @@ class Loader {
return $finalPath;
}
}
?>
......@@ -182,7 +182,11 @@ SG.TinyMceLoader.prototype = {
if (hasMatches) {
this.tinyMceOptions.selector = this.tinyMceOptions.selector.slice(1);
this.originalInit.call(tinymce, this.getTinyMceOptionsAsNewObject());
document.getElementById('pleasewait' + this.tinyMceOptions.editornumber).style.display = 'none';
var $pleaseWaitElement = document.getElementById('pleasewait' + this.tinyMceOptions.editornumber);
if ($pleaseWaitElement !== null) {
$pleaseWaitElement.style.display = 'none';
}
}
},
......@@ -200,4 +204,4 @@ SG.TinyMceLoader.prototype = {
return newObject;
}
};
\ No newline at end of file
};
......@@ -4,7 +4,7 @@
"description": "TinyMCE sources including a small PHP API",
"homepage": "https://www.sgalinski.de",
"license": "GPL-2.0+",
"version": "4.4.3",
"version": "5.0.0",
"support": {
"issues": "https://forge.typo3.org/projects/extension-tinymce"
},
......
......@@ -4,7 +4,7 @@ $EM_CONF[$_EXTKEY] = [
'title' => 'tinyMCE',
'description' => 'TinyMCE sources including a small PHP API',
'category' => 'misc',
'version' => '4.4.3',
'version' => '5.0.0',
'state' => 'stable',
'uploadfolder' => FALSE,
'createDirs' => '',
......@@ -20,8 +20,8 @@ $EM_CONF[$_EXTKEY] = [
[
'depends' =>
[
'php' => '5.5.0-0.0.0',
'typo3' => '6.2.0-8.7.99',
'php' => '7.0.0-7.1.99',
'typo3' => '7.6.0-8.7.99',
],
'conflicts' => [],
'suggests' => [],
......
!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i<g;++i)h[i]=d(e[i]);var j=f.apply(null,h);if(void 0===j)throw"module ["+b+"] returned undefined";c.instance=j},c=function(b,c,d){if("string"!=typeof b)throw"module id must be a string";if(void 0===c)throw"no dependencies for "+b;if(void 0===d)throw"no definition function for "+b;a[b]={deps:c,defn:d,instance:void 0}},d=function(c){var d=a[c];if(void 0===d)throw"module ["+c+"] was undefined";return void 0===d.instance&&b(c),d.instance},e=function(a,b){for(var c=a.length,e=new Array(c),f=0;f<c;++f)e.push(d(a[f]));b.apply(null,b)},f={};f.bolt={module:{api:{define:c,require:e,demand:d}}};var g=c;g("0",[],function(){return function(a){function b(){function a(a){"remove"===a&&this.each(function(a,b){var c=d(b);c&&c.remove()}),this.find("span.mceEditor,div.mceEditor").each(function(a,b){var c=i().get(b.id.replace(/_parent$/,""));c&&c.remove()})}function b(b){var c,d=this;if(null!=b)a.call(d),d.each(function(a,c){var d;(d=i().get(c.id))&&d.setContent(b)});else if(d.length>0&&(c=i().get(d[0].id)))return c.getContent()}function d(a){var b=null;return a&&a.id&&g.tinymce&&(b=i().get(a.id)),b}function e(a){return!!(a&&a.length&&g.tinymce&&a.is(":tinymce"))}var h={};f.each(["text","html","val"],function(a,g){var i=h[g]=f.fn[g],j="text"===g;f.fn[g]=function(a){var g=this;if(!e(g))return i.apply(g,arguments);if(a!==c)return b.call(g.filter(":tinymce"),a),i.apply(g.not(":tinymce"),arguments),g;var h="",k=arguments;return(j?g:g.eq(0)).each(function(a,b){var c=d(b);h+=c?j?c.getContent().replace(/<(?:"[^"]*"|'[^']*'|[^'">])*>/g,""):c.getContent({save:!0}):i.apply(f(b),k)}),h}}),f.each(["append","prepend"],function(a,b){var g=h[b]=f.fn[b],i="prepend"===b;f.fn[b]=function(a){var b=this;return e(b)?a!==c?("string"==typeof a&&b.filter(":tinymce").each(function(b,c){var e=d(c);e&&e.setContent(i?a+e.getContent():e.getContent()+a)}),g.apply(b.not(":tinymce"),arguments),b):void 0:g.apply(b,arguments)}}),f.each(["remove","replaceWith","replaceAll","empty"],function(b,c){var d=h[c]=f.fn[c];f.fn[c]=function(){return a.call(this,c),d.apply(this,arguments)}}),h.attr=f.fn.attr,f.fn.attr=function(a,g){var i=this,j=arguments;if(!a||"value"!==a||!e(i))return g!==c?h.attr.apply(i,j):h.attr.apply(i,j);if(g!==c)return b.call(i.filter(":tinymce"),g),h.attr.apply(i.not(":tinymce"),j),i;var k=i[0],l=d(k);return l?l.getContent({save:!0}):h.attr.apply(f(k),j)}}var c,d,e,f,g,h=[];g=a?a:window,f=g.jQuery;var i=function(){return g.tinymce};f.fn.tinymce=function(a){function c(){var c=[],d=0;e||(b(),e=!0),m.each(function(b,e){var f,g=e.id,h=a.oninit;g||(e.id=g=i().DOM.uniqueId()),i().get(g)||(f=i().createEditor(g,a),c.push(f),f.on("init",function(){var a,b=h;m.css("visibility",""),h&&++d==c.length&&("string"==typeof b&&(a=b.indexOf(".")===-1?null:i().resolve(b.replace(/\.\w+$/,"")),b=i().resolve(b)),b.apply(a||i(),c))}))}),f.each(c,function(a,b){b.render()})}var j,k,l,m=this,n="";if(!m.length)return m;if(!a)return i()?i().get(m[0].id):null;if(m.css("visibility","hidden"),g.tinymce||d||!(j=a.script_url))1===d?h.push(c):c();else{d=1,k=j.substring(0,j.lastIndexOf("/")),j.indexOf(".min")!=-1&&(n=".min"),g.tinymce=g.tinyMCEPreInit||{base:k,suffix:n},j.indexOf("gzip")!=-1&&(l=a.language||"en",j=j+(/\?/.test(j)?"&":"?")+"js=true&core=true&suffix="+escape(n)+"&themes="+escape(a.theme||"modern")+"&plugins="+escape(a.plugins||"")+"&languages="+(l||""),g.tinyMCE_GZ||(g.tinyMCE_GZ={start:function(){function b(a){i().ScriptLoader.markDone(i().baseURI.toAbsolute(a))}b("langs/"+l+".js"),b("themes/"+a.theme+"/theme"+n+".js"),b("themes/"+a.theme+"/langs/"+l+".js"),f.each(a.plugins.split(","),function(a,c){c&&(b("plugins/"+c+"/plugin"+n+".js"),b("plugins/"+c+"/langs/"+l+".js"))})},end:function(){}}));var o=document.createElement("script");o.type="text/javascript",o.onload=o.onreadystatechange=function(b){b=b||window.event,2===d||"load"!=b.type&&!/complete|loaded/.test(o.readyState)||(i().dom.Event.domLoaded=1,d=2,a.script_loaded&&a.script_loaded(),c(),f.each(h,function(a,b){b()}))},o.src=j,document.body.appendChild(o)}return m},f.extend(f.expr[":"],{tinymce:function(a){var b;return!!(a.id&&"tinymce"in g&&(b=i().get(a.id),b&&b.editorManager===i()))}})}}),d("0")()}();
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
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