2 /***************************************************************
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
6 * (c) 2004-2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
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.
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.
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.
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
29 * Displays image selector for the RTE
31 * @author Kasper Skaarhoj <kasper@typo3.com>
32 * @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
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');
44 * @author Kasper Skaarhoj <kasper@typo3.com>
48 class tx_rtehtmlarea_image_folderTree
extends t3lib_folderTree
{
52 * Wrapping the title in a link, if applicable.
54 * @param string Title, ready for output.
55 * @param array The "record"
56 * @return string Wrapping title string.
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>';
63 return '<span class="typo3-dimmed">'.$title.'</span>';
68 * Returns true if the input "record" contains a folder which can be linked.
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
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'
77 if (strstr($v['path'],'_recycler_') ||
strstr($v['path'],'_temp_') ||
$webpath!='web') {
84 * Wrap the plus/minus icon in a link
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
92 function PM_ATagWrap($icon,$cmd,$bMark='') {
95 $name=' name="'.$bMark.'"';
97 $aOnClick = 'return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');';
98 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
104 * @param mixed Input tree array. If not array, then $this->tree is used.
105 * @return string HTML output of the tree.
107 function printTree($treeArr='') {
108 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
110 if (!is_array($treeArr)) $treeArr=$this->tree
;
115 // Traverse rows for the tree and print them into table rows:
116 foreach($treeArr as $k => $v) {
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>';
122 $out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>';
131 * @author Kasper Skaarhoj <kasper@typo3.com>
135 class tx_rtehtmlarea_select_image
extends browse_links
{
136 var $extKey = 'rtehtmlarea';
145 var $classesImageJSOptions;
147 var $buttonConfig = array();
155 global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;
158 $this->siteUrl
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL');
159 $this->act
= t3lib_div
::_GP('act');
160 $this->editorNo
= t3lib_div
::_GP('editorNo');
161 $this->expandPage
= t3lib_div
::_GP('expandPage');
162 $this->expandFolder
= t3lib_div
::_GP('expandFolder');
165 $this->mode
= t3lib_div
::_GP('mode');
171 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL'); // Current site url
173 // the script to link to
174 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
180 $RTEtsConfigParts = explode(':',t3lib_div
::_GP('RTEtsConfigParams'));
181 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($RTEtsConfigParts[5]));
182 $this->thisConfig
= t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
183 $this->imgPath
= $RTEtsConfigParts[6];
185 if (is_array($this->thisConfig
['buttons.']) && is_array($this->thisConfig
['buttons.']['image.'])) {
186 $this->buttonConfig
= $this->thisConfig
['buttons.']['image.'];
189 $this->allowedItems
= explode(',','magic,plain,dragdrop,image');
190 if (is_array($this->buttonConfig
['options.']) && $this->buttonConfig
['options.']['removeItems']) {
191 $this->allowedItems
= array_diff($this->allowedItems
,t3lib_div
::trimExplode(',',$this->buttonConfig
['options.']['removeItems'],1));
193 $this->allowedItems
= array_diff($this->allowedItems
,t3lib_div
::trimExplode(',',$this->thisConfig
['blindImageOptions'],1));
195 reset($this->allowedItems
);
196 if (!in_array($this->act
,$this->allowedItems
)) {
197 $this->act
= current($this->allowedItems
);
200 if ($this->act
== 'plain') {
201 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['plainImageMaxWidth']) $this->plainMaxWidth
= $TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['plainImageMaxWidth'];
202 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['plainImageMaxHeight']) $this->plainMaxHeight
= $TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['plainImageMaxHeight'];
203 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['plain.'])) {
204 if ($this->buttonConfig
['options.']['plain.']['maxWidth']) $this->plainMaxWidth
= $this->buttonConfig
['options.']['plain.']['maxWidth'];
205 if ($this->buttonConfig
['options.']['plain.']['maxHeight']) $this->plainMaxHeight
= $this->buttonConfig
['options.']['plain.']['maxHeight'];
207 if (!$this->plainMaxWidth
) $this->plainMaxWidth
= 640;
208 if (!$this->plainMaxHeight
) $this->plainMaxHeight
= 680;
209 } elseif ($this->act
== 'magic') {
210 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['magic.'])) {
211 if ($this->buttonConfig
['options.']['magic.']['maxWidth']) $this->magicMaxWidth
= $this->buttonConfig
['options.']['magic.']['maxWidth'];
212 if ($this->buttonConfig
['options.']['magic.']['maxHeight']) $this->magicMaxHeight
= $this->buttonConfig
['options.']['magic.']['maxHeight'];
214 // 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
215 if (!$this->magicMaxWidth
) $this->magicMaxWidth
= 300;
216 if (!$this->magicMaxHeight
) $this->magicMaxHeight
= 1000;
219 if($this->thisConfig
['classesImage']) {
220 $classesImageArray = t3lib_div
::trimExplode(',',$this->thisConfig
['classesImage'],1);
221 $this->classesImageJSOptions
= '<option value=""></option>';
222 reset($classesImageArray);
223 while(list(,$class)=each($classesImageArray)) {
224 $this->classesImageJSOptions
.= '<option value="' .$class . '">' . $class . '</option>';
228 $this->magicProcess();
230 // Creating backend template object:
231 $this->doc
= t3lib_div
::makeInstance('template');
232 $this->doc
->docType
= 'xhtml_trans';
233 $this->doc
->backPath
= $BACK_PATH;
239 * [Describe function...]
243 function rteImageStorageDir() {
244 $dir = $this->imgPath ?
$this->imgPath
: $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
249 * [Describe function...]
253 function magicProcess() {
254 global $TYPO3_CONF_VARS;
256 if ($this->act
=='magic' && t3lib_div
::_GP('insertMagicImage')) {
257 $filepath = t3lib_div
::_GP('insertMagicImage');
259 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
261 $imgObj->mayScaleUp
=0;
262 $imgObj->tempPath
=PATH_site
.$imgObj->tempPath
;
264 $imgInfo = $imgObj->getImageDimensions($filepath);
266 if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir()) {
267 $fI=pathinfo($imgInfo[3]);
268 $fileFunc = t3lib_div
::makeInstance('t3lib_basicFileFunctions');
269 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
270 $destPath =PATH_site
.$this->rteImageStorageDir();
271 if (@is_dir
($destPath)) {
272 $destName = $fileFunc->getUniqueName($basename,$destPath);
273 if (isset($TYPO3_CONF_VARS['BE']['fileCreateMask'])) {
274 @chmod
($destName, $TYPO3_CONF_VARS['BE']['fileCreateMask']);
276 @copy
($imgInfo[3],$destName);
278 $cWidth = t3lib_div
::intInRange(t3lib_div
::_GP('cWidth'),0,$this->magicMaxWidth
);
279 $cHeight = t3lib_div
::intInRange(t3lib_div
::_GP('cHeight'),0,$this->magicMaxHeight
);
280 if (!$cWidth) $cWidth = $this->magicMaxWidth
;
281 if (!$cHeight) $cHeight = $this->magicMaxHeight
;
283 $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
285 $fI=pathinfo($imgI[3]);
286 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
287 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
288 if (isset($TYPO3_CONF_VARS['BE']['fileCreateMask'])) {
289 @chmod
($destName, $TYPO3_CONF_VARS['BE']['fileCreateMask']);
291 @copy
($imgI[3],$destName);
293 $destName = dirname($destName).'/'.rawurlencode(basename($destName));
294 $iurl = $this->siteUrl
.substr($destName,strlen(PATH_site
));
296 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
299 <title>Untitled</title>
301 <script language="javascript" type="text/javascript">
303 var editor = window.opener.RTEarea[' . $this->editorNo
. ']["editor"];
304 var HTMLArea = window.opener.HTMLArea;
305 function insertImage(file,width,height,origFile) {
306 var styleWidth, styleHeight;
307 styleWidth = parseInt(width);
308 if (isNaN(styleWidth) || styleWidth == 0) {
313 styleHeight = parseInt(height);
314 if (isNaN(styleHeight) || styleHeight == 0) {
315 styleHeight = "auto";
319 editor.renderPopup_insertImage(\'<img src="\'+file+\'" style="width: \'+styleWidth+\'; height: \'+styleHeight+\';"'.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['enableClickEnlarge'] && !(is_array($this->buttonConfig
['clickEnlarge.']) && $this->buttonConfig
['clickEnlarge.']['disabled']))?
' clickenlargesrc="\'+origFile+\'" clickenlarge="0"':'').' />\');
324 <script type="text/javascript">
326 insertImage(\''.$iurl.'\','.$imgI[0].','.$imgI[1].',\''.substr($imgInfo[3],strlen(PATH_site
)).'\');
340 * [Describe function...]
344 function getJSCode() {
345 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
348 var editor = window.opener.RTEarea[' . $this->editorNo
. ']["editor"];
349 var HTMLArea = window.opener.HTMLArea;
350 function jumpToUrl(URL,anchor) { //
351 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act
.'" : "";
352 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo
.'" : "";
353 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div
::_GP('RTEtsConfigParams')).'";
355 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
356 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
358 var theLocation = URL+add_act+add_editorNo+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
359 window.location.href = theLocation;
362 function insertImage(file,width,height,origFile) {
363 var styleWidth, styleHeight;
364 styleWidth = parseInt(width);
365 if (isNaN(styleWidth) || styleWidth == 0) {
370 styleHeight = parseInt(height);
371 if (isNaN(styleHeight) || styleHeight == 0) {
372 styleHeight = "auto";
376 editor.renderPopup_insertImage(\'<img src="\'+file+\'" style="width: \'+styleWidth+\'; height: \'+styleHeight+\';"'.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['enableClickEnlarge'] && !(is_array($this->buttonConfig
['clickEnlarge.']) && $this->buttonConfig
['clickEnlarge.']['disabled']))?
' clickenlargesrc="\'+origFile+\'" clickenlarge="0"':'').' />\');
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();
385 function getCurrentImageRef() {
386 if (editor._selectedImage) {
387 return editor._selectedImage;
392 function printCurrentImageOptions() {
393 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
394 if(classesImage) var styleSelector=\'<select name="iClass" style="width:140px;">' . $this->classesImageJSOptions
. '</select>\';
395 var floatSelector=\'<select 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"\';
398 sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
400 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('class').': </td><td>\'+styleSelector+\'</td></tr>\';
402 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('width').': </td><td><input type="text" name="iWidth" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
403 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('height').': </td><td><input type="text" name="iHeight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
404 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('border').': </td><td><input type="checkbox" name="iBorder" value="1" /></td></tr>\';
405 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('float').': </td><td>\'+floatSelector+\'</td></tr>\';
406 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('margin_lr').': </td><td><input type="text" name="iHspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).'></td></tr>\';
407 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('margin_tb').': </td><td><input type="text" name="iVspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
408 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('title').': </td><td><input type="text" name="iTitle"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
409 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('alt').': </td><td><input type="text" name="iAlt"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
410 '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['enableClickEnlarge'] && !(is_array($this->buttonConfig
['clickEnlarge.']) && $this->buttonConfig
['clickEnlarge.']['disabled']))?
'if (selectedImageRef && selectedImageRef.getAttribute("clickenlargesrc")) 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>\';':'').' sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
411 sz+=\'</form></table>\';
414 function setImageProperties() {
415 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
416 if (selectedImageRef) {
417 if(document.imageData.iWidth.value && document.imageData.iWidth.value != "auto") {
418 selectedImageRef.style.width = document.imageData.iWidth.value + "px";
420 selectedImageRef.style.width = "auto";
422 selectedImageRef.removeAttribute("width");
423 if(document.imageData.iHeight.value && document.imageData.iHeight.value != "auto") {
424 selectedImageRef.style.height=document.imageData.iHeight.value + "px";
426 selectedImageRef.style.height = "auto";
428 selectedImageRef.removeAttribute("height");
430 selectedImageRef.style.paddingTop = "0px";
431 selectedImageRef.style.paddingBottom = "0px";
432 selectedImageRef.style.paddingRight = "0px";
433 selectedImageRef.style.paddingLeft = "0px";
434 selectedImageRef.style.padding = ""; // this statement ignored by Mozilla 1.3.1
435 if(document.imageData.iVspace.value != "" && !isNaN(parseInt(document.imageData.iVspace.value))) {
436 selectedImageRef.style.paddingTop = parseInt(document.imageData.iVspace.value) + "px";
437 selectedImageRef.style.paddingBottom = selectedImageRef.style.paddingTop;
439 if(document.imageData.iHspace.value != "" && !isNaN(parseInt(document.imageData.iHspace.value))) {
440 selectedImageRef.style.paddingRight = parseInt(document.imageData.iHspace.value) + "px";
441 selectedImageRef.style.paddingLeft = selectedImageRef.style.paddingRight;
443 selectedImageRef.removeAttribute("vspace");
444 selectedImageRef.removeAttribute("hspace");
446 selectedImageRef.title=document.imageData.iTitle.value;
447 selectedImageRef.alt=document.imageData.iAlt.value;
449 selectedImageRef.style.borderStyle = "none";
450 selectedImageRef.style.borderWidth = "0px";
451 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
452 if(document.imageData.iBorder.checked) {
453 selectedImageRef.style.borderStyle = "solid";
454 selectedImageRef.style.borderWidth = "thin";
456 selectedImageRef.removeAttribute("border");
458 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
459 if (iFloat || selectedImageRef.style.cssFloat || selectedImageRef.style.styleFloat) {
461 selectedImageRef.style.styleFloat = iFloat;
463 selectedImageRef.style.cssFloat = iFloat;
468 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
469 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
470 selectedImageRef.className = iClass;
474 '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['enableClickEnlarge'] && !(is_array($this->buttonConfig
['clickEnlarge.']) && $this->buttonConfig
['clickEnlarge.']['disabled']))?
'
475 if (document.imageData.iClickEnlarge && document.imageData.iClickEnlarge.checked) selectedImageRef.setAttribute("clickenlarge","1");
476 else selectedImageRef.setAttribute("clickenlarge","0");':'').'
478 HTMLArea.edHidePopup();
482 function insertImagePropertiesInForm() {
483 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
484 if (selectedImageRef) {
485 var styleWidth, styleHeight, paddingTop, paddingRight;
486 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
487 styleWidth = parseInt(styleWidth);
488 if (isNaN(styleWidth) || styleWidth == 0) { styleWidth = "auto"; }
489 document.imageData.iWidth.value = styleWidth;
490 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
491 styleHeight = parseInt(styleHeight);
492 if (isNaN(styleHeight) || styleHeight == 0) { styleHeight = "auto"; }
493 document.imageData.iHeight.value = styleHeight;
495 paddingTop = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
496 paddingTop = parseInt(paddingTop);
497 if (isNaN(paddingTop) || paddingTop < 0) { paddingTop = ""; }
498 document.imageData.iVspace.value = paddingTop;
499 paddingRight = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
500 paddingRight = parseInt(paddingRight);
501 if (isNaN(paddingRight) || paddingRight < 0) { paddingRight = ""; }
502 document.imageData.iHspace.value = paddingRight;
504 document.imageData.iTitle.value = selectedImageRef.title;
505 document.imageData.iAlt.value = selectedImageRef.alt;
507 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
508 document.imageData.iBorder.checked = 1;
511 var fObj=document.imageData.iFloat;
512 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
515 if (fObj.options[a].value == value) {
516 fObj.selectedIndex = a;
521 var fObj=document.imageData.iClass;
522 var value=selectedImageRef.className;
525 if (fObj.options[a].value == value) {
526 fObj.selectedIndex = a;
531 '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['enableClickEnlarge'] && !(is_array($this->buttonConfig
['clickEnlarge.']) && $this->buttonConfig
['clickEnlarge.']['disabled']))?
'if (selectedImageRef.getAttribute("clickenlargesrc")) {
532 if (selectedImageRef.getAttribute("clickenlarge") == "1") document.imageData.iClickEnlarge.checked = 1;
533 else document.imageData.iClickEnlarge.removeAttribute("checked");
539 function openDragDrop() {
540 var url = "' . $BACK_PATH . t3lib_extMgm
::extRelPath($this->extKey
) . 'mod3/browse_links.php?mode=filedrag&editorNo='.$this->editorNo
.'&bparams=|||"+escape("gif,jpg,jpeg,png");
541 window.opener.browserWin = window.open(url,"Typo3WinBrowser","height=350,width=600,status=0,menubar=0,resizable=1,scrollbars=1");
542 HTMLArea.edHidePopup();
545 var selectedImageRef = getCurrentImageRef(); // Setting this to a reference to the image object.
547 '.($this->act
=='dragdrop'?
'openDragDrop();':'');
549 // Finally, add the accumulated JavaScript to the template object:
550 $this->doc
->JScode
= $this->doc
->wrapScriptTags($JScode);
554 * Session data for this class can be set from outside with this method.
557 * @param array Session data array
558 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
560 function processSessionData($data) {
563 if ($this->act
!= 'image') {
564 if (isset($this->act
)) {
565 $data['act'] = $this->act
;
568 $this->act
= $data['act'];
572 if (isset($this->expandFolder
)) {
573 $data['expandFolder'] = $this->expandFolder
;
576 $this->expandFolder
= $data['expandFolder'];
579 return array($data, $store);
583 * [Describe function...]
587 function main_rte() {
588 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
591 $this->content
= $this->doc
->startPage($LANG->getLL('Insert Image',1));
593 // Making menu in top:
595 if (in_array('image',$this->allowedItems
) && ($this->act
=='image' || t3lib_div
::_GP('cWidth'))) {
596 $menuDef['page']['isActive'] = $this->act
=='image';
597 $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
598 $menuDef['page']['url'] = '#';
599 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&editorNo='.$this->editorNo
.'\');return false;"';
601 if (in_array('magic',$this->allowedItems
)){
602 $menuDef['file']['isActive'] = $this->act
=='magic';
603 $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
604 $menuDef['file']['url'] = '#';
605 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&editorNo='.$this->editorNo
.'\');return false;"';
607 if (in_array('plain',$this->allowedItems
)) {
608 $menuDef['url']['isActive'] = $this->act
=='plain';
609 $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
610 $menuDef['url']['url'] = '#';
611 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&editorNo='.$this->editorNo
.'\');return false;"';
613 if (in_array('dragdrop',$this->allowedItems
)) {
614 $menuDef['mail']['isActive'] = $this->act
=='dragdrop';
615 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
616 $menuDef['mail']['url'] = '#';
617 $menuDef['mail']['addParams'] = 'onClick="openDragDrop();return false;"';
619 $this->content
.= $this->doc
->getTabMenuRaw($menuDef);
621 if ($this->act
!='image') {
623 // ***************************
625 // ***************************
626 // Create upload/create folder forms, if a path is given:
627 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
628 $fileProcessor = t3lib_div
::makeInstance('t3lib_basicFileFunctions');
629 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
630 $path=$this->expandFolder
;
631 if (!$path ||
!@is_dir
($path)) {
632 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
634 if ($path!='/' && @is_dir
($path)) {
635 $uploadForm=$this->uploadForm($path);
636 $createFolder=$this->createFolder($path);
641 $this->content
.= $uploadForm;
642 if ($BE_USER->isAdmin() ||
$BE_USER->getTSConfigVal('options.createFoldersInEB')) {
643 $this->content
.=$createFolder;
647 // Getting flag for showing/not showing thumbnails:
648 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect');
651 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
652 $_MOD_MENU = array('displayThumbs' => '');
653 $_MCONF['name']='file_list';
654 $_MOD_SETTINGS = t3lib_BEfunc
::getModuleData($_MOD_MENU, t3lib_div
::_GP('SET'), $_MCONF['name']);
655 $addParams = '&act='.$this->act
.'&editorNo='.$this->editorNo
.'&expandFolder='.rawurlencode($this->expandFolder
);
656 $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>';
662 $foldertree = t3lib_div
::makeInstance('tx_rtehtmlarea_image_folderTree');
663 $tree=$foldertree->getBrowsableTree();
664 list(,,$specUid) = explode('_',t3lib_div
::_GP('PM'));
665 $files = $this->expandFolder($foldertree->specUIDmap
[$specUid],$this->act
=='plain',$noThumbs?
$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
667 $this->content
.= '<table border=0 cellpadding=0 cellspacing=0>
669 <td valign=top>'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
671 <td valign=top>'.$files.'</td>
674 <br />'.$thumbNailCheck;
676 // ***************************
678 // ***************************
679 if ($this->act
=='magic') {
680 $this->content
.= $this->getMsgBox($LANG->getLL('magicImage_msg'));
682 if ($this->act
=='plain') {
683 $this->content
.= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth
, $this->plainMaxHeight
));
687 document.write(printCurrentImageOptions());
688 insertImagePropertiesInForm();';
689 $this->content
.= '<br />'.$this->doc
->wrapScriptTags($JScode);
691 $this->content
.= $this->doc
->endPage();
692 return $this->content
;
695 /***************************
699 ***************************/
701 * @param [type] $expandFolder: ...
702 * @param [type] $plainFlag: ...
705 function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) {
706 global $LANG, $BE_USER, $BACK_PATH;
708 $expandFolder = $expandFolder ?
$expandFolder :t3lib_div
::_GP('expandFolder');
711 if ($expandFolder && $this->checkFolder($expandFolder)) {
712 $files = t3lib_div
::getFilesInDir($expandFolder,($plainFlag?
'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1); // $extensionList="",$prependPath=0,$order="")
713 if (is_array($files)) {
716 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
718 $titleLen = intval($BE_USER->uc
['titleLen']);
719 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
720 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd(basename($expandFolder),$titleLen));
721 $out.='<span class="nobr">'.$picon.'</span><br />';
723 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
725 $imgObj->mayScaleUp
=0;
726 $imgObj->tempPath
=PATH_site
.$imgObj->tempPath
;
729 while(list(,$filepath)=each($files)) {
730 $fI=pathinfo($filepath);
732 $origFile = t3lib_div
::rawUrlEncodeFP(substr($filepath,strlen(PATH_site
)));
733 $iurl = $this->siteUrl
.$origFile;
734 $imgInfo = $imgObj->getImageDimensions($filepath);
736 $icon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
737 $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
738 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
739 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
741 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo
.'&insertMagicImage='.rawurlencode($filepath).'\');">';
743 $ATag = '<a href="#" onclick="return insertImage(\''.$iurl.'\','.$imgInfo[0].','.$imgInfo[1].',\''.$origFile.'\');">';
746 if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth
) ||
($imgInfo[1] > $this->plainMaxHeight
))) {
752 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
756 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div
::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
759 $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.' </td><td nowrap="nowrap">'.$pDim.' </td></tr>';
760 $lines[]='<tr><td colspan="2">'.($noThumbs ?
'' : $ATag2.t3lib_BEfunc
::getThumbNail($this->doc
->backPath
.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
762 $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
764 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
771 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
772 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
774 * @param string Absolute filepath on server to which to upload.
775 * @return string HTML for an upload form.
777 function uploadForm($path) {
781 // Create header, showing upload path:
782 $header = t3lib_div
::isFirstPartOfStr($path,PATH_site
)?
substr($path,strlen(PATH_site
)):$path;
783 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
787 Form, for uploading files:
789 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
790 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
792 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
797 // Traverse the number of upload fields (default is 3):
798 for ($a=1;$a<=$count;$a++
) {
799 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc
->formWidth(35).' size="50" />
800 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
801 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
804 // Make footer of upload form, including the submit button:
805 $redirectValue = $this->thisScript
.'?act='.$this->act
.'&editorNo='.$this->editorNo
.'&mode='.$this->mode
.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams
);
806 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
807 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
810 <div id="c-override">
811 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
826 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
827 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
829 * @param string Absolute filepath on server in which to create the new folder.
830 * @return string HTML for the create folder form.
832 function createFolder($path) {
834 // Create header, showing upload path:
835 $header = t3lib_div
::isFirstPartOfStr($path,PATH_site
)?
substr($path,strlen(PATH_site
)):$path;
836 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
840 Form, for creating new folders:
842 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
843 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
845 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
850 // Create the new-folder name field:
852 $code.='<input'.$this->doc
->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
853 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
855 // Make footer of upload form, including the submit button:
856 $redirectValue = $this->thisScript
.'?act='.$this->act
.'&editorNo='.$this->editorNo
.'&mode='.$this->mode
.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams
);
857 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
858 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
871 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']) {
872 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);