Index: typo3/sysext/rtehtmlarea/mod3/browse_links.php
===================================================================
--- typo3/sysext/rtehtmlarea/mod3/browse_links.php	(révision 4064)
+++ typo3/sysext/rtehtmlarea/mod3/browse_links.php	(copie de travail)
@@ -3,7 +3,7 @@
 *  Copyright notice
 *
 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
-*  (c) 2005-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2005-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -35,7 +35,7 @@
  * $Id$
  *
  * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
- * @author	Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author	Stanislas Rolland <typo3(arobas)sjbr.ca>
  */
 
 error_reporting (E_ALL ^ E_NOTICE);
@@ -55,50 +55,42 @@
  * @subpackage core
  */
 class tx_rtehtmlarea_SC_browse_links {
-	var $mode;
-	var $button = 'link';
+	public $mode = 'rte';
+	public $button = 'link';
+	public $readOnly = false;
+	protected $content = '';
 
 	/**
-	 * Main function, detecting the current mode of the element browser and branching out to internal methods.
+	 * Main function, rendering the element browser in RTE mode.
 	 *
 	 * @return	void
 	 */
 	function main()	{
-		global $BE_USER, $SOBE;
-
-		$this->mode = t3lib_div::_GP('mode');
-		if (!$this->mode)	{
-			$this->mode = 'rte';
-		}
-
-		$this->content = '';
-
-		//altMountPoints
+			// Setting alternative web browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
 		$altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
 		if ($altMountPoints) {
 			$GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
 			$GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
-			$browser_readOnly = true;
+			$this->readOnly = true;
 		}
-			
-			// Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
+			// Setting alternative file browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
 		$altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
 		if ($altMountPoints) {
 			$altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
-			foreach($altMountPoints as $filePathRelativeToFileadmindir)	{
+			foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
 				$GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 0);
 			}
 			$GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
-			$browser_readOnly = true;
+			$this->readOnly = true;
 		}
-			
-			// render type by user func
+			// Render type by user function
 		$browserRendered = false;
-		if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
+		if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
 			foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
 				$browserRenderObj = t3lib_div::getUserObj($classRef);
-				if(is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render'))	{
+				if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render'))	{
 					if ($browserRenderObj->isValid($this->mode, $this)) {
+						$browserRenderObj->readOnly = $this->readOnly;
 						$this->content .=  $browserRenderObj->render($this->mode, $this);
 						$browserRendered = true;
 						break;
@@ -106,39 +98,15 @@
 				}
 			}
 		}
-
-			// if type was not rendered use default rendering functions
-		if(!$browserRendered) {
-
-			$SOBE->browser = t3lib_div::makeInstance('tx_rtehtmlarea_browse_links');
-			$SOBE->browser->init();
-			if ($browser_readOnly) {
-				$SOBE->browser->readOnly = true;	
-			}
-			
-			$modData = $BE_USER->getModuleData('browse_links.php','ses');
-			list($modData, $store) = $SOBE->browser->processSessionData($modData);
-			$BE_USER->pushModuleData('browse_links.php',$modData);
-			
-			
-			
-			
-							// Output the correct content according to $this->mode
-			switch((string)$this->mode)	{
-				case 'rte':
-					$this->content = $SOBE->browser->main_rte();
-				break;
-				case 'db':
-					$this->content = $SOBE->browser->main_db();
-				break;
-				case 'file':
-				case 'filedrag':
-					$this->content = $SOBE->browser->main_file();
-				break;
-				case 'wizard':
-					$this->content = $SOBE->browser->main_rte(1);
-				break;
-			}
+			// If type was not rendered, use default rendering functions
+		if (!$browserRendered) {
+			$GLOBALS['SOBE']->browser = t3lib_div::makeInstance('tx_rtehtmlarea_browse_links');
+			$GLOBALS['SOBE']->browser->readOnly = $this->readOnly;
+			$GLOBALS['SOBE']->browser->init();
+			$modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php','ses');
+			list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
+			$GLOBALS['BE_USER']->pushModuleData('browse_links.php',$modData);
+			$this->content = $GLOBALS['SOBE']->browser->main_rte();
 		}
 	}
 
@@ -150,15 +118,13 @@
 	function printContent()	{
 		echo $this->content;
 	}
-
-
 }
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/browse_links.php'])	{
 	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/browse_links.php']);
 }
 
-// Make instance:
+	// Make instance:
 $SOBE = t3lib_div::makeInstance('tx_rtehtmlarea_SC_browse_links');
 $SOBE->main();
 $SOBE->printContent();
Index: typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php
===================================================================
--- typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php	(révision 4064)
+++ typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php	(copie de travail)
@@ -868,10 +868,8 @@
 	 * @return	string		the html content for the upload form
 	 */
 	protected function insertUploadForm($folderPath) {
-		global $BE_USER;
-		
 		$content = '';
-		if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+		if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB') && !$this->readOnly && count($GLOBALS['FILEMOUNTS'])) {
 			$path = $folderPath;
 			$fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
 			$fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
@@ -886,7 +884,7 @@
 				$uploadForm='';
 			}
 			$content .= $uploadForm;
-			if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
+			if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
 				$content.=$createFolder;
 			}
 		}
Index: typo3/sysext/rtehtmlarea/mod4/select_image.php
===================================================================
--- typo3/sysext/rtehtmlarea/mod4/select_image.php	(révision 4064)
+++ typo3/sysext/rtehtmlarea/mod4/select_image.php	(copie de travail)
@@ -3,7 +3,7 @@
 *  Copyright notice
 *
 *  (c) 1999-2008 Kasper Skaarhoj (kasper@typo3.com)
-*  (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2004-2008 Stanislas Rolland <typo3(arobas)jbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -29,7 +29,7 @@
  * Displays image selector for the RTE
  *
  * @author	Kasper Skaarhoj <kasper@typo3.com>
- * @author	Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author	Stanislas Rolland <typo3(arobas)jbr.ca>
  *
  * $Id$  *
  */
@@ -52,43 +52,35 @@
  * @subpackage core
  */
 class tx_rtehtmlarea_SC_select_image {
-	var $mode;
-	var $button = 'image';
+	public $mode = 'rte';
+	public $button = 'image';
+	public $readOnly = false;
+	protected $content = '';
 
 	/**
-	 * Main function, detecting the current mode of the element browser and branching out to internal methods.
+	 * Main function, rendering the element browser in RTE mode.
 	 *
 	 * @return	void
 	 */
 	function main()	{
-		global $BE_USER, $SOBE;
-
-
-		$this->mode = t3lib_div::_GP('mode');
-		if (!$this->mode)	{
-			$this->mode = 'rte';
-		}
-
-		$this->content = '';
-
-		// Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
+			// Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
 		$altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
 		if ($altMountPoints) {
 			$altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
-			foreach($altMountPoints as $filePathRelativeToFileadmindir)	{
+			foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
 				$GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 0);
 			}
 			$GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
-			$browser_readOnly = true;
+			$this->readOnly = true;
 		}
-		
-			// render type by user func
+			// Rendering type by user function
 		$browserRendered = false;
-		if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
+		if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
 			foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
 				$browserRenderObj = t3lib_div::getUserObj($classRef);
-				if(is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render'))	{
+				if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
 					if ($browserRenderObj->isValid($this->mode, $this)) {
+						$browserRenderObj->readOnly = $this->readOnly;
 						$this->content .=  $browserRenderObj->render($this->mode, $this);
 						$browserRendered = true;
 						break;
@@ -96,20 +88,15 @@
 				}
 			}
 		}
-
-			// if type was not rendered use default rendering functions
-		if(!$browserRendered) {
-
-			$SOBE->browser = t3lib_div::makeInstance('tx_rtehtmlarea_select_image');
-			$SOBE->browser->init();
-			if ($browser_readOnly) {
-				$SOBE->browser->readOnly = true;
-			}
-			$modData = $BE_USER->getModuleData('select_image.php','ses');
-			list($modData, $store) = $SOBE->browser->processSessionData($modData);
-			$BE_USER->pushModuleData('select_image.php',$modData);
-
-			$this->content = $SOBE->browser->main_rte();
+			// If type was not rendered, use default rendering functions
+		if (!$browserRendered) {
+			$GLOBALS['SOBE']->browser = t3lib_div::makeInstance('tx_rtehtmlarea_select_image');
+			$GLOBALS['SOBE']->browser->readOnly = $this->readOnly;
+			$GLOBALS['SOBE']->browser->init();
+			$modData = $GLOBALS['BE_USER']->getModuleData('select_image.php','ses');
+			list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
+			$GLOBALS['BE_USER']->pushModuleData('select_image.php',$modData);
+			$this->content = $GLOBALS['SOBE']->browser->main_rte();
 		}
 	}
 
@@ -121,16 +108,14 @@
 	function printContent()	{
 		echo $this->content;
 	}
-
 }
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/select_image.php'])	{
 	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/select_image.php']);
 }
 
-// Make instance:
+	// Make instance:
 $SOBE = t3lib_div::makeInstance('tx_rtehtmlarea_SC_select_image');
 $SOBE->main();
 $SOBE->printContent();
-
 ?>
