Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / mod4 / class.tx_rtehtmlarea_dam_browse_media.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasper@typo3.com)
6 * (c) 2004-2011 Stanislas Rolland <typo3(arobas)sjbr.ca>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * Displays image selector for the RTE
30 *
31 * @author Kasper Skårhøj <kasper@typo3.com>
32 *
33 * $Id$ *
34 */
35 require_once(t3lib_extMgm::extPath('dam').'class.tx_dam_browse_media.php');
36
37 /**
38 * Script Class
39 *
40 * @author Kasper Skårhøj <kasper@typo3.com>
41 * @package TYPO3
42 * @subpackage tx_rte
43 */
44 class tx_rtehtmlarea_dam_browse_media extends tx_dam_browse_media {
45 var $extKey = 'rtehtmlarea';
46 var $content;
47 var $act;
48 var $allowedItems;
49 var $removedProperties = array();
50 var $defaultClass;
51 var $plainMaxWidth;
52 var $plainMaxHeight;
53 var $lockPlainWidth = 'false';
54 var $lockPlainHeight = 'false';
55 var $magicMaxWidth;
56 var $magicMaxHeight;
57 var $imgPath;
58 var $imgTitleDAMColumn = '';
59 var $classesImageJSOptions;
60 var $editorNo;
61 var $sys_language_content;
62 var $thisConfig;
63 var $buttonConfig = array();
64
65 /**
66 * Check if this object should be rendered.
67 *
68 * @param string $type Type: "file", ...
69 * @param object $pObj Parent object.
70 * @return boolean
71 * @see SC_browse_links::main()
72 */
73 function isValid($type, $pObj) {
74 $isValid = false;
75
76 $pArr = explode('|', t3lib_div::_GP('bparams'));
77
78 if ($type=='rte' && $pObj->button == 'image') {
79 $isValid = true;
80 }
81
82 return $isValid;
83 }
84
85 /**
86 * Rendering
87 * Called in SC_browse_links::main() when isValid() returns true;
88 *
89 * @param string $type Type: "file", ...
90 * @param object $pObj Parent object.
91 * @return string Rendered content
92 * @see SC_browse_links::main()
93 */
94 function render($type, $pObj) {
95 global $LANG, $BE_USER, $BACK_PATH;
96
97 $this->pObj = $pObj;
98
99 // init class browse_links
100 $this->init();
101
102 switch((string)$this->mode) {
103 case 'rte':
104 $content = $this->main_rte();
105 break;
106 // case 'wizard':
107 // $content = $this->main_rte(1);
108 // break;
109 default:
110 $content = '';
111 break;
112 }
113
114 return $content;
115 }
116
117 /**
118 * Initialisation
119 *
120 * @return [type] ...
121 */
122 function init() {
123 global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;
124
125 // Main GPvars:
126 $this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
127 $this->act = t3lib_div::_GP('act');
128 $this->expandPage = t3lib_div::_GP('expandPage');
129 $this->expandFolder = t3lib_div::_GP('expandFolder');
130
131 // Find RTE parameters
132 $this->bparams = t3lib_div::_GP('bparams');
133 $this->editorNo = t3lib_div::_GP('editorNo');
134 $this->sys_language_content = t3lib_div::_GP('sys_language_content');
135 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
136 if (!$this->editorNo) {
137 $pArr = explode('|', $this->bparams);
138 $pRteArr = explode(':', $pArr[1]);
139 $this->editorNo = $pRteArr[0];
140 $this->sys_language_content = $pRteArr[1];
141 $this->RTEtsConfigParams = $pArr[2];
142 }
143
144 // Find "mode"
145 $this->mode = t3lib_div::_GP('mode');
146 if (!$this->mode) {
147 $this->mode='rte';
148 }
149
150 // Site URL
151 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); // Current site url
152
153 // the script to link to
154 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
155
156 if (!$this->act) {
157 $this->act='magic';
158 }
159
160 // init fileProcessor
161 $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
162 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
163
164
165 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
166 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
167 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
168 $this->imgPath = $RTEtsConfigParts[6];
169
170 if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {
171 $this->buttonConfig = $this->thisConfig['buttons.']['image.'];
172 t3lib_div::loadTCA('tx_dam');
173 if (is_array($this->buttonConfig['title.']) && is_array($TCA['tx_dam']['columns'][$this->buttonConfig['title.']['useDAMColumn']])) {
174 $this->imgTitleDAMColumn = $this->buttonConfig['title.']['useDAMColumn'];
175 }
176 if (is_array($this->buttonConfig['properties.'])) {
177 if ($this->buttonConfig['properties.']['removeItems']) {
178 $this->removedProperties = t3lib_div::trimExplode(',',$this->buttonConfig['properties.']['removeItems'],1);
179 }
180 if (is_array($this->buttonConfig['properties.']['class.']) && trim($this->buttonConfig['properties.']['class.']['default'])) {
181 $this->defaultClass = trim($this->buttonConfig['properties.']['class.']['default']);
182 }
183 }
184 }
185
186 if (is_array($this->thisConfig['proc.']) && $this->thisConfig['proc.']['plainImageMode']) {
187 $plainImageMode = $this->thisConfig['proc.']['plainImageMode'];
188 $this->lockPlainWidth = ($plainImageMode == 'lockDimensions')?'true':'false';
189 $this->lockPlainHeight = ($this->lockPlainWidth || $plainImageMode == 'lockRatio' || ($plainImageMode == 'lockRatioWhenSmaller'))?'true':'false';
190 }
191
192 if (!$this->imgTitleDAMColumn) {
193 $this->imgTitleDAMColumn = 'caption';
194 }
195
196 $this->allowedItems = explode(',','magic,plain,image,upload');
197 $clientInfo = t3lib_div::clientInfo();
198 if ($clientInfo['BROWSER'] !== 'opera') {
199 $this->allowedItems[] = 'dragdrop';
200 }
201 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
202 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
203 } else {
204 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindImageOptions'],1));
205 }
206
207 reset($this->allowedItems);
208 if (!in_array($this->act,$this->allowedItems)) {
209 $this->act = current($this->allowedItems);
210 }
211
212 if ($this->act == 'magic') {
213 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {
214 if ($this->buttonConfig['options.']['magic.']['maxWidth']) $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];
215 if ($this->buttonConfig['options.']['magic.']['maxHeight']) $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];
216 }
217 // These defaults allow images to be based on their width - to a certain degree - by setting a high height. Then we're almost certain the image will be based on the width
218 if (!$this->magicMaxWidth) $this->magicMaxWidth = 300;
219 if (!$this->magicMaxHeight) $this->magicMaxHeight = 1000;
220 } elseif ($this->act == 'plain') {
221 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {
222 if ($this->buttonConfig['options.']['plain.']['maxWidth']) $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];
223 if ($this->buttonConfig['options.']['plain.']['maxHeight']) $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];
224 }
225 if (!$this->plainMaxWidth) $this->plainMaxWidth = 640;
226 if (!$this->plainMaxHeight) $this->plainMaxHeight = 680;
227 }
228
229 if ($this->thisConfig['classesImage']) {
230 $classesImageArray = t3lib_div::trimExplode(',',$this->thisConfig['classesImage'],1);
231 $this->classesImageJSOptions = '<option value=""></option>';
232 foreach ($classesImageArray as $class) {
233 $this->classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
234 }
235 }
236
237 // init the DAM object
238 $this->initDAM();
239
240 $this->getModSettings();
241
242 $this->processParams();
243
244 // Insert the image if we are done
245 $this->imageInsert();
246
247 // Creating backend template object:
248 $this->doc = t3lib_div::makeInstance('template');
249 $this->doc->backPath = $BACK_PATH;
250 }
251
252 /**
253 * [Describe function...]
254 *
255 * @return [type] ...
256 */
257 function rteImageStorageDir() {
258 $dir = $this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
259 return $dir;
260 }
261
262 /**
263 * [Describe function...]
264 *
265 * @return [type] ...
266 */
267 function imageInsert() {
268 global $TCA,$TYPO3_CONF_VARS;
269
270 if (t3lib_div::_GP('insertImage')) {
271 $filepath = t3lib_div::_GP('insertImage');
272
273 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
274 $imgObj->init();
275 $imgObj->mayScaleUp=0;
276 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
277 $imgInfo = $imgObj->getImageDimensions($filepath);
278 $imgMetaData = tx_dam::meta_getDataForFile($filepath,'uid,pid,alt_text,hpixels,vpixels,'.$this->imgTitleDAMColumn.','.$TCA['tx_dam']['ctrl']['languageField']);
279 $imgMetaData = $this->getRecordOverlay('tx_dam',$imgMetaData,$this->sys_language_content);
280
281 switch ($this->act) {
282 case 'magic':
283 if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir() && is_array($imgMetaData)) {
284 $fI=pathinfo($imgInfo[3]);
285 $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
286 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
287 $destPath =PATH_site.$this->rteImageStorageDir();
288 if (@is_dir($destPath)) {
289 $destName = $fileFunc->getUniqueName($basename,$destPath);
290 @copy($imgInfo[3],$destName);
291 t3lib_div::fixPermissions($destName);
292 $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);
293 $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'),0,$this->magicMaxHeight);
294 if (!$cWidth) $cWidth = $this->magicMaxWidth;
295 if (!$cHeight) $cHeight = $this->magicMaxHeight;
296
297 $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
298 if ($imgI[3]) {
299 $fI=pathinfo($imgI[3]);
300 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
301 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
302 @copy($imgI[3],$destName);
303 t3lib_div::fixPermissions($destName);
304 $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
305 $this->imageInsertJS($iurl,$imgI[0],$imgI[1],$imgMetaData['alt_text'],$imgMetaData[$this->imgTitleDAMColumn],substr($imgInfo[3],strlen(PATH_site)));
306 }
307 }
308 }
309 exit;
310 break;
311 case 'plain':
312 if (is_array($imgInfo) && count($imgInfo)==4 && is_array($imgMetaData)) {
313 $iurl = $this->siteUrl.substr($imgInfo[3],strlen(PATH_site));
314 $this->imageInsertJS($iurl,$imgMetaData['hpixels'],$imgMetaData['vpixels'],$imgMetaData['alt_text'],$imgMetaData[$this->imgTitleDAMColumn],substr($imgInfo[3],strlen(PATH_site)));
315 }
316 exit;
317 break;
318 }
319 }
320 }
321
322 function imageInsertJS($url,$width,$height,$altText,$titleText,$origFile) {
323 global $TYPO3_CONF_VARS;
324
325 echo'
326 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
327 <html>
328 <head>
329 <title>Untitled</title>
330 </head>
331 <script type="text/javascript">
332 /*<![CDATA[*/
333 var plugin = window.parent.RTEarea["' . $this->editorNo . '"].editor.getPlugin("TYPO3Image");
334 function insertImage(file,width,height,alt,title) {
335 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):'') . ' alt="\'+alt+\'" title="\'+title+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
336 }
337 /*]]>*/
338 </script>
339 <body>
340 <script type="text/javascript">
341 /*<![CDATA[*/
342 insertImage('.t3lib_div::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div::quoteJSvalue($altText,1).','.t3lib_div::quoteJSvalue($titleText,1).');
343 /*]]>*/
344 </script>
345 </body>
346 </html>';
347 }
348
349 /**
350 * [Describe function...]
351 *
352 * @return [type] ...
353 */
354 function getJSCode() {
355 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
356
357 $JScode='
358 var plugin = window.parent.RTEarea["' . $editorNo . '"].editor.getPlugin("TYPO3Image");
359 var HTMLArea = window.parent.HTMLArea;
360 var Ext = window.parent.Ext;
361 if (Ext.isWebKit) {
362 plugin.dialog.mon(Ext.get(plugin.dialog.getComponent("content-iframe").getEl().dom.contentWindow.document.documentElement), "dragend", plugin.onDrop, plugin, {single: true});
363 }
364 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) {
365 return jumpToUrl(\''.$this->thisScript.'?act='.$this->act.'&mode='.$this->mode.'&bparams='.$this->bparams.'&insertImage='.'\'+fp);
366 }
367 function jumpToUrl(URL,anchor) {
368 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
369 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
370 var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content='.$this->sys_language_content.'" : "";
371 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div::_GP('RTEtsConfigParams')).'";
372
373 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
374 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
375
376 var theLocation = URL+add_act+add_editorNo+add_sys_language_content+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
377 window.location.href = theLocation;
378 return false;
379 }
380 function launchView(url) {
381 var thePreviewWindow="";
382 thePreviewWindow = window.open("'.$this->siteUrl.TYPO3_mainDir.'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
383 if (thePreviewWindow && thePreviewWindow.focus) {
384 thePreviewWindow.focus();
385 }
386 }
387 function getCurrentImageRef() {
388 if (plugin.image) {
389 return plugin.image;
390 } else {
391 return null;
392 }
393 }
394 function printCurrentImageOptions() {
395 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
396 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $this->classesImageJSOptions . '</select>\';
397 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>\';
398 var bgColor=\' class="bgColor4"\';
399 var sz="";
400 sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
401 '.(in_array('class', $this->removedProperties)?'':'
402 if(classesImage) {
403 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
404 }')
405 .(in_array('width', $this->removedProperties)?'':'
406 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainWidth .')) {
407 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>\';
408 }')
409 .(in_array('height', $this->removedProperties)?'':'
410 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainHeight .')) {
411 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>\';
412 }')
413 .(in_array('border', $this->removedProperties)?'':'
414 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
415 .(in_array('float', $this->removedProperties)?'':'
416 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
417 .(in_array('paddingTop', $this->removedProperties)?'':'
418 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>\';')
419 .(in_array('paddingRight', $this->removedProperties)?'':'
420 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>\';')
421 .(in_array('paddingBottom', $this->removedProperties)?'':'
422 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>\';')
423 .(in_array('paddingLeft', $this->removedProperties)?'':'
424 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>\';')
425 .(in_array('title', $this->removedProperties)?'':'
426 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>\';')
427 .(in_array('alt', $this->removedProperties)?'':'
428 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>\';')
429 .((!$TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] || in_array('clickenlarge', $this->removedProperties))?'':'
430 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>\';').'
431 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
432 sz+=\'</form></table>\';
433 return sz;
434 }
435 function setImageProperties() {
436 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
437 if (selectedImageRef) {
438 if (document.imageData.iWidth) {
439 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
440 selectedImageRef.style.width = "";
441 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
442 }
443 }
444 if (document.imageData.iHeight) {
445 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
446 selectedImageRef.style.height = "";
447 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
448 }
449 }
450 if (document.imageData.iPaddingTop) {
451 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
452 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
453 } else {
454 selectedImageRef.style.paddingTop = "";
455 }
456 }
457 if (document.imageData.iPaddingRight) {
458 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
459 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
460 } else {
461 selectedImageRef.style.paddingRight = "";
462 }
463 }
464 if (document.imageData.iPaddingBottom) {
465 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
466 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
467 } else {
468 selectedImageRef.style.paddingBottom = "";
469 }
470 }
471 if (document.imageData.iPaddingLeft) {
472 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
473 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
474 } else {
475 selectedImageRef.style.paddingLeft = "";
476 }
477 }
478 if (document.imageData.iTitle) {
479 selectedImageRef.title=document.imageData.iTitle.value;
480 }
481 if (document.imageData.iAlt) {
482 selectedImageRef.alt=document.imageData.iAlt.value;
483 }
484
485 if (document.imageData.iBorder) {
486 selectedImageRef.style.borderStyle = "";
487 selectedImageRef.style.borderWidth = "";
488 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
489 selectedImageRef.style.borderTopStyle = "";
490 selectedImageRef.style.borderRightStyle = "";
491 selectedImageRef.style.borderBottomStyle = "";
492 selectedImageRef.style.borderLeftStyle = "";
493 selectedImageRef.style.borderTopWidth = "";
494 selectedImageRef.style.borderRightWidth = "";
495 selectedImageRef.style.borderBottomWidth = "";
496 selectedImageRef.style.borderLeftWidth = "";
497 if(document.imageData.iBorder.checked) {
498 selectedImageRef.style.borderStyle = "solid";
499 selectedImageRef.style.borderWidth = "thin";
500 }
501 selectedImageRef.removeAttribute("border");
502 }
503 if (document.imageData.iFloat) {
504 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
505 if (document.all) {
506 selectedImageRef.style.styleFloat = iFloat ? iFloat : "";
507 } else {
508 selectedImageRef.style.cssFloat = iFloat ? iFloat : "";
509 }
510 }
511 if (classesImage && document.imageData.iClass) {
512 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
513 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
514 selectedImageRef.className = iClass;
515 } else {
516 selectedImageRef.className = "";
517 }
518 }
519
520 if (document.imageData.iClickEnlarge) {
521 if (document.imageData.iClickEnlarge.checked) {
522 selectedImageRef.setAttribute("clickenlarge","1");
523 } else {
524 selectedImageRef.removeAttribute("clickenlarge");
525 }
526 }
527 plugin.close();
528 }
529 return false;
530 }
531 function insertImagePropertiesInForm() {
532 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
533 if (selectedImageRef) {
534 var styleWidth, styleHeight, padding;
535 if (document.imageData.iWidth) {
536 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
537 styleWidth = parseInt(styleWidth);
538 if (!(isNaN(styleWidth) || styleWidth == 0)) {
539 document.imageData.iWidth.value = styleWidth;
540 }
541 }
542 if (document.imageData.iHeight) {
543 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
544 styleHeight = parseInt(styleHeight);
545 if (!(isNaN(styleHeight) || styleHeight == 0)) {
546 document.imageData.iHeight.value = styleHeight;
547 }
548 }
549 if (document.imageData.iPaddingTop) {
550 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
551 var padding = parseInt(padding);
552 if (isNaN(padding) || padding <= 0) { padding = ""; }
553 document.imageData.iPaddingTop.value = padding;
554 }
555 if (document.imageData.iPaddingRight) {
556 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
557 var padding = parseInt(padding);
558 if (isNaN(padding) || padding <= 0) { padding = ""; }
559 document.imageData.iPaddingRight.value = padding;
560 }
561 if (document.imageData.iPaddingBottom) {
562 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
563 var padding = parseInt(padding);
564 if (isNaN(padding) || padding <= 0) { padding = ""; }
565 document.imageData.iPaddingBottom.value = padding;
566 }
567 if (document.imageData.iPaddingLeft) {
568 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
569 var padding = parseInt(padding);
570 if (isNaN(padding) || padding <= 0) { padding = ""; }
571 document.imageData.iPaddingLeft.value = padding;
572 }
573 if (document.imageData.iTitle) {
574 document.imageData.iTitle.value = selectedImageRef.title;
575 }
576 if (document.imageData.iAlt) {
577 document.imageData.iAlt.value = selectedImageRef.alt;
578 }
579 if (document.imageData.iBorder) {
580 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
581 document.imageData.iBorder.checked = 1;
582 }
583 }
584 if (document.imageData.iFloat) {
585 var fObj=document.imageData.iFloat;
586 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
587 var l=fObj.length;
588 for (var a=0;a<l;a++) {
589 if (fObj.options[a].value == value) {
590 fObj.selectedIndex = a;
591 }
592 }
593 }
594
595 if (classesImage && document.imageData.iClass) {
596 var fObj=document.imageData.iClass;
597 var value=selectedImageRef.className;
598 var l=fObj.length;
599 for (var a=0;a < l; a++) {
600 if (fObj.options[a].value == value) {
601 fObj.selectedIndex = a;
602 }
603 }
604 }
605 if (document.imageData.iClickEnlarge) {
606 if (selectedImageRef.getAttribute("clickenlarge") == "1") {
607 document.imageData.iClickEnlarge.checked = 1;
608 } else {
609 document.imageData.iClickEnlarge.checked = 0;
610 }
611 }
612 return false;
613 }
614 }
615
616 var selectedImageRef = getCurrentImageRef();'; // Setting this to a reference to the image object.
617
618 // Finally, add the accumulated JavaScript to the template object:
619 $this->doc->JScodeArray['rtehtmlarea'] = $JScode;
620 }
621
622 function reinitParams() {
623 if ($this->editorNo) {
624 $pArr = explode('|', $this->bparams);
625 $pArr[1] = implode(':', array($this->editorNo, $this->sys_language_content));
626 $pArr[2] = $this->RTEtsConfigParams;
627 if ($this->act == 'dragdrop' || $this->act == 'plain') {
628 $pArr[3] = 'jpg,jpeg,gif,png';
629 }
630 $this->bparams = implode('|', $pArr);
631 }
632 parent::reinitParams();
633 }
634
635 /**
636 * Return true or false whether thumbs should be displayed or not
637 *
638 * @return boolean
639 */
640 function displayThumbs() {
641 global $BE_USER;
642 return parent::displayThumbs() && !$BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect') && ($this->act != 'dragdrop');
643 }
644
645 /**
646 * Create HTML checkbox to enable/disable thumbnail display
647 *
648 * @return string HTML code
649 */
650 function addDisplayOptions() {
651 global $BE_USER;
652
653 // Getting flag for showing/not showing thumbnails:
654 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInEB') || ($this->mode == 'rte' && $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect')) || ($this->act == 'dragdrop');
655 if ($noThumbs) {
656 $thumbNailCheckbox = '';
657 } else {
658
659 $thumbNailCheckbox = t3lib_BEfunc::getFuncCheck('', 'SET[displayThumbs]',$this->displayThumbs(), $this->thisScript, t3lib_div::implodeArrayForUrl('',$this->addParams));
660 $description = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:displayThumbs',1);
661 $id = 'l'.uniqid('tx_dam_scbase');
662 $idAttr = ' id="'.$id.'"';
663 $thumbNailCheckbox = str_replace('<input', '<input'.$idAttr, $thumbNailCheckbox);
664 $thumbNailCheckbox .= ' <label for="'.$id.'">'.$description.'</label>';
665 $this->damSC->addOption('html', 'thumbnailCheckbox', $thumbNailCheckbox);
666 }
667 $this->damSC->addOption('funcCheck', 'extendedInfo', $GLOBALS['LANG']->getLL('displayExtendedInfo',1));
668 }
669
670 /**
671 * Render list of files.
672 *
673 * @param array List of files. See t3lib_div::getFilesInDir
674 * @param string $mode EB mode: "db", "file", ...
675 * @return string HTML output
676 */
677 function renderFileList($files, $mode='file') {
678 global $LANG, $BACK_PATH, $BE_USER, $TYPO3_CONF_VARS;
679
680 $out = '';
681
682 // Listing the files:
683 if (is_array($files) AND count($files)) {
684
685 $displayThumbs = $this->displayThumbs();
686 $displayImage = ($this->act === 'dragdrop');
687
688 // Traverse the file list:
689 $lines=array();
690 foreach($files as $fI) {
691
692 if (!$fI['__exists']) {
693 continue;
694 }
695
696 // Create file icon:
697 $titleAttrib = tx_dam_guiFunc::icon_getTitleAttribute($fI);
698 $iconFile = tx_dam::icon_getFileType($fI);
699 $iconTag = tx_dam_guiFunc::icon_getFileTypeImgTag($fI);
700 $iconAndFilename = $iconTag.htmlspecialchars(t3lib_div::fixed_lgd_cs($fI['file_title'], $BE_USER->uc['titleLen']));
701
702
703 // Create links for adding the file:
704 if (strstr($fI['file_name_absolute'], ',') || strstr($fI['file_name_absolute'], '|')) { // In case an invalid character is in the filepath, display error message:
705 $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'), ', |'));
706 $ATag_insert = '<a href="#" onclick="alert('.$eMsg.');return false;">';
707
708 // If filename is OK, just add it:
709 } else {
710
711 // JS: insertElement(table, uid, type, filename, fpath, filetype, imagefile ,action, close)
712 $onClick_params = implode (', ', array(
713 "'".$fI['_ref_table']."'",
714 "'".$fI['_ref_id']."'",
715 "'".$mode."'",
716 $this->quoteJSvalue($fI['file_name']),
717 $this->quoteJSvalue($fI['_ref_file_path']),
718 "'".$fI['file_type']."'",
719 "'".$iconFile."'")
720 );
721 $onClick = 'return insertElement('.$onClick_params.');';
722 $ATag_add = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.$titleAttrib.'>';
723 $onClick = 'return insertElement('.$onClick_params.', \'\', 1);';
724 $ATag_insert = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.$titleAttrib.'>';
725 }
726
727 // Create link to showing details about the file in a window:
728 if ($fI['__exists']) {
729 $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($fI['file_name_absolute']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
730 $ATag_info = '<a href="'.htmlspecialchars($Ahref).'">';
731 $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>';
732
733 } else {
734 $info = '&nbsp;';
735 }
736
737 // Thumbnail/size generation:
738 $clickThumb = '';
739 if (t3lib_div::inList($TYPO3_CONF_VARS['GFX']['imagefile_ext'], $fI['file_type']) AND $displayThumbs AND is_file($fI['file_name_absolute'])) {
740 $clickThumb = t3lib_BEfunc::getThumbNail($BACK_PATH.'thumbs.php', $fI['file_path_absolute'].$fI['file_name'], '');
741 $clickThumb = '<div style="width:56px; overflow:auto; padding: 5px; background-color:#fff; border:solid 1px #ccc;">'.$ATag_insert.$clickThumb.'</a>'.'</div>';
742 } elseif ($displayThumbs) {
743 $clickThumb = '<div style="width:68px"></div>';
744 }
745
746 // Drag & drop image
747 if ($displayImage AND t3lib_div::inList($TYPO3_CONF_VARS['GFX']['imagefile_ext'], $fI['file_type']) AND is_file($fI['file_name_absolute'])) {
748 if (t3lib_div::_GP('noLimit')) {
749 $maxW=10000;
750 $maxH=10000;
751 } else {
752 $maxW=380;
753 $maxH=500;
754 }
755 $IW = $fI['hpixels'];
756 $IH = $fI['vpixels'];
757 if ($IW>$maxW) {
758 $IH=ceil($IH/$IW*$maxW);
759 $IW=$maxW;
760 }
761 if ($IH>$maxH) {
762 $IW=ceil($IW/$IH*$maxH);
763 $IH=$maxH;
764 }
765 $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].'" />';
766 $clickThumb = '<div style="width:380px; overflow:auto; padding: 5px; background-color:#fff; border:solid 1px #ccc;">'.$clickThumb.'</div>';
767 }
768
769 // Show element:
770 $lines[] = '
771 <tr class="bgColor4">
772 <td valign="top" nowrap="nowrap" style="min-width:20em">'.($displayImage?'':$ATag_insert).$iconAndFilename.'</a>'.'&nbsp;</td>
773 <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>
774 <td valign="top" nowrap="nowrap" width="1%">'.$info.'</td>
775 </tr>';
776
777
778 $infoText = '';
779 if ($this->getModSettings('extendedInfo')) {
780 $infoText = tx_dam_guiFunc::meta_compileInfoData ($fI, 'file_name, file_size:filesize, _dimensions, caption:truncate:50, instructions', 'table');
781 $infoText = str_replace('<table>', '<table border="0" cellpadding="0" cellspacing="1">', $infoText);
782 $infoText = str_replace('<strong>', '<strong style="font-weight:normal;">', $infoText);
783 $infoText = str_replace('</td><td>', '</td><td class="bgColor-10">', $infoText);
784 }
785
786
787 if (($displayThumbs || $displayImage) AND $infoText) {
788 $lines[] = '
789 <tr class="bgColor">
790 <td valign="top" colspan="3">
791 <table border="0" cellpadding="0" cellspacing="0"><tr>
792 <td valign="top">'.$clickThumb.'</td>
793 <td valign="top" style="padding-left:1em">'.$infoText.'</td></tr>
794 </table>
795 <div style="height:0.5em;"></div>
796 </td>
797 </tr>';
798 } elseif ($clickThumb OR $infoText) {
799 $lines[] = '
800 <tr class="bgColor">
801 <td valign="top" colspan="3" style="padding-left:22px">
802 '.$clickThumb.$infoText.'
803 <div style="height:0.5em;"></div>
804 </td>
805 </tr>';
806 }
807
808 $lines[] = '
809 <tr>
810 <td colspan="3"><div style="height:0.5em;"></div></td>
811 </tr>';
812 }
813
814 // Wrap all the rows in table tags:
815 $out .= '
816
817
818
819 <!--
820 File listing
821 -->
822 <table cellpadding="0" cellspacing="0" id="typo3-fileList">
823 '.implode('',$lines).'
824 </table>';
825 }
826
827 // Return accumulated content for filelisting:
828 return $out;
829 }
830
831 /**
832 * Makes a DAM db query and collects data to be used in EB display
833 *
834 * @param string $allowedFileTypes Comma list of allowed file types
835 * @param string $disallowedFileTypes Comma list of disallowed file types
836 * @param string $mode EB mode: "db", "file", ...
837 * @return array Array of file elements
838 */
839 function getFileListArr($allowedFileTypes, $disallowedFileTypes, $mode) {
840 global $TYPO3_CONF_VARS, $TYPO3_DB;
841
842 $filearray = array();
843
844 // Use the current selection to create a query and count selected records
845 $this->damSC->selection->addSelectionToQuery();
846 $this->damSC->selection->qg->query['FROM']['tx_dam'] = tx_dam_db::getMetaInfoFieldList(true, array('hpixels','vpixels',$this->imgTitleDAMColumn,'alt_text'));
847 #$this->damSC->selection->qg->addSelectFields(...
848 if ($allowedFileTypes) {
849 $extList = '"'.implode ('","', explode(',',$allowedFileTypes)).'"';
850 $this->damSC->selection->qg->addWhere('AND tx_dam.file_type IN ('.$extList.')', 'WHERE', 'tx_dam.file_type');
851 }
852 if ($disallowedFileTypes) {
853 $extList = '"'.implode ('","', explode(',',$disallowedFileTypes)).'"';
854 $this->damSC->selection->qg->addWhere('AND NOT tx_dam.file_type IN ('.$extList.')', 'WHERE', 'NOT tx_dam.file_type');
855 }
856 if ($this->act == 'plain') {
857 $this->damSC->selection->qg->addWhere('AND tx_dam.hpixels <= '.intval($this->plainMaxWidth), 'WHERE', 'tx_dam.hpixels');
858 $this->damSC->selection->qg->addWhere('AND tx_dam.vpixels <= '.intval($this->plainMaxHeight), 'WHERE', 'tx_dam.vpixels');
859 }
860
861 $this->damSC->selection->execSelectionQuery(TRUE);
862
863 // any records found?
864 if($this->damSC->selection->pointer->countTotal) {
865
866 // limit query for browsing
867 $this->damSC->selection->addLimitToQuery();
868 $this->damSC->selection->execSelectionQuery();
869
870 if($this->damSC->selection->res) {
871 while($row = $TYPO3_DB->sql_fetch_assoc($this->damSC->selection->res)) {
872
873 $row['file_title'] = $row['title'] ? $row['title'] : $row['file_name'];
874 $row['file_path_absolute'] = tx_dam::path_makeAbsolute($row['file_path']);
875 $row['file_name_absolute'] = $row['file_path_absolute'].$row['file_name'];
876 $row['__exists'] = @is_file($row['file_name_absolute']);
877
878 if ($mode=='db') {
879 $row['_ref_table'] = 'tx_dam';
880 $row['_ref_id'] = $row['uid'];
881 $row['_ref_file_path'] = '';
882 } else {
883 $row['_ref_table'] = '';
884 $row['_ref_id'] = t3lib_div::shortMD5($row['file_name_absolute']);
885 $row['_ref_file_path'] = $row['file_name_absolute'];
886 }
887
888 $filearray[] = $row;
889 if (count($filearray) >= $this->damSC->selection->pointer->itemsPerPage) {
890 break;
891 }
892 }
893 }
894 }
895 return $filearray;
896 }
897
898 /**
899 * [Describe function...]
900 *
901 * @return [type] ...
902 */
903 function main_rte() {
904 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
905
906 $path = tx_dam::path_makeAbsolute($this->damSC->path);
907 if (!$path OR !@is_dir($path)) {
908 // The closest TEMP-path is found
909 $path = $this->fileProcessor->findTempFolder().'/';
910 }
911 // Remove upload tab if filemount is readonly
912 if ($this->isReadOnlyFolder($path)) {
913 $this->allowedItems = array_diff($this->allowedItems, array('upload'));
914 }
915 $this->damSC->path = tx_dam::path_makeRelative($path); // mabe not needed
916
917 // Starting content:
918 $this->content = $this->doc->startPage($LANG->getLL('Insert Image',1));
919
920 $this->reinitParams();
921
922 // Making menu in top:
923 $menuDef = array();
924 if (in_array('image',$this->allowedItems) && ($this->act=='image' || t3lib_div::_GP('cWidth'))) {
925 $menuDef['page']['isActive'] = $this->act=='image';
926 $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
927 $menuDef['page']['url'] = '#';
928 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=image&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
929 }
930 if (in_array('magic',$this->allowedItems)){
931 $menuDef['file']['isActive'] = $this->act=='magic';
932 $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
933 $menuDef['file']['url'] = '#';
934 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=magic&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
935 }
936 if (in_array('plain',$this->allowedItems)) {
937 $menuDef['url']['isActive'] = $this->act=='plain';
938 $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
939 $menuDef['url']['url'] = '#';
940 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=plain&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
941 }
942 if (in_array('dragdrop',$this->allowedItems)) {
943 $menuDef['mail']['isActive'] = $this->act=='dragdrop';
944 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
945 $menuDef['mail']['url'] = '#';
946 $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=dragdrop&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
947 }
948 if (in_array('upload', $this->allowedItems)) {
949 $menuDef['upload']['isActive'] = ($this->act=='upload');
950 $menuDef['upload']['label'] = $LANG->getLL('tx_dam_file_upload.title',1);
951 $menuDef['upload']['url'] = '#';
952 $menuDef['upload']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars($this->thisScript.'?act=upload&mode='.$this->mode.'&bparams='.$this->bparams).'\');return false;"';
953 }
954 $this->content .= $this->doc->getTabMenuRaw($menuDef);
955
956 $pArr = explode('|', $this->bparams);
957 switch($this->act) {
958 case 'image':
959 $JScode = '
960 document.write(printCurrentImageOptions());
961 insertImagePropertiesInForm();';
962 $this->content.= '<br />'.$this->doc->wrapScriptTags($JScode);
963 break;
964 case 'upload':
965 $this->content.= $this->dam_upload($this->allowedFileTypes, $this->disallowedFileTypes);
966 $this->content.= $this->damSC->getOptions();
967 $this->content.='<br /><br />';
968 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
969 $this->content.= $this->createFolder($path);
970 $this->content.= '<br />';
971 }
972 break;
973 case 'dragdrop':
974 case 'plain':
975 //$this->allowedFileTypes = t3lib_div::trimExplode(',', $pArr[3], true);
976 case 'magic':
977 $this->addDisplayOptions();
978 $this->content.= $this->dam_select($this->allowedFileTypes, $this->disallowedFileTypes);
979 $this->content.= $this->damSC->getOptions();
980
981 if ($this->act=='magic') {
982 $this->content .= $this->getMsgBox($LANG->getLL('magicImage_msg'));
983 }
984 if ($this->act=='plain') {
985 $this->content .= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight));
986 }
987 break;
988 default:
989 break;
990 }
991 // Ending page, returning content:
992 $this->content .= $this->doc->endPage();
993 $this->getJSCode();
994 $this->content = $this->damSC->doc->insertStylesAndJS($this->content);
995 return $this->content;
996 }
997
998 /**
999 * Import from t3lib_page in order to create backend version
1000 * Creates language-overlay for records in general (where translation is found in records from the same table)
1001 *
1002 * @param string Table name
1003 * @param array Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField']
1004 * @param integer Pointer to the sys_language uid for content on the site.
1005 * @param string Overlay mode. If "hideNonTranslated" then records without translation will not be returned un-translated but unset (and return value is false)
1006 * @return mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return false if no translation is found.
1007 */
1008 function getRecordOverlay($table,$row,$sys_language_content,$OLmode='') {
1009 global $TCA, $TYPO3_DB;
1010 if ($row['uid']>0 && $row['pid']>0) {
1011 if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) {
1012 if (!$TCA[$table]['ctrl']['transOrigPointerTable']) {
1013 // Will try to overlay a record only if the sys_language_content value is larger that zero.
1014 if ($sys_language_content>0) {
1015 // Must be default language or [All], otherwise no overlaying:
1016 if ($row[$TCA[$table]['ctrl']['languageField']]<=0) {
1017 // Select overlay record:
1018 $res = $TYPO3_DB->exec_SELECTquery(
1019 '*',
1020 $table,
1021 'pid='.intval($row['pid']).
1022 ' AND '.$TCA[$table]['ctrl']['languageField'].'='.intval($sys_language_content).
1023 ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
1024 t3lib_BEfunc::BEenableFields($table).
1025 t3lib_BEfunc::deleteClause($table),
1026 '',
1027 '',
1028 '1'
1029 );
1030 $olrow = $TYPO3_DB->sql_fetch_assoc($res);
1031 //$this->versionOL($table,$olrow);
1032
1033 // Merge record content by traversing all fields:
1034 if (is_array($olrow)) {
1035 foreach($row as $fN => $fV) {
1036 if ($fN!='uid' && $fN!='pid' && isset($olrow[$fN])) {
1037 if ($TCA[$table]['l10n_mode'][$fN]!='exclude' && ($TCA[$table]['l10n_mode'][$fN]!='mergeIfNotBlank' || strcmp(trim($olrow[$fN]),''))) {
1038 $row[$fN] = $olrow[$fN];
1039 }
1040 }
1041 }
1042 } elseif ($OLmode==='hideNonTranslated' && $row[$TCA[$table]['ctrl']['languageField']]==0) { // Unset, if non-translated records should be hidden. ONLY done if the source record really is default language and not [All] in which case it is allowed.
1043 unset($row);
1044 }
1045
1046 // Otherwise, check if sys_language_content is different from the value of the record - that means a japanese site might try to display french content.
1047 } elseif ($sys_language_content!=$row[$TCA[$table]['ctrl']['languageField']]) {
1048 unset($row);
1049 }
1050 } else {
1051 // When default language is displayed, we never want to return a record carrying another language!:
1052 if ($row[$TCA[$table]['ctrl']['languageField']]>0) {
1053 unset($row);
1054 }
1055 }
1056 }
1057 }
1058 }
1059
1060 return $row;
1061 }
1062
1063 }
1064
1065 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_dam_browse_media.php'])) {
1066 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_dam_browse_media.php']);
1067 }
1068
1069 ?>