470b42cfca24edac78a832d835560a84a8b1ca6e
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / mod4 / class.tx_rtehtmlarea_select_image.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 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_typo3.'class.browse_links.php');
37 require_once(PATH_t3lib.'class.t3lib_foldertree.php');
38 require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
39 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
40
41 /**
42 * Local Folder Tree
43 *
44 * @author Kasper Skaarhoj <kasper@typo3.com>
45 * @package TYPO3
46 * @subpackage tx_rte
47 */
48 class tx_rtehtmlarea_image_folderTree extends t3lib_folderTree {
49 var $ext_IconMode=1;
50
51 /**
52 * Wrapping the title in a link, if applicable.
53 *
54 * @param string Title, ready for output.
55 * @param array The "record"
56 * @return string Wrapping title string.
57 */
58 function wrapTitle($title,$v) {
59 if ($this->ext_isLinkable($v)) {
60 $aOnClick = 'return jumpToUrl(\'?editorNo='.$GLOBALS['SOBE']->browser->editorNo.'&expandFolder='.rawurlencode($v['path']).'\');';
61 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
62 } else {
63 return '<span class="typo3-dimmed">'.$title.'</span>';
64 }
65 }
66
67 /**
68 * Returns true if the input "record" contains a folder which can be linked.
69 *
70 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title
71 * @return boolean True is returned if the path is found in the web-part of the the server and is NOT a recycler or temp folder
72 */
73 function ext_isLinkable($v) {
74 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']);
75 if ($GLOBALS['SOBE']->browser->act=='magic') return 1; //$webpath='web'; // The web/non-web path does not matter if the mode is 'magic'
76
77 if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web') {
78 return 0;
79 }
80 return 1;
81 }
82
83 /**
84 * Wrap the plus/minus icon in a link
85 *
86 * @param string HTML string to wrap, probably an image tag.
87 * @param string Command for 'PM' get var
88 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
89 * @return string Link-wrapped input string
90 * @access private
91 */
92 function PM_ATagWrap($icon,$cmd,$bMark='') {
93 if ($bMark) {
94 $anchor = '#'.$bMark;
95 $name=' name="'.$bMark.'"';
96 }
97 $aOnClick = 'return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');';
98 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
99 }
100
101 /**
102 * Print tree.
103 *
104 * @param mixed Input tree array. If not array, then $this->tree is used.
105 * @return string HTML output of the tree.
106 */
107 function printTree($treeArr='') {
108 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
109
110 if (!is_array($treeArr)) $treeArr=$this->tree;
111
112 $out='';
113 $c=0;
114
115 // Traverse rows for the tree and print them into table rows:
116 foreach($treeArr as $k => $v) {
117 $c++;
118 $bgColor=' class="'.(($c+1)%2 ? 'bgColor' : 'bgColor-10').'"';
119 $out.='<tr'.$bgColor.'><td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd($v['row']['title'],$titleLen),$v['row']).'</td></tr>';
120 }
121
122 $out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>';
123 return $out;
124 }
125 }
126
127
128 /**
129 * Script Class
130 *
131 * @author Kasper Skaarhoj <kasper@typo3.com>
132 * @package TYPO3
133 * @subpackage tx_rte
134 */
135 class tx_rtehtmlarea_select_image extends browse_links {
136 var $extKey = 'rtehtmlarea';
137 var $content;
138 var $allowedItems;
139 var $removedProperties = array();
140 var $defaultClass;
141 var $plainMaxWidth;
142 var $plainMaxHeight;
143 var $lockPlainWidth = 'false';
144 var $lockPlainHeight = 'false';
145 var $magicMaxWidth;
146 var $magicMaxHeight;
147 var $imgPath;
148 var $classesImageJSOptions;
149 var $editorNo;
150 var $buttonConfig = array();
151
152 /**
153 * Initialisation
154 *
155 * @return [type] ...
156 */
157 function init() {
158 global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;
159
160 // Main GPvars:
161 $this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
162 $this->act = t3lib_div::_GP('act');
163 $this->editorNo = t3lib_div::_GP('editorNo');
164 $this->expandPage = t3lib_div::_GP('expandPage');
165 $this->expandFolder = t3lib_div::_GP('expandFolder');
166
167 // Find "mode"
168 $this->mode = t3lib_div::_GP('mode');
169 if (!$this->mode) {
170 $this->mode='rte';
171 }
172
173 // Site URL
174 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); // Current site url
175
176 // the script to link to
177 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
178
179 if (!$this->act) {
180 $this->act='magic';
181 }
182
183 $RTEtsConfigParts = explode(':',t3lib_div::_GP('RTEtsConfigParams'));
184 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
185 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
186 $this->imgPath = $RTEtsConfigParts[6];
187
188 if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {
189 $this->buttonConfig = $this->thisConfig['buttons.']['image.'];
190 if (is_array($this->buttonConfig['properties.'])) {
191 if ($this->buttonConfig['properties.']['removeItems']) {
192 $this->removedProperties = t3lib_div::trimExplode(',',$this->buttonConfig['properties.']['removeItems'],1);
193 }
194 if (is_array($this->buttonConfig['properties.']['class.']) && trim($this->buttonConfig['properties.']['class.']['default'])) {
195 $this->defaultClass = trim($this->buttonConfig['properties.']['class.']['default']);
196 }
197 }
198
199 }
200
201 if (is_array($this->thisConfig['proc.']) && $this->thisConfig['proc.']['plainImageMode']) {
202 $plainImageMode = $this->thisConfig['proc.']['plainImageMode'];
203 $this->lockPlainWidth = ($plainImageMode == 'lockDimensions')?'true':'false';
204 $this->lockPlainHeight = ($this->lockPlainWidth || $plainImageMode == 'lockRatio' || ($plainImageMode == 'lockRatioWhenSmaller'))?'true':'false';
205 }
206
207 $this->allowedItems = explode(',','magic,plain,image');
208 $clientInfo = t3lib_div::clientInfo();
209 if ($clientInfo['BROWSER'] !== 'opera') {
210 $this->allowedItems[] = 'dragdrop';
211 }
212 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
213 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
214 } else {
215 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindImageOptions'],1));
216 }
217 reset($this->allowedItems);
218 if (!in_array($this->act,$this->allowedItems)) {
219 $this->act = current($this->allowedItems);
220 }
221
222 if ($this->act == 'plain') {
223 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth']) $this->plainMaxWidth = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth'];
224 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight']) $this->plainMaxHeight = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight'];
225 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {
226 if ($this->buttonConfig['options.']['plain.']['maxWidth']) $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];
227 if ($this->buttonConfig['options.']['plain.']['maxHeight']) $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];
228 }
229 if (!$this->plainMaxWidth) $this->plainMaxWidth = 640;
230 if (!$this->plainMaxHeight) $this->plainMaxHeight = 680;
231 } elseif ($this->act == 'magic') {
232 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {
233 if ($this->buttonConfig['options.']['magic.']['maxWidth']) $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];
234 if ($this->buttonConfig['options.']['magic.']['maxHeight']) $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];
235 }
236 // 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
237 if (!$this->magicMaxWidth) $this->magicMaxWidth = 300;
238 if (!$this->magicMaxHeight) $this->magicMaxHeight = 1000;
239 }
240
241 if ($this->thisConfig['classesImage']) {
242 $classesImageArray = t3lib_div::trimExplode(',',$this->thisConfig['classesImage'],1);
243 $this->classesImageJSOptions = '<option value=""></option>';
244 foreach ($classesImageArray as $class) {
245 $this->classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
246 }
247 }
248
249 $this->magicProcess();
250
251 // Creating backend template object:
252 $this->doc = t3lib_div::makeInstance('template');
253 $this->doc->bodyTagAdditions = 'onLoad="initDialog();"';
254 $this->doc->docType= 'xhtml_trans';
255 $this->doc->backPath = $BACK_PATH;
256
257 $this->getJSCode();
258 }
259
260 /**
261 * [Describe function...]
262 *
263 * @return [type] ...
264 */
265 function rteImageStorageDir() {
266 $dir = $this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
267 return $dir;
268 }
269
270 /**
271 * [Describe function...]
272 *
273 * @return [type] ...
274 */
275 function magicProcess() {
276 global $TYPO3_CONF_VARS;
277
278 if ($this->act=='magic' && t3lib_div::_GP('insertMagicImage')) {
279 $filepath = t3lib_div::_GP('insertMagicImage');
280
281 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
282 $imgObj->init();
283 $imgObj->mayScaleUp=0;
284 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
285
286 $imgInfo = $imgObj->getImageDimensions($filepath);
287
288 if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir()) {
289 $fI=pathinfo($imgInfo[3]);
290 $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
291 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
292 $destPath =PATH_site.$this->rteImageStorageDir();
293 if (@is_dir($destPath)) {
294 $destName = $fileFunc->getUniqueName($basename,$destPath);
295 @copy($imgInfo[3],$destName);
296 t3lib_div::fixPermissions($destName);
297 $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);
298 $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'),0,$this->magicMaxHeight);
299 if (!$cWidth) $cWidth = $this->magicMaxWidth;
300 if (!$cHeight) $cHeight = $this->magicMaxHeight;
301
302 $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
303 if ($imgI[3]) {
304 $fI=pathinfo($imgI[3]);
305 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
306 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
307 @copy($imgI[3],$destName);
308 t3lib_div::fixPermissions($destName);
309 $destName = dirname($destName).'/'.rawurlencode(basename($destName));
310 $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
311 echo'
312 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
313 <html>
314 <head>
315 <title>Untitled</title>
316 </head>
317 <script type="text/javascript">
318 /*<![CDATA[*/
319 var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
320 var plugin = dialog.plugin;
321 function insertImage(file,width,height) {
322 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
323 }
324 /*]]>*/
325 </script>
326 <body>
327 <script type="text/javascript">
328 /*<![CDATA[*/
329 insertImage(\''.$iurl.'\','.$imgI[0].','.$imgI[1].');
330 /*]]>*/
331 </script>
332 </body>
333 </html>';
334 }
335
336 }
337 }
338 exit;
339 }
340 }
341
342 /**
343 * [Describe function...]
344 *
345 * @return [type] ...
346 */
347 function getJSCode() {
348 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
349
350 $JScode='
351 var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
352 var plugin = dialog.plugin;
353 var HTMLArea = window.opener.HTMLArea;
354
355
356 function initDialog() {
357 dialog.captureEvents("skipUnload");
358 }
359 function jumpToUrl(URL,anchor) {
360 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
361 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
362 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div::_GP('RTEtsConfigParams')).'";
363
364 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
365 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
366
367 var theLocation = URL+add_act+add_editorNo+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
368 window.location.href = theLocation;
369 return false;
370 }
371 function insertImage(file,width,height) {
372 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
373 }
374 function launchView(url) {
375 var thePreviewWindow="";
376 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");
377 if (thePreviewWindow && thePreviewWindow.focus) {
378 thePreviewWindow.focus();
379 }
380 }
381 function getCurrentImageRef() {
382 if (plugin.image) {
383 return plugin.image;
384 } else {
385 return null;
386 }
387 }
388 function printCurrentImageOptions() {
389 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
390 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $this->classesImageJSOptions . '</select>\';
391 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>\';
392 var bgColor=\' class="bgColor4"\';
393 var sz="";
394 sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
395 '.(in_array('class', $this->removedProperties)?'':'
396 if(classesImage) {
397 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
398 }')
399 .(in_array('width', $this->removedProperties)?'':'
400 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainWidth .')) {
401 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>\';
402 }')
403 .(in_array('height', $this->removedProperties)?'':'
404 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainHeight .')) {
405 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>\';
406 }')
407 .(in_array('border', $this->removedProperties)?'':'
408 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
409 .(in_array('float', $this->removedProperties)?'':'
410 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
411 .(in_array('paddingTop', $this->removedProperties)?'':'
412 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>\';')
413 .(in_array('paddingRight', $this->removedProperties)?'':'
414 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>\';')
415 .(in_array('paddingBottom', $this->removedProperties)?'':'
416 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>\';')
417 .(in_array('paddingLeft', $this->removedProperties)?'':'
418 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>\';')
419 .(in_array('title', $this->removedProperties)?'':'
420 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>\';')
421 .(in_array('alt', $this->removedProperties)?'':'
422 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>\';')
423 .((!$TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] || in_array('clickenlarge', $this->removedProperties))?'':'
424 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>\';').'
425 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
426 sz+=\'</form></table>\';
427 return sz;
428 }
429 function setImageProperties() {
430 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
431 if (selectedImageRef) {
432 if (document.imageData.iWidth) {
433 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
434 selectedImageRef.style.width = "";
435 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
436 }
437 }
438 if (document.imageData.iHeight) {
439 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
440 selectedImageRef.style.height = "";
441 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
442 }
443 }
444 if (document.imageData.iPaddingTop) {
445 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
446 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
447 } else {
448 selectedImageRef.style.paddingTop = "";
449 }
450 }
451 if (document.imageData.iPaddingRight) {
452 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
453 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
454 } else {
455 selectedImageRef.style.paddingRight = "";
456 }
457 }
458 if (document.imageData.iPaddingBottom) {
459 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
460 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
461 } else {
462 selectedImageRef.style.paddingBottom = "";
463 }
464 }
465 if (document.imageData.iPaddingLeft) {
466 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
467 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
468 } else {
469 selectedImageRef.style.paddingLeft = "";
470 }
471 }
472 if (document.imageData.iTitle) {
473 selectedImageRef.title=document.imageData.iTitle.value;
474 }
475 if (document.imageData.iAlt) {
476 selectedImageRef.alt=document.imageData.iAlt.value;
477 }
478
479 if (document.imageData.iBorder) {
480 selectedImageRef.style.borderStyle = "";
481 selectedImageRef.style.borderWidth = "";
482 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
483 selectedImageRef.style.borderTopStyle = "";
484 selectedImageRef.style.borderRightStyle = "";
485 selectedImageRef.style.borderBottomStyle = "";
486 selectedImageRef.style.borderLeftStyle = "";
487 selectedImageRef.style.borderTopWidth = "";
488 selectedImageRef.style.borderRightWidth = "";
489 selectedImageRef.style.borderBottomWidth = "";
490 selectedImageRef.style.borderLeftWidth = "";
491 if(document.imageData.iBorder.checked) {
492 selectedImageRef.style.borderStyle = "solid";
493 selectedImageRef.style.borderWidth = "thin";
494 }
495 selectedImageRef.removeAttribute("border");
496 }
497
498 if (document.imageData.iFloat) {
499 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
500 if (iFloat || selectedImageRef.style.cssFloat || selectedImageRef.style.styleFloat) {
501 if (document.all) {
502 selectedImageRef.style.styleFloat = (iFloat != "none") ? iFloat : "";
503 } else {
504 selectedImageRef.style.cssFloat = (iFloat != "none") ? iFloat : "";
505 }
506 }
507 }
508
509 if (classesImage && document.imageData.iClass) {
510 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
511 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
512 selectedImageRef.className = iClass;
513 } else {
514 selectedImageRef.className = "";
515 }
516 }
517
518 if (document.imageData.iClickEnlarge) {
519 if (document.imageData.iClickEnlarge.checked) {
520 selectedImageRef.setAttribute("clickenlarge","1");
521 } else {
522 selectedImageRef.removeAttribute("clickenlarge");
523 }
524 }
525 dialog.close();
526 }
527 return false;
528 }
529 function insertImagePropertiesInForm() {
530 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
531 if (selectedImageRef) {
532 var styleWidth, styleHeight, padding;
533 if (document.imageData.iWidth) {
534 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
535 styleWidth = parseInt(styleWidth);
536 if (!(isNaN(styleWidth) || styleWidth == 0)) {
537 document.imageData.iWidth.value = styleWidth;
538 }
539 }
540 if (document.imageData.iHeight) {
541 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
542 styleHeight = parseInt(styleHeight);
543 if (!(isNaN(styleHeight) || styleHeight == 0)) {
544 document.imageData.iHeight.value = styleHeight;
545 }
546 }
547 if (document.imageData.iPaddingTop) {
548 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
549 var padding = parseInt(padding);
550 if (isNaN(padding) || padding <= 0) { padding = ""; }
551 document.imageData.iPaddingTop.value = padding;
552 }
553 if (document.imageData.iPaddingRight) {
554 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
555 var padding = parseInt(padding);
556 if (isNaN(padding) || padding <= 0) { padding = ""; }
557 document.imageData.iPaddingRight.value = padding;
558 }
559 if (document.imageData.iPaddingBottom) {
560 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
561 var padding = parseInt(padding);
562 if (isNaN(padding) || padding <= 0) { padding = ""; }
563 document.imageData.iPaddingBottom.value = padding;
564 }
565 if (document.imageData.iPaddingLeft) {
566 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
567 var padding = parseInt(padding);
568 if (isNaN(padding) || padding <= 0) { padding = ""; }
569 document.imageData.iPaddingLeft.value = padding;
570 }
571 if (document.imageData.iTitle) {
572 document.imageData.iTitle.value = selectedImageRef.title;
573 }
574 if (document.imageData.iAlt) {
575 document.imageData.iAlt.value = selectedImageRef.alt;
576 }
577 if (document.imageData.iBorder) {
578 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
579 document.imageData.iBorder.checked = 1;
580 }
581 }
582 if (document.imageData.iFloat) {
583 var fObj=document.imageData.iFloat;
584 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
585 var l=fObj.length;
586 for (var a=0;a<l;a++) {
587 if (fObj.options[a].value == value) {
588 fObj.selectedIndex = a;
589 }
590 }
591 }
592
593 if (classesImage && document.imageData.iClass) {
594 var fObj=document.imageData.iClass;
595 var value=selectedImageRef.className;
596 var l=fObj.length;
597 for (var a=0;a < l; a++) {
598 if (fObj.options[a].value == value) {
599 fObj.selectedIndex = a;
600 }
601 }
602 }
603 if (document.imageData.iClickEnlarge) {
604 if (selectedImageRef.getAttribute("clickenlarge") == "1") {
605 document.imageData.iClickEnlarge.checked = 1;
606 } else {
607 document.imageData.iClickEnlarge.checked = 0;
608 }
609 }
610 return false;
611 }
612 }
613
614 var selectedImageRef = getCurrentImageRef();'; // Setting this to a reference to the image object.
615
616 // Finally, add the accumulated JavaScript to the template object:
617 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
618 }
619
620 /**
621 * Session data for this class can be set from outside with this method.
622 * Call after init()
623 *
624 * @param array Session data array
625 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
626 */
627 function processSessionData($data) {
628 $store = false;
629
630 if ($this->act != 'image') {
631 if (isset($this->act)) {
632 $data['act'] = $this->act;
633 $store = true;
634 } else {
635 $this->act = $data['act'];
636 }
637 }
638
639 if (isset($this->expandFolder)) {
640 $data['expandFolder'] = $this->expandFolder;
641 $store = true;
642 } else {
643 $this->expandFolder = $data['expandFolder'];
644 }
645
646 return array($data, $store);
647 }
648
649 /**
650 * [Describe function...]
651 *
652 * @return [type] ...
653 */
654 function main_rte() {
655 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
656
657 // Starting content:
658 $this->content = $this->doc->startPage($LANG->getLL('Insert Image',1));
659
660 // Making menu in top:
661 $menuDef = array();
662 if (in_array('image',$this->allowedItems) && ($this->act=='image' || t3lib_div::_GP('cWidth'))) {
663 $menuDef['page']['isActive'] = $this->act=='image';
664 $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
665 $menuDef['page']['url'] = '#';
666 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&editorNo='.$this->editorNo.'\');return false;"';
667 }
668 if (in_array('magic',$this->allowedItems)){
669 $menuDef['file']['isActive'] = $this->act=='magic';
670 $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
671 $menuDef['file']['url'] = '#';
672 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&editorNo='.$this->editorNo.'\');return false;"';
673 }
674 if (in_array('plain',$this->allowedItems)) {
675 $menuDef['url']['isActive'] = $this->act=='plain';
676 $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
677 $menuDef['url']['url'] = '#';
678 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&editorNo='.$this->editorNo.'\');return false;"';
679 }
680 if (in_array('dragdrop',$this->allowedItems)) {
681 $menuDef['mail']['isActive'] = $this->act=='dragdrop';
682 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
683 $menuDef['mail']['url'] = '#';
684 $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&editorNo='.$this->editorNo.'&bparams=|||\'+escape(\'gif,jpg,jpeg,png\'));return false;"';
685 }
686 $this->content .= $this->doc->getTabMenuRaw($menuDef);
687
688 if ($this->act!='image') {
689
690 // ***************************
691 // Upload
692 // ***************************
693 // Create upload/create folder forms, if a path is given:
694 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
695 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
696 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
697 $path=$this->expandFolder;
698 if (!$path || !@is_dir($path)) {
699 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
700 }
701 if ($path!='/' && @is_dir($path)) {
702 $uploadForm=$this->uploadForm($path);
703 $createFolder=$this->createFolder($path);
704 } else {
705 $createFolder='';
706 $uploadForm='';
707 }
708 $this->content .= $uploadForm;
709 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
710 $this->content.=$createFolder;
711 }
712 }
713
714 // Getting flag for showing/not showing thumbnails:
715 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect') || ($this->act == 'dragdrop');
716
717 if (!$noThumbs) {
718 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
719 $_MOD_MENU = array('displayThumbs' => '');
720 $_MCONF['name']='file_list';
721 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
722 $addParams = '&act='.$this->act.'&editorNo='.$this->editorNo.'&expandFolder='.rawurlencode($this->expandFolder);
723 $thumbNailCheck = t3lib_BEfunc::getFuncCheck('','SET[displayThumbs]',$_MOD_SETTINGS['displayThumbs'],'select_image.php',$addParams,'id="checkDisplayThumbs"').' <label for="checkDisplayThumbs">'.$LANG->sL('LLL:EXT:lang/locallang_mod_file_list.php:displayThumbs',1).'</label>';
724 } else {
725 $thumbNailCheck='';
726 }
727
728 // Create folder tree:
729 if ($this->act == 'dragdrop') {
730 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
731 $foldertree->thisScript=$this->thisScript;
732 $foldertree->ext_noTempRecyclerDirs = true;
733 } else {
734 $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_image_folderTree');
735 }
736 $tree = $foldertree->getBrowsableTree();
737 list(,,$specUid) = explode('_',t3lib_div::_GP('PM'));
738 if ($this->act == 'dragdrop') {
739 $pArr = explode('|',$this->bparams);
740 $allowedTablesOrFileTypes = $pArr[3];
741 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
742 } else {
743 $files = $this->expandFolder($foldertree->specUIDmap[$specUid],$this->act=='plain',$noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
744 }
745
746 $this->content.= '<table border=0 cellpadding=0 cellspacing=0>
747 <tr>
748 <td valign=top>'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
749 <td>&nbsp;</td>
750 <td valign=top>'.$files.'</td>
751 </tr>
752 </table>
753 <br />'.$thumbNailCheck;
754
755 // ***************************
756 // Help
757 // ***************************
758 if ($this->act=='magic') {
759 $this->content .= $this->getMsgBox($LANG->getLL('magicImage_msg'));
760 }
761 if ($this->act=='plain') {
762 $this->content .= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight));
763 }
764 } else {
765 $JScode = '
766 document.write(printCurrentImageOptions());
767 insertImagePropertiesInForm();';
768 $this->content.= '<br />'.$this->doc->wrapScriptTags($JScode);
769 }
770 $this->content.= $this->doc->endPage();
771 return $this->content;
772 }
773
774 /***************************
775 *
776 * OTHER FUNCTIONS:
777 *
778 ***************************/
779 /**
780 * @param [type] $expandFolder: ...
781 * @param [type] $plainFlag: ...
782 * @return [type] ...
783 */
784 function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) {
785 global $LANG, $BE_USER, $BACK_PATH;
786
787 $expandFolder = $expandFolder ? $expandFolder :t3lib_div::_GP('expandFolder');
788 $out='';
789
790 if ($expandFolder && $this->checkFolder($expandFolder)) {
791 $files = t3lib_div::getFilesInDir($expandFolder,($plainFlag?'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1); // $extensionList="",$prependPath=0,$order="")
792 if (is_array($files)) {
793 reset($files);
794
795 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
796
797 $titleLen = intval($BE_USER->uc['titleLen']);
798 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
799 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
800 $out.='<span class="nobr">'.$picon.'</span><br />';
801
802 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
803 $imgObj->init();
804 $imgObj->mayScaleUp=0;
805 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
806
807 $lines=array();
808 while(list(,$filepath)=each($files)) {
809 $fI=pathinfo($filepath);
810
811 $origFile = t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site)));
812 $iurl = $this->siteUrl.$origFile;
813 $imgInfo = $imgObj->getImageDimensions($filepath);
814 // File icon:
815 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
816 $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
817 $size=' ('.t3lib_div::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
818 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
819 if (!$plainFlag) {
820 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo.'&insertMagicImage='.rawurlencode($filepath).'\');">';
821 } else {
822 $ATag = '<a href="#" onclick="return insertImage(\''.$iurl.'\','.$imgInfo[0].','.$imgInfo[1].');">';
823 }
824 $ATag_e='</a>';
825 if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth) || ($imgInfo[1] > $this->plainMaxHeight))) {
826 $ATag='';
827 $ATag_e='';
828 $ATag2='';
829 $ATag2_e='';
830 } else {
831 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
832 $ATag2_e='</a>';
833 }
834
835 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
836
837
838 $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td><td nowrap="nowrap">'.$pDim.'&nbsp;</td></tr>';
839 $lines[]='<tr><td colspan="2">'.($noThumbs ? '' : $ATag2.t3lib_BEfunc::getThumbNail($this->doc->backPath.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
840 '</td></tr>';
841 $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
842 }
843 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
844 }
845 }
846 return $out;
847 }
848
849 /**
850 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
851 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
852 *
853 * @param string Absolute filepath on server to which to upload.
854 * @return string HTML for an upload form.
855 */
856 function uploadForm($path) {
857 global $BACK_PATH;
858 $count=3;
859
860 // Create header, showing upload path:
861 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
862 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
863 $code.='
864
865 <!--
866 Form, for uploading files:
867 -->
868 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
869 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
870 <tr>
871 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
872 </tr>
873 <tr>
874 <td>';
875
876 // Traverse the number of upload fields (default is 3):
877 for ($a=1;$a<=$count;$a++) {
878 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
879 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
880 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
881 }
882
883 // Make footer of upload form, including the submit button:
884 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
885 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
886 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
887
888 $code.='
889 <div id="c-override">
890 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
891 </div>
892 ';
893
894
895 $code.='</td>
896 </tr>
897 </table>
898 </form>';
899
900 return $code;
901 }
902
903
904 /**
905 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
906 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
907 *
908 * @param string Absolute filepath on server in which to create the new folder.
909 * @return string HTML for the create folder form.
910 */
911 function createFolder($path) {
912 global $BACK_PATH;
913 // Create header, showing upload path:
914 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
915 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
916 $code.='
917
918 <!--
919 Form, for creating new folders:
920 -->
921 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
922 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
923 <tr>
924 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
925 </tr>
926 <tr>
927 <td>';
928
929 // Create the new-folder name field:
930 $a=1;
931 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
932 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
933
934 // Make footer of upload form, including the submit button:
935 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
936 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
937 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
938
939 $code.='</td>
940 </tr>
941 </table>
942 </form>';
943
944 return $code;
945 }
946
947 /**
948 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
949 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
950 *
951 * @param string The folder path to expand
952 * @param string List of fileextensions to show
953 * @return string HTML output
954 */
955 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
956 global $BACK_PATH;
957
958 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
959 $out='';
960 if ($expandFolder && $this->checkFolder($expandFolder)) {
961 if ($this->isWebFolder($expandFolder)) {
962
963 // Read files from directory:
964 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
965 if (is_array($files)) {
966 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
967
968 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
969 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
970 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
971 $out.=$picon.'<br />';
972
973 // Init row-array:
974 $lines=array();
975
976 // Add "drag-n-drop" message:
977 $lines[]='
978 <tr>
979 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
980 </tr>';
981
982 // Fraverse files:
983 while(list(,$filepath)=each($files)) {
984 $fI = pathinfo($filepath);
985
986 // URL of image:
987 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
988
989 // Show only web-images
990 if (t3lib_div::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
991 $imgInfo = @getimagesize($filepath);
992 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
993
994 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
995 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
996 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
997 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
998
999 if (t3lib_div::_GP('noLimit')) {
1000 $maxW=10000;
1001 $maxH=10000;
1002 } else {
1003 $maxW=380;
1004 $maxH=500;
1005 }
1006 $IW = $imgInfo[0];
1007 $IH = $imgInfo[1];
1008 if ($IW>$maxW) {
1009 $IH=ceil($IH/$IW*$maxW);
1010 $IW=$maxW;
1011 }
1012 if ($IH>$maxH) {
1013 $IW=ceil($IW/$IH*$maxH);
1014 $IH=$maxH;
1015 }
1016
1017 // Make row:
1018 $lines[]='
1019 <tr class="bgColor4">
1020 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1021 <td nowrap="nowrap">'.
1022 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
1023 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1024 '</a>':'').
1025 $pDim.'&nbsp;</td>
1026 </tr>';
1027 // Remove hardcoded border="1"
1028 // Add default class for images
1029 $lines[]='
1030 <tr>
1031 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" alt=""' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):''). ' /></td>
1032 </tr>';
1033 $lines[]='
1034 <tr>
1035 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1036 </tr>';
1037 }
1038 }
1039
1040 // Finally, wrap all rows in a table tag:
1041 $out.='
1042
1043
1044 <!--
1045 File listing / Drag-n-drop
1046 -->
1047 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1048 '.implode('',$lines).'
1049 </table>';
1050 }
1051 } else {
1052 // Print this warning if the folder is NOT a web folder:
1053 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1054 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1055 }
1056 }
1057 return $out;
1058 }
1059
1060 }
1061
1062 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']) {
1063 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);
1064 }
1065
1066 ?>