* Fixed JS error when opening the TYPO3 image browser and proc.plainImageMode is...
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / mod4 / class.tx_rtehtmlarea_dam_browse_media.php
index 75cb584..e4741f3 100644 (file)
@@ -3,7 +3,7 @@
 *  Copyright notice
 *
 *  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
-*  (c) 2004-2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -49,8 +49,12 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
        var $content;
        var $act;
        var $allowedItems;
+       var $removedProperties = array();
+       var $defaultClass;
        var $plainMaxWidth;
        var $plainMaxHeight;
+       var $lockPlainWidth = 'false';
+       var $lockPlainHeight = 'false';
        var $magicMaxWidth;
        var $magicMaxHeight;
        var $imgPath;
@@ -58,6 +62,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
        var $classesImageJSOptions;
        var $editorNo;
        var $sys_language_content;
+       var $thisConfig;
        var $buttonConfig = array();
        
        /**
@@ -162,9 +167,35 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                
                if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {
                        $this->buttonConfig = $this->thisConfig['buttons.']['image.'];
+                       t3lib_div::loadTCA('tx_dam');
+                       if (is_array($this->buttonConfig['title.']) && is_array($TCA['tx_dam']['columns'][$this->buttonConfig['title.']['useDAMColumn']])) {
+                               $this->imgTitleDAMColumn = $this->buttonConfig['title.']['useDAMColumn'];
+                       }
+                       if (is_array($this->buttonConfig['properties.'])) {
+                               if ($this->buttonConfig['properties.']['removeItems']) {
+                                       $this->removedProperties = t3lib_div::trimExplode(',',$this->buttonConfig['properties.']['removeItems'],1);
+                               }
+                               if (is_array($this->buttonConfig['properties.']['class.']) && trim($this->buttonConfig['properties.']['class.']['default'])) {
+                                       $this->defaultClass = trim($this->buttonConfig['properties.']['class.']['default']);
+                               }
+                       }
+               }
+               
+               if (is_array($this->thisConfig['proc.']) && $this->thisConfig['proc.']['plainImageMode']) {
+                       $plainImageMode = $this->thisConfig['proc.']['plainImageMode'];
+                       $this->lockPlainWidth = ($plainImageMode == 'lockDimensions')?'true':'false';
+                       $this->lockPlainHeight = ($this->lockPlainWidth || $plainImageMode == 'lockRatio' || ($plainImageMode == 'lockRatioWhenSmaller'))?'true':'false';
                }
                
-               $this->allowedItems = explode(',','magic,plain,dragdrop,image,upload');
+               if (!$this->imgTitleDAMColumn) {
+                       $this->imgTitleDAMColumn = 'caption';
+               }
+
+               $this->allowedItems = explode(',','magic,plain,image,upload');
+               $clientInfo = t3lib_div::clientInfo();
+               if ($clientInfo['BROWSER'] !== 'opera') {
+                       $this->allowedItems[] = 'dragdrop';
+               }
                if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
                        $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
                } else {
@@ -198,8 +229,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                if ($this->thisConfig['classesImage']) {
                        $classesImageArray = t3lib_div::trimExplode(',',$this->thisConfig['classesImage'],1);
                        $this->classesImageJSOptions = '<option value=""></option>';
-                       reset($classesImageArray);
-                       while(list(,$class)=each($classesImageArray)) {
+                       foreach ($classesImageArray as $class) {
                                $this->classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
                        }
                }
@@ -219,7 +249,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                $this->doc->docType= 'xhtml_trans';
                $this->doc->backPath = $BACK_PATH;
                
-               $this->getJSCode();
+               //$this->getJSCode();
        }
 
        /**
@@ -248,12 +278,6 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                        $imgObj->mayScaleUp=0;
                        $imgObj->tempPath=PATH_site.$imgObj->tempPath;
                        $imgInfo = $imgObj->getImageDimensions($filepath);
-                       
-                       t3lib_div::loadTCA('tx_dam');
-                       if (is_array($this->buttonConfig['title.']) && is_array($TCA['tx_dam']['columns'][$this->buttonConfig['title.']['useDAMColumn']])) {
-                               $this->imgTitleDAMColumn = $this->buttonConfig['title.']['useDAMColumn'];
-                       }
-                       if (!$this->imgTitleDAMColumn) $this->imgTitleDAMColumn = 'caption';
                        $imgMetaData = tx_dam::meta_getDataForFile($filepath,'uid,pid,alt_text,hpixels,vpixels,'.$this->imgTitleDAMColumn.','.$TCA['tx_dam']['ctrl']['languageField']);
                        $imgMetaData = $this->getRecordOverlay('tx_dam',$imgMetaData,$this->sys_language_content);
                        
@@ -266,6 +290,9 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                                                $destPath =PATH_site.$this->rteImageStorageDir();
                                                if (@is_dir($destPath)) {
                                                        $destName = $fileFunc->getUniqueName($basename,$destPath);
+                                                       if (isset($TYPO3_CONF_VARS['BE']['fileCreateMask'])) {
+                                                               @chmod($destName, $TYPO3_CONF_VARS['BE']['fileCreateMask']);
+                                                       }
                                                        @copy($imgInfo[3],$destName);
                                                        
                                                        $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);
@@ -278,6 +305,9 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                                                                $fI=pathinfo($imgI[3]);
                                                                $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
                                                                $destName = $fileFunc->getUniqueName($mainBase,$destPath);
+                                                               if (isset($TYPO3_CONF_VARS['BE']['fileCreateMask'])) {
+                                                                       @chmod($destName, $TYPO3_CONF_VARS['BE']['fileCreateMask']);
+                                                               }
                                                                @copy($imgI[3],$destName);
                                                                $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
                                                                $this->imageInsertJS($iurl,$imgI[0],$imgI[1],$imgMetaData['alt_text'],$imgMetaData[$this->imgTitleDAMColumn],substr($imgInfo[3],strlen(PATH_site)));
@@ -306,32 +336,19 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
 <head>
        <title>Untitled</title>
 </head>
-<script language="javascript" type="text/javascript">
+<script type="text/javascript">
 /*<![CDATA[*/
-       var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
-       var HTMLArea = window.opener.HTMLArea;
-       function insertImage(file,width,height,alt,title,origFile)      {
-               var styleWidth, styleHeight;
-               styleWidth = parseInt(width);
-               if (isNaN(styleWidth) || styleWidth == 0) {
-                       styleWidth = "auto";
-               } else {
-                       styleWidth += "px";
-               }
-               styleHeight = parseInt(height);
-               if (isNaN(styleHeight) || styleHeight == 0) {
-                       styleHeight = "auto";
-               } else {
-                       styleHeight += "px";
-               }
-               editor.renderPopup_insertImage(\'<img src="\'+file+\'" alt="\'+alt+\'" title="\'+title+\'" style="width: \'+styleWidth+\'; height: \'+styleHeight+\';"'.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?' clickenlargesrc="\'+origFile+\'" clickenlarge="0"':'').' />\');
+       var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
+       var plugin = dialog.plugin;
+       function insertImage(file,width,height,alt,title)       {
+               plugin.insertImage(\'<img src="\'+file+\'"'  . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):'') . ' alt="\'+alt+\'" title="\'+title+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
        }
 /*]]>*/
 </script>
 <body>
 <script type="text/javascript">
 /*<![CDATA[*/
-       insertImage('.t3lib_div::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div::quoteJSvalue($altText,1).','.t3lib_div::quoteJSvalue($titleText,1).','.t3lib_div::quoteJSvalue($origFile,1).');
+       insertImage('.t3lib_div::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div::quoteJSvalue($altText,1).','.t3lib_div::quoteJSvalue($titleText,1).');
 /*]]>*/
 </script>
 </body>
@@ -345,14 +362,15 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
         */
        function getJSCode()    {
                global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
-
+               
                $JScode='
-                       var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
+                       var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
+                       var plugin = dialog.plugin;
                        var HTMLArea = window.opener.HTMLArea;
                        function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)  {
                                return jumpToUrl(\''.$this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&bparams='.$this->bparams.'&insertImage='.'\'+fp);
                        }
-                       function jumpToUrl(URL,anchor)  {       //
+                       function jumpToUrl(URL,anchor)  {
                                var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
                                var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
                                var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content='.$this->sys_language_content.'" : "";
@@ -373,31 +391,49 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                                }
                        }
                        function getCurrentImageRef() {
-                               if (editor._selectedImage) {
-                                       return editor._selectedImage;
+                               if (plugin.image) {
+                                       return plugin.image;
                                } else {
                                        return null;
                                }
                        }
                        function printCurrentImageOptions() {
                                var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
-                               if(classesImage) var styleSelector=\'<select name="iClass" style="width:140px;">' . $this->classesImageJSOptions  . '</select>\';
-                               var floatSelector=\'<select name="iFloat" id="iFloat"><option value="">' . $LANG->getLL('notSet') . '</option><option value="none">' . $LANG->getLL('nonFloating') . '</option><option value="left">' . $LANG->getLL('left') . '</option><option value="right">' . $LANG->getLL('right') . '</option></select>\';
+                               if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $this->classesImageJSOptions  . '</select>\';
+                               var floatSelector=\'<select id="iFloat" name="iFloat"><option value="">' . $LANG->getLL('notSet') . '</option><option value="none">' . $LANG->getLL('nonFloating') . '</option><option value="left">' . $LANG->getLL('left') . '</option><option value="right">' . $LANG->getLL('right') . '</option></select>\';
                                var bgColor=\' class="bgColor4"\';
                                var sz="";
                                sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
+                               '.(in_array('class', $this->removedProperties)?'':'
                                if(classesImage) {
-                                       sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('class').': </td><td>\'+styleSelector+\'</td></tr>\';
-                               }
-                               sz+=\'<tr><td\'+bgColor+\'><label for="iWidth">'.$LANG->getLL('width').': </label></td><td><input type="text" name="iWidth" id="iWidth" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
-                               sz+=\'<tr><td\'+bgColor+\'><label for="iHeight">'.$LANG->getLL('height').': </label></td><td><input type="text" name="iHeight" id="iHeight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
-                               sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" name="iBorder" id="iBorder" value="1" /></td></tr>\';
-                               sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';
-                               sz+=\'<tr><td\'+bgColor+\'><label for="iHspace">'.$LANG->getLL('margin_lr').': </label></td><td><input type="text" name="iHspace" id="iHspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).'></td></tr>\';
-                               sz+=\'<tr><td\'+bgColor+\'><label for="iVspace">'.$LANG->getLL('margin_tb').': </label></td><td><input type="text" name="iVspace" id="iVspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
-                               sz+=\'<tr><td\'+bgColor+\'><label for="iTitle">'.$LANG->getLL('title').': </label></td><td><input type="text" name="iTitle" id="iTitle"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
-                               sz+=\'<tr><td\'+bgColor+\'><label for="iAlt">'.$LANG->getLL('alt').': </label></td><td><input type="text" name="iAlt" id="iAlt"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
-                               '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'if (selectedImageRef && selectedImageRef.getAttribute("clickenlargesrc")) sz+=\'<tr><td\'+bgColor+\'><label for="iClickEnlarge">'.$LANG->sL('LLL:EXT:cms/locallang_ttc.php:image_zoom',1).' </label></td><td><input type="checkbox" name="iClickEnlarge" id="iClickEnlarge" value="1" /></td></tr>\';':'').'
+                                       sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
+                               }')
+                               .(in_array('width', $this->removedProperties)?'':'
+                               if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainWidth .')) {
+                                       sz+=\'<tr><td\'+bgColor+\'><label for="iWidth">'.$LANG->getLL('width').': </label></td><td><input type="text" id="iWidth" name="iWidth" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
+                               }')
+                               .(in_array('height', $this->removedProperties)?'':'
+                               if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainHeight .')) {
+                                       sz+=\'<tr><td\'+bgColor+\'><label for="iHeight">'.$LANG->getLL('height').': </label></td><td><input type="text" id="iHeight" name="iHeight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
+                               }')
+                               .(in_array('border', $this->removedProperties)?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
+                               .(in_array('float', $this->removedProperties)?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
+                               .(in_array('paddingTop', $this->removedProperties)?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingTop">'.$LANG->getLL('padding_top').': </label></td><td><input type="text" id="iPaddingTop" name="iPaddingTop" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).'></td></tr>\';')
+                               .(in_array('paddingRight', $this->removedProperties)?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingRight">'.$LANG->getLL('padding_right').': </label></td><td><input type="text" id="iPaddingRight" name="iPaddingRight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
+                               .(in_array('paddingBottom', $this->removedProperties)?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingBottom">'.$LANG->getLL('padding_bottom').': </label></td><td><input type="text" id="iPaddingBottom" name="iPaddingBottom" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
+                               .(in_array('paddingLeft', $this->removedProperties)?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingLeft">'.$LANG->getLL('padding_left').': </label></td><td><input type="text" id="iPaddingLeft" name="iPaddingLeft" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
+                               .(in_array('title', $this->removedProperties)?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iTitle">'.$LANG->getLL('title').': </label></td><td><input type="text" id="iTitle" name="iTitle"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';')
+                               .(in_array('alt', $this->removedProperties)?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iAlt">'.$LANG->getLL('alt').': </label></td><td><input type="text" id="iAlt" name="iAlt"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';')
+                               .((!$TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] || in_array('clickenlarge', $this->removedProperties))?'':'
+                               sz+=\'<tr><td\'+bgColor+\'><label for="iClickEnlarge">'.$LANG->sL('LLL:EXT:cms/locallang_ttc.php:image_zoom',1).' </label></td><td><input type="checkbox" name="iClickEnlarge" id="iClickEnlarge" value="0" /></td></tr>\';').'
                                sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
                                sz+=\'</form></table>\';
                                return sz;
@@ -405,152 +441,206 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                        function setImageProperties() {
                                var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
                                if (selectedImageRef)   {
-                                       if(document.imageData.iWidth.value && document.imageData.iWidth.value != "auto") {
-                                               selectedImageRef.style.width = document.imageData.iWidth.value + "px";
-                                       } else {
-                                               selectedImageRef.style.width = "auto";
+                                       if (document.imageData.iWidth) {
+                                               if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
+                                                       selectedImageRef.style.width = "";
+                                                       selectedImageRef.width = parseInt(document.imageData.iWidth.value);
+                                               } else {
+                                                       selectedImageRef.style.width = "auto";
+                                               }
                                        }
-                                       selectedImageRef.removeAttribute("width");
-                                       if(document.imageData.iHeight.value && document.imageData.iHeight.value != "auto") {
-                                               selectedImageRef.style.height=document.imageData.iHeight.value + "px";
-                                       } else {
-                                               selectedImageRef.style.height = "auto";
-                                       }
-                                       selectedImageRef.removeAttribute("height");
-
-                                       selectedImageRef.style.paddingTop = "0px";
-                                       selectedImageRef.style.paddingBottom = "0px";
-                                       selectedImageRef.style.paddingRight = "0px";
-                                       selectedImageRef.style.paddingLeft = "0px";
-                                       selectedImageRef.style.padding = "";  // this statement ignored by Mozilla 1.3.1
-                                       if(document.imageData.iVspace.value != "" && !isNaN(parseInt(document.imageData.iVspace.value))) {
-                                               selectedImageRef.style.paddingTop = parseInt(document.imageData.iVspace.value) + "px";
-                                               selectedImageRef.style.paddingBottom = selectedImageRef.style.paddingTop;
-                                       }
-                                       if(document.imageData.iHspace.value != "" && !isNaN(parseInt(document.imageData.iHspace.value))) {
-                                               selectedImageRef.style.paddingRight = parseInt(document.imageData.iHspace.value) + "px";
-                                               selectedImageRef.style.paddingLeft = selectedImageRef.style.paddingRight;
-                                       }
-                                       selectedImageRef.removeAttribute("vspace");
-                                       selectedImageRef.removeAttribute("hspace");
-
-                                       selectedImageRef.title=document.imageData.iTitle.value;
-                                       selectedImageRef.alt=document.imageData.iAlt.value;
-
-                                       selectedImageRef.style.borderStyle = "none";
-                                       selectedImageRef.style.borderWidth = "0px";
-                                       selectedImageRef.style.border = "";  // this statement ignored by Mozilla 1.3.1
-                                       if(document.imageData.iBorder.checked) {
-                                               selectedImageRef.style.borderStyle = "solid";
-                                               selectedImageRef.style.borderWidth = "thin";
-                                       }
-                                       selectedImageRef.removeAttribute("border");
-
-                                       var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
-                                       if (iFloat || selectedImageRef.style.cssFloat || selectedImageRef.style.styleFloat)     {
-                                               if(document.all) {
-                                                       selectedImageRef.style.styleFloat = iFloat;
+                                       if (document.imageData.iHeight) {
+                                               if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
+                                                       selectedImageRef.style.height = "";
+                                                       selectedImageRef.height = parseInt(document.imageData.iHeight.value);
+                                               } else {
+                                                       selectedImageRef.style.height = "auto";
+                                               }
+                                       }
+                                       if (document.imageData.iPaddingTop) {
+                                               if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
+                                                       selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
                                                } else {
-                                                       selectedImageRef.style.cssFloat = iFloat;
+                                                       selectedImageRef.style.paddingTop = "";
                                                }
                                        }
+                                       if (document.imageData.iPaddingRight) {
+                                               if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
+                                                       selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
+                                               } else {
+                                                       selectedImageRef.style.paddingRight = "";
+                                               }
+                                       }
+                                       if (document.imageData.iPaddingBottom) {
+                                               if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
+                                                       selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
+                                               } else {
+                                                       selectedImageRef.style.paddingBottom = "";
+                                               }
+                                       }
+                                       if (document.imageData.iPaddingLeft) {
+                                               if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
+                                                       selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
+                                               } else {
+                                                       selectedImageRef.style.paddingLeft = "";
+                                               }
+                                       }
+                                       if (document.imageData.iTitle) {
+                                               selectedImageRef.title=document.imageData.iTitle.value;
+                                       }
+                                       if (document.imageData.iAlt) {
+                                               selectedImageRef.alt=document.imageData.iAlt.value;
+                                       }
                                        
-                                       if(classesImage) {
+                                       if (document.imageData.iBorder) {
+                                               selectedImageRef.style.borderStyle = "";
+                                               selectedImageRef.style.borderWidth = "";
+                                               selectedImageRef.style.border = "";  // this statement ignored by Mozilla 1.3.1
+                                               selectedImageRef.style.borderTopStyle = "";
+                                               selectedImageRef.style.borderRightStyle = "";
+                                               selectedImageRef.style.borderBottomStyle = "";
+                                               selectedImageRef.style.borderLeftStyle = "";
+                                               selectedImageRef.style.borderTopWidth = "";
+                                               selectedImageRef.style.borderRightWidth = "";
+                                               selectedImageRef.style.borderBottomWidth = "";
+                                               selectedImageRef.style.borderLeftWidth = "";
+                                               if(document.imageData.iBorder.checked) {
+                                                       selectedImageRef.style.borderStyle = "solid";
+                                                       selectedImageRef.style.borderWidth = "thin";
+                                               }
+                                               selectedImageRef.removeAttribute("border");
+                                       }
+                                       
+                                       if (document.imageData.iFloat) {
+                                               var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
+                                               if (iFloat || selectedImageRef.style.cssFloat || selectedImageRef.style.styleFloat) {
+                                                       if (document.all) {
+                                                               selectedImageRef.style.styleFloat = (iFloat != "none") ? iFloat : "";
+                                                       } else {
+                                                               selectedImageRef.style.cssFloat = (iFloat != "none") ? iFloat : "";
+                                                       }
+                                               }
+                                       }
+
+                                       if (classesImage && document.imageData.iClass) {
                                                var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
-                                               if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value))     {
+                                               if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
                                                        selectedImageRef.className = iClass;
+                                               } else {
+                                                       selectedImageRef.className = "";
                                                }
                                        }
                                        
-                                       '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'
-                                       if (document.imageData.iClickEnlarge && document.imageData.iClickEnlarge.checked) selectedImageRef.setAttribute("clickenlarge","1");
-                                               else selectedImageRef.setAttribute("clickenlarge","0");':'').'
-                                       
-                                       HTMLArea.edHidePopup();
+                                       if (document.imageData.iClickEnlarge) {
+                                               if (document.imageData.iClickEnlarge.checked) {
+                                                       selectedImageRef.setAttribute("clickenlarge","1");
+                                               } else {
+                                                       selectedImageRef.removeAttribute("clickenlarge");
+                                               }
+                                       }
+                                       dialog.close();
                                }
                                return false;
                        }
                        function insertImagePropertiesInForm()  {
                                var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
                                if (selectedImageRef)   {
-                                       var styleWidth, styleHeight, paddingTop, paddingRight;
-                                       styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
-                                       styleWidth = parseInt(styleWidth);
-                                       if (isNaN(styleWidth) || styleWidth == 0) { styleWidth = "auto"; }
-                                       document.imageData.iWidth.value = styleWidth;
-                                       styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
-                                       styleHeight = parseInt(styleHeight);
-                                       if (isNaN(styleHeight) || styleHeight == 0) { styleHeight = "auto"; }
-                                       document.imageData.iHeight.value = styleHeight;
-
-                                       paddingTop = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
-                                       paddingTop = parseInt(paddingTop);
-                                       if (isNaN(paddingTop) || paddingTop < 0) { paddingTop = ""; }
-                                       document.imageData.iVspace.value = paddingTop;
-                                       paddingRight = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
-                                       paddingRight = parseInt(paddingRight);
-                                       if (isNaN(paddingRight) || paddingRight < 0) { paddingRight = ""; }
-                                       document.imageData.iHspace.value = paddingRight;
-
-                                       document.imageData.iTitle.value = selectedImageRef.title;
-                                       document.imageData.iAlt.value = selectedImageRef.alt;
-
-                                       if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
-                                               document.imageData.iBorder.checked = 1;
-                                       }
-
-                                       var fObj=document.imageData.iFloat;
-                                       var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
-                                       var l=fObj.length;
-                                       for (a=0;a<l;a++)       {
-                                               if (fObj.options[a].value == value)     {
-                                                       fObj.selectedIndex = a;
+                                       var styleWidth, styleHeight, padding;
+                                       if (document.imageData.iWidth) {
+                                               styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
+                                               styleWidth = parseInt(styleWidth);
+                                               if (isNaN(styleWidth) || styleWidth == 0) { styleWidth = "auto"; }
+                                               document.imageData.iWidth.value = styleWidth;
+                                       }
+                                       if (document.imageData.iHeight) {
+                                               styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
+                                               styleHeight = parseInt(styleHeight);
+                                               if (isNaN(styleHeight) || styleHeight == 0) { styleHeight = "auto"; }
+                                               document.imageData.iHeight.value = styleHeight;
+                                       }
+                                       if (document.imageData.iPaddingTop) {
+                                               var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
+                                               var padding = parseInt(padding);
+                                               if (isNaN(padding) || padding <= 0) { padding = ""; }
+                                               document.imageData.iPaddingTop.value = padding;
+                                       }
+                                       if (document.imageData.iPaddingRight) {
+                                               padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
+                                               var padding = parseInt(padding);
+                                               if (isNaN(padding) || padding <= 0) { padding = ""; }
+                                               document.imageData.iPaddingRight.value = padding;
+                                       }
+                                       if (document.imageData.iPaddingBottom) {
+                                               var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
+                                               var padding = parseInt(padding);
+                                               if (isNaN(padding) || padding <= 0) { padding = ""; }
+                                               document.imageData.iPaddingBottom.value = padding;
+                                       }
+                                       if (document.imageData.iPaddingLeft) {
+                                               var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
+                                               var padding = parseInt(padding);
+                                               if (isNaN(padding) || padding <= 0) { padding = ""; }
+                                               document.imageData.iPaddingLeft.value = padding;
+                                       }
+                                       if (document.imageData.iTitle) {
+                                               document.imageData.iTitle.value = selectedImageRef.title;
+                                       }
+                                       if (document.imageData.iAlt) {
+                                               document.imageData.iAlt.value = selectedImageRef.alt;
+                                       }
+                                       if (document.imageData.iBorder) {
+                                               if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
+                                                       document.imageData.iBorder.checked = 1;
+                                               }
+                                       }
+                                       if (document.imageData.iFloat) {
+                                               var fObj=document.imageData.iFloat;
+                                               var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
+                                               var l=fObj.length;
+                                               for (var a=0;a<l;a++)   {
+                                                       if (fObj.options[a].value == value) {
+                                                               fObj.selectedIndex = a;
+                                                       }
                                                }
                                        }
 
-                                       if(classesImage) {
+                                       if (classesImage && document.imageData.iClass) {
                                                var fObj=document.imageData.iClass;
                                                var value=selectedImageRef.className;
                                                var l=fObj.length;
-                                               for (a=0;a<l;a++)       {
+                                               for (var a=0;a < l; a++)        {
                                                        if (fObj.options[a].value == value)     {
                                                                fObj.selectedIndex = a;
                                                        }
                                                }
                                        }
-                                       
-                                       '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'if (selectedImageRef.getAttribute("clickenlargesrc")) {
-                                               if (selectedImageRef.getAttribute("clickenlarge") == "1") document.imageData.iClickEnlarge.checked = 1;
-                                                       else document.imageData.iClickEnlarge.removeAttribute("checked");
-                                       }':'').'
+                                       if (document.imageData.iClickEnlarge) {
+                                               if (selectedImageRef.getAttribute("clickenlarge") == "1") {
+                                                       document.imageData.iClickEnlarge.checked = 1;
+                                               } else {
+                                                       document.imageData.iClickEnlarge.checked = 0;
+                                               }
+                                       }
+                                       return false;
                                }
-                               return false;
-                       }
-
-                       function openDragDrop() {
-                               var url = "' . $BACK_PATH . 'browse_links.php?mode=filedrag&editorNo='.$this->editorNo.'&bparams=|'.implode(':', array($this->editorNo,$this->sys_language_content)).'||"+escape("gif,jpg,jpeg,png");
-                               window.opener.browserWin = window.open(url,"Typo3WinBrowser","height=350,width=600,status=0,menubar=0,resizable=1,scrollbars=1");
-                               HTMLArea.edHidePopup();
                        }
 
-                       var selectedImageRef = getCurrentImageRef();    // Setting this to a reference to the image object.
-
-                       '.($this->act=='dragdrop'?'openDragDrop();':'');
+                       var selectedImageRef = getCurrentImageRef();';  // Setting this to a reference to the image object.
 
                        // Finally, add the accumulated JavaScript to the template object:
-               $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
+               $this->doc->JScodeArray['rtehtmlarea'] = $JScode;
        }
        
        function reinitParams() {
-// We need to pass along some RTE parameters
                if ($this->editorNo) {
                        $pArr = explode('|', $this->bparams);
                        $pArr[1] = implode(':', array($this->editorNo, $this->sys_language_content));
                        $pArr[2] = $this->RTEtsConfigParams;
+                       if ($this->act == 'dragdrop' || $this->act == 'plain') {
+                               $pArr[3] = 'jpg,jpeg,gif,png';
+                       }
                        $this->bparams = implode('|', $pArr);
-                       
                }
-// We need to pass along some RTE parameters
                parent::reinitParams();
        }
        
@@ -561,9 +651,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
         */
        function displayThumbs() {
                global $BE_USER;
-// Honor options.noThumbsInRTEimageSelect              
-               return parent::displayThumbs() && !$BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect');
-// Honor options.noThumbsInRTEimageSelect
+               return parent::displayThumbs() && !$BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect') && ($this->act != 'dragdrop');
        }
        
        /**
@@ -575,9 +663,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                global $BE_USER;
                
                        // Getting flag for showing/not showing thumbnails:
-// Honor options.noThumbsInRTEimageSelect
-               $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInEB') || ($this->mode == 'rte' && $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect'));
-// Honor options.noThumbsInRTEimageSelect
+               $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInEB') || ($this->mode == 'rte' && $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect')) || ($this->act == 'dragdrop');
                if ($noThumbs)  {
                        $thumbNailCheckbox = '';
                } else {
@@ -601,7 +687,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
         * @return      string          HTML output
         */
        function renderFileList($files, $mode='file') {
-               global $LANG;
+               global $LANG, $BACK_PATH, $BE_USER, $TYPO3_CONF_VARS;
 
                $out = '';
 
@@ -609,6 +695,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                if (is_array($files) AND count($files)) {
 
                        $displayThumbs = $this->displayThumbs();
+                       $displayImage = ($this->act === 'dragdrop');
 
                                // Traverse the file list:
                        $lines=array();
@@ -622,7 +709,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                                $titleAttrib = tx_dam_guiFunc::icon_getTitleAttribute($fI);
                                $iconFile = tx_dam::icon_getFileType($fI);
                                $iconTag = tx_dam_guiFunc::icon_getFileTypeImgTag($fI);
-                               $iconAndFilename = $iconTag.htmlspecialchars(t3lib_div::fixed_lgd_cs($fI['file_title'], $GLOBALS['BE_USER']->uc['titleLen']));
+                               $iconAndFilename = $iconTag.htmlspecialchars(t3lib_div::fixed_lgd_cs($fI['file_title'], $BE_USER->uc['titleLen']));
 
 
                                        // Create links for adding the file:
@@ -651,9 +738,9 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
 
                                        // Create link to showing details about the file in a window:
                                if ($fI['__exists']) {
-                                       $Ahref = $GLOBALS['BACK_PATH'].'show_item.php?table='.rawurlencode($fI['file_name_absolute']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
+                                       $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($fI['file_name_absolute']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
                                        $ATag_info = '<a href="'.htmlspecialchars($Ahref).'">';
-                                       $info = $ATag_info.'<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom2.gif', 'width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).'</a>';
+                                       $info = $ATag_info.'<img'.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/zoom2.gif', 'width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).'</a>';
 
                                } else {
                                        $info = '&nbsp;';
@@ -661,21 +748,41 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
 
                                        // Thumbnail/size generation:
                                $clickThumb = '';
-                               if (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fI['file_type']) AND $displayThumbs AND is_file($fI['file_name_absolute'])) {
-// adding $GLOBALS['BACK_PATH']
-                                       $clickThumb = t3lib_BEfunc::getThumbNail($GLOBALS['BACK_PATH'].'thumbs.php', $fI['file_path_absolute'].$fI['file_name'], '');
-// adding $GLOBALS['BACK_PATH']
+                               if (t3lib_div::inList($TYPO3_CONF_VARS['GFX']['imagefile_ext'], $fI['file_type']) AND $displayThumbs AND is_file($fI['file_name_absolute']))    {
+                                       $clickThumb = t3lib_BEfunc::getThumbNail($BACK_PATH.'thumbs.php', $fI['file_path_absolute'].$fI['file_name'], '');
                                        $clickThumb = '<div style="width:56px; overflow:auto; padding: 5px; background-color:#fff; border:solid 1px #ccc;">'.$ATag_insert.$clickThumb.'</a>'.'</div>';
                                } elseif ($displayThumbs) {
                                        $clickThumb = '<div style="width:68px"></div>';
                                }
-
+                               
+                                       // Drag & drop image
+                               if ($displayImage AND t3lib_div::inList($TYPO3_CONF_VARS['GFX']['imagefile_ext'], $fI['file_type']) AND is_file($fI['file_name_absolute']))     {
+                                       if (t3lib_div::_GP('noLimit'))  {
+                                               $maxW=10000;
+                                               $maxH=10000;
+                                       } else {
+                                               $maxW=380;
+                                               $maxH=500;
+                                       }
+                                       $IW = $fI['hpixels'];
+                                       $IH = $fI['vpixels'];
+                                       if ($IW>$maxW)  {
+                                               $IH=ceil($IH/$IW*$maxW);
+                                               $IW=$maxW;
+                                       }
+                                       if ($IH>$maxH)  {
+                                               $IW=ceil($IW/$IH*$maxH);
+                                               $IH=$maxH;
+                                       }
+                                       $clickThumb = '<img src="'.$this->siteUrl.substr($fI['file_name_absolute'],strlen(PATH_site)).'" width="'.$IW.'" height="'.$IH.'"' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):''). ' alt="'.$fI['alt_text'].'" title="'.$fI[$this->imgTitleDAMColumn].'" />';
+                                       $clickThumb = '<div style="width:380px; overflow:auto; padding: 5px; background-color:#fff; border:solid 1px #ccc;">'.$clickThumb.'</div>';
+                               }
 
                                        // Show element:
                                $lines[] = '
                                        <tr class="bgColor4">
-                                               <td valign="top" nowrap="nowrap" style="min-width:20em">'.$ATag_insert.$iconAndFilename.'</a>'.'&nbsp;</td>
-                                               <td valign="top" width="1%">'.$ATag_add.'<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" /></a></td>
+                                               <td valign="top" nowrap="nowrap" style="min-width:20em">'.($displayImage?'':$ATag_insert).$iconAndFilename.'</a>'.'&nbsp;</td>
+                                               <td valign="top" width="1%">'.($displayImage?'':$ATag_add).'<img'.t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/plusbullet2.gif', 'width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" /></a></td>
                                                <td valign="top" nowrap="nowrap" width="1%">'.$info.'</td>
                                        </tr>';
 
@@ -689,7 +796,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                                }
 
 
-                               if ($displayThumbs AND $infoText) {
+                               if (($displayThumbs || $displayImage) AND $infoText) {
                                        $lines[] = '
                                                <tr class="bgColor">
                                                        <td valign="top" colspan="3">
@@ -742,16 +849,15 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
         * @return      array           Array of file elements
         */
        function getFileListArr($allowedFileTypes, $disallowedFileTypes, $mode) {
-               global $TYPO3_CONF_VARS;
+               global $TYPO3_CONF_VARS, $TYPO3_DB;
                
                $filearray = array();
-
                //
                // Use the current selection to create a query and count selected records
                //
 
                $this->damSC->selection->addSelectionToQuery();
-               $this->damSC->selection->qg->query['FROM']['tx_dam'] = tx_dam_db::getMetaInfoFieldList(true, array('hpixels','vpixels','caption'));
+               $this->damSC->selection->qg->query['FROM']['tx_dam'] = tx_dam_db::getMetaInfoFieldList(true, array('hpixels','vpixels',$this->imgTitleDAMColumn,'alt_text'));
                #$this->damSC->selection->qg->addSelectFields(...
                if ($allowedFileTypes) {
                        $extList = '"'.implode ('","', explode(',',$allowedFileTypes)).'"';
@@ -761,12 +867,10 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                        $extList = '"'.implode ('","', explode(',',$disallowedFileTypes)).'"';
                        $this->damSC->selection->qg->addWhere('AND NOT tx_dam.file_type IN ('.$extList.')', 'WHERE', 'NOT tx_dam.file_type');
                }
-// selection with limited dimensions
                if ($this->act == 'plain') {
                        $this->damSC->selection->qg->addWhere('AND tx_dam.hpixels <= '.intval($this->plainMaxWidth), 'WHERE', 'tx_dam.hpixels');
                        $this->damSC->selection->qg->addWhere('AND tx_dam.vpixels <= '.intval($this->plainMaxHeight), 'WHERE', 'tx_dam.vpixels');
                }
-// selection with limited dimensions
                
                $this->damSC->selection->execSelectionQuery(TRUE);
 
@@ -778,7 +882,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                        $this->damSC->selection->execSelectionQuery();
 
                        if($this->damSC->selection->res) {
-                               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($this->damSC->selection->res)) {
+                               while($row = $TYPO3_DB->sql_fetch_assoc($this->damSC->selection->res)) {
 
                                        $row['file_title'] = $row['title'] ? $row['title'] : $row['file_name'];
                                        $row['file_path_absolute'] = tx_dam::path_makeAbsolute($row['file_path']);
@@ -851,7 +955,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                        $menuDef['mail']['isActive'] = $this->act=='dragdrop';
                        $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
                        $menuDef['mail']['url'] = '#';
-                       $menuDef['mail']['addParams'] = 'onClick="openDragDrop();return false;"';
+                       $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=dragdrop&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
                }
                if (in_array('upload', $this->allowedItems)) {
                        $menuDef['upload']['isActive'] = ($this->act=='upload');
@@ -861,6 +965,7 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                }
                $this->content .= $this->doc->getTabMenuRaw($menuDef);
                
+               $pArr = explode('|', $this->bparams);
                switch($this->act)      {
                        case 'image':
                                $JScode = '
@@ -877,8 +982,9 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                                        $this->content.= '<br />';
                                }
                                break;
+                       case 'dragdrop':
                        case 'plain':
-                               $this->allowedFileTypes = 'jpg,jpeg,gif,png';
+                               //$this->allowedFileTypes = t3lib_div::trimExplode(',', $pArr[3], true);
                        case 'magic':
                                $this->addDisplayOptions();
                                $this->content.= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
@@ -895,7 +1001,8 @@ class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
                                break;
                }
                        // Ending page, returning content:
-               $this->content.= $this->doc->endPage();
+               $this->content .= $this->doc->endPage();
+               $this->getJSCode();
                $this->content = $this->damSC->doc->insertStylesAndJS($this->content);
                return $this->content;
        }