6792391409382abb082ccacf0cfec15787009275
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / mod4 / class.tx_rtehtmlarea_select_image.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_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;
144 var $lockPlainHeight;
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->docType= 'xhtml_trans';
254 $this->doc->backPath = $BACK_PATH;
255
256 $this->getJSCode();
257 }
258
259 /**
260 * [Describe function...]
261 *
262 * @return [type] ...
263 */
264 function rteImageStorageDir() {
265 $dir = $this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
266 return $dir;
267 }
268
269 /**
270 * [Describe function...]
271 *
272 * @return [type] ...
273 */
274 function magicProcess() {
275 global $TYPO3_CONF_VARS;
276
277 if ($this->act=='magic' && t3lib_div::_GP('insertMagicImage')) {
278 $filepath = t3lib_div::_GP('insertMagicImage');
279
280 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
281 $imgObj->init();
282 $imgObj->mayScaleUp=0;
283 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
284
285 $imgInfo = $imgObj->getImageDimensions($filepath);
286
287 if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir()) {
288 $fI=pathinfo($imgInfo[3]);
289 $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
290 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
291 $destPath =PATH_site.$this->rteImageStorageDir();
292 if (@is_dir($destPath)) {
293 $destName = $fileFunc->getUniqueName($basename,$destPath);
294 if (isset($TYPO3_CONF_VARS['BE']['fileCreateMask'])) {
295 @chmod($destName, $TYPO3_CONF_VARS['BE']['fileCreateMask']);
296 }
297 @copy($imgInfo[3],$destName);
298
299 $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);
300 $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'),0,$this->magicMaxHeight);
301 if (!$cWidth) $cWidth = $this->magicMaxWidth;
302 if (!$cHeight) $cHeight = $this->magicMaxHeight;
303
304 $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
305 if ($imgI[3]) {
306 $fI=pathinfo($imgI[3]);
307 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
308 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
309 if (isset($TYPO3_CONF_VARS['BE']['fileCreateMask'])) {
310 @chmod($destName, $TYPO3_CONF_VARS['BE']['fileCreateMask']);
311 }
312 @copy($imgI[3],$destName);
313
314 $destName = dirname($destName).'/'.rawurlencode(basename($destName));
315 $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
316 echo'
317 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
318 <html>
319 <head>
320 <title>Untitled</title>
321 </head>
322 <script type="text/javascript">
323 /*<![CDATA[*/
324 var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
325 var plugin = dialog.plugin;
326 function insertImage(file,width,height) {
327 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
328 }
329 /*]]>*/
330 </script>
331 <body>
332 <script type="text/javascript">
333 /*<![CDATA[*/
334 insertImage(\''.$iurl.'\','.$imgI[0].','.$imgI[1].');
335 /*]]>*/
336 </script>
337 </body>
338 </html>';
339 }
340
341 }
342 }
343 exit;
344 }
345 }
346
347 /**
348 * [Describe function...]
349 *
350 * @return [type] ...
351 */
352 function getJSCode() {
353 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
354
355 $JScode='
356 var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
357 var plugin = dialog.plugin;
358 var HTMLArea = window.opener.HTMLArea;
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="1" /></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 } else {
437 selectedImageRef.style.width = "auto";
438 }
439 }
440 if (document.imageData.iHeight) {
441 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
442 selectedImageRef.style.height = "";
443 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
444 } else {
445 selectedImageRef.style.height = "auto";
446 }
447 }
448 if (document.imageData.iPaddingTop) {
449 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
450 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
451 } else {
452 selectedImageRef.style.paddingTop = "";
453 }
454 }
455 if (document.imageData.iPaddingRight) {
456 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
457 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
458 } else {
459 selectedImageRef.style.paddingRight = "";
460 }
461 }
462 if (document.imageData.iPaddingBottom) {
463 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
464 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
465 } else {
466 selectedImageRef.style.paddingBottom = "";
467 }
468 }
469 if (document.imageData.iPaddingLeft) {
470 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
471 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
472 } else {
473 selectedImageRef.style.paddingLeft = "";
474 }
475 }
476 if (document.imageData.iTitle) {
477 selectedImageRef.title=document.imageData.iTitle.value;
478 }
479 if (document.imageData.iAlt) {
480 selectedImageRef.alt=document.imageData.iAlt.value;
481 }
482
483 if (document.imageData.iBorder) {
484 selectedImageRef.style.borderStyle = "";
485 selectedImageRef.style.borderWidth = "";
486 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
487 selectedImageRef.style.borderTopStyle = "";
488 selectedImageRef.style.borderRightStyle = "";
489 selectedImageRef.style.borderBottomStyle = "";
490 selectedImageRef.style.borderLeftStyle = "";
491 selectedImageRef.style.borderTopWidth = "";
492 selectedImageRef.style.borderRightWidth = "";
493 selectedImageRef.style.borderBottomWidth = "";
494 selectedImageRef.style.borderLeftWidth = "";
495 if(document.imageData.iBorder.checked) {
496 selectedImageRef.style.borderStyle = "solid";
497 selectedImageRef.style.borderWidth = "thin";
498 }
499 selectedImageRef.removeAttribute("border");
500 }
501
502 if (document.imageData.iFloat) {
503 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
504 if (iFloat || selectedImageRef.style.cssFloat || selectedImageRef.style.styleFloat) {
505 if (document.all) {
506 selectedImageRef.style.styleFloat = (iFloat != "none") ? iFloat : "";
507 } else {
508 selectedImageRef.style.cssFloat = (iFloat != "none") ? iFloat : "";
509 }
510 }
511 }
512
513 if (classesImage && document.imageData.iClass) {
514 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
515 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
516 selectedImageRef.className = iClass;
517 } else {
518 selectedImageRef.className = "";
519 }
520 }
521
522 if (document.imageData.iClickEnlarge) {
523 if (document.imageData.iClickEnlarge.checked) {
524 selectedImageRef.setAttribute("clickenlarge","1");
525 } else {
526 selectedImageRef.setAttribute("clickenlarge","0");
527 }
528 }
529 dialog.close();
530 }
531 return false;
532 }
533 function insertImagePropertiesInForm() {
534 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
535 if (selectedImageRef) {
536 var styleWidth, styleHeight, padding;
537 if (document.imageData.iWidth) {
538 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
539 styleWidth = parseInt(styleWidth);
540 if (isNaN(styleWidth) || styleWidth == 0) { styleWidth = "auto"; }
541 document.imageData.iWidth.value = styleWidth;
542 }
543 if (document.imageData.iHeight) {
544 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
545 styleHeight = parseInt(styleHeight);
546 if (isNaN(styleHeight) || styleHeight == 0) { styleHeight = "auto"; }
547 document.imageData.iHeight.value = styleHeight;
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->JScode = $this->doc->wrapScriptTags($JScode);
620 }
621
622 /**
623 * Session data for this class can be set from outside with this method.
624 * Call after init()
625 *
626 * @param array Session data array
627 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
628 */
629 function processSessionData($data) {
630 $store = false;
631
632 if ($this->act != 'image') {
633 if (isset($this->act)) {
634 $data['act'] = $this->act;
635 $store = true;
636 } else {
637 $this->act = $data['act'];
638 }
639 }
640
641 if (isset($this->expandFolder)) {
642 $data['expandFolder'] = $this->expandFolder;
643 $store = true;
644 } else {
645 $this->expandFolder = $data['expandFolder'];
646 }
647
648 return array($data, $store);
649 }
650
651 /**
652 * [Describe function...]
653 *
654 * @return [type] ...
655 */
656 function main_rte() {
657 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
658
659 // Starting content:
660 $this->content = $this->doc->startPage($LANG->getLL('Insert Image',1));
661
662 // Making menu in top:
663 $menuDef = array();
664 if (in_array('image',$this->allowedItems) && ($this->act=='image' || t3lib_div::_GP('cWidth'))) {
665 $menuDef['page']['isActive'] = $this->act=='image';
666 $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
667 $menuDef['page']['url'] = '#';
668 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&editorNo='.$this->editorNo.'\');return false;"';
669 }
670 if (in_array('magic',$this->allowedItems)){
671 $menuDef['file']['isActive'] = $this->act=='magic';
672 $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
673 $menuDef['file']['url'] = '#';
674 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&editorNo='.$this->editorNo.'\');return false;"';
675 }
676 if (in_array('plain',$this->allowedItems)) {
677 $menuDef['url']['isActive'] = $this->act=='plain';
678 $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
679 $menuDef['url']['url'] = '#';
680 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&editorNo='.$this->editorNo.'\');return false;"';
681 }
682 if (in_array('dragdrop',$this->allowedItems)) {
683 $menuDef['mail']['isActive'] = $this->act=='dragdrop';
684 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
685 $menuDef['mail']['url'] = '#';
686 $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&editorNo='.$this->editorNo.'&bparams=|||\'+escape(\'gif,jpg,jpeg,png\'));return false;"';
687 }
688 $this->content .= $this->doc->getTabMenuRaw($menuDef);
689
690 if ($this->act!='image') {
691
692 // ***************************
693 // Upload
694 // ***************************
695 // Create upload/create folder forms, if a path is given:
696 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
697 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
698 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
699 $path=$this->expandFolder;
700 if (!$path || !@is_dir($path)) {
701 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
702 }
703 if ($path!='/' && @is_dir($path)) {
704 $uploadForm=$this->uploadForm($path);
705 $createFolder=$this->createFolder($path);
706 } else {
707 $createFolder='';
708 $uploadForm='';
709 }
710 $this->content .= $uploadForm;
711 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
712 $this->content.=$createFolder;
713 }
714 }
715
716 // Getting flag for showing/not showing thumbnails:
717 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect') || ($this->act == 'dragdrop');
718
719 if (!$noThumbs) {
720 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
721 $_MOD_MENU = array('displayThumbs' => '');
722 $_MCONF['name']='file_list';
723 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
724 $addParams = '&act='.$this->act.'&editorNo='.$this->editorNo.'&expandFolder='.rawurlencode($this->expandFolder);
725 $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>';
726 } else {
727 $thumbNailCheck='';
728 }
729
730 // Create folder tree:
731 if ($this->act == 'dragdrop') {
732 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
733 $foldertree->thisScript=$this->thisScript;
734 $foldertree->ext_noTempRecyclerDirs = true;
735 } else {
736 $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_image_folderTree');
737 }
738 $tree = $foldertree->getBrowsableTree();
739 list(,,$specUid) = explode('_',t3lib_div::_GP('PM'));
740 if ($this->act == 'dragdrop') {
741 $pArr = explode('|',$this->bparams);
742 $allowedTablesOrFileTypes = $pArr[3];
743 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
744 } else {
745 $files = $this->expandFolder($foldertree->specUIDmap[$specUid],$this->act=='plain',$noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
746 }
747
748 $this->content.= '<table border=0 cellpadding=0 cellspacing=0>
749 <tr>
750 <td valign=top>'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
751 <td>&nbsp;</td>
752 <td valign=top>'.$files.'</td>
753 </tr>
754 </table>
755 <br />'.$thumbNailCheck;
756
757 // ***************************
758 // Help
759 // ***************************
760 if ($this->act=='magic') {
761 $this->content .= $this->getMsgBox($LANG->getLL('magicImage_msg'));
762 }
763 if ($this->act=='plain') {
764 $this->content .= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight));
765 }
766 } else {
767 $JScode = '
768 document.write(printCurrentImageOptions());
769 insertImagePropertiesInForm();';
770 $this->content.= '<br />'.$this->doc->wrapScriptTags($JScode);
771 }
772 $this->content.= $this->doc->endPage();
773 return $this->content;
774 }
775
776 /***************************
777 *
778 * OTHER FUNCTIONS:
779 *
780 ***************************/
781 /**
782 * @param [type] $expandFolder: ...
783 * @param [type] $plainFlag: ...
784 * @return [type] ...
785 */
786 function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) {
787 global $LANG, $BE_USER, $BACK_PATH;
788
789 $expandFolder = $expandFolder ? $expandFolder :t3lib_div::_GP('expandFolder');
790 $out='';
791
792 if ($expandFolder && $this->checkFolder($expandFolder)) {
793 $files = t3lib_div::getFilesInDir($expandFolder,($plainFlag?'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1); // $extensionList="",$prependPath=0,$order="")
794 if (is_array($files)) {
795 reset($files);
796
797 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
798
799 $titleLen = intval($BE_USER->uc['titleLen']);
800 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
801 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
802 $out.='<span class="nobr">'.$picon.'</span><br />';
803
804 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
805 $imgObj->init();
806 $imgObj->mayScaleUp=0;
807 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
808
809 $lines=array();
810 while(list(,$filepath)=each($files)) {
811 $fI=pathinfo($filepath);
812
813 $origFile = t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site)));
814 $iurl = $this->siteUrl.$origFile;
815 $imgInfo = $imgObj->getImageDimensions($filepath);
816 // File icon:
817 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
818 $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
819 $size=' ('.t3lib_div::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
820 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
821 if (!$plainFlag) {
822 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo.'&insertMagicImage='.rawurlencode($filepath).'\');">';
823 } else {
824 $ATag = '<a href="#" onclick="return insertImage(\''.$iurl.'\','.$imgInfo[0].','.$imgInfo[1].');">';
825 }
826 $ATag_e='</a>';
827 if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth) || ($imgInfo[1] > $this->plainMaxHeight))) {
828 $ATag='';
829 $ATag_e='';
830 $ATag2='';
831 $ATag2_e='';
832 } else {
833 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
834 $ATag2_e='</a>';
835 }
836
837 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
838
839
840 $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td><td nowrap="nowrap">'.$pDim.'&nbsp;</td></tr>';
841 $lines[]='<tr><td colspan="2">'.($noThumbs ? '' : $ATag2.t3lib_BEfunc::getThumbNail($this->doc->backPath.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
842 '</td></tr>';
843 $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
844 }
845 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
846 }
847 }
848 return $out;
849 }
850
851 /**
852 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
853 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
854 *
855 * @param string Absolute filepath on server to which to upload.
856 * @return string HTML for an upload form.
857 */
858 function uploadForm($path) {
859 global $BACK_PATH;
860 $count=3;
861
862 // Create header, showing upload path:
863 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
864 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
865 $code.='
866
867 <!--
868 Form, for uploading files:
869 -->
870 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
871 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
872 <tr>
873 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
874 </tr>
875 <tr>
876 <td>';
877
878 // Traverse the number of upload fields (default is 3):
879 for ($a=1;$a<=$count;$a++) {
880 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
881 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
882 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
883 }
884
885 // Make footer of upload form, including the submit button:
886 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
887 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
888 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
889
890 $code.='
891 <div id="c-override">
892 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
893 </div>
894 ';
895
896
897 $code.='</td>
898 </tr>
899 </table>
900 </form>';
901
902 return $code;
903 }
904
905
906 /**
907 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
908 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
909 *
910 * @param string Absolute filepath on server in which to create the new folder.
911 * @return string HTML for the create folder form.
912 */
913 function createFolder($path) {
914 global $BACK_PATH;
915 // Create header, showing upload path:
916 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
917 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
918 $code.='
919
920 <!--
921 Form, for creating new folders:
922 -->
923 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
924 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
925 <tr>
926 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
927 </tr>
928 <tr>
929 <td>';
930
931 // Create the new-folder name field:
932 $a=1;
933 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
934 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
935
936 // Make footer of upload form, including the submit button:
937 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
938 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
939 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
940
941 $code.='</td>
942 </tr>
943 </table>
944 </form>';
945
946 return $code;
947 }
948
949 /**
950 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
951 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
952 *
953 * @param string The folder path to expand
954 * @param string List of fileextensions to show
955 * @return string HTML output
956 */
957 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
958 global $BACK_PATH;
959
960 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
961 $out='';
962 if ($expandFolder && $this->checkFolder($expandFolder)) {
963 if ($this->isWebFolder($expandFolder)) {
964
965 // Read files from directory:
966 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
967 if (is_array($files)) {
968 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
969
970 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
971 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
972 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
973 $out.=$picon.'<br />';
974
975 // Init row-array:
976 $lines=array();
977
978 // Add "drag-n-drop" message:
979 $lines[]='
980 <tr>
981 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
982 </tr>';
983
984 // Fraverse files:
985 while(list(,$filepath)=each($files)) {
986 $fI = pathinfo($filepath);
987
988 // URL of image:
989 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
990
991 // Show only web-images
992 if (t3lib_div::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
993 $imgInfo = @getimagesize($filepath);
994 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
995
996 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
997 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
998 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
999 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
1000
1001 if (t3lib_div::_GP('noLimit')) {
1002 $maxW=10000;
1003 $maxH=10000;
1004 } else {
1005 $maxW=380;
1006 $maxH=500;
1007 }
1008 $IW = $imgInfo[0];
1009 $IH = $imgInfo[1];
1010 if ($IW>$maxW) {
1011 $IH=ceil($IH/$IW*$maxW);
1012 $IW=$maxW;
1013 }
1014 if ($IH>$maxH) {
1015 $IW=ceil($IW/$IH*$maxH);
1016 $IH=$maxH;
1017 }
1018
1019 // Make row:
1020 $lines[]='
1021 <tr class="bgColor4">
1022 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1023 <td nowrap="nowrap">'.
1024 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
1025 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1026 '</a>':'').
1027 $pDim.'&nbsp;</td>
1028 </tr>';
1029 // Remove hardcoded border="1"
1030 // Add default class for images
1031 $lines[]='
1032 <tr>
1033 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" alt=""' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):''). ' /></td>
1034 </tr>';
1035 $lines[]='
1036 <tr>
1037 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1038 </tr>';
1039 }
1040 }
1041
1042 // Finally, wrap all rows in a table tag:
1043 $out.='
1044
1045
1046 <!--
1047 File listing / Drag-n-drop
1048 -->
1049 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1050 '.implode('',$lines).'
1051 </table>';
1052 }
1053 } else {
1054 // Print this warning if the folder is NOT a web folder:
1055 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1056 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1057 }
1058 }
1059 return $out;
1060 }
1061
1062 }
1063
1064 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']) {
1065 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);
1066 }
1067
1068 ?>