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