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>
32 * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
36 require_once(PATH_typo3
.'class.browse_links.php');
41 * @author Kasper Skårhøj <kasper@typo3.com>
45 class tx_rtehtmlarea_image_folderTree
extends t3lib_folderTree
{
49 * Wrapping the title in a link, if applicable.
51 * @param string Title, ready for output.
52 * @param array The "record"
53 * @return string Wrapping title string.
55 function wrapTitle($title,$v) {
56 $title = htmlspecialchars($title);
58 if ($this->ext_isLinkable($v)) {
59 $aOnClick = 'return jumpToUrl(\'?editorNo='.$GLOBALS['SOBE']->browser
->editorNo
.'&expandFolder='.rawurlencode($v['path']).'\');';
60 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
62 return '<span class="typo3-dimmed">'.$title.'</span>';
67 * Returns true if the input "record" contains a folder which can be linked.
69 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title
70 * @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
72 function ext_isLinkable($v) {
73 $webpath=t3lib_BEfunc
::getPathType_web_nonweb($v['path']);
74 if ($GLOBALS['SOBE']->browser
->act
=='magic') return 1; //$webpath='web'; // The web/non-web path does not matter if the mode is 'magic'
76 if (strstr($v['path'],'_recycler_') ||
strstr($v['path'],'_temp_') ||
$webpath!='web') {
83 * Wrap the plus/minus icon in a link
85 * @param string HTML string to wrap, probably an image tag.
86 * @param string Command for 'PM' get var
87 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
88 * @return string Link-wrapped input string
91 function PM_ATagWrap($icon,$cmd,$bMark='') {
94 $name=' name="'.$bMark.'"';
96 $aOnClick = 'return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');';
97 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
103 * @param mixed Input tree array. If not array, then $this->tree is used.
104 * @return string HTML output of the tree.
106 function printTree($treeArr='') {
107 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
109 if (!is_array($treeArr)) $treeArr=$this->tree
;
114 // Traverse rows for the tree and print them into table rows:
115 foreach($treeArr as $k => $v) {
117 $bgColor=' class="'.(($c+
1)%2 ?
'bgColor' : 'bgColor-10').'"';
118 $out.='<tr'.$bgColor.'><td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div
::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td></tr>';
121 $out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>';
130 * @author Kasper Skårhøj <kasper@typo3.com>
134 class tx_rtehtmlarea_select_image
extends browse_links
{
135 var $extKey = 'rtehtmlarea';
138 public $allowedItems;
139 public $allowedFileTypes = array();
140 protected $defaultClass;
141 protected $plainMaxWidth;
142 protected $plainMaxHeight;
143 protected $magicMaxWidth;
144 protected $magicMaxHeight;
146 protected $RTEImageStorageDir;
149 public $sys_language_content;
151 public $buttonConfig;
153 protected $imgObj; // Instance object of t3lib_stdGraphic
163 $this->initVariables();
164 $this->initConfiguration();
165 $this->initHookObjects();
167 // init fileProcessor
168 $this->fileProcessor
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
169 $this->fileProcessor
->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
171 $this->allowedItems
= $this->getAllowedItems('magic,plain,image', $this->buttonConfig
);
172 reset($this->allowedItems
);
173 if (!in_array($this->act
,$this->allowedItems
)) {
174 $this->act
= current($this->allowedItems
);
177 $this->insertImage();
179 // Creating backend template object:
180 $this->doc
= t3lib_div
::makeInstance('template');
181 $this->doc
->bodyTagAdditions
= $this->getBodyTagAdditions();
182 $this->doc
->backPath
= $BACK_PATH;
184 // Load the Prototype library and browse_links.js
185 $this->doc
->getPageRenderer()->loadPrototype();
186 $this->doc
->loadJavascriptLib('js/browse_links.js');
188 $this->doc
->getContextMenuCode();
192 * Initialize class variables
196 public function initVariables() {
199 $this->bparams
= t3lib_div
::_GP('bparams');
200 $pArr = explode('|', $this->bparams
);
201 $pRteArr = explode(':', $pArr[1]);
202 $this->editorNo
= $pRteArr[0];
203 $this->sys_language_content
= $pRteArr[1];
204 $this->RTEtsConfigParams
= $pArr[2];
205 if (!$this->editorNo
) {
206 $this->editorNo
= t3lib_div
::_GP('editorNo');
207 $this->sys_language_content
= t3lib_div
::_GP('sys_language_content');
208 $this->RTEtsConfigParams
= t3lib_div
::_GP('RTEtsConfigParams');
210 $this->expandPage
= t3lib_div
::_GP('expandPage');
211 $this->expandFolder
= t3lib_div
::_GP('expandFolder');
212 $pArr[1] = implode(':', array($this->editorNo
, $this->sys_language_content
));
213 $pArr[2] = $this->RTEtsConfigParams
;
214 if ($this->act
== 'dragdrop' ||
$this->act
== 'plain') {
215 $this->allowedFileTypes
= explode(',','jpg,jpeg,gif,png');
217 $pArr[3] = implode(',', $this->allowedFileTypes
);
218 $this->bparams
= implode('|', $pArr);
221 $this->mode
= t3lib_div
::_GP('mode');
226 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL'); // Current site url
228 // the script to link to
229 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
232 $this->act
= t3lib_div
::_GP('act');
234 $this->act
= 'magic';
239 * Initialize hook objects implementing interface t3lib_browseLinksHook
243 protected function initHookObjects() {
244 global $TYPO3_CONF_VARS;
245 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'])) {
246 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'] as $classData) {
247 $processObject = t3lib_div
::getUserObj($classData);
248 if(!($processObject instanceof t3lib_browseLinksHook
)) {
249 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
251 $parameters = array();
252 $processObject->init($this, $parameters);
253 $this->hookObjects
[] = $processObject;
259 * Provide the additional parameters to be included in the template body tag
261 * @return string the body tag additions
263 public function getBodyTagAdditions() {
264 return 'onload="initEventListeners();"';
268 * Get the path to the folder where RTE images are stored
270 * @return string the path to the folder where RTE images are stored
272 protected function getRTEImageStorageDir() {
273 return ($this->imgPath ?
$this->imgPath
: $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
277 * Insert the image in the editing area
281 protected function insertImage() {
282 if (t3lib_div
::_GP('insertImage')) {
283 $filepath = t3lib_div
::_GP('insertImage');
284 $imgInfo = $this->getImageInfo($filepath);
285 switch ($this->act
) {
287 $this->insertMagicImage($filepath, $imgInfo);
291 $this->insertPlainImage($imgInfo);
296 foreach ($this->hookObjects
as $hookObject) {
297 if (method_exists($hookObject, "insertElement")) {
298 $hookObject->insertElement($this->act
);
307 * Get the information on the image file identified its path
309 * @param string $filepath: the path to the image file
311 * @return array a 4-elements information array about the file
313 public function getImageInfo($filepath) {
314 $this->imgObj
= t3lib_div
::makeInstance('t3lib_stdGraphic');
315 $this->imgObj
->init();
316 $this->imgObj
->mayScaleUp
= 0;
317 $this->imgObj
->tempPath
= PATH_site
.$this->imgObj
->tempPath
;
318 return $this->imgObj
->getImageDimensions($filepath);
322 * Insert a magic image
324 * @param string $filepath: the path to the image file
325 * @param array $imgInfo: a 4-elements information array about the file
326 * @param string $altText: text for the alt attribute of the image
327 * @param string $titleText: text for the title attribute of the image
328 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
331 public function insertMagicImage($filepath, $imgInfo, $altText='', $titleText='', $additionalParams='') {
332 if (is_array($imgInfo) && count($imgInfo) == 4) {
333 if ($this->RTEImageStorageDir
) {
334 $fI = pathinfo($imgInfo[3]);
335 $fileFunc = t3lib_div
::makeInstance('t3lib_basicFileFunctions');
336 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
337 $destPath =PATH_site
.$this->RTEImageStorageDir
;
338 if (@is_dir
($destPath)) {
339 $destName = $fileFunc->getUniqueName($basename,$destPath);
340 @copy
($imgInfo[3],$destName);
341 t3lib_div
::fixPermissions($destName);
342 $cWidth = t3lib_div
::intInRange(t3lib_div
::_GP('cWidth'), 0, $this->magicMaxWidth
);
343 $cHeight = t3lib_div
::intInRange(t3lib_div
::_GP('cHeight'), 0, $this->magicMaxHeight
);
344 if (!$cWidth) $cWidth = $this->magicMaxWidth
;
345 if (!$cHeight) $cHeight = $this->magicMaxHeight
;
347 $imgI = $this->imgObj
->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
349 $fI=pathinfo($imgI[3]);
350 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
351 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
352 @copy
($imgI[3],$destName);
353 t3lib_div
::fixPermissions($destName);
354 $destName = dirname($destName).'/'.rawurlencode(basename($destName));
355 $iurl = $this->siteURL
.substr($destName,strlen(PATH_site
));
356 $this->imageInsertJS($iurl, $imgI[0], $imgI[1], $altText, $titleText, $additionalParams);
358 t3lib_div
::sysLog('Attempt at creating a magic image failed due to error converting image: "' . $filepath . '".', $this->extKey
. '/tx_rtehtmlarea_select_image', t3lib_div
::SYSLOG_SEVERITY_ERROR
);
361 t3lib_div
::sysLog('Attempt at creating a magic image failed due to incorrect destination path: "' . $destPath . '".', $this->extKey
. '/tx_rtehtmlarea_select_image', t3lib_div
::SYSLOG_SEVERITY_ERROR
);
364 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
);
367 t3lib_div
::sysLog('Attempt at creating a magic image failed due to missing image file info.', $this->extKey
. '/tx_rtehtmlarea_select_image', t3lib_div
::SYSLOG_SEVERITY_ERROR
);
372 * Insert a plain image
374 * @param array $imgInfo: a 4-elements information array about the file
375 * @param string $altText: text for the alt attribute of the image
376 * @param string $titleText: text for the title attribute of the image
377 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
380 public function insertPlainImage($imgInfo, $altText='', $titleText='', $additionalParams='') {
381 if (is_array($imgInfo) && count($imgInfo)==4) {
382 $iurl = $this->siteURL
.substr($imgInfo[3],strlen(PATH_site
));
383 $this->imageInsertJS($iurl, $imgInfo[0], $imgInfo[1], $altText, $titleText, $additionalParams);
388 * Echo the HTML page and JS that will insert the image
390 * @param string $url: the url of the image
391 * @param integer $width: the width of the image
392 * @param integer $height: the height of the image
393 * @param string $altText: text for the alt attribute of the image
394 * @param string $titleText: text for the title attribute of the image
395 * @param string $additionalParams: text representing more html attributes to be added on the img tag
398 protected function imageInsertJS($url, $width, $height, $altText='', $titleText='', $additionalParams='') {
400 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
403 <title>Untitled</title>
404 <script type="text/javascript">
406 var plugin = window.parent.RTEarea["' . $this->editorNo
. '"].editor.getPlugin("TYPO3Image");
407 function insertImage(file,width,height,alt,title,additionalParams) {
408 plugin.insertImage(\'<img src="\'+file+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'"\'' . ($this->defaultClass?
('+\' class="'.$this->defaultClass
.'"\''):'') .
409 '+(alt?\' alt="\'+alt+\'"\':\'\')+(title?\' title="\'+title+\'"\':\'\')+(additionalParams?\' \'+additionalParams:\'\')+\' />\');
415 <script type="text/javascript">
417 insertImage('.t3lib_div
::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div
::quoteJSvalue($altText,1).','.t3lib_div
::quoteJSvalue($titleText,1).','.t3lib_div
::quoteJSvalue($additionalParams, 1).');
425 * Generate JS code to be used on the image insert/modify dialogue
427 * @param string $act: the action to be performed
428 * @param string $editorNo: the number of the RTE instance on the page
429 * @param string $sys_language_content: the language of the content element
431 * @return string the generated JS code
433 function getJSCode($act, $editorNo, $sys_language_content) {
434 global $LANG, $TYPO3_CONF_VARS;
436 $removedProperties = array();
437 if (is_array($this->buttonConfig
['properties.'])) {
438 if ($this->buttonConfig
['properties.']['removeItems']) {
439 $removedProperties = t3lib_div
::trimExplode(',',$this->buttonConfig
['properties.']['removeItems'],1);
443 if ($this->thisConfig
['classesImage']) {
444 $classesImageArray = t3lib_div
::trimExplode(',', $this->thisConfig
['classesImage'], 1);
445 $classesImageJSOptions = '<option value=""></option>';
446 foreach ($classesImageArray as $class) {
447 $classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
451 $lockPlainWidth = 'false';
452 $lockPlainHeight = 'false';
453 if (is_array($this->thisConfig
['proc.']) && $this->thisConfig
['proc.']['plainImageMode']) {
454 $plainImageMode = $this->thisConfig
['proc.']['plainImageMode'];
455 $lockPlainWidth = ($plainImageMode == 'lockDimensions')?
'true':'false';
456 $lockPlainHeight = ($lockPlainWidth ||
$plainImageMode == 'lockRatio' ||
($plainImageMode == 'lockRatioWhenSmaller'))?
'true':'false';
460 var plugin = window.parent.RTEarea["' . $editorNo . '"].editor.getPlugin("TYPO3Image");
461 var HTMLArea = window.parent.HTMLArea;
462 function initEventListeners() {
464 Ext.EventManager.addListener(window.document.body, "dragend", plugin.onDrop, plugin, { single: true });
467 function jumpToUrl(URL,anchor) {
468 var add_act = URL.indexOf("act=")==-1 ? "&act='.$act.'" : "";
469 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$editorNo.'" : "";
470 var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content='.$sys_language_content.'" : "";
471 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams
).'";
473 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
474 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
476 var theLocation = URL+add_act+add_editorNo+add_sys_language_content+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
477 window.location.href = theLocation;
480 function insertImage(file,width,height) {
481 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
483 function launchView(url) {
484 var thePreviewWindow="";
485 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");
486 if (thePreviewWindow && thePreviewWindow.focus) {
487 thePreviewWindow.focus();
490 function getCurrentImageRef() {
497 function printCurrentImageOptions() {
498 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
499 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $classesImageJSOptions . '</select>\';
500 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>\';
501 if (plugin.getButton("Language")) {
502 var languageSelector = \'<select id="iLang" name="iLang">\';
503 plugin.getButton("Language").getStore().each(function (record) {
504 languageSelector +=\'<option value="\' + record.get("value") + \'">\' + record.get("text") + \'</option>\';
506 languageSelector += \'</select>\';
508 var bgColor=\' class="bgColor4"\';
510 sz+=\'<table border="0" cellpadding="1" cellspacing="1"><form action="" name="imageData">\';
511 '.(in_array('class', $removedProperties)?
'':'
513 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
515 .(in_array('width', $removedProperties)?
'':'
516 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $lockPlainWidth .')) {
517 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>\';
519 .(in_array('height', $removedProperties)?
'':'
520 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $lockPlainHeight .')) {
521 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>\';
523 .(in_array('border', $removedProperties)?
'':'
524 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
525 .(in_array('float', $removedProperties)?
'':'
526 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
527 .(in_array('paddingTop', $removedProperties)?
'':'
528 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>\';')
529 .(in_array('paddingRight', $removedProperties)?
'':'
530 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>\';')
531 .(in_array('paddingBottom', $removedProperties)?
'':'
532 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>\';')
533 .(in_array('paddingLeft', $removedProperties)?
'':'
534 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>\';')
535 .(in_array('title', $removedProperties)?
'':'
536 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>\';')
537 .(in_array('alt', $removedProperties)?
'':'
538 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>\';')
539 .(in_array('lang', $removedProperties)?
'':'
540 if (plugin.getButton("Language")) {
541 sz+=\'<tr><td\'+bgColor+\'><label for="iLang">\' + plugin.editor.getPlugin("Language").localize(\'Language-Tooltip\') + \': </label></td><td>\' + languageSelector + \'</td></tr>\';
543 .(in_array('clickenlarge', $removedProperties)?
'':'
544 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>\';').'
545 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
546 sz+=\'</form></table>\';
549 function setImageProperties() {
550 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
551 if (selectedImageRef) {
552 if (document.imageData.iWidth) {
553 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
554 selectedImageRef.style.width = "";
555 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
558 if (document.imageData.iHeight) {
559 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
560 selectedImageRef.style.height = "";
561 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
564 if (document.imageData.iPaddingTop) {
565 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
566 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
568 selectedImageRef.style.paddingTop = "";
571 if (document.imageData.iPaddingRight) {
572 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
573 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
575 selectedImageRef.style.paddingRight = "";
578 if (document.imageData.iPaddingBottom) {
579 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
580 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
582 selectedImageRef.style.paddingBottom = "";
585 if (document.imageData.iPaddingLeft) {
586 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
587 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
589 selectedImageRef.style.paddingLeft = "";
592 if (document.imageData.iTitle) {
593 selectedImageRef.title=document.imageData.iTitle.value;
595 if (document.imageData.iAlt) {
596 selectedImageRef.alt=document.imageData.iAlt.value;
598 if (document.imageData.iBorder) {
599 selectedImageRef.style.borderStyle = "";
600 selectedImageRef.style.borderWidth = "";
601 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
602 selectedImageRef.style.borderTopStyle = "";
603 selectedImageRef.style.borderRightStyle = "";
604 selectedImageRef.style.borderBottomStyle = "";
605 selectedImageRef.style.borderLeftStyle = "";
606 selectedImageRef.style.borderTopWidth = "";
607 selectedImageRef.style.borderRightWidth = "";
608 selectedImageRef.style.borderBottomWidth = "";
609 selectedImageRef.style.borderLeftWidth = "";
610 if(document.imageData.iBorder.checked) {
611 selectedImageRef.style.borderStyle = "solid";
612 selectedImageRef.style.borderWidth = "thin";
614 selectedImageRef.removeAttribute("border");
616 if (document.imageData.iFloat) {
617 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
619 selectedImageRef.style.styleFloat = iFloat ? iFloat : "";
621 selectedImageRef.style.cssFloat = iFloat ? iFloat : "";
624 if (classesImage && document.imageData.iClass) {
625 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
626 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
627 selectedImageRef.className = iClass;
629 selectedImageRef.className = "";
632 if (document.imageData.iLang) {
633 var iLang = document.imageData.iLang.options[document.imageData.iLang.selectedIndex].value;
634 var languageObject = plugin.editor.getPlugin("Language");
635 if (iLang || languageObject.getLanguageAttribute(selectedImageRef)) {
636 languageObject.setLanguageAttributes(selectedImageRef, iLang);
638 languageObject.setLanguageAttributes(selectedImageRef, "none");
641 if (document.imageData.iClickEnlarge) {
642 if (document.imageData.iClickEnlarge.checked) {
643 selectedImageRef.setAttribute("clickenlarge","1");
645 selectedImageRef.removeAttribute("clickenlarge");
652 function insertImagePropertiesInForm() {
653 var classesImage = ' . ($this->thisConfig
['classesImage']?
'true':'false') . ';
654 if (selectedImageRef) {
655 var styleWidth, styleHeight, padding;
656 if (document.imageData.iWidth) {
657 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
658 styleWidth = parseInt(styleWidth);
659 if (!(isNaN(styleWidth) || styleWidth == 0)) {
660 document.imageData.iWidth.value = styleWidth;
663 if (document.imageData.iHeight) {
664 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
665 styleHeight = parseInt(styleHeight);
666 if (!(isNaN(styleHeight) || styleHeight == 0)) {
667 document.imageData.iHeight.value = styleHeight;
670 if (document.imageData.iPaddingTop) {
671 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
672 var padding = parseInt(padding);
673 if (isNaN(padding) || padding <= 0) { padding = ""; }
674 document.imageData.iPaddingTop.value = padding;
676 if (document.imageData.iPaddingRight) {
677 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
678 var padding = parseInt(padding);
679 if (isNaN(padding) || padding <= 0) { padding = ""; }
680 document.imageData.iPaddingRight.value = padding;
682 if (document.imageData.iPaddingBottom) {
683 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
684 var padding = parseInt(padding);
685 if (isNaN(padding) || padding <= 0) { padding = ""; }
686 document.imageData.iPaddingBottom.value = padding;
688 if (document.imageData.iPaddingLeft) {
689 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
690 var padding = parseInt(padding);
691 if (isNaN(padding) || padding <= 0) { padding = ""; }
692 document.imageData.iPaddingLeft.value = padding;
694 if (document.imageData.iTitle) {
695 document.imageData.iTitle.value = selectedImageRef.title;
697 if (document.imageData.iAlt) {
698 document.imageData.iAlt.value = selectedImageRef.alt;
700 if (document.imageData.iBorder) {
701 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
702 document.imageData.iBorder.checked = 1;
705 if (document.imageData.iFloat) {
706 var fObj=document.imageData.iFloat;
707 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
709 for (var a=0;a<l;a++) {
710 if (fObj.options[a].value == value) {
711 fObj.selectedIndex = a;
715 if (classesImage && document.imageData.iClass) {
716 var fObj=document.imageData.iClass;
717 var value=selectedImageRef.className;
719 for (var a=0;a < l; a++) {
720 if (fObj.options[a].value == value) {
721 fObj.selectedIndex = a;
725 if (document.imageData.iLang) {
726 var fObj=document.imageData.iLang;
727 var value=plugin.editor.getPlugin("Language").getLanguageAttribute(selectedImageRef);
728 for (var i = 0, n = fObj.length; i < n; i++) {
729 if (fObj.options[i].value == value) {
730 fObj.selectedIndex = i;
732 fObj.options[0].text = plugin.editor.getPlugin("Language").localize("Remove language mark");
737 if (document.imageData.iClickEnlarge) {
738 if (selectedImageRef.getAttribute("clickenlarge") == "1") {
739 document.imageData.iClickEnlarge.checked = 1;
741 document.imageData.iClickEnlarge.checked = 0;
748 var selectedImageRef = getCurrentImageRef();'; // Setting this to a reference to the image object.
753 * Session data for this class can be set from outside with this method.
756 * @param array Session data array
757 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
759 function processSessionData($data) {
762 if ($this->act
!= 'image') {
763 if (isset($this->act
)) {
764 $data['act'] = $this->act
;
767 $this->act
= $data['act'];
771 if (isset($this->expandFolder
)) {
772 $data['expandFolder'] = $this->expandFolder
;
775 $this->expandFolder
= $data['expandFolder'];
778 return array($data, $store);
782 * [Describe function...]
786 function main_rte() {
787 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
790 $this->content
= $this->doc
->startPage($LANG->getLL('Insert Image',1));
792 // Making menu in top:
794 if (in_array('image',$this->allowedItems
) && ($this->act
=='image' || t3lib_div
::_GP('cWidth'))) {
795 $menuDef['page']['isActive'] = $this->act
=='image';
796 $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
797 $menuDef['page']['url'] = '#';
798 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&bparams='.$this->bparams
.'\');return false;"';
800 if (in_array('magic',$this->allowedItems
)){
801 $menuDef['file']['isActive'] = $this->act
=='magic';
802 $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
803 $menuDef['file']['url'] = '#';
804 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&bparams='.$this->bparams
.'\');return false;"';
806 if (in_array('plain',$this->allowedItems
)) {
807 $menuDef['url']['isActive'] = $this->act
=='plain';
808 $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
809 $menuDef['url']['url'] = '#';
810 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&bparams='.$this->bparams
.'\');return false;"';
812 if (in_array('dragdrop',$this->allowedItems
)) {
813 $menuDef['mail']['isActive'] = $this->act
=='dragdrop';
814 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
815 $menuDef['mail']['url'] = '#';
816 $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&bparams='.$this->bparams
.'\');return false;"';
819 // Call hook for extra options
820 foreach ($this->hookObjects
as $hookObject) {
821 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
824 $this->content
.= $this->doc
->getTabMenuRaw($menuDef);
829 document.write(printCurrentImageOptions());
830 insertImagePropertiesInForm();';
831 $this->content
.= '<br />'.$this->doc
->wrapScriptTags($JScode);
835 // Adding upload form, if allowed
836 $this->content
.= $this->insertUploadForm($this->expandFolder
);
837 // Getting flag for showing/not showing thumbnails:
838 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect');
840 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
841 $_MOD_MENU = array('displayThumbs' => '');
842 $_MCONF['name']='file_list';
843 $_MOD_SETTINGS = t3lib_BEfunc
::getModuleData($_MOD_MENU, t3lib_div
::_GP('SET'), $_MCONF['name']);
844 $addParams = '&act='.$this->act
.'&editorNo='.$this->editorNo
.'&expandFolder='.rawurlencode($this->expandFolder
);
845 $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>';
849 // Create folder tree:
850 $foldertree = t3lib_div
::makeInstance('tx_rtehtmlarea_image_folderTree');
851 $tree = $foldertree->getBrowsableTree();
852 list(,,$specUid) = explode('_',t3lib_div
::_GP('PM'));
853 $files = $this->expandFolder($foldertree->specUIDmap
[$specUid],$this->act
=='plain',$noThumbs?
$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
854 $this->content
.= '<table border="0" cellpadding="0" cellspacing="0">
856 <td style="vertical-align: top;">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
858 <td style="vertical-align: top;">'.$files.'</td>
861 <br />'.$thumbNailCheck;
863 $helpMessage = $this->getHelpMessage($this->act
);
865 $this->content
.= $this->getMsgBox($helpMessage);
869 $foldertree = t3lib_div
::makeInstance('TBE_FolderTree');
870 $foldertree->thisScript
=$this->thisScript
;
871 $foldertree->ext_noTempRecyclerDirs
= true;
872 $tree = $foldertree->getBrowsableTree();
873 list(,,$specUid) = explode('_',t3lib_div
::_GP('PM'));
874 $files = $this->TBE_dragNDrop($foldertree->specUIDmap
[$specUid], implode(',', $this->allowedFileTypes
));
875 $this->content
.= '<table border="0" cellpadding="0" cellspacing="0">
877 <td style="vertical-align: top;">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
879 <td style="vertical-align: top;">'.$files.'</td>
885 foreach ($this->hookObjects
as $hookObject) {
886 $this->content
.= $hookObject->getTab($this->act
);
890 $this->content
.= $this->doc
->endPage();
891 $this->doc
->JScodeArray
['rtehtmlarea'] = $this->getJSCode($this->act
, $this->editorNo
, $this->sys_language_content
);
892 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
893 return $this->content
;
897 * Create upload/create folder forms, if a path is given
899 * @param string $folderPath: the selected path , if any
901 * @return string the html content for the upload form
903 protected function insertUploadForm($folderPath) {
905 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB') && !$this->readOnly
&& count($GLOBALS['FILEMOUNTS'])) {
907 if (!$path ||
!@is_dir
($path)) {
908 // The closest TEMP-path is found
909 $path = $this->fileProcessor
->findTempFolder().'/';
911 if ($path!='/' && @is_dir
($path)) {
912 $uploadForm=$this->uploadForm($path);
913 $createFolder=$this->createFolder($path);
918 $content .= $uploadForm;
919 if ($GLOBALS['BE_USER']->isAdmin() ||
$GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
920 $content.=$createFolder;
926 /***************************
930 ***************************/
932 * @param [type] $expandFolder: ...
933 * @param [type] $plainFlag: ...
936 function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) {
937 global $LANG, $BE_USER, $BACK_PATH;
939 $expandFolder = $expandFolder ?
$expandFolder :t3lib_div
::_GP('expandFolder');
942 if ($expandFolder && $this->checkFolder($expandFolder)) {
943 $files = t3lib_div
::getFilesInDir($expandFolder,($plainFlag?
'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1); // $extensionList="",$prependPath=0,$order="")
944 if (is_array($files)) {
945 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
947 $titleLen = intval($BE_USER->uc
['titleLen']);
948 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
949 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($expandFolder),$titleLen));
950 $out.='<span class="nobr">'.$picon.'</span><br />';
952 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
954 $imgObj->mayScaleUp
=0;
955 $imgObj->tempPath
=PATH_site
.$imgObj->tempPath
;
958 foreach ($files as $filepath) {
959 $fI=pathinfo($filepath);
961 $origFile = t3lib_div
::rawUrlEncodeFP(substr($filepath,strlen(PATH_site
)));
962 $iurl = $this->siteURL
.$origFile;
963 $imgInfo = $imgObj->getImageDimensions($filepath);
965 $icon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
966 $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
967 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
968 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
969 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo
.'&insertImage='.rawurlencode($filepath).'\');">';
971 if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth
) ||
($imgInfo[1] > $this->plainMaxHeight
))) {
977 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
981 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
984 $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.' </td><td nowrap="nowrap">'.$pDim.' </td></tr>';
985 $lines[]='<tr><td colspan="2">'.($noThumbs ?
'' : $ATag2.t3lib_BEfunc
::getThumbNail($this->doc
->backPath
.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
987 $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
989 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
996 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
997 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
999 * @param string The folder path to expand
1000 * @param string List of fileextensions to show
1001 * @return string HTML output
1003 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
1006 $expandFolder = $expandFolder ?
$expandFolder : t3lib_div
::_GP('expandFolder');
1008 if ($expandFolder && $this->checkFolder($expandFolder)) {
1009 if ($this->isWebFolder($expandFolder)) {
1011 // Read files from directory:
1012 $files = t3lib_div
::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1013 if (is_array($files)) {
1014 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
1016 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
1017 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1018 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($expandFolder),$titleLen));
1019 $out.=$picon.'<br />';
1024 // Add "drag-n-drop" message:
1027 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
1031 foreach ($files as $filepath) {
1032 $fI = pathinfo($filepath);
1035 $iurl = $this->siteURL
.t3lib_div
::rawurlencodeFP(substr($filepath,strlen(PATH_site
)));
1037 // Show only web-images
1038 if (t3lib_div
::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
1039 $imgInfo = @getimagesize
($filepath);
1040 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1042 $ficon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
1043 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).'bytes'.($pDim?
', '.$pDim:'').')';
1044 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1045 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($filepath),$titleLen));
1047 if (t3lib_div
::_GP('noLimit')) {
1057 $IH=ceil($IH/$IW*$maxW);
1061 $IW=ceil($IW/$IH*$maxH);
1067 <tr class="bgColor4">
1068 <td nowrap="nowrap">'.$filenameAndIcon.' </td>
1069 <td nowrap="nowrap">'.
1070 ($imgInfo[0]!=$IW ?
'<a href="'.htmlspecialchars(t3lib_div
::linkThisScript(array('noLimit'=>'1'))).'">'.
1071 '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1075 // Remove hardcoded border="1"
1076 // Add default class for images
1079 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" alt=""' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):''). ' style="cursor:move;" /></td>
1083 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1088 // Finally, wrap all rows in a table tag:
1093 File listing / Drag-n-drop
1095 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1096 '.implode('',$lines).'
1100 // Print this warning if the folder is NOT a web folder:
1101 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1102 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1109 * Initializes the configuration variables
1113 public function initConfiguration() {
1114 $this->thisConfig
= $this->getRTEConfig();
1115 $this->buttonConfig
= $this->getButtonConfig();
1116 $this->imgPath
= $this->getImgPath();
1117 $this->RTEImageStorageDir
= $this->getRTEImageStorageDir();
1118 $this->defaultClass
= $this->getDefaultClass();
1119 $this->setMaximumImageDimensions();
1123 * Get the RTE configuration from Page TSConfig
1125 * @return array RTE configuration array
1127 protected function getRTEConfig() {
1130 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
1131 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($RTEtsConfigParts[5]));
1132 return t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
1136 * Get the path of the image to be inserted or modified
1138 * @return string path to the image
1140 protected function getImgPath() {
1141 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
1142 return $RTEtsConfigParts[6];
1146 * Get the configuration of the image button
1148 * @return array the configuration array of the image button
1150 protected function getButtonConfig() {
1151 return ((is_array($this->thisConfig
['buttons.']) && is_array($this->thisConfig
['buttons.']['image.'])) ?
$this->thisConfig
['buttons.']['image.'] : array());
1155 * Get the allowed items or tabs
1157 * @param string $items: initial list of possible items
1158 * @return array the allowed items
1160 public function getAllowedItems($items) {
1161 $allowedItems = explode(',', $items);
1162 $clientInfo = t3lib_div
::clientInfo();
1163 if ($clientInfo['BROWSER'] !== 'opera') {
1164 $allowedItems[] = 'dragdrop';
1166 // Call hook for extra options
1167 foreach ($this->hookObjects
as $hookObject) {
1168 $allowedItems = $hookObject->addAllowedItems($allowedItems);
1170 // Remove tab "image" if there is no current image
1171 if ($this->act
!== 'image') {
1172 $allowedItems = array_diff($allowedItems, array('image'));
1174 // Remove options according to RTE configuration
1175 if (is_array($this->buttonConfig
['options.']) && $this->buttonConfig
['options.']['removeItems']) {
1176 $allowedItems = array_diff($allowedItems, t3lib_div
::trimExplode(',', $this->buttonConfig
['options.']['removeItems'], 1));
1178 $allowedItems = array_diff($allowedItems, t3lib_div
::trimExplode(',', $this->thisConfig
['blindImageOptions'], 1));
1180 return $allowedItems;
1184 * Get the default image class
1186 * @return string the default class, if any
1188 protected function getDefaultClass() {
1190 if (is_array($this->buttonConfig
['properties.'])) {
1191 if (is_array($this->buttonConfig
['properties.']['class.']) && trim($this->buttonConfig
['properties.']['class.']['default'])) {
1192 $defaultClass = trim($this->buttonConfig
['properties.']['class.']['default']);
1195 return $defaultClass;
1199 * Set variables for maximum image dimensions
1203 protected function setMaximumImageDimensions() {
1204 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['plain.'])) {
1205 if ($this->buttonConfig
['options.']['plain.']['maxWidth']) $this->plainMaxWidth
= $this->buttonConfig
['options.']['plain.']['maxWidth'];
1206 if ($this->buttonConfig
['options.']['plain.']['maxHeight']) $this->plainMaxHeight
= $this->buttonConfig
['options.']['plain.']['maxHeight'];
1208 if (!$this->plainMaxWidth
) $this->plainMaxWidth
= 640;
1209 if (!$this->plainMaxHeight
) $this->plainMaxHeight
= 680;
1210 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['magic.'])) {
1211 if ($this->buttonConfig
['options.']['magic.']['maxWidth']) $this->magicMaxWidth
= $this->buttonConfig
['options.']['magic.']['maxWidth'];
1212 if ($this->buttonConfig
['options.']['magic.']['maxHeight']) $this->magicMaxHeight
= $this->buttonConfig
['options.']['magic.']['maxHeight'];
1214 // 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
1215 if (!$this->magicMaxWidth
) $this->magicMaxWidth
= 300;
1216 if (!$this->magicMaxHeight
) $this->magicMaxHeight
= 1000;
1220 * Get the help message to be displayed on a given tab
1222 * @param string $act: the identifier of the tab
1223 * @return string the text of the message
1225 public function getHelpMessage($act) {
1229 return sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth
, $this->plainMaxHeight
);
1232 return sprintf($LANG->getLL('magicImage_msg'));
1240 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php'])) {
1241 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);