This commit was manufactured by cvs2svn to create branch 'Kasper'.
[Packages/TYPO3.CMS.git] / typo3 / rte_select_image.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Displays image selector for the RTE
29 * Belongs to the "rte" extension
30 *
31 * @author Kasper Skårhøj <kasper@typo3.com>
32 * @package TYPO3
33 * @subpackage core
34 *
35 */
36
37
38
39 $BACK_PATH="";
40 require ("init.php");
41 require ("template.php");
42 require_once (PATH_t3lib."class.t3lib_browsetree.php");
43 require_once (PATH_t3lib."class.t3lib_foldertree.php");
44 require_once (PATH_t3lib."class.t3lib_stdgraphic.php");
45 require_once (PATH_t3lib."class.t3lib_basicfilefunc.php");
46 include ("sysext/lang/locallang_rte_select_image.php");
47
48
49
50 // ***************************
51 // Script Classes
52 // ***************************
53 class localFolderTree extends t3lib_folderTree {
54 function wrapTitle($title,$v) {
55 if ($this->ext_isLinkable($v)) {
56 return '<a href="#" onClick="return jumpToUrl(\'?expandFolder='.rawurlencode($v["path"]).'\');">'.$title.'</a>';
57 } else {
58 return '<font color="#666666">'.$title.'</font>';
59 }
60 }
61 function printTree($treeArr="") {
62 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
63 if (!is_array($treeArr)) $treeArr=$this->tree;
64 reset($treeArr);
65 $out="";
66 $c=0;
67 $xCol = t3lib_div::modifyHTMLColor($GLOBALS["SOBE"]->doc->bgColor,-10,-10,-10);
68 while(list($k,$v)=each($treeArr)) {
69 $c++;
70 $bgColor=' bgColor="'.(($c+1)%2 ? $GLOBALS["SOBE"]->doc->bgColor : $xCol).'"';
71 $out.='<tr'.$bgColor.'><td nowrap>'.$v["HTML"].$this->wrapTitle(t3lib_div::fixed_lgd($v["row"]["title"],$titleLen),$v["row"]).'</td></tr>';
72 }
73 $out='<table border=0 cellpadding=0 cellspacing=0>'.$out.'</table>';
74 return $out;
75 }
76 function PM_ATagWrap($icon,$cmd,$bMark="") {
77 if ($bMark) {
78 $anchor = "#".$bMark;
79 $name=' name="'.$bMark.'"';
80 }
81 return '<a href="#"'.$name.' onClick="return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');">'.$icon.'</a>';
82 }
83 function ext_getRelFolder($path) {
84 return substr($path,strlen(PATH_site));
85 }
86 function ext_isLinkable($v) {
87 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v["path"]);
88 if ($GLOBALS["SOBE"]->act=="magic") return 1;//$webpath="web"; // The web/non-web path does not matter if the mode is "magic"
89
90 if (strstr($v["path"],"_recycler_") || strstr($v["path"],"_temp_") || $webpath!="web") {
91 return 0;
92 }
93 return 1;
94 }
95 }
96 class SC_rte_select_image {
97 var $content;
98 var $siteUrl;
99
100 var $act;
101 var $modData;
102 var $thisConfig;
103 var $allowedItems;
104 var $doc;
105 var $imgPath;
106
107 function preinit() {
108 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
109
110 // Current site url:
111 $this->siteUrl = t3lib_div::getIndpEnv("TYPO3_SITE_URL");
112
113 // Determine nature of current url:
114 $this->act=t3lib_div::GPvar("act");
115
116 $this->modData = $BE_USER->getModuleData("rte_select_image.php","ses");
117 if ($this->act!="image") {
118 if (isset($this->act)) {
119 $this->modData["act"]=$this->act;
120 $BE_USER->pushModuleData("rte_select_image.php",$this->modData);
121 } else {
122 $this->act=$this->modData["act"];
123 }
124 }
125 $expandPage = t3lib_div::GPvar("expandFolder");
126 if (isset($expandPage)) {
127 $this->modData["expandFolder"]=$expandPage;
128 $BE_USER->pushModuleData("rte_select_image.php",$this->modData);
129 } else {
130 $HTTP_GET_VARS["expandFolder"]=$this->modData["expandFolder"];
131 }
132
133 if (!$this->act) {
134 $this->act="magic";
135 }
136
137
138
139 $RTEtsConfigParts = explode(":",t3lib_div::GPvar("RTEtsConfigParams"));
140 if (count($RTEtsConfigParts)<2) die("Error: The GET parameter 'RTEtsConfigParams' was missing. Close the window.");
141 $RTEsetup = $GLOBALS["BE_USER"]->getTSConfig("RTE",t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
142 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup["properties"],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
143 $this->imgPath = $RTEtsConfigParts[6];
144
145 $this->allowedItems = array_diff(explode(",","magic,plain,dragdrop,image"),t3lib_div::trimExplode(",",$this->thisConfig["blindImageOptions"],1));
146 reset($this->allowedItems);
147 if (!in_array($this->act,$this->allowedItems)) $this->act = current($this->allowedItems);
148 }
149 function rteImageStorageDir() {
150 # debug($this->thisConfig);
151 # exit;
152 $dir = $this->imgPath ? $this->imgPath : $GLOBALS["TYPO3_CONF_VARS"]["BE"]["RTE_imageStorageDir"];;
153 #debug($dir);
154 return $dir;
155 # return $this->thisConfig["proc."]["RTE_imageStorageDir"]?$this->thisConfig["proc."]["RTE_imageStorageDir"]:$GLOBALS["TYPO3_CONF_VARS"]["BE"]["RTE_imageStorageDir"];
156 }
157 function magicProcess() {
158 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
159
160 if ($this->act=="magic" && t3lib_div::GPvar("insertMagicImage")) {
161 $filepath = t3lib_div::GPvar("insertMagicImage");
162
163 $imgObj = t3lib_div::makeInstance("t3lib_stdGraphic");
164 $imgObj->init();
165 $imgObj->mayScaleUp=0;
166 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
167
168 $imgInfo = $imgObj->getImageDimensions($filepath);
169
170 if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir()) {
171 $fI=pathinfo($imgInfo[3]);
172 $fileFunc = t3lib_div::makeInstance("t3lib_basicFileFunctions");
173 $basename = $fileFunc->cleanFileName("RTEmagicP_".$fI["basename"]);
174 $destPath =PATH_site.$this->rteImageStorageDir();
175 if (@is_dir($destPath)) {
176 $destName = $fileFunc->getUniqueName($basename,$destPath);
177 @copy($imgInfo[3],$destName);
178
179 $cHeight=t3lib_div::intInRange(t3lib_div::GPvar("cHeight"),0,500);
180 $cWidth=t3lib_div::intInRange(t3lib_div::GPvar("cWidth"),0,500);
181 if (!$cHeight) $cHeight=200;
182 if (!$cWidth) $cWidth=300;
183 // This thing allows 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
184 $cHeight=1000;
185 // debug(array($cHeight,$cWidth));
186 //exit;
187 $imgI = $imgObj->imageMagickConvert($filepath,"WEB",$cWidth."m",$cHeight."m"); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
188 // debug($imgI);
189 if ($imgI[3]) {
190 $fI=pathinfo($imgI[3]);
191 $mainBase="RTEmagicC_".substr(basename($destName),10).".".$fI["extension"];
192 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
193 @copy($imgI[3],$destName);
194
195 $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
196 echo'
197 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
198 <html>
199 <head>
200 <title>Untitled</title>
201 </head>
202 <script language="javascript" type="text/javascript">
203 function insertImage(file,width,height) {
204 self.parent.parent.renderPopup_insertImage(\'<img src="\'+file+\'" width="\'+width+\'" height="\'+height+\'" border=0>\');
205 }
206 </script>
207 <body>
208 <script language="javascript" type="text/javascript">
209 insertImage(\''.$iurl.'\','.$imgI[0].','.$imgI[1].');
210 </script>
211 </body>
212 </html>';
213 }
214
215 }
216 }
217 exit;
218 }
219 }
220 function init() {
221 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
222
223 $this->doc = t3lib_div::makeInstance("template");
224 $this->doc->backPath = $BACK_PATH;
225 $this->doc->JScode='
226 <script language="javascript" type="text/javascript">
227 function jumpToUrl(URL,anchor) {
228 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
229 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div::GPvar("RTEtsConfigParams")).'";
230
231 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.width : "";
232 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.height : "";
233
234 var theLocation = URL+add_act+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
235 document.location = theLocation;
236 return false;
237 }
238 function insertImage(file,width,height) {
239 self.parent.parent.renderPopup_insertImage(\'<img src="\'+file+\'" width="\'+width+\'" height="\'+height+\'" border=0>\');
240 }
241 function launchView(url) {
242 var thePreviewWindow="";
243 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");
244 if (thePreviewWindow && thePreviewWindow.focus) {
245 thePreviewWindow.focus();
246 }
247 }
248 function getCurrentImageRef() {
249 if (self.parent.parent
250 && self.parent.parent.document.idPopup
251 && self.parent.parent.document.idPopup.document
252 && self.parent.parent.document.idPopup.document._selectedImage) {
253 // self.parent.parent.debugObj(self.parent.parent.document.idPopup.document._selectedImage);
254 return self.parent.parent.document.idPopup.document._selectedImage;
255 }
256 return "";
257 }
258 function printCurrentImageOptions() {
259 // alert(selectedImageRef.href);
260 var styleSelector=\'<select name="iClass" style="width:140px;"><option value=""></option><option value="TestClass">TestClass</option></select>\';
261 var alignSelector=\'<select name="iAlign" style="width:60px;"><option value=""></option><option value="left">Left</option><option value="right">Right</option></select>\';
262 var bgColor=\' bgColor="'.$this->doc->bgColor4.'"\';
263 var sz="";
264 sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
265 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL("width").': <input type="text" name="iWidth" value=""'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).'>&nbsp;&nbsp;'.$LANG->getLL("height").': <input type="text" name="iHeight" value=""'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).'>&nbsp;&nbsp;'.$LANG->getLL("border").': <input type="checkbox" name="iBorder" value="1"></td></tr>\';
266 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL("margin_lr").': <input type="text" name="iHspace" value=""'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).'>&nbsp;&nbsp;'.$LANG->getLL("margin_tb").': <input type="text" name="iVspace" value=""'.$GLOBALS["TBE_TEMPLATE"]->formWidth(4).'></td></tr>\';
267 // sz+=\'<tr><td\'+bgColor+\'>Textwrapping: \'+alignSelector+\'&nbsp;&nbsp;Style: \'+styleSelector+\'</td></tr>\';
268 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL("title").': <input type="text" name="iTitle"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).'></td></tr>\';
269 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL("update").'" onClick="return setImageProperties();"></td></tr>\';
270 sz+=\'</form></table>\';
271 return sz;
272 }
273 function setImageProperties() {
274 if (selectedImageRef) {
275 selectedImageRef.width=document.imageData.iWidth.value;
276 selectedImageRef.height=document.imageData.iHeight.value;
277 selectedImageRef.vspace=document.imageData.iVspace.value;
278 selectedImageRef.hspace=document.imageData.iHspace.value;
279 selectedImageRef.title=document.imageData.iTitle.value;
280 selectedImageRef.alt=document.imageData.iTitle.value;
281
282 selectedImageRef.border= (document.imageData.iBorder.checked ? 1 : 0);
283
284 /*
285 var iAlign = document.imageData.iAlign.options[document.imageData.iAlign.selectedIndex].value;
286 if (iAlign || selectedImageRef.align) {
287 selectedImageRef.align=iAlign;
288 }
289
290 selectedImageRef.style.cssText="";
291
292 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
293 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
294 selectedImageRef["class"]=iClass;
295 selectedImageRef.attributes["class"].value=iClass;
296 }
297 */
298 // selectedImageRef.style="";
299 self.parent.parent.edHidePopup();
300 }
301 return false;
302 }
303 function insertImagePropertiesInForm() {
304 if (selectedImageRef) {
305 document.imageData.iWidth.value = selectedImageRef.width;
306 document.imageData.iHeight.value = selectedImageRef.height;
307 document.imageData.iVspace.value = selectedImageRef.vspace;
308 document.imageData.iHspace.value = selectedImageRef.hspace;
309 document.imageData.iTitle.value = selectedImageRef.title;
310 if (parseInt(selectedImageRef.border)) {
311 document.imageData.iBorder.checked = 1;
312 }
313 /*
314 // Update align
315 var fObj=document.imageData.iAlign;
316 var value=selectedImageRef.align;
317 var l=fObj.length;
318 for (a=0;a<l;a++) {
319 if (fObj.options[a].value == value) {
320 fObj.selectedIndex = a;
321 }
322 }
323 // Update class
324 // selectedImageRef.className ??
325 var fObj=document.imageData.iClass;
326 var value=selectedImageRef.attributes["class"].value;
327 var l=fObj.length;
328 for (a=0;a<l;a++) {
329 if (fObj.options[a].value == value) {
330 fObj.selectedIndex = a;
331 }
332 }
333 */
334
335 }
336 // alert(document.imageData);
337 return false;
338 }
339
340 function openDragDrop() {
341 var url = "browse_links.php?mode=filedrag&bparams=|||"+escape("gif,jpg,jpeg,png");
342 browserWin = window.open(url,"Typo3WinBrowser","height=350,width=600,status=0,menubar=0,resizable=1,scrollbars=1");
343 browserWin.focus();
344 self.parent.parent.edHidePopup(1);
345 }
346
347 var selectedImageRef = getCurrentImageRef(); // Setting this to a reference to the image object.
348
349 '.($this->act=="dragdrop"?"openDragDrop();":"").'
350
351 // alert(selectedImageRef.href);
352 </script>
353 ';
354
355 // Starting content:
356 $this->content="";
357 $this->content.=$this->doc->startPage("RTE image insert");
358
359 }
360 function main() {
361 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
362 global $FILEMOUNTS;
363
364 $menu='<table border=0 cellpadding=2 cellspacing=1><tr>';
365 $bgcolor=' bgcolor="'.$this->doc->bgColor4.'"';
366 $bgcolorA=' bgcolor="'.$this->doc->bgColor5.'"';
367 if ($this->act=="image" || t3lib_div::GPvar("cWidth")) { // If $this->act is specifically set to "image" or if cWidth is passed around...
368 $menu.='<td align=center nowrap width="25%"'.($this->act=="image"?$bgcolorA:$bgcolor).'><a href="#" onClick="jumpToUrl(\'?act=image\');return false;"><strong>'.$LANG->getLL("currentImage").'</strong></a></td>';
369 }
370 if (in_array("magic",$this->allowedItems)) $menu.='<td align=center nowrap width="25%"'.($this->act=="magic"?$bgcolorA:$bgcolor).'><a href="#" onClick="jumpToUrl(\'?act=magic\');return false;"><strong>'.$LANG->getLL("magicImage").'</strong></a></td>';
371 if (in_array("plain",$this->allowedItems)) $menu.='<td align=center nowrap width="25%"'.($this->act=="plain"?$bgcolorA:$bgcolor).'><a href="#" onClick="jumpToUrl(\'?act=plain\');return false;"><strong>'.$LANG->getLL("plainImage").'</strong></a></td>';
372 if (in_array("dragdrop",$this->allowedItems)) $menu.='<td align=center nowrap width="25%"'.$bgcolor.'><a href="#" onClick="openDragDrop();return false;"><strong>'.$LANG->getLL("dragDropImage").'</strong></a></td>';
373 $menu.='</tr></table>';
374
375 $this->content.='<img src=clear.gif width=1 height=2>';
376 $this->content.=$menu;
377 $this->content.='<img src=clear.gif width=1 height=10>';
378
379 if ($this->act!="image") {
380 // File-folders:
381 $foldertree = t3lib_div::makeInstance("localFolderTree");
382 $tree=$foldertree->getBrowsableTree();
383 list(,,$specUid) = explode("_",t3lib_div::GPvar("PM"));
384 $files = $this->expandFolder($foldertree->specUIDmap[$specUid],$this->act=="plain");
385
386 $this->content.= '<table border=0 cellpadding=0 cellspacing=0>
387 <tr>
388 <td valign=top><font face=verdana size=1 color=black>'.$this->barheader($LANG->getLL("folderTree").':').$tree.'</font></td>
389 <td>&nbsp;</td>
390 <td valign=top><font face=verdana size=1 color=black>'.$files.'</font></td>
391 </tr>
392 </table>
393 <BR>';
394
395 /*
396 // Target:
397 if ($this->act!="mail") {
398 $ltarget='<table border=0 cellpadding=2 cellspacing=1><form name="ltargetform" id="ltargetform"><tr>';
399 $ltarget.='<td width=90>Target:</td>';
400 $ltarget.='<td><input type="text" name="ltarget" onChange="setTarget(this.value);" value="'.htmlspecialchars($curUrlArray["target"]).'"></td>';
401 $ltarget.='<td><select name="ltarget_type" onChange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
402 <option></option>
403 <option value="_top">Top</option>
404 <option value="_blank">New window</option>
405 </select></td>';
406 if (($curUrlInfo["act"]=="page" || $curUrlInfo["act"]=="file") && $curUrlArray["href"]) {
407 $ltarget.='<td><input type="submit" value="Update" onClick="return link_current();"></td>';
408 }
409 $ltarget.='</tr></form></table>';
410
411 $this->content.=$ltarget;
412 }
413 */
414
415
416
417
418 // ***************************
419 // Upload
420 // ***************************
421 $fileProcessor = t3lib_div::makeInstance("t3lib_basicFileFunctions");
422 $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS["BE"]["fileExtensions"]);
423 $path=t3lib_div::GPvar("expandFolder");
424 if (!$path || $path=="/" || !@is_dir($path)) {
425 $path = $fileProcessor->findTempFolder(); // The closest TEMP-path is found
426 if ($path) $path.="/";
427 }
428 if ($path && @is_dir($path)) {
429 $this->content.=$this->uploadForm($path)."<BR>";
430 }
431
432 // ***************************
433 // Help
434 // ***************************
435
436 if ($this->act=="magic") {
437 $this->content.='<img src="gfx/icon_note.gif" width="18" height="16" align=top>'.$LANG->getLL("magicImage_msg").'<BR>';
438 }
439 if ($this->act=="plain") {
440 $this->content.='<img src="gfx/icon_note.gif" width="18" height="16" align=top>'.$LANG->getLL("plainImage_msg").'<BR>';
441 }
442 } else {
443 $this->content.='
444 <script language="javascript" type="text/javascript">
445 document.write(printCurrentImageOptions());
446 insertImagePropertiesInForm();
447 </script>
448 ';
449 }
450
451 }
452 function printContent() {
453 global $SOBE;
454
455 $this->content.= $this->doc->endPage();
456 echo $this->content;
457 }
458
459 // ***************************
460 // OTHER FUNCTIONS:
461 // ***************************
462
463 function expandFolder($expandFolder=0,$plainFlag=0) {
464 global $LANG;
465
466 $expandFolder = $expandFolder ? $expandFolder :t3lib_div::GPvar("expandFolder");
467 $out="";
468
469 $resolutionLimit_x=640;
470 $resolutionLimit_y=680;
471
472 if ($expandFolder) {
473 $files = t3lib_div::getFilesInDir($expandFolder,($plainFlag?"jpg,jpeg,gif,png":$GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"]),1,1); // $extensionList="",$prependPath=0,$order="")
474 if (is_array($files)) {
475 reset($files);
476
477 $out.=$this->barheader(sprintf($LANG->getLL("images").' (%s):',count($files)));
478
479 $titleLen=intval($GLOBALS["BE_USER"]->uc["titleLen"]);
480 $picon='<img src="gfx/i/_icon_webfolders.gif" width="18" height="16" align=top>';
481 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
482 $out.='<nobr>'.$picon.'</nobr><BR>';
483
484 $imgObj = t3lib_div::makeInstance("t3lib_stdGraphic");
485 $imgObj->init();
486 $imgObj->mayScaleUp=0;
487 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
488
489 $noThumbs = $GLOBALS["BE_USER"]->getTSConfigVal("options.noThumbsInRTEimageSelect");
490
491 $lines=array();
492 while(list(,$filepath)=each($files)) {
493 $fI=pathinfo($filepath);
494
495 $iurl = $this->siteUrl.substr($filepath,strlen(PATH_site));
496 //debug($iurl);
497 $imgInfo = $imgObj->getImageDimensions($filepath);
498
499
500 // debug($imgInfo);
501
502 // debug($fI);
503 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI["extension"]));
504 $pDim = $imgInfo[0]."x".$imgInfo[1]." pixels";
505 $size=" (".t3lib_div::formatSize(filesize($filepath))."bytes, ".$pDim.")";
506 $icon = '<img src="gfx/fileicons/'.$icon.'" width=18 height=16 border=0 title="'.$fI["basename"].$size.'" align=absmiddle>';
507 if (!$plainFlag) {
508 $ATag = '<a href="#" onClick="return jumpToUrl(\'?insertMagicImage='.rawurlencode($filepath).'\');">';
509 } else {
510 $ATag = '<a href="#" onClick="return insertImage(\''.$iurl.'\','.$imgInfo[0].','.$imgInfo[1].');">';
511 }
512 $ATag_e="</a>";
513 if ($plainFlag && ($imgInfo[0]>$resolutionLimit_x || $imgInfo[1]>$resolutionLimit_y)) {
514 $ATag="";
515 $ATag_e="";
516 $ATag2="";
517 $ATag2_e="";
518 } else {
519 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
520 $ATag2_e="</a>";
521 }
522
523 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
524
525 $lines[]='<tr bgcolor="'.$this->doc->bgColor4.'"><td nowrap>'.$filenameAndIcon.'&nbsp;</td><td nowrap>'.$pDim.'&nbsp;</td></tr>';
526 $lines[]='<tr><td colspan=2>'.(
527 $noThumbs ?
528 "" :
529 $ATag2.t3lib_BEfunc::getThumbNail("thumbs.php",$filepath,"hspace=5 vspace=5 border=1").$ATag2_e).
530 '</td></tr>';
531 $lines[]='<tr><td colspan=2><img src=clear.gif width=1 height=3></td></tr>';
532 }
533 $out.='<table border=0 cellpadding=0 cellspacing=1>'.implode("",$lines).'</table>';
534 }
535 }
536 return $out;
537 }
538 function uploadForm($path) {
539 global $LANG,$SOBE;
540
541 // debug($path);
542 $count=1;
543 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
544 $code=$this->barheader($LANG->getLL("uploadImage").":");
545 $code.='<table border=0 cellpadding=0 cellspacing=3><FORM action="tce_file.php" method="POST" name="editform" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'"><tr><td>';
546 $code.="<strong>".$LANG->getLL("path").":</strong> ".$header."</td></tr><tr><td>";
547 for ($a=1;$a<=$count;$a++) {
548 $code.='<input type="File" name="upload_'.$a.'"'.$this->doc->formWidth(30).'>
549 <input type="Hidden" name="file[upload]['.$a.'][target]" value="'.$path.'">
550 <input type="Hidden" name="file[upload]['.$a.'][data]" value="'.$a.'"><BR>';
551 }
552 $code.='<input type="Hidden" name="redirect" value="rte_select_image.php?act='.$this->act.'&expandFolder='.rawurlencode($path).'&RTEtsConfigParams='.rawurlencode(t3lib_div::GPvar("RTEtsConfigParams")).'"><input type="Submit" name="submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_upload.php.submit").'"></td></tr></FORM></table>';
553 return $code;
554 }
555 function barheader($str) {
556 global $LANG,$SOBE;
557
558 return '<table border=0 cellpadding=2 cellspacing=0 width=100% bgcolor="'.$this->doc->bgColor5.'"><tr><td><strong>'.$str.'</strong></td></tr></table>';
559 }
560 function printCurrentUrl($str) {
561 global $LANG,$SOBE;
562
563 return '<table border=0 cellpadding=0 cellspacing=0 width=100% bgcolor="'.$this->doc->bgColor5.'"><tr><td><strong>Current Link:</strong> '.$str.'</td></tr></table>';
564 }
565 }
566
567 // Include extension?
568 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/rte_select_image.php"]) {
569 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/rte_select_image.php"]);
570 }
571
572
573
574
575
576
577
578
579
580
581
582
583 // Make instance:
584 $SOBE = t3lib_div::makeInstance("SC_rte_select_image");
585 $SOBE->preinit();
586 $SOBE->magicProcess();
587 $SOBE->init();
588 $SOBE->main();
589 $SOBE->printContent();
590 ?>