* Feature #6579 continued: Backtracking on the use of Prototype.js by htmlArea RTE.
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 12 Nov 2007 15:25:50 +0000 (15:25 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 12 Nov 2007 15:25:50 +0000 (15:25 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2690 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/DefaultInline/default-inline.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/DynamicCSS/dynamiccss.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/InlineCSS/inlinecss.js
typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php

index 91136a9..fed3c7a 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2007-11-12  Oliver Hader  <oh@inpublica.de>
 
        * (minor) Fixed bug #6696: Parts of the TYPO3 back-end do not work correctly with prototype.js 1.6.0
+       * Feature #6579 continued: Backtracking on the use of Prototype.js by htmlArea RTE.
 
 2007-11-11  Ingmar Schlecht  <ingmar@typo3.org>
 
index 7ca809f..4c4c665 100644 (file)
@@ -1,3 +1,7 @@
+2007-11-12  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
+
+       * Feature #6579 continued: Backtracking on the use of Prototype.js by htmlArea RTE.
+
 2007-11-10  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * (cleanup) Protect rtehtmlarea 'for' loops from properties possibly added by JS frameworks.
index eff19c8..410132b 100644 (file)
@@ -568,7 +568,6 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                <link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />';
                        
                                // Loading JavaScript files and code
-                       //$this->TCEform->loadJavascriptLib('prototype');
                        $this->TCEform->additionalCode_pre['loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
                        $this->TCEform->additionalJS_pre['loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
 
@@ -914,7 +913,6 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                </script>';
                $loadJavascriptCode .= '
                <script type="text/javascript" src="' . $this->buildJSMainLangFile($RTEcounter) . '"></script>
-               <script type="text/javascript" src="'. ($this->is_FE()?'/typo3/':'') . 'contrib/prototype/prototype.js"></script>
                <script type="text/javascript" src="' . $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea.js', "htmlarea") . '"></script>
                ';
                return $loadJavascriptCode;
index c7493d9..9056cf0 100644 (file)
@@ -122,7 +122,8 @@ HTMLArea.onload = function(){
 };
 HTMLArea.loadTimer;
 HTMLArea._scripts = [];
-HTMLArea.scriptLoaded = [];
+HTMLArea._scriptLoaded = [];
+HTMLArea._request = [];
 HTMLArea.loadScript = function(url, plugin) {
        if (plugin) url = _editor_url + "/plugins/" + plugin + '/' + url;
        if (HTMLArea.is_opera) url = _typo3_host_url + url;
@@ -134,32 +135,55 @@ if(HTMLArea.is_gecko) HTMLArea.loadScript(RTEarea[0]["htmlarea-gecko"] ? RTEarea
 if(HTMLArea.is_ie) HTMLArea.loadScript(RTEarea[0]["htmlarea-ie"] ? RTEarea[0]["htmlarea-ie"] : _editor_url + "htmlarea-ie.js");
 
 /*
- * Get a script using an asynchronous request
+ * Get a script using asynchronous XMLHttpRequest
  */
-HTMLArea._getScript = function (i, asynchronous, url) {
-       if (typeof(url) === "undefined") {
+HTMLArea.MSXML_XMLHTTP_PROGIDS = new Array("Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP");
+HTMLArea.XMLHTTPResponseHandler = function (i) {
+       return (function() {
                var url = HTMLArea._scripts[i];
-       }
-       if (typeof(asynchronous) === "undefined") {
-               var asynchronous = true;
-       }
-       new Ajax.Request(url, {
-               asynchronous    : asynchronous,
-               method          : "get",
-               onSuccess       : function(transport) {
-                       HTMLArea.scriptLoaded[i] = true;
-                       return true;
-               },
-               onException     : function(transport) {
-                       HTMLArea._appendToLog("ERROR [HTMLArea::getScript]: Unable to get " + url + " . Exception raised: " + transport.statusText);
-                       return false;
-               },
-               onFailure       : function(transport) {
-                       HTMLArea._appendToLog("ERROR [HTMLArea::getScript]: Unable to get " + url + " . Server reported " + transport.statusText);
-                       return false;
+               if (HTMLArea._request[i].readyState != 4) return;
+               if (HTMLArea._request[i].status == 200) { 
+                       try {
+                               eval(HTMLArea._request[i].responseText);
+                               HTMLArea._scriptLoaded[i] = true;
+                               i = null;
+                       } catch (e) {
+                               HTMLArea._appendToLog("ERROR [HTMLArea::getScript]: Unable to get script " + url + ": " + e);
+                       }
+               } else {
+                       HTMLArea._appendToLog("ERROR [HTMLArea::getScript]: Unable to get " + url + " . Server reported " + HTMLArea._request[i].status);
                }
        });
 };
+HTMLArea._getScript = function (i,asynchronous,url) {
+       if (typeof(url) == "undefined") var url = HTMLArea._scripts[i];
+       if (typeof(asynchronous) == "undefined") var asynchronous = true;
+       if (window.XMLHttpRequest) HTMLArea._request[i] = new XMLHttpRequest();
+               else if (window.ActiveXObject) {
+                       var success = false;
+                       for (var k = 0; k < HTMLArea.MSXML_XMLHTTP_PROGIDS.length && !success; k++) {
+                               try {
+                                       HTMLArea._request[i] = new ActiveXObject(HTMLArea.MSXML_XMLHTTP_PROGIDS[k]);
+                                       success = true;
+                               } catch (e) { }
+                       }
+                       if (!success) return false;
+               }
+       var request = HTMLArea._request[i];
+       if (request) {
+               request.open("GET", url, asynchronous);
+               if (asynchronous) request.onreadystatechange = HTMLArea.XMLHTTPResponseHandler(i);
+               if (window.XMLHttpRequest) request.send(null);
+                       else if (window.ActiveXObject) request.send();
+               if (!asynchronous) {
+                       if (request.status == 200) return request.responseText;
+                               else return '';
+               }
+               return true;
+       } else {
+               return false;
+       }
+};
 
 /*
  * Wait for the loading process to complete
@@ -167,16 +191,21 @@ HTMLArea._getScript = function (i, asynchronous, url) {
 HTMLArea.checkInitialLoad = function() {
        var scriptsLoaded = true;
        for (var i = HTMLArea._scripts.length; --i >= 0;) {
-               scriptsLoaded = scriptsLoaded && HTMLArea.scriptLoaded[i];
+               scriptsLoaded = scriptsLoaded && HTMLArea._scriptLoaded[i];
        }
-       if (HTMLArea.loadTimer) window.clearTimeout(HTMLArea.loadTimer);
+       if(HTMLArea.loadTimer) window.clearTimeout(HTMLArea.loadTimer);
        if (scriptsLoaded) {
                HTMLArea.is_loaded = true;
                HTMLArea._appendToLog("[HTMLArea::init]: All scripts successfully loaded.");
                HTMLArea._appendToLog("[HTMLArea::init]: Editor url set to: " + _editor_url);
                HTMLArea._appendToLog("[HTMLArea::init]: Editor skin CSS set to: " + _editor_CSS);
                HTMLArea._appendToLog("[HTMLArea::init]: Editor content skin CSS set to: " + _editor_edited_content_CSS);
-               return true;
+               if (window.ActiveXObject) {
+                       for (var i = HTMLArea._scripts.length; --i >= 0;) {
+                               HTMLArea._request[i].onreadystatechange = new Function();
+                               HTMLArea._request[i] = null;
+                       }
+               }
        } else {
                HTMLArea.loadTimer = window.setTimeout("HTMLArea.checkInitialLoad();", 200);
                return false;
@@ -188,10 +217,21 @@ HTMLArea.checkInitialLoad = function() {
  */
 HTMLArea.init = function() {
        HTMLArea._eventCache = HTMLArea._eventCacheConstructor();
-       for (var i = HTMLArea._scripts.length; --i >= 0;) {
-               HTMLArea._getScript(i);
+       if (window.XMLHttpRequest || window.ActiveXObject) {
+               try { 
+                       var success = true;
+                       for (var i = HTMLArea._scripts.length; --i >= 0 && success;) success = success && HTMLArea._getScript(i);
+               } catch (e) {
+                       HTMLArea._appendToLog("ERROR [HTMLArea::init]: Unable to use XMLHttpRequest: "+ e);
+               }
+               if (success) {
+                       HTMLArea.checkInitialLoad();
+               } else {
+                       if (HTMLArea.is_ie) window.setTimeout('if (window.document.getElementById("pleasewait1")) { window.document.getElementById("pleasewait1").innerHTML = HTMLArea.I18N.msg["ActiveX-required"]; } else { alert(HTMLArea.I18N.msg["ActiveX-required"]); };', 200);
+               }
+       } else {
+               if (HTMLArea.is_ie) alert(HTMLArea.I18N.msg["ActiveX-required"]);
        }
-       HTMLArea.checkInitialLoad();
 };
 
 /*
@@ -3103,19 +3143,123 @@ HTMLArea.allElementsAreDisplayed = function(elements) {
 };
 
 /**
- * htmlArea plugin class using the Prototype JavaScript framework
+ *     Base, version 1.0.2
+ *     Copyright 2006, Dean Edwards
+ *     License: http://creativecommons.org/licenses/LGPL/2.1/
  */
-HTMLArea.plugin = Class.create( {
-       
-       /**
-        * Class constructor
-        *
-        * @param       object          editor: instance of RTE
-        * @param       string          pluginName: name of the plugin
-        *
-        * @return      boolean         true if the plugin was configured
-        */
-       initialize : function(editor, pluginName) {
+
+HTMLArea.Base = function() {
+       if (arguments.length) {
+               if (this == window) { // cast an object to this class
+                       HTMLArea.Base.prototype.extend.call(arguments[0], arguments.callee.prototype);
+               } else {
+                       this.extend(arguments[0]);
+               }
+       }
+};
+
+HTMLArea.Base.version = "1.0.2";
+
+HTMLArea.Base.prototype = {
+       extend: function(source, value) {
+               var extend = HTMLArea.Base.prototype.extend;
+               if (arguments.length == 2) {
+                       var ancestor = this[source];
+                       // overriding?
+                       if ((ancestor instanceof Function) && (value instanceof Function) &&
+                               ancestor.valueOf() != value.valueOf() && /\bbase\b/.test(value)) {
+                               var method = value;
+                       //      var _prototype = this.constructor.prototype;
+                       //      var fromPrototype = !Base._prototyping && _prototype[source] == ancestor;
+                               value = function() {
+                                       var previous = this.base;
+                               //      this.base = fromPrototype ? _prototype[source] : ancestor;
+                                       this.base = ancestor;
+                                       var returnValue = method.apply(this, arguments);
+                                       this.base = previous;
+                                       return returnValue;
+                               };
+                               // point to the underlying method
+                               value.valueOf = function() {
+                                       return method;
+                               };
+                               value.toString = function() {
+                                       return String(method);
+                               };
+                       }
+                       return this[source] = value;
+               } else if (source) {
+                       var _prototype = {toSource: null};
+                       // do the "toString" and other methods manually
+                       var _protected = ["toString", "valueOf"];
+                       // if we are prototyping then include the constructor
+                       if (HTMLArea.Base._prototyping) _protected[2] = "constructor";
+                       for (var i = 0; (name = _protected[i]); i++) {
+                               if (source[name] != _prototype[name]) {
+                                       extend.call(this, name, source[name]);
+                               }
+                       }
+                       // copy each of the source object's properties to this object
+                       for (var name in source) {
+                               if (!_prototype[name]) {
+                                       extend.call(this, name, source[name]);
+                               }
+                       }
+               }
+               return this;
+       },
+
+       base: function() {
+               // call this method from any other method to invoke that method's ancestor
+       }
+};
+
+HTMLArea.Base.extend = function(_instance, _static) {
+       var extend = HTMLArea.Base.prototype.extend;
+       if (!_instance) _instance = {};
+       // build the prototype
+       HTMLArea.Base._prototyping = true;
+       var _prototype = new this;
+       extend.call(_prototype, _instance);
+       var constructor = _prototype.constructor;
+       _prototype.constructor = this;
+       delete HTMLArea.Base._prototyping;
+       // create the wrapper for the constructor function
+       var klass = function() {
+               if (!HTMLArea.Base._prototyping) constructor.apply(this, arguments);
+               this.constructor = klass;
+       };
+       klass.prototype = _prototype;
+       // build the class interface
+       klass.extend = this.extend;
+       klass.implement = this.implement;
+       klass.toString = function() {
+               return String(constructor);
+       };
+       extend.call(klass, _static);
+       // single instance
+       var object = constructor ? klass : _prototype;
+       // class initialisation
+       if (object.init instanceof Function) object.init();
+       return object;
+};
+
+HTMLArea.Base.implement = function(_interface) {
+       if (_interface instanceof Function) _interface = _interface.prototype;
+       this.prototype.extend(_interface);
+};
+
+/**
+ * HTMLArea. plugin constructor
+ *
+ * @param      object          editor: instance of RTE
+ * @param      string          pluginName: name of the plugin
+ *
+ * @return     boolean         true if the plugin was configured
+ */
+HTMLArea.plugin = HTMLArea.Base.extend({
+
+       constructor : function(editor, pluginName) {
                this.editor = editor;
                this.editorNumber = editor._editorNumber;
                this.editorConfiguration = editor.config;
index d36df8f..48d3cc8 100644 (file)
  *
  * TYPO3 SVN ID: $Id$
  */
-DefaultInline = Class.create(HTMLArea.plugin, {
+DefaultInline = HTMLArea.plugin.extend({
+               
+       constructor : function(editor, pluginName) {
+               this.base(editor, pluginName);
+       },
        
        /*
         * This function gets called by the class constructor
@@ -64,31 +68,8 @@ DefaultInline = Class.create(HTMLArea.plugin, {
                        this.registerButton(buttonConfiguration);
                }
                return true;
-       }
-});
-
-/* The list of buttons added by this plugin */
-DefaultInline.buttonList = [
-       ["Bold", null],
-       ["Italic", null],
-       ["StrikeThrough", null],
-       ["Subscript", null],
-       ["Superscript", null],
-       ["Underline", null]
-];
-
-/* The list of hotkeys handled by this plugin */
-DefaultInline.hotKeyList = {
-       b : "Bold",
-       i : "Italic",
-       s : "StrikeThrough",
-       u : "Underline"
-};
-
-/*
- * Definition of additional methods
- */
-DefaultInline.addMethods({
+        },
+        
        /*
         * This function gets called when some inline element button was pressed.
         */
@@ -136,4 +117,23 @@ DefaultInline.addMethods({
                        button.state("active", commandState);
                }
        }
-});
\ No newline at end of file
+});
+
+/* The list of buttons added by this plugin */
+DefaultInline.buttonList = [
+       ["Bold", null],
+       ["Italic", null],
+       ["StrikeThrough", null],
+       ["Subscript", null],
+       ["Superscript", null],
+       ["Underline", null]
+];
+
+/* The list of hotkeys handled by this plugin */
+DefaultInline.hotKeyList = {
+       b : "Bold",
+       i : "Italic",
+       s : "StrikeThrough",
+       u : "Underline"
+};
+
index a0d6c38..0e73503 100644 (file)
@@ -155,7 +155,7 @@ DynamicCSS.applyCSSRule=function(editor,i18n,cssRules,cssArray){
 DynamicCSS.applyCSSIEImport = function(editor,i18n,cssIEImport,cssArray){
        var newCssArray = new Object();
        newCssArray = cssArray;
-       for(var i=0;i<cssIEImport.length;i++){
+       for (var i=0;i<cssIEImport.length;i++){
                if(cssIEImport[i].imports){
                        newCssArray = DynamicCSS.applyCSSIEImport(editor,i18n,cssIEImport[i].imports,newCssArray);
                }
@@ -313,7 +313,7 @@ DynamicCSS.prototype.updateValue = function(editor,obj) {
                className = parent.className;
                if(HTMLArea.reservedClassNames.test(className)) {
                        var cls = className.split(" ");
-                       for(var i = cls.length; i > 0;) if(!HTMLArea.reservedClassNames.test(cls[--i])) className = cls[i];
+                       for (var i = cls.length; i > 0;) if(!HTMLArea.reservedClassNames.test(cls[--i])) className = cls[i];
                }
        }
        if(obj.lastTag != tagName || obj.lastClass != className){
@@ -326,19 +326,23 @@ DynamicCSS.prototype.updateValue = function(editor,obj) {
                                // style class only allowed if parent tag is not body or editor is in fullpage mode
                        if(tagName != 'body' || editor.config.fullPage){
                                if(cssArray[tagName]){
-                                       for(cssClass in cssArray[tagName]){
-                                               if(cssClass == 'none') {
-                                                       select.options[0] = new Option(cssArray[tagName][cssClass],cssClass);
-                                               } else {
-                                                       select.options[select.options.length] = new Option(cssArray[tagName][cssClass],cssClass);
-                                                       if (!editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
+                                       for (cssClass in cssArray[tagName]){
+                                               if (cssArray[tagName].hasOwnProperty(cssClass)) {
+                                                       if (cssClass == 'none') {
+                                                               select.options[0] = new Option(cssArray[tagName][cssClass],cssClass);
+                                                       } else {
+                                                               select.options[select.options.length] = new Option(cssArray[tagName][cssClass],cssClass);
+                                                               if (!editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
+                                                       }
                                                }
                                        }
                                }
-                               if(cssArray['all']){
-                                       for(cssClass in cssArray['all']){
-                                               select.options[select.options.length] = new Option(cssArray['all'][cssClass],cssClass);
-                                               if (!editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
+                               if (cssArray['all']){
+                                       for (cssClass in cssArray['all']){
+                                               if (cssArray['all'].hasOwnProperty(cssClass)) {
+                                                       select.options[select.options.length] = new Option(cssArray['all'][cssClass],cssClass);
+                                                       if (!editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
+                                               }
                                        }
                                }
                        } else {
index 9cc7368..bbb049b 100644 (file)
  *
  * TYPO3 SVN ID: $Id$
  */
-
-InlineCSS = Class.create(HTMLArea.plugin, {
+InlineCSS = HTMLArea.plugin.extend({
+               
+       constructor : function(editor, pluginName) {
+               this.base(editor, pluginName);
+       },
        
        /*
         * This function gets called by the class constructor
@@ -72,107 +75,8 @@ InlineCSS = Class.create(HTMLArea.plugin, {
                this.registerDropDown(dropDownConfiguration);
                
                return true;
-       }
-});
-
-InlineCSS.parseStyleSheet = function(editor){
-       var obj = editor.config.customSelects["InlineCSS-class"];
-       var iframe = editor._iframe.contentWindow ? editor._iframe.contentWindow.document : editor._iframe.contentDocument;
-       var newCssArray = new Object();
-       obj.loaded = true;
-       for(var i=0;i<iframe.styleSheets.length;i++){
-                       // Mozilla
-            if(HTMLArea.is_gecko){
-                       try{ newCssArray = InlineCSS.applyCSSRule(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].cssRules,newCssArray); }
-                       catch(e){ obj.loaded = false; }
-               } else {
-                       try{
-                                       // @import StyleSheets (IE)
-                               if(iframe.styleSheets[i].imports){
-                                       newCssArray = InlineCSS.applyCSSIEImport(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].imports,newCssArray);
-                               }
-                               if(iframe.styleSheets[i].rules){
-                                       newCssArray = InlineCSS.applyCSSRule(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].rules,newCssArray);
-                               }
-                       } catch(e) { obj.loaded = false; }
-               }
-       }
-       return newCssArray;
-};
-
-InlineCSS.applyCSSRule = function(editor,i18n,cssRules,cssArray){
-       var cssElements = new Array();
-       var cssElement = new Array();
-       var newCssArray = new Object();
-       var tagName, className, rule, k;
-       var obj = editor.config.customSelects["InlineCSS-class"];
-       newCssArray = cssArray;
-       for(rule=0;rule<cssRules.length;rule++){
-                       // StyleRule
-               if(cssRules[rule].selectorText){
-                       if(cssRules[rule].selectorText.search(/:+/)==-1){
-                                       // split equal Styles (Mozilla-specific) e.q. head, body {border:0px}
-                                       // for ie not relevant. returns allways one element
-                               cssElements = cssRules[rule].selectorText.split(",");
-                               for(k=0;k<cssElements.length;k++){
-                                       cssElement = cssElements[k].split(".");
-                                       tagName = cssElement[0].toLowerCase().trim();
-                                       if(!tagName) tagName = 'all';
-                                       className = cssElement[1];
-                                       if( (!obj["classesCharacter"] && (tagName == 'span')) || ((tagName != "all" || obj["showTagFreeClasses"] == true) && obj["classesCharacter"] && obj["classesCharacter"].indexOf(className) != -1)) {
-                                               if(!newCssArray[tagName]) newCssArray[tagName] = new Object();
-                                               if(className){
-                                                       cssName = className;
-                                                       if (HTMLArea.classesLabels) cssName = HTMLArea.classesLabels[className] ? HTMLArea.classesLabels[className] : cssName ;
-                                                       if (tagName != 'all') cssName = '<'+cssName+'>';
-                                               } else {
-                                                       className = 'none';
-                                                       if(tagName == 'all') cssName = i18n["Default"];
-                                                               else cssName = '<'+i18n["Default"]+'>';
-                                               }
-                                               newCssArray[tagName][className] = cssName;
-                                       }
-                               }
-                       }
-               } else {
-                               // ImportRule (Mozilla)
-                       if (cssRules[rule].styleSheet) {
-                               newCssArray = InlineCSS.applyCSSRule(editor, i18n, cssRules[rule].styleSheet.cssRules, newCssArray);
-                       }
-                               // MediaRule (Mozilla)
-                       if (cssRules[rule].cssRules) {
-                               newCssArray = InlineCSS.applyCSSRule(editor, i18n, cssRules[rule].cssRules, newCssArray);
-                       }
-               }
-       }
-       return newCssArray;
-};
-
-InlineCSS.applyCSSIEImport=function(editor,i18n,cssIEImport,cssArray){
-       var newCssArray = new Object();
-       newCssArray = cssArray;
-
-       for(var i=0;i<cssIEImport.length;i++){
-               if(cssIEImport[i].imports){
-                       newCssArray = InlineCSS.applyCSSIEImport(editor,i18n,cssIEImport[i].imports,newCssArray);
-               }
-               if(cssIEImport[i].rules){
-                       newCssArray = InlineCSS.applyCSSRule(editor,i18n,cssIEImport[i].rules,newCssArray);
-               }
-       }
-       return newCssArray;
-};
-
-InlineCSS.getCSSArrayLater = function(editor,instance) {
-       return (function() {
-               instance.getCSSArray(editor);
-       });
-};
-
-/*
- * Definition of additional methods
- */
-InlineCSS.addMethods({
+       },
+       
        onSelect : function(editor, buttonId) {
                var obj = this.editorConfiguration.customSelects[buttonId];
                var tbobj = editor._toolbarObjects[buttonId];
@@ -439,3 +343,98 @@ InlineCSS.addMethods({
                }
        }
 });
+
+InlineCSS.parseStyleSheet = function(editor) {
+       var obj = editor.config.customSelects["InlineCSS-class"];
+       var iframe = editor._iframe.contentWindow ? editor._iframe.contentWindow.document : editor._iframe.contentDocument;
+       var newCssArray = new Object();
+       obj.loaded = true;
+       for(var i=0;i<iframe.styleSheets.length;i++){
+                       // Mozilla
+            if(HTMLArea.is_gecko){
+                       try{ newCssArray = InlineCSS.applyCSSRule(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].cssRules,newCssArray); }
+                       catch(e){ obj.loaded = false; }
+               } else {
+                       try{
+                                       // @import StyleSheets (IE)
+                               if(iframe.styleSheets[i].imports){
+                                       newCssArray = InlineCSS.applyCSSIEImport(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].imports,newCssArray);
+                               }
+                               if(iframe.styleSheets[i].rules){
+                                       newCssArray = InlineCSS.applyCSSRule(editor,HTMLArea.I18N.InlineCSS,iframe.styleSheets[i].rules,newCssArray);
+                               }
+                       } catch(e) { obj.loaded = false; }
+               }
+       }
+       return newCssArray;
+};
+
+InlineCSS.applyCSSRule = function(editor,i18n,cssRules,cssArray){
+       var cssElements = new Array();
+       var cssElement = new Array();
+       var newCssArray = new Object();
+       var tagName, className, rule, k;
+       var obj = editor.config.customSelects["InlineCSS-class"];
+       newCssArray = cssArray;
+       for(rule=0;rule<cssRules.length;rule++){
+                       // StyleRule
+               if(cssRules[rule].selectorText){
+                       if(cssRules[rule].selectorText.search(/:+/)==-1){
+                                       // split equal Styles (Mozilla-specific) e.q. head, body {border:0px}
+                                       // for ie not relevant. returns allways one element
+                               cssElements = cssRules[rule].selectorText.split(",");
+                               for(k=0;k<cssElements.length;k++){
+                                       cssElement = cssElements[k].split(".");
+                                       tagName = cssElement[0].toLowerCase().trim();
+                                       if(!tagName) tagName = 'all';
+                                       className = cssElement[1];
+                                       if( (!obj["classesCharacter"] && (tagName == 'span')) || ((tagName != "all" || obj["showTagFreeClasses"] == true) && obj["classesCharacter"] && obj["classesCharacter"].indexOf(className) != -1)) {
+                                               if(!newCssArray[tagName]) newCssArray[tagName] = new Object();
+                                               if(className){
+                                                       cssName = className;
+                                                       if (HTMLArea.classesLabels) cssName = HTMLArea.classesLabels[className] ? HTMLArea.classesLabels[className] : cssName ;
+                                                       if (tagName != 'all') cssName = '<'+cssName+'>';
+                                               } else {
+                                                       className = 'none';
+                                                       if(tagName == 'all') cssName = i18n["Default"];
+                                                               else cssName = '<'+i18n["Default"]+'>';
+                                               }
+                                               newCssArray[tagName][className] = cssName;
+                                       }
+                               }
+                       }
+               } else {
+                               // ImportRule (Mozilla)
+                       if (cssRules[rule].styleSheet) {
+                               newCssArray = InlineCSS.applyCSSRule(editor, i18n, cssRules[rule].styleSheet.cssRules, newCssArray);
+                       }
+                               // MediaRule (Mozilla)
+                       if (cssRules[rule].cssRules) {
+                               newCssArray = InlineCSS.applyCSSRule(editor, i18n, cssRules[rule].cssRules, newCssArray);
+                       }
+               }
+       }
+       return newCssArray;
+};
+
+InlineCSS.applyCSSIEImport=function(editor,i18n,cssIEImport,cssArray){
+       var newCssArray = new Object();
+       newCssArray = cssArray;
+
+       for(var i=0;i<cssIEImport.length;i++){
+               if(cssIEImport[i].imports){
+                       newCssArray = InlineCSS.applyCSSIEImport(editor,i18n,cssIEImport[i].imports,newCssArray);
+               }
+               if(cssIEImport[i].rules){
+                       newCssArray = InlineCSS.applyCSSRule(editor,i18n,cssIEImport[i].rules,newCssArray);
+               }
+       }
+       return newCssArray;
+};
+
+InlineCSS.getCSSArrayLater = function(editor,instance) {
+       return (function() {
+               instance.getCSSArray(editor);
+       });
+};
+
index 6b0188f..1871633 100644 (file)
@@ -272,7 +272,6 @@ class tx_rtehtmlarea_pi2 extends tx_rtehtmlarea_base {
                
                        // Loading CSS, JavaScript files and code
                $TSFE->additionalHeaderData['htmlArea'] = $additionalCode_loadCSS;
-               //$this->TCEform->loadJavascriptLib('prototype');
                $this->TCEform->additionalJS_initial = $this->loadJSfiles($this->TCEform->RTEcounter);
                $this->TCEform->additionalJS_pre[] = $this->loadJScode($this->TCEform->RTEcounter);