2 /***************************************************************
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
6 * (c) 2004-2008 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';
139 var $removedProperties = array();
144 var $lockPlainHeight;
148 var $classesImageJSOptions;
150 var $buttonConfig = array();
158 global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;
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');
168 $this->mode
= t3lib_div
::_GP('mode');
174 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL'); // Current site url
176 // the script to link to
177 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
183 $RTEtsConfigParts = explode(':',t3lib_div
::_GP('RTEtsConfigParams'));
184 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($RTEtsConfigParts[5]));
185 $this->thisConfig
= t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
186 $this->imgPath
= $RTEtsConfigParts[6];
188 if (is_array($this->thisConfig
['buttons.']) && is_array($this->thisConfig
['buttons.']['image.'])) {
189 $this->buttonConfig
= $this->thisConfig
['buttons.']['image.'];
190 if (is_array($this->buttonConfig
['properties.'])) {
191 if ($this->buttonConfig
['properties.']['removeItems']) {
192 $this->removedProperties
= t3lib_div
::trimExplode(',',$this->buttonConfig
['properties.']['removeItems'],1);
194 if (is_array($this->buttonConfig
['properties.']['class.']) && trim($this->buttonConfig
['properties.']['class.']['default'])) {
195 $this->defaultClass
= trim($this->buttonConfig
['properties.']['class.']['default']);
201 if (is_array($this->thisConfig
['proc.']) && $this->thisConfig
['proc.']['plainImageMode']) {
202 $plainImageMode = $this->thisConfig
['proc.']['plainImageMode'];
203 $this->lockPlainWidth
= ($plainImageMode == 'lockDimensions')?
'true':'false';
204 $this->lockPlainHeight
= ($this->lockPlainWidth ||
$plainImageMode == 'lockRatio' ||
($plainImageMode == 'lockRatioWhenSmaller'))?
'true':'false';
207 $this->allowedItems
= explode(',','magic,plain,image');
208 $clientInfo = t3lib_div
::clientInfo();
209 if ($clientInfo['BROWSER'] !== 'opera') {
210 $this->allowedItems
[] = 'dragdrop';
212 if (is_array($this->buttonConfig
['options.']) && $this->buttonConfig
['options.']['removeItems']) {
213 $this->allowedItems
= array_diff($this->allowedItems
,t3lib_div
::trimExplode(',',$this->buttonConfig
['options.']['removeItems'],1));
215 $this->allowedItems
= array_diff($this->allowedItems
,t3lib_div
::trimExplode(',',$this->thisConfig
['blindImageOptions'],1));
217 reset($this->allowedItems
);
218 if (!in_array($this->act
,$this->allowedItems
)) {
219 $this->act
= current($this->allowedItems
);
222 if ($this->act
== 'plain') {
223 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['plainImageMaxWidth']) $this->plainMaxWidth
= $TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['plainImageMaxWidth'];
224 if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['plainImageMaxHeight']) $this->plainMaxHeight
= $TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['plainImageMaxHeight'];
225 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['plain.'])) {
226 if ($this->buttonConfig
['options.']['plain.']['maxWidth']) $this->plainMaxWidth
= $this->buttonConfig
['options.']['plain.']['maxWidth'];
227 if ($this->buttonConfig
['options.']['plain.']['maxHeight']) $this->plainMaxHeight
= $this->buttonConfig
['options.']['plain.']['maxHeight'];
229 if (!$this->plainMaxWidth
) $this->plainMaxWidth
= 640;
230 if (!$this->plainMaxHeight
) $this->plainMaxHeight
= 680;
231 } elseif ($this->act
== 'magic') {
232 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['magic.'])) {
233 if ($this->buttonConfig
['options.']['magic.']['maxWidth']) $this->magicMaxWidth
= $this->buttonConfig
['options.']['magic.']['maxWidth'];
234 if ($this->buttonConfig
['options.']['magic.']['maxHeight']) $this->magicMaxHeight
= $this->buttonConfig
['options.']['magic.']['maxHeight'];
236 // These defaults allow images to be based on their width - to a certain degree - by setting a high height. Then we're almost certain the image will be based on the width
237 if (!$this->magicMaxWidth
) $this->magicMaxWidth
= 300;
238 if (!$this->magicMaxHeight
) $this->magicMaxHeight
= 1000;
241 if ($this->thisConfig
['classesImage']) {
242 $classesImageArray = t3lib_div
::trimExplode(',',$this->thisConfig
['classesImage'],1);
243 $this->classesImageJSOptions
= '<option value=""></option>';
244 foreach ($classesImageArray as $class) {
245 $this->classesImageJSOptions
.= '<option value="' .$class . '">' . $class . '</option>';
249 $this->magicProcess();
251 // Creating backend template object:
252 $this->doc
= t3lib_div
::makeInstance('template');
253 $this->doc
->docType
= 'xhtml_trans';
254 $this->doc
->backPath
= $BACK_PATH;
260 * [Describe function...]
264 function rteImageStorageDir() {
265 $dir = $this->imgPath ?
$this->imgPath
: $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
270 * [Describe function...]
274 function magicProcess() {
275 global $TYPO3_CONF_VARS;
277 if ($this->act
=='magic' && t3lib_div
::_GP('insertMagicImage')) {
278 $filepath = t3lib_div
::_GP('insertMagicImage');
280 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
282 $imgObj->mayScaleUp
=0;
283 $imgObj->tempPath
=PATH_site
.$imgObj->tempPath
;
285 $imgInfo = $imgObj->getImageDimensions($filepath);
287 if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir()) {
288 $fI=pathinfo($imgInfo[3]);
289 $fileFunc = t3lib_div
::makeInstance('t3lib_basicFileFunctions');
290 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
291 $destPath =PATH_site
.$this->rteImageStorageDir();
292 if (@is_dir
($destPath)) {
293 $destName = $fileFunc->getUniqueName($basename,$destPath);
294 if (isset($TYPO3_CONF_VARS['BE']['fileCreateMask'])) {
295 @chmod
($destName, $TYPO3_CONF_VARS['BE']['fileCreateMask']);
297 @copy
($imgInfo[3],$destName);
299 $cWidth = t3lib_div
::intInRange(t3lib_div
::_GP('cWidth'),0,$this->magicMaxWidth
);
300 $cHeight = t3lib_div
::intInRange(t3lib_div
::_GP('cHeight'),0,$this->magicMaxHeight
);
301 if (!$cWidth) $cWidth = $this->magicMaxWidth
;
302 if (!$cHeight) $cHeight = $this->magicMaxHeight
;
304 $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
306 $fI=pathinfo($imgI[3]);
307 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
308 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
309 if (isset($TYPO3_CONF_VARS['BE']['fileCreateMask'])) {
310 @chmod
($destName, $TYPO3_CONF_VARS['BE']['fileCreateMask']);
312 @copy
($imgI[3],$destName);
314 $destName = dirname($destName).'/'.rawurlencode(basename($destName));
315 $iurl = $this->siteUrl
.substr($destName,strlen(PATH_site
));
317 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
320 <title>Untitled</title>
322 <script type="text/javascript">
324 var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
325 var plugin = dialog.plugin;
326 function insertImage(file,width,height) {
327 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
332 <script type="text/javascript">
334 insertImage(\''.$iurl.'\','.$imgI[0].','.$imgI[1].');
348 * [Describe function...]
352 function getJSCode() {
353 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
356 var dialog = window.opener.HTMLArea.Dialog["TYPO3Image"];
357 var plugin = dialog.plugin;
358 var HTMLArea = window.opener.HTMLArea;
359 function jumpToUrl(URL,anchor) {
360 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act
.'" : "";
361 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo
.'" : "";
362 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div
::_GP('RTEtsConfigParams')).'";
364 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
365 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
367 var theLocation = URL+add_act+add_editorNo+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
368 window.location.href = theLocation;
371 function insertImage(file,width,height) {
372 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
374 function launchView(url) {
375 var thePreviewWindow="";
376 thePreviewWindow = window.open("'.$this->siteUrl
.TYPO3_mainDir
.'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
377 if (thePreviewWindow && thePreviewWindow.focus) {
378 thePreviewWindow.focus();
381 function getCurrentImageRef() {
388 function printCurrentImageOptions() {
389 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
390 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $this->classesImageJSOptions
. '</select>\';
391 var floatSelector=\'<select id="iFloat" name="iFloat"><option value="">' . $LANG->getLL('notSet') . '</option><option value="none">' . $LANG->getLL('nonFloating') . '</option><option value="left">' . $LANG->getLL('left') . '</option><option value="right">' . $LANG->getLL('right') . '</option></select>\';
392 var bgColor=\' class="bgColor4"\';
394 sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
395 '.(in_array('class', $this->removedProperties
)?
'':'
397 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
399 .(in_array('width', $this->removedProperties
)?
'':'
400 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainWidth
.')) {
401 sz+=\'<tr><td\'+bgColor+\'><label for="iWidth">'.$LANG->getLL('width').': </label></td><td><input type="text" id="iWidth" name="iWidth" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
403 .(in_array('height', $this->removedProperties
)?
'':'
404 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainHeight
.')) {
405 sz+=\'<tr><td\'+bgColor+\'><label for="iHeight">'.$LANG->getLL('height').': </label></td><td><input type="text" id="iHeight" name="iHeight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
407 .(in_array('border', $this->removedProperties
)?
'':'
408 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
409 .(in_array('float', $this->removedProperties
)?
'':'
410 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
411 .(in_array('paddingTop', $this->removedProperties
)?
'':'
412 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingTop">'.$LANG->getLL('padding_top').': </label></td><td><input type="text" id="iPaddingTop" name="iPaddingTop" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).'></td></tr>\';')
413 .(in_array('paddingRight', $this->removedProperties
)?
'':'
414 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingRight">'.$LANG->getLL('padding_right').': </label></td><td><input type="text" id="iPaddingRight" name="iPaddingRight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
415 .(in_array('paddingBottom', $this->removedProperties
)?
'':'
416 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingBottom">'.$LANG->getLL('padding_bottom').': </label></td><td><input type="text" id="iPaddingBottom" name="iPaddingBottom" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
417 .(in_array('paddingLeft', $this->removedProperties
)?
'':'
418 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingLeft">'.$LANG->getLL('padding_left').': </label></td><td><input type="text" id="iPaddingLeft" name="iPaddingLeft" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
419 .(in_array('title', $this->removedProperties
)?
'':'
420 sz+=\'<tr><td\'+bgColor+\'><label for="iTitle">'.$LANG->getLL('title').': </label></td><td><input type="text" id="iTitle" name="iTitle"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';')
421 .(in_array('alt', $this->removedProperties
)?
'':'
422 sz+=\'<tr><td\'+bgColor+\'><label for="iAlt">'.$LANG->getLL('alt').': </label></td><td><input type="text" id="iAlt" name="iAlt"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';')
423 .((!$TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['enableClickEnlarge'] ||
in_array('clickenlarge', $this->removedProperties
))?
'':'
424 sz+=\'<tr><td\'+bgColor+\'><label for="iClickEnlarge">'.$LANG->sL('LLL:EXT:cms/locallang_ttc.php:image_zoom',1).' </label></td><td><input type="checkbox" name="iClickEnlarge" id="iClickEnlarge" value="1" /></td></tr>\';').'
425 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
426 sz+=\'</form></table>\';
429 function setImageProperties() {
430 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
431 if (selectedImageRef) {
432 if (document.imageData.iWidth) {
433 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
434 selectedImageRef.style.width = "";
435 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
437 selectedImageRef.style.width = "auto";
440 if (document.imageData.iHeight) {
441 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
442 selectedImageRef.style.height = "";
443 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
445 selectedImageRef.style.height = "auto";
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";
452 selectedImageRef.style.paddingTop = "";
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";
459 selectedImageRef.style.paddingRight = "";
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";
466 selectedImageRef.style.paddingBottom = "";
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";
473 selectedImageRef.style.paddingLeft = "";
476 if (document.imageData.iTitle) {
477 selectedImageRef.title=document.imageData.iTitle.value;
479 if (document.imageData.iAlt) {
480 selectedImageRef.alt=document.imageData.iAlt.value;
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";
499 selectedImageRef.removeAttribute("border");
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) {
506 selectedImageRef.style.styleFloat = (iFloat != "none") ? iFloat : "";
508 selectedImageRef.style.cssFloat = (iFloat != "none") ? iFloat : "";
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;
518 selectedImageRef.className = "";
522 if (document.imageData.iClickEnlarge) {
523 if (document.imageData.iClickEnlarge.checked) {
524 selectedImageRef.setAttribute("clickenlarge","1");
526 selectedImageRef.setAttribute("clickenlarge","0");
533 function insertImagePropertiesInForm() {
534 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
535 if (selectedImageRef) {
536 var styleWidth, styleHeight, padding;
537 if (document.imageData.iWidth) {
538 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
539 styleWidth = parseInt(styleWidth);
540 if (isNaN(styleWidth) || styleWidth == 0) { styleWidth = "auto"; }
541 document.imageData.iWidth.value = styleWidth;
543 if (document.imageData.iHeight) {
544 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
545 styleHeight = parseInt(styleHeight);
546 if (isNaN(styleHeight) || styleHeight == 0) { styleHeight = "auto"; }
547 document.imageData.iHeight.value = styleHeight;
549 if (document.imageData.iPaddingTop) {
550 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
551 var padding = parseInt(padding);
552 if (isNaN(padding) || padding <= 0) { padding = ""; }
553 document.imageData.iPaddingTop.value = padding;
555 if (document.imageData.iPaddingRight) {
556 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
557 var padding = parseInt(padding);
558 if (isNaN(padding) || padding <= 0) { padding = ""; }
559 document.imageData.iPaddingRight.value = padding;
561 if (document.imageData.iPaddingBottom) {
562 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
563 var padding = parseInt(padding);
564 if (isNaN(padding) || padding <= 0) { padding = ""; }
565 document.imageData.iPaddingBottom.value = padding;
567 if (document.imageData.iPaddingLeft) {
568 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
569 var padding = parseInt(padding);
570 if (isNaN(padding) || padding <= 0) { padding = ""; }
571 document.imageData.iPaddingLeft.value = padding;
573 if (document.imageData.iTitle) {
574 document.imageData.iTitle.value = selectedImageRef.title;
576 if (document.imageData.iAlt) {
577 document.imageData.iAlt.value = selectedImageRef.alt;
579 if (document.imageData.iBorder) {
580 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
581 document.imageData.iBorder.checked = 1;
584 if (document.imageData.iFloat) {
585 var fObj=document.imageData.iFloat;
586 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
588 for (var a=0;a<l;a++) {
589 if (fObj.options[a].value == value) {
590 fObj.selectedIndex = a;
595 if (classesImage && document.imageData.iClass) {
596 var fObj=document.imageData.iClass;
597 var value=selectedImageRef.className;
599 for (var a=0;a < l; a++) {
600 if (fObj.options[a].value == value) {
601 fObj.selectedIndex = a;
605 if (document.imageData.iClickEnlarge) {
606 if (selectedImageRef.getAttribute("clickenlarge") == "1") {
607 document.imageData.iClickEnlarge.checked = 1;
609 document.imageData.iClickEnlarge.checked = 0;
616 var selectedImageRef = getCurrentImageRef();'; // Setting this to a reference to the image object.
618 // Finally, add the accumulated JavaScript to the template object:
619 $this->doc
->JScode
= $this->doc
->wrapScriptTags($JScode);
623 * Session data for this class can be set from outside with this method.
626 * @param array Session data array
627 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
629 function processSessionData($data) {
632 if ($this->act
!= 'image') {
633 if (isset($this->act
)) {
634 $data['act'] = $this->act
;
637 $this->act
= $data['act'];
641 if (isset($this->expandFolder
)) {
642 $data['expandFolder'] = $this->expandFolder
;
645 $this->expandFolder
= $data['expandFolder'];
648 return array($data, $store);
652 * [Describe function...]
656 function main_rte() {
657 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
660 $this->content
= $this->doc
->startPage($LANG->getLL('Insert Image',1));
662 // Making menu in top:
664 if (in_array('image',$this->allowedItems
) && ($this->act
=='image' || t3lib_div
::_GP('cWidth'))) {
665 $menuDef['page']['isActive'] = $this->act
=='image';
666 $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
667 $menuDef['page']['url'] = '#';
668 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&editorNo='.$this->editorNo
.'\');return false;"';
670 if (in_array('magic',$this->allowedItems
)){
671 $menuDef['file']['isActive'] = $this->act
=='magic';
672 $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
673 $menuDef['file']['url'] = '#';
674 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&editorNo='.$this->editorNo
.'\');return false;"';
676 if (in_array('plain',$this->allowedItems
)) {
677 $menuDef['url']['isActive'] = $this->act
=='plain';
678 $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
679 $menuDef['url']['url'] = '#';
680 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&editorNo='.$this->editorNo
.'\');return false;"';
682 if (in_array('dragdrop',$this->allowedItems
)) {
683 $menuDef['mail']['isActive'] = $this->act
=='dragdrop';
684 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
685 $menuDef['mail']['url'] = '#';
686 $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&editorNo='.$this->editorNo
.'&bparams=|||\'+escape(\'gif,jpg,jpeg,png\'));return false;"';
688 $this->content
.= $this->doc
->getTabMenuRaw($menuDef);
690 if ($this->act
!='image') {
692 // ***************************
694 // ***************************
695 // Create upload/create folder forms, if a path is given:
696 if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
697 $fileProcessor = t3lib_div
::makeInstance('t3lib_basicFileFunctions');
698 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
699 $path=$this->expandFolder
;
700 if (!$path ||
!@is_dir
($path)) {
701 $path = $fileProcessor->findTempFolder().'/'; // The closest TEMP-path is found
703 if ($path!='/' && @is_dir
($path)) {
704 $uploadForm=$this->uploadForm($path);
705 $createFolder=$this->createFolder($path);
710 $this->content
.= $uploadForm;
711 if ($BE_USER->isAdmin() ||
$BE_USER->getTSConfigVal('options.createFoldersInEB')) {
712 $this->content
.=$createFolder;
716 // Getting flag for showing/not showing thumbnails:
717 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect') ||
($this->act
== 'dragdrop');
720 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
721 $_MOD_MENU = array('displayThumbs' => '');
722 $_MCONF['name']='file_list';
723 $_MOD_SETTINGS = t3lib_BEfunc
::getModuleData($_MOD_MENU, t3lib_div
::_GP('SET'), $_MCONF['name']);
724 $addParams = '&act='.$this->act
.'&editorNo='.$this->editorNo
.'&expandFolder='.rawurlencode($this->expandFolder
);
725 $thumbNailCheck = t3lib_BEfunc
::getFuncCheck('','SET[displayThumbs]',$_MOD_SETTINGS['displayThumbs'],'select_image.php',$addParams,'id="checkDisplayThumbs"').' <label for="checkDisplayThumbs">'.$LANG->sL('LLL:EXT:lang/locallang_mod_file_list.php:displayThumbs',1).'</label>';
730 // Create folder tree:
731 if ($this->act
== 'dragdrop') {
732 $foldertree = t3lib_div
::makeInstance('TBE_FolderTree');
733 $foldertree->thisScript
=$this->thisScript
;
734 $foldertree->ext_noTempRecyclerDirs
= true;
736 $foldertree = t3lib_div
::makeInstance('tx_rtehtmlarea_image_folderTree');
738 $tree = $foldertree->getBrowsableTree();
739 list(,,$specUid) = explode('_',t3lib_div
::_GP('PM'));
740 if ($this->act
== 'dragdrop') {
741 $pArr = explode('|',$this->bparams
);
742 $allowedTablesOrFileTypes = $pArr[3];
743 $files = $this->TBE_dragNDrop($foldertree->specUIDmap
[$specUid],$pArr[3]);
745 $files = $this->expandFolder($foldertree->specUIDmap
[$specUid],$this->act
=='plain',$noThumbs?
$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
748 $this->content
.= '<table border=0 cellpadding=0 cellspacing=0>
750 <td valign=top>'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
752 <td valign=top>'.$files.'</td>
755 <br />'.$thumbNailCheck;
757 // ***************************
759 // ***************************
760 if ($this->act
=='magic') {
761 $this->content
.= $this->getMsgBox($LANG->getLL('magicImage_msg'));
763 if ($this->act
=='plain') {
764 $this->content
.= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth
, $this->plainMaxHeight
));
768 document.write(printCurrentImageOptions());
769 insertImagePropertiesInForm();';
770 $this->content
.= '<br />'.$this->doc
->wrapScriptTags($JScode);
772 $this->content
.= $this->doc
->endPage();
773 return $this->content
;
776 /***************************
780 ***************************/
782 * @param [type] $expandFolder: ...
783 * @param [type] $plainFlag: ...
786 function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) {
787 global $LANG, $BE_USER, $BACK_PATH;
789 $expandFolder = $expandFolder ?
$expandFolder :t3lib_div
::_GP('expandFolder');
792 if ($expandFolder && $this->checkFolder($expandFolder)) {
793 $files = t3lib_div
::getFilesInDir($expandFolder,($plainFlag?
'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1); // $extensionList="",$prependPath=0,$order="")
794 if (is_array($files)) {
797 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
799 $titleLen = intval($BE_USER->uc
['titleLen']);
800 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
801 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd(basename($expandFolder),$titleLen));
802 $out.='<span class="nobr">'.$picon.'</span><br />';
804 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
806 $imgObj->mayScaleUp
=0;
807 $imgObj->tempPath
=PATH_site
.$imgObj->tempPath
;
810 while(list(,$filepath)=each($files)) {
811 $fI=pathinfo($filepath);
813 $origFile = t3lib_div
::rawUrlEncodeFP(substr($filepath,strlen(PATH_site
)));
814 $iurl = $this->siteUrl
.$origFile;
815 $imgInfo = $imgObj->getImageDimensions($filepath);
817 $icon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
818 $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
819 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
820 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
822 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo
.'&insertMagicImage='.rawurlencode($filepath).'\');">';
824 $ATag = '<a href="#" onclick="return insertImage(\''.$iurl.'\','.$imgInfo[0].','.$imgInfo[1].');">';
827 if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth
) ||
($imgInfo[1] > $this->plainMaxHeight
))) {
833 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
837 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div
::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
840 $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.' </td><td nowrap="nowrap">'.$pDim.' </td></tr>';
841 $lines[]='<tr><td colspan="2">'.($noThumbs ?
'' : $ATag2.t3lib_BEfunc
::getThumbNail($this->doc
->backPath
.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
843 $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
845 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
852 * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
853 * The files are uploaded to the tce_file.php script in the core which will handle the upload.
855 * @param string Absolute filepath on server to which to upload.
856 * @return string HTML for an upload form.
858 function uploadForm($path) {
862 // Create header, showing upload path:
863 $header = t3lib_div
::isFirstPartOfStr($path,PATH_site
)?
substr($path,strlen(PATH_site
)):$path;
864 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
868 Form, for uploading files:
870 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
871 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
873 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
878 // Traverse the number of upload fields (default is 3):
879 for ($a=1;$a<=$count;$a++
) {
880 $code.='<input type="file" name="upload_'.$a.'"'.$this->doc
->formWidth(35).' size="50" />
881 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
882 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
885 // Make footer of upload form, including the submit button:
886 $redirectValue = $this->thisScript
.'?act='.$this->act
.'&editorNo='.$this->editorNo
.'&mode='.$this->mode
.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams
);
887 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
888 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
891 <div id="c-override">
892 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
907 * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
908 * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
910 * @param string Absolute filepath on server in which to create the new folder.
911 * @return string HTML for the create folder form.
913 function createFolder($path) {
915 // Create header, showing upload path:
916 $header = t3lib_div
::isFirstPartOfStr($path,PATH_site
)?
substr($path,strlen(PATH_site
)):$path;
917 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
921 Form, for creating new folders:
923 <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
924 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
926 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
931 // Create the new-folder name field:
933 $code.='<input'.$this->doc
->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
934 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
936 // Make footer of upload form, including the submit button:
937 $redirectValue = $this->thisScript
.'?act='.$this->act
.'&editorNo='.$this->editorNo
.'&mode='.$this->mode
.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams
);
938 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
939 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
950 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
951 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
953 * @param string The folder path to expand
954 * @param string List of fileextensions to show
955 * @return string HTML output
957 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
960 $expandFolder = $expandFolder ?
$expandFolder : $this->expandFolder
;
962 if ($expandFolder && $this->checkFolder($expandFolder)) {
963 if ($this->isWebFolder($expandFolder)) {
965 // Read files from directory:
966 $files = t3lib_div
::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
967 if (is_array($files)) {
968 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
970 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
971 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
972 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($expandFolder),$titleLen));
973 $out.=$picon.'<br />';
978 // Add "drag-n-drop" message:
981 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
985 while(list(,$filepath)=each($files)) {
986 $fI = pathinfo($filepath);
989 $iurl = $this->siteURL
.t3lib_div
::rawurlencodeFP(substr($filepath,strlen(PATH_site
)));
991 // Show only web-images
992 if (t3lib_div
::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
993 $imgInfo = @getimagesize
($filepath);
994 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
996 $ficon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
997 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).'bytes'.($pDim?
', '.$pDim:'').')';
998 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
999 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($filepath),$titleLen));
1001 if (t3lib_div
::_GP('noLimit')) {
1011 $IH=ceil($IH/$IW*$maxW);
1015 $IW=ceil($IW/$IH*$maxH);
1021 <tr class="bgColor4">
1022 <td nowrap="nowrap">'.$filenameAndIcon.' </td>
1023 <td nowrap="nowrap">'.
1024 ($imgInfo[0]!=$IW ?
'<a href="'.htmlspecialchars(t3lib_div
::linkThisScript(array('noLimit'=>'1'))).'">'.
1025 '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1029 // Remove hardcoded border="1"
1030 // Add default class for images
1033 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" alt=""' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):''). ' /></td>
1037 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1042 // Finally, wrap all rows in a table tag:
1047 File listing / Drag-n-drop
1049 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1050 '.implode('',$lines).'
1054 // Print this warning if the folder is NOT a web folder:
1055 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1056 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1064 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']) {
1065 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);