2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasper@typo3.com)
6 * (c) 2004-2012 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>
32 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
34 require_once(PATH_typo3
. 'class.browse_links.php');
35 require_once(PATH_t3lib
. 'file/Service/MagicImageService.php');
40 * @author Kasper Skårhøj <kasper@typo3.com>
44 class tx_rtehtmlarea_image_folderTree
extends TBE_FolderTree
{
45 var $ext_IconMode = 1;
48 * Wrapping the title in a link, if applicable.
50 * @param string Title, ready for output.
51 * @param t3lib_file_Folder The "record"
52 * @return string Wrapping title string.
54 function wrapTitle($title, t3lib_file_Folder
$folderObject) {
55 if ($this->ext_isLinkable($folderObject)) {
56 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript
.
57 '?editorNo=' . $GLOBALS['SOBE']->browser
->editorNo
.
58 '&act=' . $GLOBALS['SOBE']->browser
->act
.
59 '&mode=' . $GLOBALS['SOBE']->browser
->mode
.
60 '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
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 t3lib_file_Folder Object 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(t3lib_file_Folder
$folderObject) {
74 // $folderObject->getStorage()->isPublic() does not matter if the mode is 'magic'
75 return ($GLOBALS['SOBE']->browser
->act
=== 'magic') || parent
::ext_isLinkable($folderObject);
79 * Wrap the plus/minus icon in a link
81 * @param string HTML string to wrap, probably an image tag.
82 * @param string Command for 'PM' get var
83 * @return string Link-wrapped input string
86 public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) {
87 if ($this->thisScript
) {
88 $js = htmlspecialchars('Tree.thisScript=\'' . $GLOBALS['BACK_PATH'] . 'ajax.php\';Tree.load(\'' . $cmd . '\', ' . intval($isExpand) . ', this);');
89 return '<a class="pm" onclick="' . $js . '">' . $icon . '</a>';
100 * @author Kasper Skårhøj <kasper@typo3.com>
104 class tx_rtehtmlarea_select_image
extends browse_links
{
105 var $extKey = 'rtehtmlarea';
108 public $allowedItems;
109 public $allowedFileTypes = array();
110 protected $defaultClass;
111 protected $plainMaxWidth;
112 protected $plainMaxHeight;
113 protected $magicMaxWidth;
114 protected $magicMaxHeight;
116 protected $RTEImageStorageDir;
119 public $sys_language_content;
121 public $buttonConfig;
123 protected $imgObj; // Instance object of t3lib_stdGraphic
132 $this->initVariables();
133 $this->initConfiguration();
134 $this->initHookObjects();
136 // init fileProcessor
137 $this->fileProcessor
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
138 $this->fileProcessor
->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
140 $this->allowedItems
= $this->getAllowedItems('magic,plain,image');
142 $this->insertImage();
144 // Creating backend template object:
145 $this->doc
= t3lib_div
::makeInstance('template');
146 $this->doc
->bodyTagAdditions
= $this->getBodyTagAdditions();
147 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
149 // Load the Prototype library and browse_links.js
150 $this->doc
->getPageRenderer()->loadPrototype();
151 $this->doc
->loadJavascriptLib('js/tree.js');
152 $this->doc
->loadJavascriptLib('js/browse_links.js');
153 $this->doc
->JScode
.= $this->doc
->wrapScriptTags('
154 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
156 $this->doc
->getContextMenuCode();
160 * Initialize class variables
164 public function initVariables() {
166 $this->act
= t3lib_div
::_GP('act');
171 $this->bparams
= t3lib_div
::_GP('bparams');
172 $pArr = explode('|', $this->bparams
);
173 $pRteArr = explode(':', $pArr[1]);
174 $this->editorNo
= $pRteArr[0];
175 $this->sys_language_content
= $pRteArr[1];
176 $this->RTEtsConfigParams
= $pArr[2];
177 if (!$this->editorNo
) {
178 $this->editorNo
= t3lib_div
::_GP('editorNo');
179 $this->sys_language_content
= t3lib_div
::_GP('sys_language_content');
180 $this->RTEtsConfigParams
= t3lib_div
::_GP('RTEtsConfigParams');
182 $this->expandPage
= t3lib_div
::_GP('expandPage');
183 $this->expandFolder
= t3lib_div
::_GP('expandFolder');
184 $pArr[1] = implode(':', array($this->editorNo
, $this->sys_language_content
));
185 $pArr[2] = $this->RTEtsConfigParams
;
186 if ($this->act
== 'dragdrop' ||
$this->act
== 'plain') {
187 $this->allowedFileTypes
= explode(',','jpg,jpeg,gif,png');
189 $pArr[3] = implode(',', $this->allowedFileTypes
);
190 $this->bparams
= implode('|', $pArr);
193 $this->mode
= t3lib_div
::_GP('mode');
198 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL'); // Current site url
200 // the script to link to
201 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
205 * Initialize hook objects implementing interface t3lib_browseLinksHook
209 protected function initHookObjects() {
210 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'])) {
211 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'] as $classData) {
212 $processObject = t3lib_div
::getUserObj($classData);
213 if(!($processObject instanceof t3lib_browseLinksHook
)) {
214 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
216 $parameters = array();
217 $processObject->init($this, $parameters);
218 $this->hookObjects
[] = $processObject;
224 * Provide the additional parameters to be included in the template body tag
226 * @return string the body tag additions
228 public function getBodyTagAdditions() {
229 return 'onload="initEventListeners();"';
233 * Get the path to the folder where RTE images are stored
235 * @return string the path to the folder where RTE images are stored
237 protected function getRTEImageStorageDir() {
238 return ($this->imgPath ?
$this->imgPath
: $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
242 * Insert the image in the editing area
246 protected function insertImage() {
247 if (t3lib_div
::_GP('insertImage')) {
248 $table = t3lib_div
::_GP('table');
249 $uid = t3lib_div
::_GP('uid');
250 $fileObject = t3lib_file_Factory
::getInstance()->getFileObject($uid);
251 // Get default values for alt and title attributes from file properties
252 $altText = $fileObject->getProperty('alternative');
253 $titleText = $fileObject->getProperty('name');
254 switch ($this->act
) {
256 $this->insertMagicImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '" data-htmlarea-file-table="' . $table . '"');
260 $this->insertPlainImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '" data-htmlarea-file-table="' . $table . '"');
265 foreach ($this->hookObjects
as $hookObject) {
266 if (method_exists($hookObject, 'insertElement')) {
267 $hookObject->insertElement($this->act
);
276 * Insert a magic image
278 * @param t3lib_file_FileInterface $fileObject: the image file
279 * @param string $altText: text for the alt attribute of the image
280 * @param string $titleText: text for the title attribute of the image
281 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
284 public function insertMagicImage(t3lib_file_FileInterface
$fileObject, $altText='', $titleText='', $additionalParams='') {
285 if ($this->RTEImageStorageDir
) {
286 // Create the magic image
287 /** @var $magicImageService t3lib_file_Service_MagicImageService */
288 $magicImageService = t3lib_div
::makeInstance('t3lib_file_Service_MagicImageService');
289 $imageConfiguration = array(
290 'width' => t3lib_div
::_GP('cWidth'),
291 'height' => t3lib_div
::_GP('cHeight'),
292 'maxW' => $this->magicMaxWidth
,
293 'maxH' => $this->magicMaxHeight
,
296 $magicImage = $magicImageService->createMagicImage(
299 $this->getRTEImageStorageDir()
302 if ($magicImage instanceof t3lib_file_FileInterface
) {
303 $filePath = $magicImage->getForLocalProcessing(FALSE);
304 $imageInfo = @getimagesize
($filePath);
305 $imageUrl = $this->siteURL
. substr($filePath, strlen(PATH_site
));
306 $this->imageInsertJS($imageUrl, $imageInfo[0], $imageInfo[1], $altText, $titleText, $additionalParams);
309 t3lib_div
::sysLog('Attempt at creating a magic image failed due to absent RTE_imageStorageDir', $this->extKey
. '/tx_rtehtmlarea_select_image', t3lib_div
::SYSLOG_SEVERITY_ERROR
);
314 * Insert a plain image
316 * @param t3lib_file_FileInterface $fileObject: the image file
317 * @param string $altText: text for the alt attribute of the image
318 * @param string $titleText: text for the title attribute of the image
319 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
322 public function insertPlainImage(t3lib_file_FileInterface
$fileObject, $altText='', $titleText='', $additionalParams='') {
323 $filePath = $fileObject->getForLocalProcessing(FALSE);
324 $imageInfo = @getimagesize
($filePath);
325 $imageUrl = $this->siteURL
. substr($filePath, strlen(PATH_site
));
326 $this->imageInsertJS($imageUrl, $imageInfo[0], $imageInfo[1], $altText, $titleText, $additionalParams);
330 * Echo the HTML page and JS that will insert the image
332 * @param string $url: the url of the image
333 * @param integer $width: the width of the image
334 * @param integer $height: the height of the image
335 * @param string $altText: text for the alt attribute of the image
336 * @param string $titleText: text for the title attribute of the image
337 * @param string $additionalParams: text representing more html attributes to be added on the img tag
340 protected function imageInsertJS($url, $width, $height, $altText='', $titleText='', $additionalParams='') {
345 <title>Untitled</title>
346 <script type="text/javascript">
348 var plugin = window.parent.RTEarea["' . $this->editorNo
. '"].editor.getPlugin("TYPO3Image");
349 function insertImage(file,width,height,alt,title,additionalParams) {
350 plugin.insertImage(\'<img src="\'+file+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'"\'' . ($this->defaultClass?
('+\' class="'.$this->defaultClass
.'"\''):'') .
351 '+(alt?\' alt="\'+alt+\'"\':\'\')+(title?\' title="\'+title+\'"\':\'\')+(additionalParams?\' \'+additionalParams:\'\')+\' />\');
357 <script type="text/javascript">
359 insertImage('.t3lib_div
::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div
::quoteJSvalue($altText,1).','.t3lib_div
::quoteJSvalue($titleText,1).','.t3lib_div
::quoteJSvalue($additionalParams, 1).');
367 * Generate JS code to be used on the image insert/modify dialogue
369 * @param string $act: the action to be performed
370 * @param string $editorNo: the number of the RTE instance on the page
371 * @param string $sys_language_content: the language of the content element
373 * @return string the generated JS code
375 function getJSCode($act, $editorNo, $sys_language_content) {
377 $removedProperties = array();
378 if (is_array($this->buttonConfig
['properties.'])) {
379 if ($this->buttonConfig
['properties.']['removeItems']) {
380 $removedProperties = t3lib_div
::trimExplode(',',$this->buttonConfig
['properties.']['removeItems'],1);
383 // The following property is deprecated as of TYPO3 4.6 and will be removed in TYPO3 4.8
384 if ($this->thisConfig
['classesImage']) {
385 $classesImageArray = t3lib_div
::trimExplode(',', $this->thisConfig
['classesImage'], 1);
386 $classesImageJSOptions = '<option value=""></option>';
387 foreach ($classesImageArray as $class) {
388 $classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
391 if ($this->buttonConfig
['properties.']['class.']['allowedClasses']) {
392 $classesImageArray = t3lib_div
::trimExplode(',', $this->buttonConfig
['properties.']['class.']['allowedClasses'], 1);
393 $classesImageJSOptions = '<option value=""></option>';
394 foreach ($classesImageArray as $class) {
395 $classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
398 $lockPlainWidth = 'false';
399 $lockPlainHeight = 'false';
400 if (is_array($this->thisConfig
['proc.']) && $this->thisConfig
['proc.']['plainImageMode']) {
401 $plainImageMode = $this->thisConfig
['proc.']['plainImageMode'];
402 $lockPlainWidth = ($plainImageMode == 'lockDimensions')?
'true':'false';
403 $lockPlainHeight = ($lockPlainWidth ||
$plainImageMode == 'lockRatio' ||
($plainImageMode == 'lockRatioWhenSmaller'))?
'true':'false';
407 var plugin = window.parent.RTEarea["' . $editorNo . '"].editor.getPlugin("TYPO3Image");
408 var HTMLArea = window.parent.HTMLArea;
410 HTMLArea.TYPO3Image.insertElement = function (table, uid, type, filename, filePath, fileExt, fileIcon) {
411 return jumpToUrl(\'?editorNo=\' + \'' . $editorNo . '\' + \'&insertImage=\' + filePath + \'&table=\' + table + \'&uid=\' + uid + \'&type=\' + type + \'bparams=\' + \'' . $this->bparams
. '\');
413 function insertElement(table, uid, type, fileName, filePath, fileExt, fileIcon, action, close) {
414 return jumpToUrl(\'?editorNo=\' + \'' . $editorNo . '\' + \'&insertImage=\' + filePath + \'&table=\' + table + \'&uid=\' + uid + \'&type=\' + type + \'bparams=\' + \'' . $this->bparams
. '\');
416 function initEventListeners() {
418 Ext.EventManager.addListener(window.document.body, "dragend", plugin.onDrop, plugin, { single: true });
421 function jumpToUrl(URL,anchor) {
422 var add_act = URL.indexOf("act=")==-1 ? "&act='.$act.'" : "";
423 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$editorNo.'" : "";
424 var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content='.$sys_language_content.'" : "";
425 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams
).'";
427 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
428 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
430 var theLocation = URL+add_act+add_editorNo+add_sys_language_content+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
431 window.location.href = theLocation;
434 function insertImage(file,width,height) {
435 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
437 function launchView(url) {
438 var thePreviewWindow="";
439 thePreviewWindow = window.open("'.t3lib_div
::getIndpEnv('TYPO3_SITE_URL').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");
440 if (thePreviewWindow && thePreviewWindow.focus) {
441 thePreviewWindow.focus();
444 function getCurrentImageRef() {
451 function printCurrentImageOptions() {
452 var classesImage = ' . (($this->buttonConfig
['properties.']['class.']['allowedClasses'] ||
$this->thisConfig
['classesImage']) ?
'true' : 'false') . ';
453 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $classesImageJSOptions . '</select>\';
454 var floatSelector=\'<select id="iFloat" name="iFloat"><option value="">' . $GLOBALS['LANG']->getLL('notSet') . '</option><option value="none">' . $GLOBALS['LANG']->getLL('nonFloating') . '</option><option value="left">' . $GLOBALS['LANG']->getLL('left') . '</option><option value="right">' . $GLOBALS['LANG']->getLL('right') . '</option></select>\';
455 if (plugin.getButton("Language")) {
456 var languageSelector = \'<select id="iLang" name="iLang">\';
457 plugin.getButton("Language").getStore().each(function (record) {
458 languageSelector +=\'<option value="\' + record.get("value") + \'">\' + record.get("text") + \'</option>\';
460 languageSelector += \'</select>\';
462 var bgColor=\' class="bgColor4"\';
464 sz+=\'<table border="0" cellpadding="1" cellspacing="1"><form action="" name="imageData">\';
465 '.(in_array('class', $removedProperties)?
'':'
467 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$GLOBALS['LANG']->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
469 .(in_array('width', $removedProperties)?
'':'
470 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $lockPlainWidth .')) {
471 sz+=\'<tr><td\'+bgColor+\'><label for="iWidth">'.$GLOBALS['LANG']->getLL('width').': </label></td><td><input type="text" id="iWidth" name="iWidth" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
473 .(in_array('height', $removedProperties)?
'':'
474 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $lockPlainHeight .')) {
475 sz+=\'<tr><td\'+bgColor+\'><label for="iHeight">'.$GLOBALS['LANG']->getLL('height').': </label></td><td><input type="text" id="iHeight" name="iHeight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
477 .(in_array('border', $removedProperties)?
'':'
478 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$GLOBALS['LANG']->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
479 .(in_array('float', $removedProperties)?
'':'
480 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$GLOBALS['LANG']->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
481 .(in_array('paddingTop', $removedProperties)?
'':'
482 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingTop">'.$GLOBALS['LANG']->getLL('padding_top').': </label></td><td><input type="text" id="iPaddingTop" name="iPaddingTop" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).'></td></tr>\';')
483 .(in_array('paddingRight', $removedProperties)?
'':'
484 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingRight">'.$GLOBALS['LANG']->getLL('padding_right').': </label></td><td><input type="text" id="iPaddingRight" name="iPaddingRight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
485 .(in_array('paddingBottom', $removedProperties)?
'':'
486 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingBottom">'.$GLOBALS['LANG']->getLL('padding_bottom').': </label></td><td><input type="text" id="iPaddingBottom" name="iPaddingBottom" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
487 .(in_array('paddingLeft', $removedProperties)?
'':'
488 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingLeft">'.$GLOBALS['LANG']->getLL('padding_left').': </label></td><td><input type="text" id="iPaddingLeft" name="iPaddingLeft" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';')
489 .(in_array('title', $removedProperties)?
'':'
490 sz+=\'<tr><td\'+bgColor+\'><label for="iTitle">'.$GLOBALS['LANG']->getLL('title').': </label></td><td><input type="text" id="iTitle" name="iTitle"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';')
491 .(in_array('alt', $removedProperties)?
'':'
492 sz+=\'<tr><td\'+bgColor+\'><label for="iAlt">'.$GLOBALS['LANG']->getLL('alt').': </label></td><td><input type="text" id="iAlt" name="iAlt"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';')
493 .(in_array('lang', $removedProperties)?
'':'
494 if (plugin.getButton("Language")) {
495 sz+=\'<tr><td\'+bgColor+\'><label for="iLang">\' + plugin.editor.getPlugin("Language").localize(\'Language-Tooltip\') + \': </label></td><td>\' + languageSelector + \'</td></tr>\';
497 .((in_array('clickenlarge', $removedProperties) ||
in_array('data-htmlarea-clickenlarge', $removedProperties)) ?
'':'
498 sz+=\'<tr><td\'+bgColor+\'><label for="iClickEnlarge">'.$GLOBALS['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>\';').'
499 sz+=\'<tr><td><input type="submit" value="'.$GLOBALS['LANG']->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
500 sz+=\'</form></table>\';
503 function setImageProperties() {
504 var classesImage = ' . (($this->buttonConfig
['properties.']['class.']['allowedClasses'] ||
$this->thisConfig
['classesImage']) ?
'true' : 'false') . ';
505 if (selectedImageRef) {
506 if (document.imageData.iWidth) {
507 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
508 selectedImageRef.style.width = "";
509 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
512 if (document.imageData.iHeight) {
513 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
514 selectedImageRef.style.height = "";
515 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
518 if (document.imageData.iPaddingTop) {
519 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
520 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
522 selectedImageRef.style.paddingTop = "";
525 if (document.imageData.iPaddingRight) {
526 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
527 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
529 selectedImageRef.style.paddingRight = "";
532 if (document.imageData.iPaddingBottom) {
533 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
534 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
536 selectedImageRef.style.paddingBottom = "";
539 if (document.imageData.iPaddingLeft) {
540 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
541 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
543 selectedImageRef.style.paddingLeft = "";
546 if (document.imageData.iTitle) {
547 selectedImageRef.title=document.imageData.iTitle.value;
549 if (document.imageData.iAlt) {
550 selectedImageRef.alt=document.imageData.iAlt.value;
552 if (document.imageData.iBorder) {
553 selectedImageRef.style.borderStyle = "";
554 selectedImageRef.style.borderWidth = "";
555 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
556 selectedImageRef.style.borderTopStyle = "";
557 selectedImageRef.style.borderRightStyle = "";
558 selectedImageRef.style.borderBottomStyle = "";
559 selectedImageRef.style.borderLeftStyle = "";
560 selectedImageRef.style.borderTopWidth = "";
561 selectedImageRef.style.borderRightWidth = "";
562 selectedImageRef.style.borderBottomWidth = "";
563 selectedImageRef.style.borderLeftWidth = "";
564 if(document.imageData.iBorder.checked) {
565 selectedImageRef.style.borderStyle = "solid";
566 selectedImageRef.style.borderWidth = "thin";
568 selectedImageRef.removeAttribute("border");
570 if (document.imageData.iFloat) {
571 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
573 selectedImageRef.style.styleFloat = iFloat ? iFloat : "";
575 selectedImageRef.style.cssFloat = iFloat ? iFloat : "";
578 if (classesImage && document.imageData.iClass) {
579 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
580 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
581 selectedImageRef.className = iClass;
583 selectedImageRef.className = "";
586 if (document.imageData.iLang) {
587 var iLang = document.imageData.iLang.options[document.imageData.iLang.selectedIndex].value;
588 var languageObject = plugin.editor.getPlugin("Language");
589 if (iLang || languageObject.getLanguageAttribute(selectedImageRef)) {
590 languageObject.setLanguageAttributes(selectedImageRef, iLang);
592 languageObject.setLanguageAttributes(selectedImageRef, "none");
595 if (document.imageData.iClickEnlarge) {
596 if (document.imageData.iClickEnlarge.checked) {
597 selectedImageRef.setAttribute("data-htmlarea-clickenlarge","1");
599 selectedImageRef.removeAttribute("data-htmlarea-clickenlarge");
600 selectedImageRef.removeAttribute("clickenlarge");
607 function insertImagePropertiesInForm() {
608 var classesImage = ' . (($this->buttonConfig
['properties.']['class.']['allowedClasses'] ||
$this->thisConfig
['classesImage']) ?
'true' : 'false') . ';
609 if (selectedImageRef) {
610 var styleWidth, styleHeight, padding;
611 if (document.imageData.iWidth) {
612 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
613 styleWidth = parseInt(styleWidth);
614 if (!(isNaN(styleWidth) || styleWidth == 0)) {
615 document.imageData.iWidth.value = styleWidth;
618 if (document.imageData.iHeight) {
619 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
620 styleHeight = parseInt(styleHeight);
621 if (!(isNaN(styleHeight) || styleHeight == 0)) {
622 document.imageData.iHeight.value = styleHeight;
625 if (document.imageData.iPaddingTop) {
626 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
627 var padding = parseInt(padding);
628 if (isNaN(padding) || padding <= 0) { padding = ""; }
629 document.imageData.iPaddingTop.value = padding;
631 if (document.imageData.iPaddingRight) {
632 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
633 var padding = parseInt(padding);
634 if (isNaN(padding) || padding <= 0) { padding = ""; }
635 document.imageData.iPaddingRight.value = padding;
637 if (document.imageData.iPaddingBottom) {
638 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
639 var padding = parseInt(padding);
640 if (isNaN(padding) || padding <= 0) { padding = ""; }
641 document.imageData.iPaddingBottom.value = padding;
643 if (document.imageData.iPaddingLeft) {
644 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
645 var padding = parseInt(padding);
646 if (isNaN(padding) || padding <= 0) { padding = ""; }
647 document.imageData.iPaddingLeft.value = padding;
649 if (document.imageData.iTitle) {
650 document.imageData.iTitle.value = selectedImageRef.title;
652 if (document.imageData.iAlt) {
653 document.imageData.iAlt.value = selectedImageRef.alt;
655 if (document.imageData.iBorder) {
656 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
657 document.imageData.iBorder.checked = 1;
660 if (document.imageData.iFloat) {
661 var fObj=document.imageData.iFloat;
662 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
664 for (var a=0;a<l;a++) {
665 if (fObj.options[a].value == value) {
666 fObj.selectedIndex = a;
670 if (classesImage && document.imageData.iClass) {
671 var fObj=document.imageData.iClass;
672 var value=selectedImageRef.className;
674 for (var a=0;a < l; a++) {
675 if (fObj.options[a].value == value) {
676 fObj.selectedIndex = a;
680 if (document.imageData.iLang) {
681 var fObj=document.imageData.iLang;
682 var value=plugin.editor.getPlugin("Language").getLanguageAttribute(selectedImageRef);
683 for (var i = 0, n = fObj.length; i < n; i++) {
684 if (fObj.options[i].value == value) {
685 fObj.selectedIndex = i;
687 fObj.options[0].text = plugin.editor.getPlugin("Language").localize("Remove language mark");
692 if (document.imageData.iClickEnlarge) {
693 if (selectedImageRef.getAttribute("data-htmlarea-clickenlarge") == "1" || selectedImageRef.getAttribute("clickenlarge") == "1") {
694 document.imageData.iClickEnlarge.checked = 1;
696 document.imageData.iClickEnlarge.checked = 0;
703 var selectedImageRef = getCurrentImageRef();'; // Setting this to a reference to the image object.
708 * Session data for this class can be set from outside with this method.
711 * @param array Session data array
712 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
714 function processSessionData($data) {
717 if ($this->act
!= 'image') {
718 if (isset($this->act
)) {
719 $data['act'] = $this->act
;
722 $this->act
= $data['act'];
726 if (isset($this->expandFolder
)) {
727 $data['expandFolder'] = $this->expandFolder
;
730 $this->expandFolder
= $data['expandFolder'];
733 return array($data, $store);
737 * [Describe function...]
741 function main_rte() {
743 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->getLL('Insert Image',1));
745 // Making menu in top:
747 if (in_array('image', $this->allowedItems
) && (($this->act
=== 'image') || t3lib_div
::_GP('cWidth'))) {
748 $menuDef['image']['isActive'] = FALSE;
749 $menuDef['image']['label'] = $GLOBALS['LANG']->getLL('currentImage', 1);
750 $menuDef['image']['url'] = '#';
751 $menuDef['image']['addParams'] = 'onClick="jumpToUrl(\'?act=image&bparams=' . $this->bparams
. '\');return false;"';
753 if (in_array('magic', $this->allowedItems
)){
754 $menuDef['magic']['isActive'] = FALSE;
755 $menuDef['magic']['label'] = $GLOBALS['LANG']->getLL('magicImage', 1);
756 $menuDef['magic']['url'] = '#';
757 $menuDef['magic']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&bparams=' . $this->bparams
. '\');return false;"';
759 if (in_array('plain', $this->allowedItems
)) {
760 $menuDef['plain']['isActive'] = FALSE;
761 $menuDef['plain']['label'] = $GLOBALS['LANG']->getLL('plainImage', 1);
762 $menuDef['plain']['url'] = '#';
763 $menuDef['plain']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&bparams=' . $this->bparams
. '\');return false;"';
765 if (in_array('dragdrop', $this->allowedItems
)) {
766 $menuDef['dragdrop']['isActive'] = FALSE;
767 $menuDef['dragdrop']['label'] = $GLOBALS['LANG']->getLL('dragDropImage', 1);
768 $menuDef['dragdrop']['url'] = '#';
769 $menuDef['dragdrop']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&bparams=' . $this->bparams
. '\');return false;"';
772 // Call hook for extra options
773 foreach ($this->hookObjects
as $hookObject) {
774 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
777 // Order the menu items as specified in Page TSconfig
778 $menuDef = $this->orderMenuDefinition($menuDef);
780 // Set active menu item
782 if (($this->act
=== FALSE) ||
!in_array($this->act
, $this->allowedItems
)) {
783 $this->act
= key($menuDef);
785 $menuDef[$this->act
]['isActive'] = TRUE;
787 $this->content
.= $this->doc
->getTabMenuRaw($menuDef);
789 switch ($this->act
) {
792 document.write(printCurrentImageOptions());
793 insertImagePropertiesInForm();';
794 $this->content
.= '<br />'.$this->doc
->wrapScriptTags($JScode);
798 // Create folder tree:
799 $foldertree = t3lib_div
::makeInstance('tx_rtehtmlarea_image_folderTree');
800 $foldertree->thisScript
= $this->thisScript
;
801 $tree = $foldertree->getBrowsableTree();
802 // Get currently selected folder
803 if (!$this->curUrlInfo
['value'] ||
$this->curUrlInfo
['act'] != $this->act
) {
806 $cmpPath = $this->curUrlInfo
['value'];
807 if (!isset($this->expandFolder
)) {
808 $this->expandFolder
= $cmpPath;
812 if ($this->expandFolder
) {
814 $selectedFolder = t3lib_file_Factory
::getInstance()->getFolderObjectFromCombinedIdentifier(
817 } catch (Exception
$e) {
818 $selectedFolder = FALSE;
821 // Adding upload form, if allowed
822 if ($selectedFolder) {
823 $this->content
.= $this->insertUploadForm($selectedFolder);
826 // Render the filelist if there is a folder selected
827 if ($selectedFolder) {
828 $files = $this->TBE_expandFolder(
830 $this->act
=== 'plain' ?
'jpg,jpeg,gif,png' : $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
831 $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInRTEimageSelect')
834 // Setup filelist indexed elements:
835 $this->doc
->JScode
.= $this->doc
->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements
) . ');');
840 Wrapper table for folder tree / file/folder list:
842 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
844 <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('folderTree') . ':') . $tree . '</td>
845 <td class="c-wCell" valign="top">' . $files . '</td>
850 $helpMessage = $this->getHelpMessage($this->act
);
852 $this->content
.= $this->getMsgBox($helpMessage);
856 $foldertree = t3lib_div
::makeInstance('TBE_FolderTree');
857 $foldertree->thisScript
= $this->thisScript
;
858 $foldertree->ext_noTempRecyclerDirs
= TRUE;
859 $tree = $foldertree->getBrowsableTree();
860 // Get currently selected folder
861 if (!$this->curUrlInfo
['value'] ||
$this->curUrlInfo
['act'] != $this->act
) {
864 $cmpPath = $this->curUrlInfo
['value'];
865 if (!isset($this->expandFolder
)) {
866 $this->expandFolder
= $cmpPath;
870 if ($this->expandFolder
) {
872 $selectedFolder = t3lib_file_Factory
::getInstance()->getFolderObjectFromCombinedIdentifier(
875 } catch (Exception
$e) {
876 $selectedFolder = FALSE;
879 // Render the filelist if there is a folder selected
880 if ($selectedFolder) {
881 $files = $this->TBE_dragNDrop($selectedFolder, implode(',', $this->allowedFileTypes
));
884 $this->content
.= '<table border="0" cellpadding="0" cellspacing="0">
886 <td style="vertical-align: top;">' . $this->barheader($GLOBALS['LANG']->getLL('folderTree') . ':') . $tree . '</td>
888 <td style="vertical-align: top;">' .$files. '</td>
894 foreach ($this->hookObjects
as $hookObject) {
895 $this->content
.= $hookObject->getTab($this->act
);
899 $this->content
.= $this->doc
->endPage();
900 $this->doc
->JScodeArray
['rtehtmlarea'] = $this->getJSCode($this->act
, $this->editorNo
, $this->sys_language_content
);
901 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
902 return $this->content
;
906 * Create upload/create folder forms, if a folder is given
908 * @param t3lib_file_Folder $selectedFolder Absolute filepath on server to which to upload.
909 * @return string HTML for an upload form.
911 protected function insertUploadForm(t3lib_file_Folder
$selectedFolder) {
913 if (!$this->readOnly
) {
914 // Add upload form if allowed
915 if (!$selectedFolder) {
916 $fileStorages = $GLOBALS['BE_USER']->getFileStorages();
917 $fileStorage = reset($fileStorages);
918 $selectedFolder = $fileStorage->getRootLevelFolder();
920 if ($selectedFolder) {
921 $uploadForm = $this->uploadForm($selectedFolder);
922 $createFolder = $this->createFolder($selectedFolder);
924 $uploadForm = $createFolder = '';
926 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
927 $content .= $uploadForm;
928 if ($GLOBALS['BE_USER']->isAdmin() ||
$GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
929 $content .= $createFolder;
937 * Initializes the configuration variables
941 public function initConfiguration(){
942 $this->thisConfig
= $this->getRTEConfig();
943 $this->buttonConfig
= $this->getButtonConfig();
944 $this->imgPath
= $this->getImgPath();
945 $this->RTEImageStorageDir
= $this->getRTEImageStorageDir();
946 $this->defaultClass
= $this->getDefaultClass();
947 $this->setMaximumImageDimensions();
951 * Get the RTE configuration from Page TSConfig
953 * @return array RTE configuration array
955 protected function getRTEConfig() {
956 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
957 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($RTEtsConfigParts[5]));
958 return t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
962 * Get the path of the image to be inserted or modified
964 * @return string path to the image
966 protected function getImgPath() {
967 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
968 return $RTEtsConfigParts[6];
972 * Get the configuration of the image button
974 * @return array the configuration array of the image button
976 protected function getButtonConfig() {
977 return ((is_array($this->thisConfig
['buttons.']) && is_array($this->thisConfig
['buttons.']['image.'])) ?
$this->thisConfig
['buttons.']['image.'] : array());
981 * Get the allowed items or tabs
983 * @param string $items: initial list of possible items
984 * @return array the allowed items
986 public function getAllowedItems($items) {
987 $allowedItems = explode(',', $items);
988 $clientInfo = t3lib_div
::clientInfo();
989 if ($clientInfo['BROWSER'] !== 'opera') {
990 $allowedItems[] = 'dragdrop';
992 // Call hook for extra options
993 foreach ($this->hookObjects
as $hookObject) {
994 $allowedItems = $hookObject->addAllowedItems($allowedItems);
996 // Remove tab "image" if there is no current image
997 if ($this->act
!== 'image') {
998 $allowedItems = array_diff($allowedItems, array('image'));
1000 // Remove options according to RTE configuration
1001 if (is_array($this->buttonConfig
['options.']) && $this->buttonConfig
['options.']['removeItems']) {
1002 $allowedItems = array_diff($allowedItems, t3lib_div
::trimExplode(',', $this->buttonConfig
['options.']['removeItems'], 1));
1004 // This PageTSConfig property is deprecated as of TYPO3 4.6 and will be removed in TYPO3 4.8
1005 $allowedItems = array_diff($allowedItems, t3lib_div
::trimExplode(',', $this->thisConfig
['blindImageOptions'], 1));
1007 return $allowedItems;
1011 * Order the definition of menu items according to configured order
1013 * @param array $menuDefinition: definition of menu items
1014 * @return array ordered menu definition
1016 public function orderMenuDefinition($menuDefinition) {
1017 $orderedMenuDefinition = array();
1018 if (is_array($this->buttonConfig
['options.']) && $this->buttonConfig
['options.']['orderItems']) {
1019 $orderItems = t3lib_div
::trimExplode(',', $this->buttonConfig
['options.']['orderItems'], TRUE);
1020 $orderItems = array_intersect($orderItems, $this->allowedItems
);
1021 foreach ($orderItems as $item) {
1022 $orderedMenuDefinition[$item] = $menuDefinition[$item];
1025 $orderedMenuDefinition = $menuDefinition;
1027 return $orderedMenuDefinition;
1031 * Get the default image class
1033 * @return string the default class, if any
1035 protected function getDefaultClass() {
1037 if (is_array($this->buttonConfig
['properties.'])) {
1038 if (is_array($this->buttonConfig
['properties.']['class.']) && trim($this->buttonConfig
['properties.']['class.']['default'])) {
1039 $defaultClass = trim($this->buttonConfig
['properties.']['class.']['default']);
1042 return $defaultClass;
1046 * Set variables for maximum image dimensions
1050 protected function setMaximumImageDimensions() {
1051 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['plain.'])) {
1052 if ($this->buttonConfig
['options.']['plain.']['maxWidth']) $this->plainMaxWidth
= $this->buttonConfig
['options.']['plain.']['maxWidth'];
1053 if ($this->buttonConfig
['options.']['plain.']['maxHeight']) $this->plainMaxHeight
= $this->buttonConfig
['options.']['plain.']['maxHeight'];
1055 if (!$this->plainMaxWidth
) $this->plainMaxWidth
= 640;
1056 if (!$this->plainMaxHeight
) $this->plainMaxHeight
= 680;
1057 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['magic.'])) {
1058 if ($this->buttonConfig
['options.']['magic.']['maxWidth']) $this->magicMaxWidth
= $this->buttonConfig
['options.']['magic.']['maxWidth'];
1059 if ($this->buttonConfig
['options.']['magic.']['maxHeight']) $this->magicMaxHeight
= $this->buttonConfig
['options.']['magic.']['maxHeight'];
1061 // 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
1062 if (!$this->magicMaxWidth
) $this->magicMaxWidth
= 300;
1063 if (!$this->magicMaxHeight
) $this->magicMaxHeight
= 1000;
1067 * Get the help message to be displayed on a given tab
1069 * @param string $act: the identifier of the tab
1070 * @return string the text of the message
1072 public function getHelpMessage($act) {
1075 return sprintf($GLOBALS['LANG']->getLL('plainImage_msg'), $this->plainMaxWidth
, $this->plainMaxHeight
);
1078 return sprintf($GLOBALS['LANG']->getLL('magicImage_msg'));
1086 * Render list of files.
1088 * @param array List of files. See t3lib_div::getFilesInDir
1089 * @param string If set a header with a folder icon and folder name are shown
1090 * @param boolean Whether to show thumbnails or not. If set, no thumbnails are shown.
1091 * @return string HTML output
1093 function fileList(array $files, t3lib_file_Folder
$folder = NULL, $noThumbs = 0) {
1096 // Listing the files:
1097 if (is_array($files)) {
1100 // Create headline (showing number of files):
1101 $filesCount = count($files);
1102 $out .= $this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):', $filesCount));
1103 $out .= '<div id="filelist">';
1104 $out .= $this->getBulkSelector($filesCount);
1106 $titleLen = intval($GLOBALS['BE_USER']->uc
['titleLen']);
1108 // Create the header of current folder:
1110 $folderIcon = t3lib_iconWorks
::getSpriteIconForFile('folder');
1111 $lines[] = '<tr class="t3-row-header">
1112 <td colspan="4">' . $folderIcon . htmlspecialchars(t3lib_div
::fixed_lgd_cs($folder->getIdentifier(), $titleLen)) . '</td>
1116 if ($filesCount == 0) {
1118 <tr class="file_list_normal">
1119 <td colspan="4">No files found.</td>
1123 // Init graphic object for reading file and image dimensions:
1124 /** @var $imgObj t3lib_stdGraphic */
1125 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
1127 $imgObj->mayScaleUp
= 0;
1128 $imgObj->tempPath
= PATH_site
. $imgObj->tempPath
;
1130 // Traverse the file list:
1131 /** @var $fileObject t3lib_file_File */
1132 foreach ($files as $fileObject) {
1133 $fileExtension = $fileObject->getExtension();
1134 // Thumbnail/size generation:
1135 if (t3lib_div
::inList(strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), strtolower($fileExtension)) && !$noThumbs) {
1136 $imageUrl = $fileObject->process(t3lib_file_ProcessedFile
::CONTEXT_IMAGEPREVIEW
, array('width' => 64, 'height' => 64))->getPublicUrl(TRUE);
1138 $imgInfo = $imgObj->getImageDimensions($fileObject->getForLocalProcessing(FALSE));
1139 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1140 $clickIcon = '<img src="' . $imageUrl . '" hspace="5" vspace="5" border="1"';
1146 // Create file icon:
1147 $size = ' ('.t3lib_div
::formatSize($fileObject->getSize()) . 'bytes' . ($pDim ?
', ' . $pDim : '') . ')';
1148 $icon = t3lib_iconWorks
::getSpriteIconForFile($fileExtension, array('title' => $fileObject->getName() . $size));
1150 // Create links for adding the file:
1151 $filesIndex = count($this->elements
);
1152 $this->elements
['file_' . $filesIndex] = array(
1154 'table' => 'sys_file',
1155 'uid' => $fileObject->getUid(),
1156 'fileName' => $fileObject->getName(),
1157 'filePath' => $fileObject->getUid(),
1158 'fileExt' => $fileExtension,
1159 'fileIcon' => $icon,
1161 $element = $this->elements
['file_' . $filesIndex];
1162 if ($this->act
=== 'plain' && (($imgInfo[0] > $this->plainMaxWidth
) ||
($imgInfo[1] > $this->plainMaxHeight
)) ||
!t3lib_div
::inList('jpg,jpeg,gif,png', $fileExtension)) {
1167 $this->elements
['file_' . $filesIndex] = array(
1169 'table' => 'sys_file',
1170 'uid' => $fileObject->getUid(),
1171 'fileName' => $fileObject->getName(),
1172 'filePath' => $fileObject->getUid(),
1173 'fileExt' => $fileExtension,
1174 'fileIcon' => $icon,
1176 $ATag = "<a href=\"#\" onclick=\"return BrowseLinks.File.insertElement('file_$filesIndex');\">";
1177 $ATag_alt = substr($ATag,0,-4).",1);\">";
1181 // Create link to showing details about the file in a window:
1182 $Ahref = $GLOBALS['BACK_PATH'].'show_item.php?type=file&table='.rawurlencode($fileObject->getCombinedIdentifier()).'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'));
1183 $ATag2='<a href="'.htmlspecialchars($Ahref).'">';
1186 // Combine the stuff:
1187 $filenameAndIcon = $ATag_alt . $icon . htmlspecialchars(t3lib_div
::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
1190 if ($pDim) { // Image...
1192 <tr class="file_list_normal">
1193 <td nowrap="nowrap">'.$filenameAndIcon.' </td>
1194 <td nowrap="nowrap">' . ($ATag2 . '<img'.t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'], 'gfx/zoom2.gif', 'width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('info', 1) . '" alt="" /> ' . $GLOBALS['LANG']->getLL('info', 1) . $ATag2_e) . '</td>
1195 <td nowrap="nowrap"> '.$pDim.'</td>
1199 <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e . '</td>
1203 <tr class="file_list_normal">
1204 <td nowrap="nowrap">'.$filenameAndIcon.' </td>
1205 <td nowrap="nowrap">' . ($ATag2 . '<img' . t3lib_iconWorks
::skinImg($GLOBALS['BACK_PATH'],'gfx/zoom2.gif','width="12" height="12"') . ' title="' . $GLOBALS['LANG']->getLL('info', 1) . '" alt="" /> ' . $GLOBALS['LANG']->getLL('info', 1) . $ATag2_e) . '</td>
1211 // Wrap all the rows in table tags:
1219 <table cellpadding="0" cellspacing="0" id="typo3-filelist">
1220 '.implode('',$lines).'
1223 // Return accumulated content for filelisting:
1228 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php'])) {
1229 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);