957c40ac4c2ff404fa7c7cb29f2269c3c5101cc2
[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 // init fileProcessor
180 $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
181 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
182
183 if (!$this->act) {
184 $this->act='magic';
185 }
186
187 $RTEtsConfigParts = explode(':',t3lib_div::_GP('RTEtsConfigParams'));
188 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
189 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
190 $this->imgPath = $RTEtsConfigParts[6];
191
192 if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {
193 $this->buttonConfig = $this->thisConfig['buttons.']['image.'];
194 if (is_array($this->buttonConfig['properties.'])) {
195 if ($this->buttonConfig['properties.']['removeItems']) {
196 $this->removedProperties = t3lib_div::trimExplode(',',$this->buttonConfig['properties.']['removeItems'],1);
197 }
198 if (is_array($this->buttonConfig['properties.']['class.']) && trim($this->buttonConfig['properties.']['class.']['default'])) {
199 $this->defaultClass = trim($this->buttonConfig['properties.']['class.']['default']);
200 }
201 }
202
203 }
204
205 if (is_array($this->thisConfig['proc.']) && $this->thisConfig['proc.']['plainImageMode']) {
206 $plainImageMode = $this->thisConfig['proc.']['plainImageMode'];
207 $this->lockPlainWidth = ($plainImageMode == 'lockDimensions')?'true':'false';
208 $this->lockPlainHeight = ($this->lockPlainWidth || $plainImageMode == 'lockRatio' || ($plainImageMode == 'lockRatioWhenSmaller'))?'true':'false';
209 }
210
211 $this->allowedItems = explode(',','magic,plain,image');
212 $clientInfo = t3lib_div::clientInfo();
213 if ($clientInfo['BROWSER'] !== 'opera') {
214 $this->allowedItems[] = 'dragdrop';
215 }
216 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
217 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
218 } else {
219 $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindImageOptions'],1));
220 }
221 reset($this->allowedItems);
222 if (!in_array($this->act,$this->allowedItems)) {
223 $this->act = current($this->allowedItems);
224 }
225
226 if ($this->act == 'plain') {
227 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth']) $this->plainMaxWidth = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth'];
228 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight']) $this->plainMaxHeight = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight'];
229 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {
230 if ($this->buttonConfig['options.']['plain.']['maxWidth']) $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];
231 if ($this->buttonConfig['options.']['plain.']['maxHeight']) $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];
232 }
233 if (!$this->plainMaxWidth) $this->plainMaxWidth = 640;
234 if (!$this->plainMaxHeight) $this->plainMaxHeight = 680;
235 } elseif ($this->act == 'magic') {
236 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {
237 if ($this->buttonConfig['options.']['magic.']['maxWidth']) $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];
238 if ($this->buttonConfig['options.']['magic.']['maxHeight']) $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];
239 }
240 // 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
241 if (!$this->magicMaxWidth) $this->magicMaxWidth = 300;
242 if (!$this->magicMaxHeight) $this->magicMaxHeight = 1000;
243 }
244
245 if ($this->thisConfig['classesImage']) {
246 $classesImageArray = t3lib_div::trimExplode(',',$this->thisConfig['classesImage'],1);
247 $this->classesImageJSOptions = '<option value=""></option>';
248 foreach ($classesImageArray as $class) {
249 $this->classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
250 }
251 }
252
253 $this->magicProcess();
254
255 // Creating backend template object:
256 $this->doc = t3lib_div::makeInstance('template');
257 $this->doc->bodyTagAdditions = 'onLoad="initDialog();"';
258 $this->doc->docType= 'xhtml_trans';
259 $this->doc->backPath = $BACK_PATH;
260
261 $this->getJSCode();
262 }
263
264 /**
265 * [Describe function...]
266 *
267 * @return [type] ...
268 */
269 function rteImageStorageDir() {
270 $dir = $this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
271 return $dir;
272 }
273
274 /**
275 * [Describe function...]
276 *
277 * @return [type] ...
278 */
279 function magicProcess() {
280 global $TYPO3_CONF_VARS;
281
282 if ($this->act=='magic' && t3lib_div::_GP('insertMagicImage')) {
283 $filepath = t3lib_div::_GP('insertMagicImage');
284
285 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
286 $imgObj->init();
287 $imgObj->mayScaleUp=0;
288 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
289
290 $imgInfo = $imgObj->getImageDimensions($filepath);
291
292 if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir()) {
293 $fI=pathinfo($imgInfo[3]);
294 $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
295 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
296 $destPath =PATH_site.$this->rteImageStorageDir();
297 if (@is_dir($destPath)) {
298 $destName = $fileFunc->getUniqueName($basename,$destPath);
299 @copy($imgInfo[3],$destName);
300 t3lib_div::fixPermissions($destName);
301 $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);
302 $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'),0,$this->magicMaxHeight);
303 if (!$cWidth) $cWidth = $this->magicMaxWidth;
304 if (!$cHeight) $cHeight = $this->magicMaxHeight;
305
306 $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
307 if ($imgI[3]) {
308 $fI=pathinfo($imgI[3]);
309 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
310 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
311 @copy($imgI[3],$destName);
312 t3lib_div::fixPermissions($destName);
313 $destName = dirname($destName).'/'.rawurlencode(basename($destName));
314 $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
315 echo'
316 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
317 <html>
318 <head>
319 <title>Untitled</title>
320 </head>
321 <script type="text/javascript">
322 /*<![CDATA[*/
323 var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
324 var plugin = dialog.plugin;
325 function insertImage(file,width,height) {
326 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
327 }
328 /*]]>*/
329 </script>
330 <body>
331 <script type="text/javascript">
332 /*<![CDATA[*/
333 insertImage(\''.$iurl.'\','.$imgI[0].','.$imgI[1].');
334 /*]]>*/
335 </script>
336 </body>
337 </html>';
338 }
339
340 }
341 }
342 exit;
343 }
344 }
345
346 /**
347 * [Describe function...]
348 *
349 * @return [type] ...
350 */
351 function getJSCode() {
352 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
353
354 $JScode='
355 var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
356 var plugin = dialog.plugin;
357 var HTMLArea = window.opener.HTMLArea;
358
359
360 function initDialog() {
361 dialog.captureEvents("skipUnload");
362 }
363 function jumpToUrl(URL,anchor) {
364 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
365 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
366 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div::_GP('RTEtsConfigParams')).'";
367
368 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
369 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
370
371 var theLocation = URL+add_act+add_editorNo+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
372 window.location.href = theLocation;
373 return false;
374 }
375 function insertImage(file,width,height) {
376 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
377 }
378 function launchView(url) {
379 var thePreviewWindow="";
380 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");
381 if (thePreviewWindow && thePreviewWindow.focus) {
382 thePreviewWindow.focus();
383 }
384 }
385 function getCurrentImageRef() {
386 if (plugin.image) {
387 return plugin.image;
388 } else {
389 return null;
390 }
391 }
392 function printCurrentImageOptions() {
393 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
394 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $this->classesImageJSOptions . '</select>\';
395 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>\';
396 var bgColor=\' class="bgColor4"\';
397 var sz="";
398 sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
399 '.(in_array('class', $this->removedProperties)?'':'
400 if(classesImage) {
401 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
402 }')
403 .(in_array('width', $this->removedProperties)?'':'
404 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainWidth .')) {
405 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>\';
406 }')
407 .(in_array('height', $this->removedProperties)?'':'
408 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainHeight .')) {
409 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>\';
410 }')
411 .(in_array('border', $this->removedProperties)?'':'
412 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
413 .(in_array('float', $this->removedProperties)?'':'
414 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
415 .(in_array('paddingTop', $this->removedProperties)?'':'
416 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>\';')
417 .(in_array('paddingRight', $this->removedProperties)?'':'
418 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>\';')
419 .(in_array('paddingBottom', $this->removedProperties)?'':'
420 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>\';')
421 .(in_array('paddingLeft', $this->removedProperties)?'':'
422 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>\';')
423 .(in_array('title', $this->removedProperties)?'':'
424 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>\';')
425 .(in_array('alt', $this->removedProperties)?'':'
426 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>\';')
427 .((!$TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] || in_array('clickenlarge', $this->removedProperties))?'':'
428 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>\';').'
429 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
430 sz+=\'</form></table>\';
431 return sz;
432 }
433 function setImageProperties() {
434 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
435 if (selectedImageRef) {
436 if (document.imageData.iWidth) {
437 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
438 selectedImageRef.style.width = "";
439 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
440 }
441 }
442 if (document.imageData.iHeight) {
443 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
444 selectedImageRef.style.height = "";
445 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
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.removeAttribute("clickenlarge");
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)) {
541 document.imageData.iWidth.value = styleWidth;
542 }
543 }
544 if (document.imageData.iHeight) {
545 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
546 styleHeight = parseInt(styleHeight);
547 if (!(isNaN(styleHeight) || styleHeight == 0)) {
548 document.imageData.iHeight.value = styleHeight;
549 }
550 }
551 if (document.imageData.iPaddingTop) {
552 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
553 var padding = parseInt(padding);
554 if (isNaN(padding) || padding <= 0) { padding = ""; }
555 document.imageData.iPaddingTop.value = padding;
556 }
557 if (document.imageData.iPaddingRight) {
558 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
559 var padding = parseInt(padding);
560 if (isNaN(padding) || padding <= 0) { padding = ""; }
561 document.imageData.iPaddingRight.value = padding;
562 }
563 if (document.imageData.iPaddingBottom) {
564 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
565 var padding = parseInt(padding);
566 if (isNaN(padding) || padding <= 0) { padding = ""; }
567 document.imageData.iPaddingBottom.value = padding;
568 }
569 if (document.imageData.iPaddingLeft) {
570 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
571 var padding = parseInt(padding);
572 if (isNaN(padding) || padding <= 0) { padding = ""; }
573 document.imageData.iPaddingLeft.value = padding;
574 }
575 if (document.imageData.iTitle) {
576 document.imageData.iTitle.value = selectedImageRef.title;
577 }
578 if (document.imageData.iAlt) {
579 document.imageData.iAlt.value = selectedImageRef.alt;
580 }
581 if (document.imageData.iBorder) {
582 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
583 document.imageData.iBorder.checked = 1;
584 }
585 }
586 if (document.imageData.iFloat) {
587 var fObj=document.imageData.iFloat;
588 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
589 var l=fObj.length;
590 for (var a=0;a<l;a++) {
591 if (fObj.options[a].value == value) {
592 fObj.selectedIndex = a;
593 }
594 }
595 }
596
597 if (classesImage && document.imageData.iClass) {
598 var fObj=document.imageData.iClass;
599 var value=selectedImageRef.className;
600 var l=fObj.length;
601 for (var a=0;a < l; a++) {
602 if (fObj.options[a].value == value) {
603 fObj.selectedIndex = a;
604 }
605 }
606 }
607 if (document.imageData.iClickEnlarge) {
608 if (selectedImageRef.getAttribute("clickenlarge") == "1") {
609 document.imageData.iClickEnlarge.checked = 1;
610 } else {
611 document.imageData.iClickEnlarge.checked = 0;
612 }
613 }
614 return false;
615 }
616 }
617
618 var selectedImageRef = getCurrentImageRef();'; // Setting this to a reference to the image object.
619
620 // Finally, add the accumulated JavaScript to the template object:
621 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
622 }
623
624 /**
625 * Session data for this class can be set from outside with this method.
626 * Call after init()
627 *
628 * @param array Session data array
629 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
630 */
631 function processSessionData($data) {
632 $store = false;
633
634 if ($this->act != 'image') {
635 if (isset($this->act)) {
636 $data['act'] = $this->act;
637 $store = true;
638 } else {
639 $this->act = $data['act'];
640 }
641 }
642
643 if (isset($this->expandFolder)) {
644 $data['expandFolder'] = $this->expandFolder;
645 $store = true;
646 } else {
647 $this->expandFolder = $data['expandFolder'];
648 }
649
650 return array($data, $store);
651 }
652
653 /**
654 * [Describe function...]
655 *
656 * @return [type] ...
657 */
658 function main_rte() {
659 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
660
661 // Starting content:
662 $this->content = $this->doc->startPage($LANG->getLL('Insert Image',1));
663
664 // Making menu in top:
665 $menuDef = array();
666 if (in_array('image',$this->allowedItems) && ($this->act=='image' || t3lib_div::_GP('cWidth'))) {
667 $menuDef['page']['isActive'] = $this->act=='image';
668 $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
669 $menuDef['page']['url'] = '#';
670 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&editorNo='.$this->editorNo.'\');return false;"';
671 }
672 if (in_array('magic',$this->allowedItems)){
673 $menuDef['file']['isActive'] = $this->act=='magic';
674 $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
675 $menuDef['file']['url'] = '#';
676 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&editorNo='.$this->editorNo.'\');return false;"';
677 }
678 if (in_array('plain',$this->allowedItems)) {
679 $menuDef['url']['isActive'] = $this->act=='plain';
680 $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
681 $menuDef['url']['url'] = '#';
682 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&editorNo='.$this->editorNo.'\');return false;"';
683 }
684 if (in_array('dragdrop',$this->allowedItems)) {
685 $menuDef['mail']['isActive'] = $this->act=='dragdrop';
686 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
687 $menuDef['mail']['url'] = '#';
688 $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&editorNo='.$this->editorNo.'&bparams=|||\'+escape(\'gif,jpg,jpeg,png\'));return false;"';
689 }
690 $this->content .= $this->doc->getTabMenuRaw($menuDef);
691
692 if ($this->act!='image') {
693
694 // ***************************
695 // Upload
696 // ***************************
697 // Create upload/create folder forms, if a path is given:
698 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB') && !$this->readOnly && count($GLOBALS['FILEMOUNTS'])) {
699 $path=$this->expandFolder;
700 if (!$path || !@is_dir($path)) {
701 // The closest TEMP-path is found
702 $path = $this->fileProcessor->findTempFolder().'/';
703 }
704 if ($path!='/' && @is_dir($path)) {
705 $uploadForm=$this->uploadForm($path);
706 $createFolder=$this->createFolder($path);
707 } else {
708 $createFolder='';
709 $uploadForm='';
710 }
711 $this->content .= $uploadForm;
712 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
713 $this->content.=$createFolder;
714 }
715 }
716
717 // Getting flag for showing/not showing thumbnails:
718 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect') || ($this->act == 'dragdrop');
719
720 if (!$noThumbs) {
721 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
722 $_MOD_MENU = array('displayThumbs' => '');
723 $_MCONF['name']='file_list';
724 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
725 $addParams = '&act='.$this->act.'&editorNo='.$this->editorNo.'&expandFolder='.rawurlencode($this->expandFolder);
726 $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>';
727 } else {
728 $thumbNailCheck='';
729 }
730
731 // Create folder tree:
732 if ($this->act == 'dragdrop') {
733 $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
734 $foldertree->thisScript=$this->thisScript;
735 $foldertree->ext_noTempRecyclerDirs = true;
736 } else {
737 $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_image_folderTree');
738 }
739 $tree = $foldertree->getBrowsableTree();
740 list(,,$specUid) = explode('_',t3lib_div::_GP('PM'));
741 if ($this->act == 'dragdrop') {
742 $pArr = explode('|',$this->bparams);
743 $allowedTablesOrFileTypes = $pArr[3];
744 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid],$pArr[3]);
745 } else {
746 $files = $this->expandFolder($foldertree->specUIDmap[$specUid],$this->act=='plain',$noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
747 }
748
749 $this->content.= '<table border=0 cellpadding=0 cellspacing=0>
750 <tr>
751 <td valign=top>'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
752 <td>&nbsp;</td>
753 <td valign=top>'.$files.'</td>
754 </tr>
755 </table>
756 <br />'.$thumbNailCheck;
757
758 // ***************************
759 // Help
760 // ***************************
761 if ($this->act=='magic') {
762 $this->content .= $this->getMsgBox($LANG->getLL('magicImage_msg'));
763 }
764 if ($this->act=='plain') {
765 $this->content .= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight));
766 }
767 } else {
768 $JScode = '
769 document.write(printCurrentImageOptions());
770 insertImagePropertiesInForm();';
771 $this->content.= '<br />'.$this->doc->wrapScriptTags($JScode);
772 }
773 $this->content.= $this->doc->endPage();
774 return $this->content;
775 }
776
777 /***************************
778 *
779 * OTHER FUNCTIONS:
780 *
781 ***************************/
782 /**
783 * @param [type] $expandFolder: ...
784 * @param [type] $plainFlag: ...
785 * @return [type] ...
786 */
787 function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) {
788 global $LANG, $BE_USER, $BACK_PATH;
789
790 $expandFolder = $expandFolder ? $expandFolder :t3lib_div::_GP('expandFolder');
791 $out='';
792
793 if ($expandFolder && $this->checkFolder($expandFolder)) {
794 $files = t3lib_div::getFilesInDir($expandFolder,($plainFlag?'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1); // $extensionList="",$prependPath=0,$order="")
795 if (is_array($files)) {
796 reset($files);
797
798 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
799
800 $titleLen = intval($BE_USER->uc['titleLen']);
801 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
802 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
803 $out.='<span class="nobr">'.$picon.'</span><br />';
804
805 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
806 $imgObj->init();
807 $imgObj->mayScaleUp=0;
808 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
809
810 $lines=array();
811 while(list(,$filepath)=each($files)) {
812 $fI=pathinfo($filepath);
813
814 $origFile = t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site)));
815 $iurl = $this->siteUrl.$origFile;
816 $imgInfo = $imgObj->getImageDimensions($filepath);
817 // File icon:
818 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
819 $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
820 $size=' ('.t3lib_div::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
821 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
822 if (!$plainFlag) {
823 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo.'&insertMagicImage='.rawurlencode($filepath).'\');">';
824 } else {
825 $ATag = '<a href="#" onclick="return insertImage(\''.$iurl.'\','.$imgInfo[0].','.$imgInfo[1].');">';
826 }
827 $ATag_e='</a>';
828 if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth) || ($imgInfo[1] > $this->plainMaxHeight))) {
829 $ATag='';
830 $ATag_e='';
831 $ATag2='';
832 $ATag2_e='';
833 } else {
834 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
835 $ATag2_e='</a>';
836 }
837
838 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
839
840
841 $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td><td nowrap="nowrap">'.$pDim.'&nbsp;</td></tr>';
842 $lines[]='<tr><td colspan="2">'.($noThumbs ? '' : $ATag2.t3lib_BEfunc::getThumbNail($this->doc->backPath.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
843 '</td></tr>';
844 $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
845 }
846 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
847 }
848 }
849 return $out;
850 }
851
852 /**
853 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
854 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
855 *
856 * @param string Absolute filepath on server to which to upload.
857 * @return string HTML for an upload form.
858 */
859 function uploadForm($path) {
860 global $BACK_PATH;
861 $count=3;
862
863 if ($this->isReadOnlyFolder($path)) return '';
864
865 // Create header, showing upload path:
866 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
867 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
868 $code.='
869
870 <!--
871 Form, for uploading files:
872 -->
873 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
874 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
875 <tr>
876 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
877 </tr>
878 <tr>
879 <td>';
880
881 // Traverse the number of upload fields (default is 3):
882 for ($a=1;$a<=$count;$a++) {
883 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
884 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
885 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
886 }
887
888 // Make footer of upload form, including the submit button:
889 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
890 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
891 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
892
893 $code.='
894 <div id="c-override">
895 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
896 </div>
897 ';
898
899
900 $code.='</td>
901 </tr>
902 </table>
903 </form>';
904
905 return $code;
906 }
907
908
909 /**
910 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
911 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
912 *
913 * @param string Absolute filepath on server in which to create the new folder.
914 * @return string HTML for the create folder form.
915 */
916 function createFolder($path) {
917 global $BACK_PATH;
918
919 if ($this->isReadOnlyFolder($path)) return '';
920
921 // Create header, showing upload path:
922 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
923 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
924 $code.='
925
926 <!--
927 Form, for creating new folders:
928 -->
929 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
930 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
931 <tr>
932 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
933 </tr>
934 <tr>
935 <td>';
936
937 // Create the new-folder name field:
938 $a=1;
939 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
940 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
941
942 // Make footer of upload form, including the submit button:
943 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
944 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
945 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
946
947 $code.='</td>
948 </tr>
949 </table>
950 </form>';
951
952 return $code;
953 }
954
955 /**
956 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
957 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
958 *
959 * @param string The folder path to expand
960 * @param string List of fileextensions to show
961 * @return string HTML output
962 */
963 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
964 global $BACK_PATH;
965
966 $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
967 $out='';
968 if ($expandFolder && $this->checkFolder($expandFolder)) {
969 if ($this->isWebFolder($expandFolder)) {
970
971 // Read files from directory:
972 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
973 if (is_array($files)) {
974 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
975
976 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
977 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
978 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen));
979 $out.=$picon.'<br />';
980
981 // Init row-array:
982 $lines=array();
983
984 // Add "drag-n-drop" message:
985 $lines[]='
986 <tr>
987 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
988 </tr>';
989
990 // Traverse files:
991 while(list(,$filepath)=each($files)) {
992 $fI = pathinfo($filepath);
993
994 // URL of image:
995 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site)));
996
997 // Show only web-images
998 if (t3lib_div::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
999 $imgInfo = @getimagesize($filepath);
1000 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1001
1002 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
1003 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')';
1004 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1005 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen));
1006
1007 if (t3lib_div::_GP('noLimit')) {
1008 $maxW=10000;
1009 $maxH=10000;
1010 } else {
1011 $maxW=380;
1012 $maxH=500;
1013 }
1014 $IW = $imgInfo[0];
1015 $IH = $imgInfo[1];
1016 if ($IW>$maxW) {
1017 $IH=ceil($IH/$IW*$maxW);
1018 $IW=$maxW;
1019 }
1020 if ($IH>$maxH) {
1021 $IW=ceil($IW/$IH*$maxH);
1022 $IH=$maxH;
1023 }
1024
1025 // Make row:
1026 $lines[]='
1027 <tr class="bgColor4">
1028 <td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td>
1029 <td nowrap="nowrap">'.
1030 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'.
1031 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1032 '</a>':'').
1033 $pDim.'&nbsp;</td>
1034 </tr>';
1035 // Remove hardcoded border="1"
1036 // Add default class for images
1037 $lines[]='
1038 <tr>
1039 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" alt=""' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):''). ' /></td>
1040 </tr>';
1041 $lines[]='
1042 <tr>
1043 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1044 </tr>';
1045 }
1046 }
1047
1048 // Finally, wrap all rows in a table tag:
1049 $out.='
1050
1051
1052 <!--
1053 File listing / Drag-n-drop
1054 -->
1055 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1056 '.implode('',$lines).'
1057 </table>';
1058 }
1059 } else {
1060 // Print this warning if the folder is NOT a web folder:
1061 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1062 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1063 }
1064 }
1065 return $out;
1066 }
1067
1068 }
1069
1070 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']) {
1071 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);
1072 }
1073
1074 ?>