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>
34 require_once(PATH_typo3
.'class.browse_links.php');
39 * @author Kasper Skårhøj <kasper@typo3.com>
43 class tx_rtehtmlarea_image_folderTree
extends t3lib_folderTree
{
47 * Wrapping the title in a link, if applicable.
49 * @param string Title, ready for output.
50 * @param array The "record"
51 * @return string Wrapping title string.
53 function wrapTitle($title,$v) {
54 $title = htmlspecialchars($title);
56 if ($this->ext_isLinkable($v)) {
57 $aOnClick = 'return jumpToUrl(\'?editorNo='.$GLOBALS['SOBE']->browser
->editorNo
.'&expandFolder='.rawurlencode($v['path']).'\');';
58 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
60 return '<span class="typo3-dimmed">'.$title.'</span>';
65 * Returns TRUE if the input "record" contains a folder which can be linked.
67 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title
68 * @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
70 function ext_isLinkable($v) {
71 $webpath=t3lib_BEfunc
::getPathType_web_nonweb($v['path']);
72 if ($GLOBALS['SOBE']->browser
->act
=='magic') return 1; //$webpath='web'; // The web/non-web path does not matter if the mode is 'magic'
74 if (strstr($v['path'],'_recycler_') ||
strstr($v['path'],'_temp_') ||
$webpath!='web') {
81 * Wrap the plus/minus icon in a link
83 * @param string HTML string to wrap, probably an image tag.
84 * @param string Command for 'PM' get var
85 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
86 * @return string Link-wrapped input string
89 function PM_ATagWrap($icon,$cmd,$bMark='') {
92 $name=' name="'.$bMark.'"';
94 $aOnClick = 'return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');';
95 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
101 * @param mixed Input tree array. If not array, then $this->tree is used.
102 * @return string HTML output of the tree.
104 function printTree($treeArr='') {
105 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
107 if (!is_array($treeArr)) $treeArr=$this->tree
;
112 // Traverse rows for the tree and print them into table rows:
113 foreach($treeArr as $k => $v) {
115 $bgColor=' class="'.(($c+
1)%2 ?
'bgColor' : 'bgColor-10').'"';
116 $out.='<tr'.$bgColor.'><td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div
::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td></tr>';
119 $out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>';
128 * @author Kasper Skårhøj <kasper@typo3.com>
132 class tx_rtehtmlarea_select_image
extends browse_links
{
133 var $extKey = 'rtehtmlarea';
136 public $allowedItems;
137 public $allowedFileTypes = array();
138 protected $defaultClass;
139 protected $plainMaxWidth;
140 protected $plainMaxHeight;
141 protected $magicMaxWidth;
142 protected $magicMaxHeight;
144 protected $RTEImageStorageDir;
147 public $sys_language_content;
149 public $buttonConfig;
151 protected $imgObj; // Instance object of t3lib_stdGraphic
161 $this->initVariables();
162 $this->initConfiguration();
163 $this->initHookObjects();
165 // init fileProcessor
166 $this->fileProcessor
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
167 $this->fileProcessor
->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
169 $this->allowedItems
= $this->getAllowedItems('magic,plain,image');
170 reset($this->allowedItems
);
171 if (!in_array($this->act
,$this->allowedItems
)) {
172 $this->act
= current($this->allowedItems
);
175 $this->insertImage();
177 // Creating backend template object:
178 $this->doc
= t3lib_div
::makeInstance('template');
179 $this->doc
->bodyTagAdditions
= $this->getBodyTagAdditions();
180 $this->doc
->backPath
= $BACK_PATH;
182 // Load the Prototype library and browse_links.js
183 $this->doc
->getPageRenderer()->loadPrototype();
184 $this->doc
->loadJavascriptLib('js/browse_links.js');
186 $this->doc
->getContextMenuCode();
190 * Initialize class variables
194 public function initVariables() {
197 $this->bparams
= t3lib_div
::_GP('bparams');
198 $pArr = explode('|', $this->bparams
);
199 $pRteArr = explode(':', $pArr[1]);
200 $this->editorNo
= $pRteArr[0];
201 $this->sys_language_content
= $pRteArr[1];
202 $this->RTEtsConfigParams
= $pArr[2];
203 if (!$this->editorNo
) {
204 $this->editorNo
= t3lib_div
::_GP('editorNo');
205 $this->sys_language_content
= t3lib_div
::_GP('sys_language_content');
206 $this->RTEtsConfigParams
= t3lib_div
::_GP('RTEtsConfigParams');
208 $this->expandPage
= t3lib_div
::_GP('expandPage');
209 $this->expandFolder
= t3lib_div
::_GP('expandFolder');
210 $pArr[1] = implode(':', array($this->editorNo
, $this->sys_language_content
));
211 $pArr[2] = $this->RTEtsConfigParams
;
212 if ($this->act
== 'dragdrop' ||
$this->act
== 'plain') {
213 $this->allowedFileTypes
= explode(',','jpg,jpeg,gif,png');
215 $pArr[3] = implode(',', $this->allowedFileTypes
);
216 $this->bparams
= implode('|', $pArr);
219 $this->mode
= t3lib_div
::_GP('mode');
224 $this->siteURL
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL'); // Current site url
226 // the script to link to
227 $this->thisScript
= t3lib_div
::getIndpEnv('SCRIPT_NAME');
230 $this->act
= t3lib_div
::_GP('act');
232 $this->act
= 'magic';
237 * Initialize hook objects implementing interface t3lib_browseLinksHook
241 protected function initHookObjects() {
242 global $TYPO3_CONF_VARS;
243 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'])) {
244 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'] as $classData) {
245 $processObject = t3lib_div
::getUserObj($classData);
246 if(!($processObject instanceof t3lib_browseLinksHook
)) {
247 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
249 $parameters = array();
250 $processObject->init($this, $parameters);
251 $this->hookObjects
[] = $processObject;
257 * Provide the additional parameters to be included in the template body tag
259 * @return string the body tag additions
261 public function getBodyTagAdditions() {
262 return 'onload="initEventListeners();"';
266 * Get the path to the folder where RTE images are stored
268 * @return string the path to the folder where RTE images are stored
270 protected function getRTEImageStorageDir() {
271 return ($this->imgPath ?
$this->imgPath
: $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']);
275 * Insert the image in the editing area
279 protected function insertImage() {
280 if (t3lib_div
::_GP('insertImage')) {
281 $filepath = t3lib_div
::_GP('insertImage');
282 $imgInfo = $this->getImageInfo($filepath);
283 switch ($this->act
) {
285 $this->insertMagicImage($filepath, $imgInfo);
289 $this->insertPlainImage($imgInfo);
294 foreach ($this->hookObjects
as $hookObject) {
295 if (method_exists($hookObject, "insertElement")) {
296 $hookObject->insertElement($this->act
);
305 * Get the information on the image file identified its path
307 * @param string $filepath: the path to the image file
309 * @return array a 4-elements information array about the file
311 public function getImageInfo($filepath) {
312 $this->imgObj
= t3lib_div
::makeInstance('t3lib_stdGraphic');
313 $this->imgObj
->init();
314 $this->imgObj
->mayScaleUp
= 0;
315 $this->imgObj
->tempPath
= PATH_site
.$this->imgObj
->tempPath
;
316 return $this->imgObj
->getImageDimensions($filepath);
320 * Insert a magic image
322 * @param string $filepath: the path to the image file
323 * @param array $imgInfo: a 4-elements information array about the file
324 * @param string $altText: text for the alt attribute of the image
325 * @param string $titleText: text for the title attribute of the image
326 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
329 public function insertMagicImage($filepath, $imgInfo, $altText='', $titleText='', $additionalParams='') {
330 if (is_array($imgInfo) && count($imgInfo) == 4) {
331 if ($this->RTEImageStorageDir
) {
332 $fI = pathinfo($imgInfo[3]);
333 $fileFunc = t3lib_div
::makeInstance('t3lib_basicFileFunctions');
334 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
335 $destPath =PATH_site
.$this->RTEImageStorageDir
;
336 if (@is_dir
($destPath)) {
337 $destName = $fileFunc->getUniqueName($basename,$destPath);
338 @copy
($imgInfo[3],$destName);
339 t3lib_div
::fixPermissions($destName);
340 $cWidth = t3lib_utility_Math
::forceIntegerInRange(t3lib_div
::_GP('cWidth'), 0, $this->magicMaxWidth
);
341 $cHeight = t3lib_utility_Math
::forceIntegerInRange(t3lib_div
::_GP('cHeight'), 0, $this->magicMaxHeight
);
342 if (!$cWidth) $cWidth = $this->magicMaxWidth
;
343 if (!$cHeight) $cHeight = $this->magicMaxHeight
;
345 $imgI = $this->imgObj
->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
347 $fI=pathinfo($imgI[3]);
348 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
349 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
350 @copy
($imgI[3],$destName);
351 t3lib_div
::fixPermissions($destName);
352 $destName = dirname($destName).'/'.rawurlencode(basename($destName));
353 $iurl = $this->siteURL
.substr($destName,strlen(PATH_site
));
354 $this->imageInsertJS($iurl, $imgI[0], $imgI[1], $altText, $titleText, $additionalParams);
356 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
);
359 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
);
362 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
);
365 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
);
370 * Insert a plain image
372 * @param array $imgInfo: a 4-elements information array about the file
373 * @param string $altText: text for the alt attribute of the image
374 * @param string $titleText: text for the title attribute of the image
375 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
378 public function insertPlainImage($imgInfo, $altText='', $titleText='', $additionalParams='') {
379 if (is_array($imgInfo) && count($imgInfo)==4) {
380 $iurl = $this->siteURL
.substr($imgInfo[3],strlen(PATH_site
));
381 $this->imageInsertJS($iurl, $imgInfo[0], $imgInfo[1], $altText, $titleText, $additionalParams);
386 * Echo the HTML page and JS that will insert the image
388 * @param string $url: the url of the image
389 * @param integer $width: the width of the image
390 * @param integer $height: the height of the image
391 * @param string $altText: text for the alt attribute of the image
392 * @param string $titleText: text for the title attribute of the image
393 * @param string $additionalParams: text representing more html attributes to be added on the img tag
396 protected function imageInsertJS($url, $width, $height, $altText='', $titleText='', $additionalParams='') {
398 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
401 <title>Untitled</title>
402 <script type="text/javascript">
404 var plugin = window.parent.RTEarea["' . $this->editorNo
. '"].editor.getPlugin("TYPO3Image");
405 function insertImage(file,width,height,alt,title,additionalParams) {
406 plugin.insertImage(\'<img src="\'+file+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'"\'' . ($this->defaultClass?
('+\' class="'.$this->defaultClass
.'"\''):'') .
407 '+(alt?\' alt="\'+alt+\'"\':\'\')+(title?\' title="\'+title+\'"\':\'\')+(additionalParams?\' \'+additionalParams:\'\')+\' />\');
413 <script type="text/javascript">
415 insertImage('.t3lib_div
::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div
::quoteJSvalue($altText,1).','.t3lib_div
::quoteJSvalue($titleText,1).','.t3lib_div
::quoteJSvalue($additionalParams, 1).');
423 * Generate JS code to be used on the image insert/modify dialogue
425 * @param string $act: the action to be performed
426 * @param string $editorNo: the number of the RTE instance on the page
427 * @param string $sys_language_content: the language of the content element
429 * @return string the generated JS code
431 function getJSCode($act, $editorNo, $sys_language_content) {
432 global $LANG, $TYPO3_CONF_VARS;
434 $removedProperties = array();
435 if (is_array($this->buttonConfig
['properties.'])) {
436 if ($this->buttonConfig
['properties.']['removeItems']) {
437 $removedProperties = t3lib_div
::trimExplode(',',$this->buttonConfig
['properties.']['removeItems'],1);
440 // The following property is deprecated as of TYPO3 4.6 and will be removed in TYPO3 4.8
441 if ($this->thisConfig
['classesImage']) {
442 $classesImageArray = t3lib_div
::trimExplode(',', $this->thisConfig
['classesImage'], 1);
443 $classesImageJSOptions = '<option value=""></option>';
444 foreach ($classesImageArray as $class) {
445 $classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
448 if ($this->buttonConfig
['properties.']['class.']['allowedClasses']) {
449 $classesImageArray = t3lib_div
::trimExplode(',', $this->buttonConfig
['properties.']['class.']['allowedClasses'], 1);
450 $classesImageJSOptions = '<option value=""></option>';
451 foreach ($classesImageArray as $class) {
452 $classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
455 $lockPlainWidth = 'false';
456 $lockPlainHeight = 'false';
457 if (is_array($this->thisConfig
['proc.']) && $this->thisConfig
['proc.']['plainImageMode']) {
458 $plainImageMode = $this->thisConfig
['proc.']['plainImageMode'];
459 $lockPlainWidth = ($plainImageMode == 'lockDimensions')?
'true':'false';
460 $lockPlainHeight = ($lockPlainWidth ||
$plainImageMode == 'lockRatio' ||
($plainImageMode == 'lockRatioWhenSmaller'))?
'true':'false';
464 var plugin = window.parent.RTEarea["' . $editorNo . '"].editor.getPlugin("TYPO3Image");
465 var HTMLArea = window.parent.HTMLArea;
466 function initEventListeners() {
468 Ext.EventManager.addListener(window.document.body, "dragend", plugin.onDrop, plugin, { single: true });
471 function jumpToUrl(URL,anchor) {
472 var add_act = URL.indexOf("act=")==-1 ? "&act='.$act.'" : "";
473 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$editorNo.'" : "";
474 var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content='.$sys_language_content.'" : "";
475 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams
).'";
477 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
478 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
480 var theLocation = URL+add_act+add_editorNo+add_sys_language_content+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
481 window.location.href = theLocation;
484 function insertImage(file,width,height) {
485 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
487 function launchView(url) {
488 var thePreviewWindow="";
489 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");
490 if (thePreviewWindow && thePreviewWindow.focus) {
491 thePreviewWindow.focus();
494 function getCurrentImageRef() {
501 function printCurrentImageOptions() {
502 var classesImage = ' . (($this->buttonConfig
['properties.']['class.']['allowedClasses'] ||
$this->thisConfig
['classesImage']) ?
'true' : 'false') . ';
503 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $classesImageJSOptions . '</select>\';
504 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>\';
505 if (plugin.getButton("Language")) {
506 var languageSelector = \'<select id="iLang" name="iLang">\';
507 plugin.getButton("Language").getStore().each(function (record) {
508 languageSelector +=\'<option value="\' + record.get("value") + \'">\' + record.get("text") + \'</option>\';
510 languageSelector += \'</select>\';
512 var bgColor=\' class="bgColor4"\';
514 sz+=\'<table border="0" cellpadding="1" cellspacing="1"><form action="" name="imageData">\';
515 '.(in_array('class', $removedProperties)?
'':'
517 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\';
519 .(in_array('width', $removedProperties)?
'':'
520 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $lockPlainWidth .')) {
521 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>\';
523 .(in_array('height', $removedProperties)?
'':'
524 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $lockPlainHeight .')) {
525 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>\';
527 .(in_array('border', $removedProperties)?
'':'
528 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';')
529 .(in_array('float', $removedProperties)?
'':'
530 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';')
531 .(in_array('paddingTop', $removedProperties)?
'':'
532 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>\';')
533 .(in_array('paddingRight', $removedProperties)?
'':'
534 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>\';')
535 .(in_array('paddingBottom', $removedProperties)?
'':'
536 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>\';')
537 .(in_array('paddingLeft', $removedProperties)?
'':'
538 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>\';')
539 .(in_array('title', $removedProperties)?
'':'
540 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>\';')
541 .(in_array('alt', $removedProperties)?
'':'
542 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>\';')
543 .(in_array('lang', $removedProperties)?
'':'
544 if (plugin.getButton("Language")) {
545 sz+=\'<tr><td\'+bgColor+\'><label for="iLang">\' + plugin.editor.getPlugin("Language").localize(\'Language-Tooltip\') + \': </label></td><td>\' + languageSelector + \'</td></tr>\';
547 .((in_array('clickenlarge', $removedProperties) ||
in_array('data-htmlarea-clickenlarge', $removedProperties)) ?
'':'
548 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>\';').'
549 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
550 sz+=\'</form></table>\';
553 function setImageProperties() {
554 var classesImage = ' . (($this->buttonConfig
['properties.']['class.']['allowedClasses'] ||
$this->thisConfig
['classesImage']) ?
'true' : 'false') . ';
555 if (selectedImageRef) {
556 if (document.imageData.iWidth) {
557 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
558 selectedImageRef.style.width = "";
559 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
562 if (document.imageData.iHeight) {
563 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
564 selectedImageRef.style.height = "";
565 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
568 if (document.imageData.iPaddingTop) {
569 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
570 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
572 selectedImageRef.style.paddingTop = "";
575 if (document.imageData.iPaddingRight) {
576 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
577 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
579 selectedImageRef.style.paddingRight = "";
582 if (document.imageData.iPaddingBottom) {
583 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
584 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
586 selectedImageRef.style.paddingBottom = "";
589 if (document.imageData.iPaddingLeft) {
590 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
591 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
593 selectedImageRef.style.paddingLeft = "";
596 if (document.imageData.iTitle) {
597 selectedImageRef.title=document.imageData.iTitle.value;
599 if (document.imageData.iAlt) {
600 selectedImageRef.alt=document.imageData.iAlt.value;
602 if (document.imageData.iBorder) {
603 selectedImageRef.style.borderStyle = "";
604 selectedImageRef.style.borderWidth = "";
605 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
606 selectedImageRef.style.borderTopStyle = "";
607 selectedImageRef.style.borderRightStyle = "";
608 selectedImageRef.style.borderBottomStyle = "";
609 selectedImageRef.style.borderLeftStyle = "";
610 selectedImageRef.style.borderTopWidth = "";
611 selectedImageRef.style.borderRightWidth = "";
612 selectedImageRef.style.borderBottomWidth = "";
613 selectedImageRef.style.borderLeftWidth = "";
614 if(document.imageData.iBorder.checked) {
615 selectedImageRef.style.borderStyle = "solid";
616 selectedImageRef.style.borderWidth = "thin";
618 selectedImageRef.removeAttribute("border");
620 if (document.imageData.iFloat) {
621 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
623 selectedImageRef.style.styleFloat = iFloat ? iFloat : "";
625 selectedImageRef.style.cssFloat = iFloat ? iFloat : "";
628 if (classesImage && document.imageData.iClass) {
629 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
630 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
631 selectedImageRef.className = iClass;
633 selectedImageRef.className = "";
636 if (document.imageData.iLang) {
637 var iLang = document.imageData.iLang.options[document.imageData.iLang.selectedIndex].value;
638 var languageObject = plugin.editor.getPlugin("Language");
639 if (iLang || languageObject.getLanguageAttribute(selectedImageRef)) {
640 languageObject.setLanguageAttributes(selectedImageRef, iLang);
642 languageObject.setLanguageAttributes(selectedImageRef, "none");
645 if (document.imageData.iClickEnlarge) {
646 if (document.imageData.iClickEnlarge.checked) {
647 selectedImageRef.setAttribute("data-htmlarea-clickenlarge","1");
649 selectedImageRef.removeAttribute("data-htmlarea-clickenlarge");
650 selectedImageRef.removeAttribute("clickenlarge");
657 function insertImagePropertiesInForm() {
658 var classesImage = ' . (($this->buttonConfig
['properties.']['class.']['allowedClasses'] ||
$this->thisConfig
['classesImage']) ?
'true' : 'false') . ';
659 if (selectedImageRef) {
660 var styleWidth, styleHeight, padding;
661 if (document.imageData.iWidth) {
662 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
663 styleWidth = parseInt(styleWidth);
664 if (!(isNaN(styleWidth) || styleWidth == 0)) {
665 document.imageData.iWidth.value = styleWidth;
668 if (document.imageData.iHeight) {
669 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
670 styleHeight = parseInt(styleHeight);
671 if (!(isNaN(styleHeight) || styleHeight == 0)) {
672 document.imageData.iHeight.value = styleHeight;
675 if (document.imageData.iPaddingTop) {
676 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
677 var padding = parseInt(padding);
678 if (isNaN(padding) || padding <= 0) { padding = ""; }
679 document.imageData.iPaddingTop.value = padding;
681 if (document.imageData.iPaddingRight) {
682 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
683 var padding = parseInt(padding);
684 if (isNaN(padding) || padding <= 0) { padding = ""; }
685 document.imageData.iPaddingRight.value = padding;
687 if (document.imageData.iPaddingBottom) {
688 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
689 var padding = parseInt(padding);
690 if (isNaN(padding) || padding <= 0) { padding = ""; }
691 document.imageData.iPaddingBottom.value = padding;
693 if (document.imageData.iPaddingLeft) {
694 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
695 var padding = parseInt(padding);
696 if (isNaN(padding) || padding <= 0) { padding = ""; }
697 document.imageData.iPaddingLeft.value = padding;
699 if (document.imageData.iTitle) {
700 document.imageData.iTitle.value = selectedImageRef.title;
702 if (document.imageData.iAlt) {
703 document.imageData.iAlt.value = selectedImageRef.alt;
705 if (document.imageData.iBorder) {
706 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
707 document.imageData.iBorder.checked = 1;
710 if (document.imageData.iFloat) {
711 var fObj=document.imageData.iFloat;
712 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
714 for (var a=0;a<l;a++) {
715 if (fObj.options[a].value == value) {
716 fObj.selectedIndex = a;
720 if (classesImage && document.imageData.iClass) {
721 var fObj=document.imageData.iClass;
722 var value=selectedImageRef.className;
724 for (var a=0;a < l; a++) {
725 if (fObj.options[a].value == value) {
726 fObj.selectedIndex = a;
730 if (document.imageData.iLang) {
731 var fObj=document.imageData.iLang;
732 var value=plugin.editor.getPlugin("Language").getLanguageAttribute(selectedImageRef);
733 for (var i = 0, n = fObj.length; i < n; i++) {
734 if (fObj.options[i].value == value) {
735 fObj.selectedIndex = i;
737 fObj.options[0].text = plugin.editor.getPlugin("Language").localize("Remove language mark");
742 if (document.imageData.iClickEnlarge) {
743 if (selectedImageRef.getAttribute("data-htmlarea-clickenlarge") == "1" || selectedImageRef.getAttribute("clickenlarge") == "1") {
744 document.imageData.iClickEnlarge.checked = 1;
746 document.imageData.iClickEnlarge.checked = 0;
753 var selectedImageRef = getCurrentImageRef();'; // Setting this to a reference to the image object.
758 * Session data for this class can be set from outside with this method.
761 * @param array Session data array
762 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
764 function processSessionData($data) {
767 if ($this->act
!= 'image') {
768 if (isset($this->act
)) {
769 $data['act'] = $this->act
;
772 $this->act
= $data['act'];
776 if (isset($this->expandFolder
)) {
777 $data['expandFolder'] = $this->expandFolder
;
780 $this->expandFolder
= $data['expandFolder'];
783 return array($data, $store);
787 * [Describe function...]
791 function main_rte() {
793 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->getLL('Insert Image',1));
795 // Making menu in top:
797 if (in_array('image', $this->allowedItems
) && (($this->act
=== 'image') || t3lib_div
::_GP('cWidth'))) {
798 $menuDef['image']['isActive'] = ($this->act
=== 'image');
799 $menuDef['image']['label'] = $GLOBALS['LANG']->getLL('currentImage', 1);
800 $menuDef['image']['url'] = '#';
801 $menuDef['image']['addParams'] = 'onClick="jumpToUrl(\'?act=image&bparams=' . $this->bparams
. '\');return false;"';
803 if (in_array('magic', $this->allowedItems
)){
804 $menuDef['magic']['isActive'] = ($this->act
=== 'magic');
805 $menuDef['magic']['label'] = $GLOBALS['LANG']->getLL('magicImage', 1);
806 $menuDef['magic']['url'] = '#';
807 $menuDef['magic']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&bparams=' . $this->bparams
. '\');return false;"';
809 if (in_array('plain', $this->allowedItems
)) {
810 $menuDef['plain']['isActive'] = ($this->act
=== 'plain');
811 $menuDef['plain']['label'] = $GLOBALS['LANG']->getLL('plainImage', 1);
812 $menuDef['plain']['url'] = '#';
813 $menuDef['plain']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&bparams=' . $this->bparams
. '\');return false;"';
815 if (in_array('dragdrop', $this->allowedItems
)) {
816 $menuDef['dragdrop']['isActive'] = ($this->act
=== 'dragdrop');
817 $menuDef['dragdrop']['label'] = $GLOBALS['LANG']->getLL('dragDropImage', 1);
818 $menuDef['dragdrop']['url'] = '#';
819 $menuDef['dragdrop']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&bparams=' . $this->bparams
. '\');return false;"';
822 // Call hook for extra options
823 foreach ($this->hookObjects
as $hookObject) {
824 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
827 $this->content
.= $this->doc
->getTabMenuRaw($menuDef);
832 document.write(printCurrentImageOptions());
833 insertImagePropertiesInForm();';
834 $this->content
.= '<br />'.$this->doc
->wrapScriptTags($JScode);
838 // Adding upload form, if allowed
839 $this->content
.= $this->insertUploadForm($this->expandFolder
);
840 // Getting flag for showing/not showing thumbnails:
841 $noThumbs = $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInRTEimageSelect');
843 // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
844 $_MOD_MENU = array('displayThumbs' => '');
845 $_MCONF['name']='file_list';
846 $_MOD_SETTINGS = t3lib_BEfunc
::getModuleData($_MOD_MENU, t3lib_div
::_GP('SET'), $_MCONF['name']);
847 $addParams = '&act='.$this->act
.'&editorNo='.$this->editorNo
.'&expandFolder='.rawurlencode($this->expandFolder
);
848 $thumbNailCheck = t3lib_BEfunc
::getFuncCheck('','SET[displayThumbs]',$_MOD_SETTINGS['displayThumbs'],'select_image.php',$addParams,'id="checkDisplayThumbs"').' <label for="checkDisplayThumbs">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.php:displayThumbs',1).'</label>';
852 // Create folder tree:
853 $foldertree = t3lib_div
::makeInstance('tx_rtehtmlarea_image_folderTree');
854 $tree = $foldertree->getBrowsableTree();
855 list(,,$specUid) = explode('_',t3lib_div
::_GP('PM'));
856 $files = $this->expandFolder($foldertree->specUIDmap
[$specUid],$this->act
=='plain',$noThumbs?
$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
857 $this->content
.= '<table border="0" cellpadding="0" cellspacing="0">
859 <td style="vertical-align: top;">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
861 <td style="vertical-align: top;">'.$files.'</td>
864 <br />'.$thumbNailCheck;
866 $helpMessage = $this->getHelpMessage($this->act
);
868 $this->content
.= $this->getMsgBox($helpMessage);
872 $foldertree = t3lib_div
::makeInstance('TBE_FolderTree');
873 $foldertree->thisScript
=$this->thisScript
;
874 $foldertree->ext_noTempRecyclerDirs
= TRUE;
875 $tree = $foldertree->getBrowsableTree();
876 list(,,$specUid) = explode('_',t3lib_div
::_GP('PM'));
877 $files = $this->TBE_dragNDrop($foldertree->specUIDmap
[$specUid], implode(',', $this->allowedFileTypes
));
878 $this->content
.= '<table border="0" cellpadding="0" cellspacing="0">
880 <td style="vertical-align: top;">'.$this->barheader($GLOBALS['LANG']->getLL('folderTree').':').$tree.'</td>
882 <td style="vertical-align: top;">'.$files.'</td>
888 foreach ($this->hookObjects
as $hookObject) {
889 $this->content
.= $hookObject->getTab($this->act
);
893 $this->content
.= $this->doc
->endPage();
894 $this->doc
->JScodeArray
['rtehtmlarea'] = $this->getJSCode($this->act
, $this->editorNo
, $this->sys_language_content
);
895 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
896 return $this->content
;
900 * Create upload/create folder forms, if a path is given
902 * @param string $folderPath: the selected path , if any
904 * @return string the html content for the upload form
906 protected function insertUploadForm($folderPath) {
908 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB') && !$this->readOnly
&& count($GLOBALS['FILEMOUNTS'])) {
910 if (!$path ||
!@is_dir
($path)) {
911 // The closest TEMP-path is found
912 $path = $this->fileProcessor
->findTempFolder().'/';
914 if ($path!='/' && @is_dir
($path)) {
915 $uploadForm=$this->uploadForm($path);
916 $createFolder=$this->createFolder($path);
921 $content .= $uploadForm;
922 if ($GLOBALS['BE_USER']->isAdmin() ||
$GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
923 $content.=$createFolder;
929 /***************************
933 ***************************/
935 * @param [type] $expandFolder: ...
936 * @param [type] $plainFlag: ...
939 function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) {
940 global $LANG, $BACK_PATH;
942 $expandFolder = $expandFolder ?
$expandFolder :t3lib_div
::_GP('expandFolder');
945 if ($expandFolder && $this->checkFolder($expandFolder)) {
946 $files = t3lib_div
::getFilesInDir($expandFolder,($plainFlag?
'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1); // $extensionList="",$prependPath=0,$order="")
947 if (is_array($files)) {
948 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
950 $titleLen = intval($GLOBALS['BE_USER']->uc
['titleLen']);
951 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
952 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($expandFolder),$titleLen));
953 $out.='<span class="nobr">'.$picon.'</span><br />';
955 $imgObj = t3lib_div
::makeInstance('t3lib_stdGraphic');
957 $imgObj->mayScaleUp
=0;
958 $imgObj->tempPath
=PATH_site
.$imgObj->tempPath
;
961 foreach ($files as $filepath) {
962 $fI=pathinfo($filepath);
964 $origFile = t3lib_div
::rawUrlEncodeFP(substr($filepath,strlen(PATH_site
)));
965 $iurl = $this->siteURL
.$origFile;
966 $imgInfo = $imgObj->getImageDimensions($filepath);
968 $icon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
969 $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
970 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
971 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
972 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo
.'&insertImage='.rawurlencode($filepath).'\');">';
974 if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth
) ||
($imgInfo[1] > $this->plainMaxHeight
))) {
980 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
984 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e;
987 $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.' </td><td nowrap="nowrap">'.$pDim.' </td></tr>';
988 $lines[]='<tr><td colspan="2">'.($noThumbs ?
'' : $ATag2.t3lib_BEfunc
::getThumbNail($this->doc
->backPath
.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
990 $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
992 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
999 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images.
1000 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE
1002 * @param string The folder path to expand
1003 * @param string List of fileextensions to show
1004 * @return string HTML output
1006 function TBE_dragNDrop($expandFolder=0,$extensionList='') {
1009 $expandFolder = $expandFolder ?
$expandFolder : t3lib_div
::_GP('expandFolder');
1011 if ($expandFolder && $this->checkFolder($expandFolder)) {
1012 if ($this->isWebFolder($expandFolder)) {
1014 // Read files from directory:
1015 $files = t3lib_div
::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='')
1016 if (is_array($files)) {
1017 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files)));
1019 $titleLen=intval($GLOBALS['BE_USER']->uc
['titleLen']);
1020 $picon='<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
1021 $picon.=htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($expandFolder),$titleLen));
1022 $out.=$picon.'<br />';
1027 // Add "drag-n-drop" message:
1030 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td>
1034 foreach ($files as $filepath) {
1035 $fI = pathinfo($filepath);
1038 $iurl = $this->siteURL
.t3lib_div
::rawurlencodeFP(substr($filepath,strlen(PATH_site
)));
1040 // Show only web-images
1041 if (t3lib_div
::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) {
1042 $imgInfo = @getimagesize
($filepath);
1043 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels';
1045 $ficon = t3lib_BEfunc
::getFileIcon(strtolower($fI['extension']));
1046 $size=' ('.t3lib_div
::formatSize(filesize($filepath)).'bytes'.($pDim?
', '.$pDim:'').')';
1047 $icon = '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
1048 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div
::fixed_lgd_cs(basename($filepath),$titleLen));
1050 if (t3lib_div
::_GP('noLimit')) {
1060 $IH=ceil($IH/$IW*$maxW);
1064 $IW=ceil($IW/$IH*$maxH);
1070 <tr class="bgColor4">
1071 <td nowrap="nowrap">'.$filenameAndIcon.' </td>
1072 <td nowrap="nowrap">'.
1073 ($imgInfo[0]!=$IW ?
'<a href="'.htmlspecialchars(t3lib_div
::linkThisScript(array('noLimit'=>'1'))).'">'.
1074 '<img'.t3lib_iconWorks
::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'.
1078 // Remove hardcoded border="1"
1079 // Add default class for images
1082 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" alt=""' . ($this->defaultClass?
(' class="'.$this->defaultClass
.'"'):''). ' style="cursor:move;" /></td>
1086 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
1091 // Finally, wrap all rows in a table tag:
1096 File listing / Drag-n-drop
1098 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox">
1099 '.implode('',$lines).'
1103 // Print this warning if the folder is NOT a web folder:
1104 $out.=$this->barheader($GLOBALS['LANG']->getLL('files'));
1105 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2');
1112 * Initializes the configuration variables
1116 public function initConfiguration() {
1117 $this->thisConfig
= $this->getRTEConfig();
1118 $this->buttonConfig
= $this->getButtonConfig();
1119 $this->imgPath
= $this->getImgPath();
1120 $this->RTEImageStorageDir
= $this->getRTEImageStorageDir();
1121 $this->defaultClass
= $this->getDefaultClass();
1122 $this->setMaximumImageDimensions();
1126 * Get the RTE configuration from Page TSConfig
1128 * @return array RTE configuration array
1130 protected function getRTEConfig() {
1131 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
1132 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($RTEtsConfigParts[5]));
1133 return t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
1137 * Get the path of the image to be inserted or modified
1139 * @return string path to the image
1141 protected function getImgPath() {
1142 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams
);
1143 return $RTEtsConfigParts[6];
1147 * Get the configuration of the image button
1149 * @return array the configuration array of the image button
1151 protected function getButtonConfig() {
1152 return ((is_array($this->thisConfig
['buttons.']) && is_array($this->thisConfig
['buttons.']['image.'])) ?
$this->thisConfig
['buttons.']['image.'] : array());
1156 * Get the allowed items or tabs
1158 * @param string $items: initial list of possible items
1159 * @return array the allowed items
1161 public function getAllowedItems($items) {
1162 $allowedItems = explode(',', $items);
1163 $clientInfo = t3lib_div
::clientInfo();
1164 if ($clientInfo['BROWSER'] !== 'opera') {
1165 $allowedItems[] = 'dragdrop';
1167 // Call hook for extra options
1168 foreach ($this->hookObjects
as $hookObject) {
1169 $allowedItems = $hookObject->addAllowedItems($allowedItems);
1171 // Remove tab "image" if there is no current image
1172 if ($this->act
!== 'image') {
1173 $allowedItems = array_diff($allowedItems, array('image'));
1175 // Remove options according to RTE configuration
1176 if (is_array($this->buttonConfig
['options.']) && $this->buttonConfig
['options.']['removeItems']) {
1177 $allowedItems = array_diff($allowedItems, t3lib_div
::trimExplode(',', $this->buttonConfig
['options.']['removeItems'], 1));
1179 // This PageTSConfig property is deprecated as of TYPO3 4.6 and will be removed in TYPO3 4.8
1180 $allowedItems = array_diff($allowedItems, t3lib_div
::trimExplode(',', $this->thisConfig
['blindImageOptions'], 1));
1182 return $allowedItems;
1186 * Get the default image class
1188 * @return string the default class, if any
1190 protected function getDefaultClass() {
1192 if (is_array($this->buttonConfig
['properties.'])) {
1193 if (is_array($this->buttonConfig
['properties.']['class.']) && trim($this->buttonConfig
['properties.']['class.']['default'])) {
1194 $defaultClass = trim($this->buttonConfig
['properties.']['class.']['default']);
1197 return $defaultClass;
1201 * Set variables for maximum image dimensions
1205 protected function setMaximumImageDimensions() {
1206 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['plain.'])) {
1207 if ($this->buttonConfig
['options.']['plain.']['maxWidth']) $this->plainMaxWidth
= $this->buttonConfig
['options.']['plain.']['maxWidth'];
1208 if ($this->buttonConfig
['options.']['plain.']['maxHeight']) $this->plainMaxHeight
= $this->buttonConfig
['options.']['plain.']['maxHeight'];
1210 if (!$this->plainMaxWidth
) $this->plainMaxWidth
= 640;
1211 if (!$this->plainMaxHeight
) $this->plainMaxHeight
= 680;
1212 if (is_array($this->buttonConfig
['options.']) && is_array($this->buttonConfig
['options.']['magic.'])) {
1213 if ($this->buttonConfig
['options.']['magic.']['maxWidth']) $this->magicMaxWidth
= $this->buttonConfig
['options.']['magic.']['maxWidth'];
1214 if ($this->buttonConfig
['options.']['magic.']['maxHeight']) $this->magicMaxHeight
= $this->buttonConfig
['options.']['magic.']['maxHeight'];
1216 // 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
1217 if (!$this->magicMaxWidth
) $this->magicMaxWidth
= 300;
1218 if (!$this->magicMaxHeight
) $this->magicMaxHeight
= 1000;
1222 * Get the help message to be displayed on a given tab
1224 * @param string $act: the identifier of the tab
1225 * @return string the text of the message
1227 public function getHelpMessage($act) {
1231 return sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth
, $this->plainMaxHeight
);
1234 return sprintf($LANG->getLL('magicImage_msg'));
1242 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php'])) {
1243 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);