2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasper@typo3.com)
6 * (c) 2004-2011 Stanislas Rolland <typo3(arobas)sjbr.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 Skårhøj <kasper@typo3.com>
35 require_once(t3lib_extMgm
::extPath('dam').'class.tx_dam_browse_media.php');
40 * @author Kasper Skårhøj <kasper@typo3.com>
44 class tx_rtehtmlarea_dam_browse_media
extends tx_dam_browse_media
{
45 var $extKey = 'rtehtmlarea';
49 var $removedProperties = array();
53 var $lockPlainWidth = 'false';
54 var $lockPlainHeight = 'false';
58 var $imgTitleDAMColumn = '';
59 var $classesImageJSOptions;
61 var $sys_language_content;
63 var $buttonConfig = array();
66 * Check if this object should be rendered.
68 * @param string $type Type: "file", ...
69 * @param object $pObj Parent object.
71 * @see SC_browse_links::main()
73 function isValid($type, $pObj) {
76 $pArr = explode('|', t3lib_div
::_GP('bparams'));
78 if ($type=='rte' && $pObj->button
== 'image') {
87 * Called in SC_browse_links::main() when isValid() returns true;
89 * @param string $type Type: "file", ...
90 * @param object $pObj Parent object.
91 * @return string Rendered content
92 * @see SC_browse_links::main()
94 function render($type, $pObj) {
95 global $LANG, $BE_USER, $BACK_PATH;
99 // init class browse_links
102 switch((string)$this->mode
) {
104 $content = $this->main_rte();
107 // $content = $this->main_rte(1);
123 global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;
126 $this->siteUrl
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL');
127 $this->act
= t3lib_div
::_GP('act');
128 $this->expandPage
= t3lib_div
::_GP('expandPage');
129 $this->expandFolder
= t3lib_div
::_GP('expandFolder');
131 // Find RTE parameters
132 $this->bparams
= t3lib_div
::_GP('bparams');
133 $this->editorNo
= t3lib_div
::_GP('editorNo');
134 $this->sys_language_content
= t3lib_div
::_GP('sys_language_content');
135 $this->RTEtsConfigParams
= t3lib_div
::_GP('RTEtsConfigParams');
136 if (!$this->editorNo
) {
137 $pArr = explode('|', $this->bparams
);
138 $pRteArr = explode(':', $pArr[1]);
139 $this->editorNo
= $pRteArr[0];
140 $this->sys_language_content
= $pRteArr[1];
141 $this->RTEtsConfigParams
= $pArr[2];
145 $this->mode
= t3lib_div
::_GP('mode');
151 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL'); // Current site url
153 // the script to link to
154 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
160 // init fileProcessor
161 $this->fileProcessor
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
162 $this->fileProcessor
->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
165 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
166 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($RTEtsConfigParts[5]));
167 $this->thisConfig
= t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
168 $this->imgPath
= $RTEtsConfigParts[6];
170 if (is_array($this->thisConfig
['buttons.']) && is_array($this->thisConfig
['buttons.']['image.'])) {
171 $this->buttonConfig
= $this->thisConfig
['buttons.']['image.'];
172 t3lib_div
::loadTCA('tx_dam');
173 if (is_array($this->buttonConfig
['title.']) && is_array($TCA['tx_dam']['columns'][$this->buttonConfig
['title.']['useDAMColumn']])) {
174 $this->imgTitleDAMColumn
= $this->buttonConfig
['title.']['useDAMColumn'];
176 if (is_array($this->buttonConfig
['properties.'])) {
177 if ($this->buttonConfig
['properties.']['removeItems']) {
178 $this->removedProperties
= t3lib_div
::trimExplode(',',$this->buttonConfig
['properties.']['removeItems'],1);
180 if (is_array($this->buttonConfig
['properties.']['class.']) && trim($this->buttonConfig
['properties.']['class.']['default'])) {
181 $this->defaultClass
= trim($this->buttonConfig
['properties.']['class.']['default']);
186 if (is_array($this->thisConfig
['proc.']) && $this->thisConfig
['proc.']['plainImageMode']) {
187 $plainImageMode = $this->thisConfig
['proc.']['plainImageMode'];
188 $this->lockPlainWidth
= ($plainImageMode == 'lockDimensions')?
'true':'false';
189 $this->lockPlainHeight
= ($this->lockPlainWidth ||
$plainImageMode == 'lockRatio' ||
($plainImageMode == 'lockRatioWhenSmaller'))?
'true':'false';
192 if (!$this->imgTitleDAMColumn
) {
193 $this->imgTitleDAMColumn
= 'caption';
196 $this->allowedItems
= explode(',','magic,plain,image,upload');
197 $clientInfo = t3lib_div
::clientInfo();
198 if ($clientInfo['BROWSER'] !== 'opera') {
199 $this->allowedItems
[] = 'dragdrop';
201 if (is_array($this->buttonConfig
['options.']) && $this->buttonConfig
['options.']['removeItems']) {
202 $this->allowedItems
= array_diff($this->allowedItems
,t3lib_div
::trimExplode(',',$this->buttonConfig
['options.']['removeItems'],1));
204 $this->allowedItems
= array_diff($this->allowedItems
,t3lib_div
::trimExplode(',',$this->thisConfig
['blindImageOptions'],1));
207 reset($this->allowedItems
);
208 if (!in_array($this->act
,$this->allowedItems
)) {
209 $this->act
= current($this->allowedItems
);
212 if ($this->act
== 'magic') {
213 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['magic.'])) {
214 if ($this->buttonConfig
['options.']['magic.']['maxWidth']) $this->magicMaxWidth
= $this->buttonConfig
['options.']['magic.']['maxWidth'];
215 if ($this->buttonConfig
['options.']['magic.']['maxHeight']) $this->magicMaxHeight
= $this->buttonConfig
['options.']['magic.']['maxHeight'];
217 // 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
218 if (!$this->magicMaxWidth
) $this->magicMaxWidth
= 300;
219 if (!$this->magicMaxHeight
) $this->magicMaxHeight
= 1000;
220 } elseif ($this->act
== 'plain') {
221 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['plain.'])) {
222 if ($this->buttonConfig
['options.']['plain.']['maxWidth']) $this->plainMaxWidth
= $this->buttonConfig
['options.']['plain.']['maxWidth'];
223 if ($this->buttonConfig
['options.']['plain.']['maxHeight']) $this->plainMaxHeight
= $this->buttonConfig
['options.']['plain.']['maxHeight'];
225 if (!$this->plainMaxWidth
) $this->plainMaxWidth
= 640;
226 if (!$this->plainMaxHeight
) $this->plainMaxHeight
= 680;
229 if ($this->thisConfig
['classesImage']) {
230 $classesImageArray = t3lib_div
::trimExplode(',',$this->thisConfig
['classesImage'],1);
231 $this->classesImageJSOptions
= '<option value=""></option>';
232 foreach ($classesImageArray as $class) {
233 $this->classesImageJSOptions
.= '<option value="' .$class . '">' . $class . '</option>';
237 // init the DAM object
240 $this->getModSettings();
242 $this->processParams();
244 // Insert the image if we are done
245 $this->imageInsert();
247 // Creating backend template object:
248 $this->doc
= t3lib_div
::makeInstance('template');
249 $this->doc
->backPath
= $BACK_PATH;
253 * [Describe function...]
257 function rteImageStorageDir() {
258 $dir = $this->imgPath ?
$this->imgPath
: $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
263 * [Describe function...]
267 function imageInsert() {
268 global $TCA,$TYPO3_CONF_VARS;
270 if (t3lib_div
::_GP('insertImage')) {
271 $filepath = t3lib_div
::_GP('insertImage');
273 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
275 $imgObj->mayScaleUp
=0;
276 $imgObj->tempPath
=PATH_site
.$imgObj->tempPath
;
277 $imgInfo = $imgObj->getImageDimensions($filepath);
278 $imgMetaData = tx_dam
::meta_getDataForFile($filepath,'uid,pid,alt_text,hpixels,vpixels,'.$this->imgTitleDAMColumn
.','.$TCA['tx_dam']['ctrl']['languageField']);
279 $imgMetaData = $this->getRecordOverlay('tx_dam',$imgMetaData,$this->sys_language_content
);
281 switch ($this->act
) {
283 if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir() && is_array($imgMetaData)) {
284 $fI=pathinfo($imgInfo[3]);
285 $fileFunc = t3lib_div
::makeInstance('t3lib_basicFileFunctions');
286 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
287 $destPath =PATH_site
.$this->rteImageStorageDir();
288 if (@is_dir
($destPath)) {
289 $destName = $fileFunc->getUniqueName($basename,$destPath);
290 @copy
($imgInfo[3],$destName);
291 t3lib_div
::fixPermissions($destName);
292 $cWidth = t3lib_div
::intInRange(t3lib_div
::_GP('cWidth'),0,$this->magicMaxWidth
);
293 $cHeight = t3lib_div
::intInRange(t3lib_div
::_GP('cHeight'),0,$this->magicMaxHeight
);
294 if (!$cWidth) $cWidth = $this->magicMaxWidth
;
295 if (!$cHeight) $cHeight = $this->magicMaxHeight
;
297 $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
299 $fI=pathinfo($imgI[3]);
300 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
301 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
302 @copy
($imgI[3],$destName);
303 t3lib_div
::fixPermissions($destName);
304 $iurl = $this->siteUrl
.substr($destName,strlen(PATH_site
));
305 $this->imageInsertJS($iurl,$imgI[0],$imgI[1],$imgMetaData['alt_text'],$imgMetaData[$this->imgTitleDAMColumn
],substr($imgInfo[3],strlen(PATH_site
)));
312 if (is_array($imgInfo) && count($imgInfo)==4 && is_array($imgMetaData)) {
313 $iurl = $this->siteUrl
.substr($imgInfo[3],strlen(PATH_site
));
314 $this->imageInsertJS($iurl,$imgMetaData['hpixels'],$imgMetaData['vpixels'],$imgMetaData['alt_text'],$imgMetaData[$this->imgTitleDAMColumn
],substr($imgInfo[3],strlen(PATH_site
)));
322 function imageInsertJS($url,$width,$height,$altText,$titleText,$origFile) {
323 global $TYPO3_CONF_VARS;
326 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
329 <title>Untitled</title>
331 <script type="text/javascript">
333 var plugin = window.parent.RTEarea["' . $this->editorNo
. '"].editor.getPlugin("TYPO3Image");
334 function insertImage(file,width,height,alt,title) {
335 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):'') . ' alt="\'+alt+\'" title="\'+title+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
340 <script type="text/javascript">
342 insertImage('.t3lib_div
::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div
::quoteJSvalue($altText,1).','.t3lib_div
::quoteJSvalue($titleText,1).');
350 * [Describe function...]
354 function getJSCode() {
355 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
358 var plugin = window.parent.RTEarea["' . $editorNo . '"].editor.getPlugin("TYPO3Image");
359 var HTMLArea = window.parent.HTMLArea;
360 var Ext = window.parent.Ext;
362 plugin.dialog.mon(Ext.get(plugin.dialog.getComponent("content-iframe").getEl().dom.contentWindow.document.documentElement), "dragend", plugin.onDrop, plugin, {single: true});
364 function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close) {
365 return jumpToUrl(\''.$this->thisScript
.'?act='.$this->act
.'&mode='.$this->mode
.'&bparams='.$this->bparams
.'&insertImage='.'\'+fp);
367 function jumpToUrl(URL,anchor) {
368 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act
.'" : "";
369 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo
.'" : "";
370 var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content='.$this->sys_language_content
.'" : "";
371 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div
::_GP('RTEtsConfigParams')).'";
373 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
374 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
376 var theLocation = URL+add_act+add_editorNo+add_sys_language_content+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
377 window.location.href = theLocation;
380 function launchView(url) {
381 var thePreviewWindow="";
382 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");
383 if (thePreviewWindow && thePreviewWindow.focus) {
384 thePreviewWindow.focus();
387 function getCurrentImageRef() {
394 function printCurrentImageOptions() {
395 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
396 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $this->classesImageJSOptions
. '</select>\';
397 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>\';
398 var bgColor=\' class="bgColor4"\';
400 sz+=\'<table border="0" cellpadding="1" cellspacing="1"><form action="" name="imageData">\';
401 '.(in_array('class', $this->removedProperties
)?
'':'
403 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
405 .(in_array('width', $this->removedProperties
)?
'':'
406 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainWidth
.')) {
407 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>\';
409 .(in_array('height', $this->removedProperties
)?
'':'
410 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $this->lockPlainHeight
.')) {
411 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>\';
413 .(in_array('border', $this->removedProperties
)?
'':'
414 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
415 .(in_array('float', $this->removedProperties
)?
'':'
416 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
417 .(in_array('paddingTop', $this->removedProperties
)?
'':'
418 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>\';')
419 .(in_array('paddingRight', $this->removedProperties
)?
'':'
420 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>\';')
421 .(in_array('paddingBottom', $this->removedProperties
)?
'':'
422 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>\';')
423 .(in_array('paddingLeft', $this->removedProperties
)?
'':'
424 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>\';')
425 .(in_array('title', $this->removedProperties
)?
'':'
426 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>\';')
427 .(in_array('alt', $this->removedProperties
)?
'':'
428 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>\';')
429 .((!$TYPO3_CONF_VARS['EXTCONF'][$this->extKey
]['enableClickEnlarge'] ||
in_array('clickenlarge', $this->removedProperties
))?
'':'
430 sz+=\'<tr><td\'+bgColor+\'><label for="iClickEnlarge">'.$LANG->sL('LLL:EXT:cms/locallang_ttc.php:image_zoom',1).' </label></td><td><input type="checkbox" name="iClickEnlarge" id="iClickEnlarge" value="0" /></td></tr>\';').'
431 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
432 sz+=\'</form></table>\';
435 function setImageProperties() {
436 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
437 if (selectedImageRef) {
438 if (document.imageData.iWidth) {
439 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
440 selectedImageRef.style.width = "";
441 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
444 if (document.imageData.iHeight) {
445 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
446 selectedImageRef.style.height = "";
447 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
450 if (document.imageData.iPaddingTop) {
451 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
452 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
454 selectedImageRef.style.paddingTop = "";
457 if (document.imageData.iPaddingRight) {
458 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
459 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
461 selectedImageRef.style.paddingRight = "";
464 if (document.imageData.iPaddingBottom) {
465 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
466 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
468 selectedImageRef.style.paddingBottom = "";
471 if (document.imageData.iPaddingLeft) {
472 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
473 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
475 selectedImageRef.style.paddingLeft = "";
478 if (document.imageData.iTitle) {
479 selectedImageRef.title=document.imageData.iTitle.value;
481 if (document.imageData.iAlt) {
482 selectedImageRef.alt=document.imageData.iAlt.value;
485 if (document.imageData.iBorder) {
486 selectedImageRef.style.borderStyle = "";
487 selectedImageRef.style.borderWidth = "";
488 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
489 selectedImageRef.style.borderTopStyle = "";
490 selectedImageRef.style.borderRightStyle = "";
491 selectedImageRef.style.borderBottomStyle = "";
492 selectedImageRef.style.borderLeftStyle = "";
493 selectedImageRef.style.borderTopWidth = "";
494 selectedImageRef.style.borderRightWidth = "";
495 selectedImageRef.style.borderBottomWidth = "";
496 selectedImageRef.style.borderLeftWidth = "";
497 if(document.imageData.iBorder.checked) {
498 selectedImageRef.style.borderStyle = "solid";
499 selectedImageRef.style.borderWidth = "thin";
501 selectedImageRef.removeAttribute("border");
503 if (document.imageData.iFloat) {
504 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
506 selectedImageRef.style.styleFloat = iFloat ? iFloat : "";
508 selectedImageRef.style.cssFloat = iFloat ? iFloat : "";
511 if (classesImage && document.imageData.iClass) {
512 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
513 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
514 selectedImageRef.className = iClass;
516 selectedImageRef.className = "";
520 if (document.imageData.iClickEnlarge) {
521 if (document.imageData.iClickEnlarge.checked) {
522 selectedImageRef.setAttribute("clickenlarge","1");
524 selectedImageRef.removeAttribute("clickenlarge");
531 function insertImagePropertiesInForm() {
532 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
533 if (selectedImageRef) {
534 var styleWidth, styleHeight, padding;
535 if (document.imageData.iWidth) {
536 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
537 styleWidth = parseInt(styleWidth);
538 if (!(isNaN(styleWidth) || styleWidth == 0)) {
539 document.imageData.iWidth.value = styleWidth;
542 if (document.imageData.iHeight) {
543 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
544 styleHeight = parseInt(styleHeight);
545 if (!(isNaN(styleHeight) || styleHeight == 0)) {
546 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
->JScodeArray
['rtehtmlarea'] = $JScode;
622 function reinitParams() {
623 if ($this->editorNo
) {
624 $pArr = explode('|', $this->bparams
);
625 $pArr[1] = implode(':', array($this->editorNo
, $this->sys_language_content
));
626 $pArr[2] = $this->RTEtsConfigParams
;
627 if ($this->act
== 'dragdrop' ||
$this->act
== 'plain') {
628 $pArr[3] = 'jpg,jpeg,gif,png';
630 $this->bparams
= implode('|', $pArr);
632 parent
::reinitParams();
636 * Return true or false whether thumbs should be displayed or not
640 function displayThumbs() {
642 return parent
::displayThumbs() && !$BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect') && ($this->act
!= 'dragdrop');
646 * Create HTML checkbox to enable/disable thumbnail display
648 * @return string HTML code
650 function addDisplayOptions() {
653 // Getting flag for showing/not showing thumbnails:
654 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInEB') ||
($this->mode
== 'rte' && $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect')) ||
($this->act
== 'dragdrop');
656 $thumbNailCheckbox = '';
659 $thumbNailCheckbox = t3lib_BEfunc
::getFuncCheck('', 'SET[displayThumbs]',$this->displayThumbs(), $this->thisScript
, t3lib_div
::implodeArrayForUrl('',$this->addParams
));
660 $description = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:displayThumbs',1);
661 $id = 'l'.uniqid('tx_dam_scbase');
662 $idAttr = ' id="'.$id.'"';
663 $thumbNailCheckbox = str_replace('<input', '<input'.$idAttr, $thumbNailCheckbox);
664 $thumbNailCheckbox .= ' <label for="'.$id.'">'.$description.'</label>';
665 $this->damSC
->addOption('html', 'thumbnailCheckbox', $thumbNailCheckbox);
667 $this->damSC
->addOption('funcCheck', 'extendedInfo', $GLOBALS['LANG']->getLL('displayExtendedInfo',1));
671 * Render list of files.
673 * @param array List of files. See t3lib_div::getFilesInDir
674 * @param string $mode EB mode: "db", "file", ...
675 * @return string HTML output
677 function renderFileList($files, $mode='file') {
678 global $LANG, $BACK_PATH, $BE_USER, $TYPO3_CONF_VARS;
682 // Listing the files:
683 if (is_array($files) AND count($files)) {
685 $displayThumbs = $this->displayThumbs();
686 $displayImage = ($this->act
=== 'dragdrop');
688 // Traverse the file list:
690 foreach($files as $fI) {
692 if (!$fI['__exists']) {
697 $titleAttrib = tx_dam_guiFunc
::icon_getTitleAttribute($fI);
698 $iconFile = tx_dam
::icon_getFileType($fI);
699 $iconTag = tx_dam_guiFunc
::icon_getFileTypeImgTag($fI);
700 $iconAndFilename = $iconTag.htmlspecialchars(t3lib_div
::fixed_lgd_cs($fI['file_title'], $BE_USER->uc
['titleLen']));
703 // Create links for adding the file:
704 if (strstr($fI['file_name_absolute'], ',') ||
strstr($fI['file_name_absolute'], '|')) { // In case an invalid character is in the filepath, display error message:
705 $eMsg = $LANG->JScharCode(sprintf($LANG->getLL('invalidChar'), ', |'));
706 $ATag_insert = '<a href="#" onclick="alert('.$eMsg.');return false;">';
708 // If filename is OK, just add it:
711 // JS: insertElement(table, uid, type, filename, fpath, filetype, imagefile ,action, close)
712 $onClick_params = implode (', ', array(
713 "'".$fI['_ref_table']."'",
714 "'".$fI['_ref_id']."'",
716 $this->quoteJSvalue($fI['file_name']),
717 $this->quoteJSvalue($fI['_ref_file_path']),
718 "'".$fI['file_type']."'",
721 $onClick = 'return insertElement('.$onClick_params.');';
722 $ATag_add = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.$titleAttrib.'>';
723 $onClick = 'return insertElement('.$onClick_params.', \'\', 1);';
724 $ATag_insert = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.$titleAttrib.'>';
727 // Create link to showing details about the file in a window:
728 if ($fI['__exists']) {
729 $Ahref = $BACK_PATH.'show_item.php?table='.rawurlencode($fI['file_name_absolute']).'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'));
730 $ATag_info = '<a href="'.htmlspecialchars($Ahref).'">';
731 $info = $ATag_info.'<img'.t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/zoom2.gif', 'width="12" height="12"').' title="'.$LANG->getLL('info',1).'" alt="" /> '.$LANG->getLL('info',1).'</a>';
737 // Thumbnail/size generation:
739 if (t3lib_div
::inList($TYPO3_CONF_VARS['GFX']['imagefile_ext'], $fI['file_type']) AND $displayThumbs AND is_file($fI['file_name_absolute'])) {
740 $clickThumb = t3lib_BEfunc
::getThumbNail($BACK_PATH.'thumbs.php', $fI['file_path_absolute'].$fI['file_name'], '');
741 $clickThumb = '<div style="width:56px; overflow:auto; padding: 5px; background-color:#fff; border:solid 1px #ccc;">'.$ATag_insert.$clickThumb.'</a>'.'</div>';
742 } elseif ($displayThumbs) {
743 $clickThumb = '<div style="width:68px"></div>';
747 if ($displayImage AND t3lib_div
::inList($TYPO3_CONF_VARS['GFX']['imagefile_ext'], $fI['file_type']) AND is_file($fI['file_name_absolute'])) {
748 if (t3lib_div
::_GP('noLimit')) {
755 $IW = $fI['hpixels'];
756 $IH = $fI['vpixels'];
758 $IH=ceil($IH/$IW*$maxW);
762 $IW=ceil($IW/$IH*$maxH);
765 $clickThumb = '<img src="'.$this->siteUrl
.substr($fI['file_name_absolute'],strlen(PATH_site
)).'" width="'.$IW.'" height="'.$IH.'"' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):''). ' alt="'.$fI['alt_text'].'" title="'.$fI[$this->imgTitleDAMColumn
].'" />';
766 $clickThumb = '<div style="width:380px; overflow:auto; padding: 5px; background-color:#fff; border:solid 1px #ccc;">'.$clickThumb.'</div>';
771 <tr class="bgColor4">
772 <td valign="top" nowrap="nowrap" style="min-width:20em">'.($displayImage?
'':$ATag_insert).$iconAndFilename.'</a>'.' </td>
773 <td valign="top" width="1%">'.($displayImage?
'':$ATag_add).'<img'.t3lib_iconWorks
::skinImg($BACK_PATH, 'gfx/plusbullet2.gif', 'width="18" height="16"').' title="'.$LANG->getLL('addToList',1).'" alt="" /></a></td>
774 <td valign="top" nowrap="nowrap" width="1%">'.$info.'</td>
779 if ($this->getModSettings('extendedInfo')) {
780 $infoText = tx_dam_guiFunc
::meta_compileInfoData ($fI, 'file_name, file_size:filesize, _dimensions, caption:truncate:50, instructions', 'table');
781 $infoText = str_replace('<table>', '<table border="0" cellpadding="0" cellspacing="1">', $infoText);
782 $infoText = str_replace('<strong>', '<strong style="font-weight:normal;">', $infoText);
783 $infoText = str_replace('</td><td>', '</td><td class="bgColor-10">', $infoText);
787 if (($displayThumbs ||
$displayImage) AND $infoText) {
790 <td valign="top" colspan="3">
791 <table border="0" cellpadding="0" cellspacing="0"><tr>
792 <td valign="top">'.$clickThumb.'</td>
793 <td valign="top" style="padding-left:1em">'.$infoText.'</td></tr>
795 <div style="height:0.5em;"></div>
798 } elseif ($clickThumb OR $infoText) {
801 <td valign="top" colspan="3" style="padding-left:22px">
802 '.$clickThumb.$infoText.'
803 <div style="height:0.5em;"></div>
810 <td colspan="3"><div style="height:0.5em;"></div></td>
814 // Wrap all the rows in table tags:
822 <table cellpadding="0" cellspacing="0" id="typo3-fileList">
823 '.implode('',$lines).'
827 // Return accumulated content for filelisting:
832 * Makes a DAM db query and collects data to be used in EB display
834 * @param string $allowedFileTypes Comma list of allowed file types
835 * @param string $disallowedFileTypes Comma list of disallowed file types
836 * @param string $mode EB mode: "db", "file", ...
837 * @return array Array of file elements
839 function getFileListArr($allowedFileTypes, $disallowedFileTypes, $mode) {
840 global $TYPO3_CONF_VARS, $TYPO3_DB;
842 $filearray = array();
844 // Use the current selection to create a query and count selected records
845 $this->damSC
->selection
->addSelectionToQuery();
846 $this->damSC
->selection
->qg
->query
['FROM']['tx_dam'] = tx_dam_db
::getMetaInfoFieldList(true, array('hpixels','vpixels',$this->imgTitleDAMColumn
,'alt_text'));
847 #$this->damSC->selection->qg->addSelectFields(...
848 if ($allowedFileTypes) {
849 $extList = '"'.implode ('","', explode(',',$allowedFileTypes)).'"';
850 $this->damSC
->selection
->qg
->addWhere('AND tx_dam.file_type IN ('.$extList.')', 'WHERE', 'tx_dam.file_type');
852 if ($disallowedFileTypes) {
853 $extList = '"'.implode ('","', explode(',',$disallowedFileTypes)).'"';
854 $this->damSC
->selection
->qg
->addWhere('AND NOT tx_dam.file_type IN ('.$extList.')', 'WHERE', 'NOT tx_dam.file_type');
856 if ($this->act
== 'plain') {
857 $this->damSC
->selection
->qg
->addWhere('AND tx_dam.hpixels <= '.intval($this->plainMaxWidth
), 'WHERE', 'tx_dam.hpixels');
858 $this->damSC
->selection
->qg
->addWhere('AND tx_dam.vpixels <= '.intval($this->plainMaxHeight
), 'WHERE', 'tx_dam.vpixels');
861 $this->damSC
->selection
->execSelectionQuery(TRUE);
863 // any records found?
864 if($this->damSC
->selection
->pointer
->countTotal
) {
866 // limit query for browsing
867 $this->damSC
->selection
->addLimitToQuery();
868 $this->damSC
->selection
->execSelectionQuery();
870 if($this->damSC
->selection
->res
) {
871 while($row = $TYPO3_DB->sql_fetch_assoc($this->damSC
->selection
->res
)) {
873 $row['file_title'] = $row['title'] ?
$row['title'] : $row['file_name'];
874 $row['file_path_absolute'] = tx_dam
::path_makeAbsolute($row['file_path']);
875 $row['file_name_absolute'] = $row['file_path_absolute'].$row['file_name'];
876 $row['__exists'] = @is_file
($row['file_name_absolute']);
879 $row['_ref_table'] = 'tx_dam';
880 $row['_ref_id'] = $row['uid'];
881 $row['_ref_file_path'] = '';
883 $row['_ref_table'] = '';
884 $row['_ref_id'] = t3lib_div
::shortMD5($row['file_name_absolute']);
885 $row['_ref_file_path'] = $row['file_name_absolute'];
889 if (count($filearray) >= $this->damSC
->selection
->pointer
->itemsPerPage
) {
899 * [Describe function...]
903 function main_rte() {
904 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
906 $path = tx_dam
::path_makeAbsolute($this->damSC
->path
);
907 if (!$path OR !@is_dir
($path)) {
908 // The closest TEMP-path is found
909 $path = $this->fileProcessor
->findTempFolder().'/';
911 // Remove upload tab if filemount is readonly
912 if ($this->isReadOnlyFolder($path)) {
913 $this->allowedItems
= array_diff($this->allowedItems
, array('upload'));
915 $this->damSC
->path
= tx_dam
::path_makeRelative($path); // mabe not needed
918 $this->content
= $this->doc
->startPage($LANG->getLL('Insert Image',1));
920 $this->reinitParams();
922 // Making menu in top:
924 if (in_array('image',$this->allowedItems
) && ($this->act
=='image' || t3lib_div
::_GP('cWidth'))) {
925 $menuDef['page']['isActive'] = $this->act
=='image';
926 $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
927 $menuDef['page']['url'] = '#';
928 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript
.'?act=image&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
930 if (in_array('magic',$this->allowedItems
)){
931 $menuDef['file']['isActive'] = $this->act
=='magic';
932 $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
933 $menuDef['file']['url'] = '#';
934 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript
.'?act=magic&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
936 if (in_array('plain',$this->allowedItems
)) {
937 $menuDef['url']['isActive'] = $this->act
=='plain';
938 $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
939 $menuDef['url']['url'] = '#';
940 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript
.'?act=plain&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
942 if (in_array('dragdrop',$this->allowedItems
)) {
943 $menuDef['mail']['isActive'] = $this->act
=='dragdrop';
944 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
945 $menuDef['mail']['url'] = '#';
946 $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\''.htmlspecialchars($this->thisScript
.'?act=dragdrop&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
948 if (in_array('upload', $this->allowedItems
)) {
949 $menuDef['upload']['isActive'] = ($this->act
=='upload');
950 $menuDef['upload']['label'] = $LANG->getLL('tx_dam_file_upload.title',1);
951 $menuDef['upload']['url'] = '#';
952 $menuDef['upload']['addParams'] = 'onclick="jumpToUrl(\''.htmlspecialchars($this->thisScript
.'?act=upload&mode='.$this->mode
.'&bparams='.$this->bparams
).'\');return false;"';
954 $this->content
.= $this->doc
->getTabMenuRaw($menuDef);
956 $pArr = explode('|', $this->bparams
);
960 document.write(printCurrentImageOptions());
961 insertImagePropertiesInForm();';
962 $this->content
.= '<br />'.$this->doc
->wrapScriptTags($JScode);
965 $this->content
.= $this->dam_upload($this->allowedFileTypes
, $this->disallowedFileTypes
);
966 $this->content
.= $this->damSC
->getOptions();
967 $this->content
.='<br /><br />';
968 if ($BE_USER->isAdmin() ||
$BE_USER->getTSConfigVal('options.createFoldersInEB')) {
969 $this->content
.= $this->createFolder($path);
970 $this->content
.= '<br />';
975 //$this->allowedFileTypes = t3lib_div::trimExplode(',', $pArr[3], true);
977 $this->addDisplayOptions();
978 $this->content
.= $this->dam_select($this->allowedFileTypes
, $this->disallowedFileTypes
);
979 $this->content
.= $this->damSC
->getOptions();
981 if ($this->act
=='magic') {
982 $this->content
.= $this->getMsgBox($LANG->getLL('magicImage_msg'));
984 if ($this->act
=='plain') {
985 $this->content
.= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth
, $this->plainMaxHeight
));
991 // Ending page, returning content:
992 $this->content
.= $this->doc
->endPage();
994 $this->content
= $this->damSC
->doc
->insertStylesAndJS($this->content
);
995 return $this->content
;
999 * Import from t3lib_page in order to create backend version
1000 * Creates language-overlay for records in general (where translation is found in records from the same table)
1002 * @param string Table name
1003 * @param array Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField']
1004 * @param integer Pointer to the sys_language uid for content on the site.
1005 * @param string Overlay mode. If "hideNonTranslated" then records without translation will not be returned un-translated but unset (and return value is false)
1006 * @return mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return false if no translation is found.
1008 function getRecordOverlay($table,$row,$sys_language_content,$OLmode='') {
1009 global $TCA, $TYPO3_DB;
1010 if ($row['uid']>0 && $row['pid']>0) {
1011 if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) {
1012 if (!$TCA[$table]['ctrl']['transOrigPointerTable']) {
1013 // Will try to overlay a record only if the sys_language_content value is larger that zero.
1014 if ($sys_language_content>0) {
1015 // Must be default language or [All], otherwise no overlaying:
1016 if ($row[$TCA[$table]['ctrl']['languageField']]<=0) {
1017 // Select overlay record:
1018 $res = $TYPO3_DB->exec_SELECTquery(
1021 'pid='.intval($row['pid']).
1022 ' AND '.$TCA[$table]['ctrl']['languageField'].'='.intval($sys_language_content).
1023 ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
1024 t3lib_BEfunc
::BEenableFields($table).
1025 t3lib_BEfunc
::deleteClause($table),
1030 $olrow = $TYPO3_DB->sql_fetch_assoc($res);
1031 //$this->versionOL($table,$olrow);
1033 // Merge record content by traversing all fields:
1034 if (is_array($olrow)) {
1035 foreach($row as $fN => $fV) {
1036 if ($fN!='uid' && $fN!='pid' && isset($olrow[$fN])) {
1037 if ($TCA[$table]['l10n_mode'][$fN]!='exclude' && ($TCA[$table]['l10n_mode'][$fN]!='mergeIfNotBlank' ||
strcmp(trim($olrow[$fN]),''))) {
1038 $row[$fN] = $olrow[$fN];
1042 } elseif ($OLmode==='hideNonTranslated' && $row[$TCA[$table]['ctrl']['languageField']]==0) { // Unset, if non-translated records should be hidden. ONLY done if the source record really is default language and not [All] in which case it is allowed.
1046 // Otherwise, check if sys_language_content is different from the value of the record - that means a japanese site might try to display french content.
1047 } elseif ($sys_language_content!=$row[$TCA[$table]['ctrl']['languageField']]) {
1051 // When default language is displayed, we never want to return a record carrying another language!:
1052 if ($row[$TCA[$table]['ctrl']['languageField']]>0) {
1065 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_dam_browse_media.php'])) {
1066 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_dam_browse_media.php']);