Index: typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
===================================================================
--- typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php	(révision 4296)
+++ typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php	(copie de travail)
@@ -339,55 +339,13 @@
 			 * LOAD CSS AND JAVASCRIPT
 			 * =======================================
 			 */
-
 				// Preloading the pageStyle
-			$filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
-			$this->TCEform->additionalCode_pre['loadCSS'] = '
-		<link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" title="HTMLArea RTE Content CSS" />';
-
-				// Loading the editor skin
-			$skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
-			if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:')  {
-				$skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
-			}
-			if (substr($skinFilename,0,4) == 'EXT:')      {       // extension
-				list($extKey,$local) = explode('/',substr($skinFilename,4),2);
-				$skinFilename='';
-				if (strcmp($extKey,'') &&  t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
-					$skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey) . $local;
-					$skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
-				}
-			} elseif (substr($skinFilename,0,1) != '/') {
-				$skinDir = $this->siteURL.dirname($skinFilename);
-				$skinFilename = $this->siteURL . $skinFilename;
-			} else {
-				$skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
-			}
-			$this->editorCSS = $skinFilename;
-			$this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
-			$this->TCEform->additionalCode_pre['loadCSS'] .= '
-		<link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" />';
-			
-				// Main skin
-			$this->TCEform->additionalCode_pre['loadCSS'] .= '
-		<link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />';
-			
-				// Additional icons from registered plugins
-			foreach ($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] as $pluginId) {
-				if (is_object($this->registeredPlugins[$pluginId])) {
-					$pathToSkin = $this->registeredPlugins[$pluginId]->getPathToSkin();
-					if ($pathToSkin) {
-						$this->TCEform->additionalCode_pre['loadCSS'] .= '
-		<link rel="stylesheet" type="text/css" href="' . $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->registeredPlugins[$pluginId]->getExtensionKey()) . $pathToSkin . '" />';
-					}
-				}
-			}
-			
+			$GLOBALS['SOBE']->doc->JScodeLibArray['rtehtmlarea-contentCSS'] = $this->getPageStyle();
+				// Including RTE skin stylesheets
+			$GLOBALS['SOBE']->doc->JScodeLibArray['rtehtmlarea-skin'] = $this->getSkin();
 				// Loading JavaScript files and code
-			if ($this->TCEform->RTEcounter == 1) {
-				$this->TCEform->additionalCode_pre['loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
-				$this->TCEform->additionalJS_pre['loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
-			}
+			$this->TCEform->additionalCode_pre['rtehtmlarea-loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
+			$this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
 
 			/* =======================================
 			 * DRAW THE EDITOR
@@ -448,6 +406,62 @@
 	}
 
 	/**
+	 * Get links to content style sheet(s)
+	 *
+	 * @return	string	link tag referenceing the content stylesheet
+	 */
+	protected function getPageStyle() {
+			// Get stylesheet file name from Page TSConfig if any
+		$filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
+		return '<link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" title="HTMLArea RTE Content CSS" />';
+	}
+
+	/**
+	 * Get links to skin style sheet(s)
+	 *
+	 * @return	string	link tags referenceing the skin stylesheets
+	 */
+	protected function getSkin() {
+			// Get skin file name from Page TSConfig if any
+		$skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
+		if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:')  {
+			$skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
+		}
+			// Skin provided by some extension
+		if (substr($skinFilename,0,4) == 'EXT:') {
+			list($extKey,$local) = explode('/',substr($skinFilename,4),2);
+			$skinFilename='';
+			if (strcmp($extKey,'') &&  t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
+				$skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey) . $local;
+				$skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
+			}
+		} elseif (substr($skinFilename,0,1) != '/') {
+			$skinDir = $this->siteURL.dirname($skinFilename);
+			$skinFilename = $this->siteURL . $skinFilename;
+		} else {
+			$skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
+		}
+		$this->editorCSS = $skinFilename;
+			// Editing area style sheet
+		$this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
+		$skin = '<link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" title="HTMLArea RTE Editing Area CSS" />';
+			// Main skin
+		$skin .= '
+<link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" title="HTMLArea RTE Skin" />';
+			// Additional icons from registered plugins
+		foreach ($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] as $pluginId) {
+			if (is_object($this->registeredPlugins[$pluginId])) {
+				$pathToSkin = $this->registeredPlugins[$pluginId]->getPathToSkin();
+				if ($pathToSkin) {
+					$skin .= '
+<link rel="stylesheet" type="text/css" href="' . $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->registeredPlugins[$pluginId]->getExtensionKey()) . $pathToSkin . '" />';
+				}
+			}
+		}
+		return $skin;
+	}
+
+	/**
 	 * Initialize toolbar configuration and enable registered plugins
 	 *
 	 * @return	void
@@ -509,7 +523,7 @@
 				$hidePlugins[] = $pluginId;
 			}
 		}
-		$this->pluginEnabledArray = array_diff($this->pluginEnabledArray, $hidePlugins);
+		$this->pluginEnabledArray = array_unique(array_diff($this->pluginEnabledArray, $hidePlugins));
 	}
 	
 	/**
@@ -684,8 +698,9 @@
 				$this->pluginEnabledArray[] = $pluginId;
 			}
 		}
+		$this->pluginEnabledArray = array_unique($this->pluginEnabledArray);
 
-			// Completing the toolbar converion array for htmlArea
+			// Completing the toolbar conversion array for htmlArea
 		foreach ($this->registeredPlugins as $pluginId => $plugin) {
 			if ($this->isPluginEnabled($pluginId)) {
 				$this->convertToolbarForHtmlAreaArray = array_unique(array_merge($this->convertToolbarForHtmlAreaArray, $plugin->getConvertToolbarForHtmlAreaArray()));
@@ -786,7 +801,6 @@
 	 */
 	 
 	function loadJScode($RTEcounter) {
-		global $TYPO3_CONF_VARS;
 		
 		$loadPluginCode = '';
 		foreach ($this->pluginEnabledCumulativeArray[$RTEcounter] as $pluginId) {
Index: typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php
===================================================================
--- typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php	(révision 4296)
+++ typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php	(copie de travail)
@@ -213,53 +213,12 @@
 		 * =======================================
 		 */
 			// Preloading the pageStyle
-		$filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
-		$additionalCode_loadCSS = '
-		<link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" title="HTMLArea RTE Content CSS" />';
-
-			// Loading the editor skin
-		$skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
-		if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:')  {
-			$skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
-		}
-		if (substr($skinFilename,0,4) == 'EXT:')      {       // extension
-			list($extKey,$local) = explode('/',substr($skinFilename,4),2);
-			$skinFilename='';
-			if (strcmp($extKey,'') &&  t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
-				$skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey).$local;
-				$skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
-			}
-		} elseif (substr($skinFilename,0,1) != '/') {
-			$skinDir = $this->siteURL.dirname($skinFilename);
-			$skinFilename = $this->siteURL.$skinFilename;
-		} else {
-			$skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
-		}
-
-		$this->editorCSS = $skinFilename;
-		$this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
-		$additionalCode_loadCSS .= '
-		<link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" />';
-		
-			// Main stylesheet
-		$additionalCode_loadCSS .= '
-		<link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />';
-		
-			// Additional icons from registered plugins
-		foreach ($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] as $pluginId) {
-			if (is_object($this->registeredPlugins[$pluginId])) {
-				$pathToSkin = $this->registeredPlugins[$pluginId]->getPathToSkin();
-				if ($pathToSkin) {
-					$additionalCode_loadCSS .= '
-		<link rel="stylesheet" type="text/css" href="' . $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->registeredPlugins[$pluginId]->getExtensionKey()) . $pathToSkin . '" />';
-				}
-			}
-		}
-		
-			// Loading CSS, JavaScript files and code
-		$TSFE->additionalHeaderData['htmlArea'] = $additionalCode_loadCSS;
+		$GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea-contentCSS'] = $this->getPageStyle();
+			// Loading RTE skin style sheets
+		$GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea-skin'] = $this->getSkin();
+			// Loading JavaScript files and code
 		$this->TCEform->additionalJS_initial = $this->loadJSfiles($this->TCEform->RTEcounter);
-		$this->TCEform->additionalJS_pre[] = $this->loadJScode($this->TCEform->RTEcounter);
+		$this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
 
 		/* =======================================
 		 * DRAW THE EDITOR
