[TASK] Remove duplicated method in Rtehtmlarea\SelectImage
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / SelectImage.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasper@typo3.com)
8 * (c) 2004-2013 Stanislas Rolland <typo3(arobas)jbr.ca>
9 * All rights reserved
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 * A copy is found in the text file GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30
31 use TYPO3\CMS\Core\Utility\GeneralUtility;
32 use TYPO3\CMS\Core\Resource;
33
34 /**
35 * Script Class
36 *
37 * @author Kasper Skårhøj <kasper@typo3.com>
38 */
39 class SelectImage extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
40
41 /**
42 * @todo Define visibility
43 */
44 public $extKey = 'rtehtmlarea';
45
46 /**
47 * @todo Define visibility
48 */
49 public $content;
50
51 public $allowedItems;
52
53 public $allowedFileTypes = array();
54
55 protected $defaultClass;
56
57 protected $plainMaxWidth;
58
59 protected $plainMaxHeight;
60
61 protected $magicMaxWidth;
62
63 protected $magicMaxHeight;
64
65 protected $imgPath;
66
67 public $editorNo;
68
69 public $sys_language_content;
70
71 public $thisConfig;
72
73 public $buttonConfig;
74
75 protected $imgObj;
76
77 /**
78 * Initialisation
79 *
80 * @return void
81 */
82 public function init() {
83 $this->initVariables();
84 $this->initConfiguration();
85 $this->initHookObjects();
86 // init fileProcessor
87 $this->fileProcessor = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
88 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
89 $this->allowedItems = $this->getAllowedItems('magic,plain,image');
90 $this->insertImage();
91 // Creating backend template object:
92 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
93 // Apply the same styles as those of the base script
94 $this->doc->bodyTagId = 'typo3-browse-links-php';
95 $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
96 $this->doc->backPath = $GLOBALS['BACK_PATH'];
97 // Load the Prototype library and browse_links.js
98 $this->doc->getPageRenderer()->loadPrototype();
99 $this->doc->loadJavascriptLib('js/tree.js');
100 $this->doc->loadJavascriptLib('js/browse_links.js');
101 $this->doc->JScode .= $this->doc->wrapScriptTags('
102 Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
103 ');
104 $this->doc->getContextMenuCode();
105 }
106
107 /**
108 * Initialize class variables
109 *
110 * @return void
111 */
112 public function initVariables() {
113 // Get "act"
114 $this->act = GeneralUtility::_GP('act');
115 if (!$this->act) {
116 $this->act = FALSE;
117 }
118 // Process bparams
119 $this->bparams = GeneralUtility::_GP('bparams');
120 $pArr = explode('|', $this->bparams);
121 $pRteArr = explode(':', $pArr[1]);
122 $this->editorNo = $pRteArr[0];
123 $this->sys_language_content = $pRteArr[1];
124 $this->RTEtsConfigParams = $pArr[2];
125 if (!$this->editorNo) {
126 $this->editorNo = GeneralUtility::_GP('editorNo');
127 $this->sys_language_content = GeneralUtility::_GP('sys_language_content');
128 $this->RTEtsConfigParams = GeneralUtility::_GP('RTEtsConfigParams');
129 }
130 $this->expandPage = GeneralUtility::_GP('expandPage');
131 $this->expandFolder = GeneralUtility::_GP('expandFolder');
132 $pArr[1] = implode(':', array($this->editorNo, $this->sys_language_content));
133 $pArr[2] = $this->RTEtsConfigParams;
134 if ($this->act == 'dragdrop' || $this->act == 'plain') {
135 $this->allowedFileTypes = explode(',', 'jpg,jpeg,gif,png');
136 }
137 $pArr[3] = implode(',', $this->allowedFileTypes);
138 $this->bparams = implode('|', $pArr);
139 // Find "mode"
140 $this->mode = GeneralUtility::_GP('mode');
141 if (!$this->mode) {
142 $this->mode = 'rte';
143 }
144 // Site URL
145 $this->siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
146 // Current site url
147 // the script to link to
148 $this->thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
149 }
150
151 /**
152 * Initialize hook objects implementing the hook interface
153 *
154 * @return void
155 */
156 protected function initHookObjects() {
157 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'])) {
158 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'] as $classData) {
159 $processObject = GeneralUtility::getUserObj($classData);
160 if (!$processObject instanceof \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface) {
161 throw new \UnexpectedValueException('$processObject must implement interface TYPO3\\CMS\\Core\\ElementBrowser\\ElementBrowserHookInterface', 1195115652);
162 }
163 $parameters = array();
164 $processObject->init($this, $parameters);
165 $this->hookObjects[] = $processObject;
166 }
167 }
168 }
169
170 /**
171 * Provide the additional parameters to be included in the template body tag
172 *
173 * @return string the body tag additions
174 */
175 public function getBodyTagAdditions() {
176 return 'onload="initEventListeners();"';
177 }
178
179 /**
180 * Get the path to the folder where RTE images are stored
181 *
182 * @return string the path to the folder where RTE images are stored
183 * @deprecated since 6.2, will be removed in two versions
184 */
185 protected function getRTEImageStorageDir() {
186 GeneralUtility::logDeprecatedFunction();
187 return $this->imgPath ?: $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];
188 }
189
190 /**
191 * Insert the image in the editing area
192 *
193 * @return void
194 */
195 protected function insertImage() {
196 $table = htmlspecialchars(GeneralUtility::_GP('table'));
197 $uid = (int) GeneralUtility::_GP('uid');
198 if (GeneralUtility::_GP('insertImage') && $uid) {
199 /** @var $fileObject Resource\File */
200 $fileObject = Resource\ResourceFactory::getInstance()->getFileObject($uid);
201 // Get default values for alt and title attributes from file properties
202 $altText = $fileObject->getProperty('alternative');
203 $titleText = $fileObject->getProperty('name');
204 switch ($this->act) {
205 case 'magic':
206 $this->insertMagicImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '" data-htmlarea-file-table="' . $table . '"');
207 die;
208 break;
209 case 'plain':
210 $this->insertPlainImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '" data-htmlarea-file-table="' . $table . '"');
211 die;
212 break;
213 default:
214 // Call hook
215 foreach ($this->hookObjects as $hookObject) {
216 if (method_exists($hookObject, 'insertElement')) {
217 $hookObject->insertElement($this->act);
218 }
219 }
220 }
221 }
222 }
223
224 /**
225 * Insert a magic image
226 *
227 * @param Resource\File $fileObject: the image file
228 * @param string $altText: text for the alt attribute of the image
229 * @param string $titleText: text for the title attribute of the image
230 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
231 * @return void
232 */
233 public function insertMagicImage(Resource\File $fileObject, $altText = '', $titleText = '', $additionalParams = '') {
234 // Create the magic image service
235 /** @var $magicImageService Resource\Service\MagicImageService */
236 $magicImageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Service\\MagicImageService');
237 // Create the magic image
238 $imageConfiguration = array(
239 'width' => GeneralUtility::_GP('cWidth'),
240 'height' => GeneralUtility::_GP('cHeight'),
241 'maxW' => $this->magicMaxWidth,
242 'maxH' => $this->magicMaxHeight
243 );
244 $magicImage = $magicImageService->createMagicImage($fileObject, $imageConfiguration);
245 $imageUrl = $magicImage->getPublicUrl();
246 // If file is local, make the url absolute
247 if (substr($imageUrl, 0, 4) !== 'http') {
248 $imageUrl = $this->siteURL . $imageUrl;
249 }
250 // Insert the magic image
251 $this->imageInsertJS($imageUrl, $magicImage->getProperty('width'), $magicImage->getProperty('height'), $altText, $titleText, $additionalParams);
252 }
253
254 /**
255 * Insert a plain image
256 *
257 * @param \TYPO3\CMS\Core\Resource\File $fileObject: the image file
258 * @param string $altText: text for the alt attribute of the image
259 * @param string $titleText: text for the title attribute of the image
260 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag
261 * @return void
262 */
263 public function insertPlainImage(Resource\File $fileObject, $altText = '', $titleText = '', $additionalParams = '') {
264 $width = $fileObject->getProperty('width');
265 $height = $fileObject->getProperty('height');
266 if (!$width || !$height) {
267 $filePath = $fileObject->getForLocalProcessing(FALSE);
268 $imageInfo = @getimagesize($filePath);
269 $width = $imageInfo[0];
270 $height = $imageInfo[1];
271 }
272 $imageUrl = $fileObject->getPublicUrl();
273 // If file is local, make the url absolute
274 if (substr($imageUrl, 0, 4) !== 'http') {
275 $imageUrl = $this->siteURL . $imageUrl;
276 }
277 $this->imageInsertJS($imageUrl, $width, $height, $altText, $titleText, $additionalParams);
278 }
279
280 /**
281 * Echo the HTML page and JS that will insert the image
282 *
283 * @param string $url: the url of the image
284 * @param integer $width: the width of the image
285 * @param integer $height: the height of the image
286 * @param string $altText: text for the alt attribute of the image
287 * @param string $titleText: text for the title attribute of the image
288 * @param string $additionalParams: text representing more html attributes to be added on the img tag
289 * @return void
290 */
291 protected function imageInsertJS($url, $width, $height, $altText = '', $titleText = '', $additionalParams = '') {
292 echo '
293 <!DOCTYPE html>
294 <html>
295 <head>
296 <title>Untitled</title>
297 <script type="text/javascript">
298 /*<![CDATA[*/
299 var plugin = window.parent.RTEarea["' . $this->editorNo . '"].editor.getPlugin("TYPO3Image");
300 function insertImage(file,width,height,alt,title,additionalParams) {
301 plugin.insertImage(\'<img src="\'+file+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'"\'' . ($this->defaultClass ? '+\' class="' . $this->defaultClass . '"\'' : '') . '+(alt?\' alt="\'+alt+\'"\':\'\')+(title?\' title="\'+title+\'"\':\'\')+(additionalParams?\' \'+additionalParams:\'\')+\' />\');
302 }
303 /*]]>*/
304 </script>
305 </head>
306 <body>
307 <script type="text/javascript">
308 /*<![CDATA[*/
309 insertImage(' . GeneralUtility::quoteJSvalue($url, 1) . ',' . $width . ',' . $height . ',' . GeneralUtility::quoteJSvalue($altText, 1) . ',' . GeneralUtility::quoteJSvalue($titleText, 1) . ',' . GeneralUtility::quoteJSvalue($additionalParams, 1) . ');
310 /*]]>*/
311 </script>
312 </body>
313 </html>';
314 }
315
316 /**
317 * Generate JS code to be used on the image insert/modify dialogue
318 *
319 * @param string $act: the action to be performed
320 * @param string $editorNo: the number of the RTE instance on the page
321 * @param string $sys_language_content: the language of the content element
322 * @return string the generated JS code
323 * @todo Define visibility
324 */
325 public function getJSCode($act, $editorNo, $sys_language_content) {
326 $removedProperties = array();
327 if (is_array($this->buttonConfig['properties.'])) {
328 if ($this->buttonConfig['properties.']['removeItems']) {
329 $removedProperties = GeneralUtility::trimExplode(',', $this->buttonConfig['properties.']['removeItems'], TRUE);
330 }
331 }
332 if ($this->buttonConfig['properties.']['class.']['allowedClasses']) {
333 $classesImageArray = GeneralUtility::trimExplode(',', $this->buttonConfig['properties.']['class.']['allowedClasses'], TRUE);
334 $classesImageJSOptions = '<option value=""></option>';
335 foreach ($classesImageArray as $class) {
336 $classesImageJSOptions .= '<option value="' . $class . '">' . $class . '</option>';
337 }
338 }
339 $lockPlainWidth = 'false';
340 $lockPlainHeight = 'false';
341 if (is_array($this->thisConfig['proc.']) && $this->thisConfig['proc.']['plainImageMode']) {
342 $plainImageMode = $this->thisConfig['proc.']['plainImageMode'];
343 $lockPlainWidth = $plainImageMode == 'lockDimensions' ? 'true' : 'false';
344 $lockPlainHeight = $lockPlainWidth || $plainImageMode == 'lockRatio' || $plainImageMode == 'lockRatioWhenSmaller' ? 'true' : 'false';
345 }
346 $JScode = '
347 var plugin = window.parent.RTEarea["' . $editorNo . '"].editor.getPlugin("TYPO3Image");
348 var HTMLArea = window.parent.HTMLArea;
349
350 HTMLArea.TYPO3Image.insertElement = function (table, uid, type, filename, filePath, fileExt, fileIcon) {
351 return jumpToUrl(\'?editorNo=\' + \'' . $editorNo . '\' + \'&insertImage=\' + filePath + \'&table=\' + table + \'&uid=\' + uid + \'&type=\' + type + \'bparams=\' + \'' . $this->bparams . '\');
352 }
353 function insertElement(table, uid, type, fileName, filePath, fileExt, fileIcon, action, close) {
354 return jumpToUrl(\'?editorNo=\' + \'' . $editorNo . '\' + \'&insertImage=\' + filePath + \'&table=\' + table + \'&uid=\' + uid + \'&type=\' + type + \'bparams=\' + \'' . $this->bparams . '\');
355 }
356 function initEventListeners() {
357 if (Ext.isWebKit) {
358 Ext.EventManager.addListener(window.document.body, "dragend", plugin.onDrop, plugin, { single: true });
359 }
360 }
361 function jumpToUrl(URL,anchor) {
362 var add_act = URL.indexOf("act=")==-1 ? "&act=' . $act . '" : "";
363 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo=' . $editorNo . '" : "";
364 var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content=' . $sys_language_content . '" : "";
365 var RTEtsConfigParams = "&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams) . '";
366
367 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
368 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
369
370 var theLocation = URL+add_act+add_editorNo+add_sys_language_content+RTEtsConfigParams+cur_width+cur_height+(typeof(anchor)=="string"?anchor:"");
371 window.location.href = theLocation;
372 return false;
373 }
374 function insertImage(file,width,height) {
375 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass ? ' class="' . $this->defaultClass . '"' : '') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\');
376 }
377 function launchView(url) {
378 var thePreviewWindow="";
379 thePreviewWindow = window.open("' . GeneralUtility::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");
380 if (thePreviewWindow && thePreviewWindow.focus) {
381 thePreviewWindow.focus();
382 }
383 }
384 function getCurrentImageRef() {
385 if (plugin.image) {
386 return plugin.image;
387 } else {
388 return null;
389 }
390 }
391 function printCurrentImageOptions() {
392 var classesImage = ' . ($this->buttonConfig['properties.']['class.']['allowedClasses'] || $this->thisConfig['classesImage'] ? 'true' : 'false') . ';
393 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $classesImageJSOptions . '</select>\';
394 var floatSelector=\'<select id="iFloat" name="iFloat"><option value="">' . $GLOBALS['LANG']->getLL('notSet') . '</option><option value="none">' . $GLOBALS['LANG']->getLL('nonFloating') . '</option><option value="left">' . $GLOBALS['LANG']->getLL('left') . '</option><option value="right">' . $GLOBALS['LANG']->getLL('right') . '</option></select>\';
395 if (plugin.getButton("Language")) {
396 var languageSelector = \'<select id="iLang" name="iLang">\';
397 plugin.getButton("Language").getStore().each(function (record) {
398 languageSelector +=\'<option value="\' + record.get("value") + \'">\' + record.get("text") + \'</option>\';
399 });
400 languageSelector += \'</select>\';
401 }
402 var bgColor=\' class="bgColor4"\';
403 var sz="";
404 sz+=\'<table border="0" cellpadding="1" cellspacing="1"><form action="" name="imageData">\';
405 ' . (in_array('class', $removedProperties) ? '' : '
406 if(classesImage) {
407 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">' . $GLOBALS['LANG']->getLL('class') . ': </label></td><td>\'+styleSelector+\'</td></tr>\';
408 }') . (in_array('width', $removedProperties) ? '' : '
409 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && ' . $lockPlainWidth . ')) {
410 sz+=\'<tr><td\'+bgColor+\'><label for="iWidth">' . $GLOBALS['LANG']->getLL('width') . ': </label></td><td><input type="text" id="iWidth" name="iWidth" value=""' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' /></td></tr>\';
411 }') . (in_array('height', $removedProperties) ? '' : '
412 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && ' . $lockPlainHeight . ')) {
413 sz+=\'<tr><td\'+bgColor+\'><label for="iHeight">' . $GLOBALS['LANG']->getLL('height') . ': </label></td><td><input type="text" id="iHeight" name="iHeight" value=""' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' /></td></tr>\';
414 }') . (in_array('border', $removedProperties) ? '' : '
415 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">' . $GLOBALS['LANG']->getLL('border') . ': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';') . (in_array('float', $removedProperties) ? '' : '
416 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">' . $GLOBALS['LANG']->getLL('float') . ': </label></td><td>\'+floatSelector+\'</td></tr>\';') . (in_array('paddingTop', $removedProperties) ? '' : '
417 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingTop">' . $GLOBALS['LANG']->getLL('padding_top') . ': </label></td><td><input type="text" id="iPaddingTop" name="iPaddingTop" value=""' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . '></td></tr>\';') . (in_array('paddingRight', $removedProperties) ? '' : '
418 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingRight">' . $GLOBALS['LANG']->getLL('padding_right') . ': </label></td><td><input type="text" id="iPaddingRight" name="iPaddingRight" value=""' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' /></td></tr>\';') . (in_array('paddingBottom', $removedProperties) ? '' : '
419 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingBottom">' . $GLOBALS['LANG']->getLL('padding_bottom') . ': </label></td><td><input type="text" id="iPaddingBottom" name="iPaddingBottom" value=""' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' /></td></tr>\';') . (in_array('paddingLeft', $removedProperties) ? '' : '
420 sz+=\'<tr><td\'+bgColor+\'><label for="iPaddingLeft">' . $GLOBALS['LANG']->getLL('padding_left') . ': </label></td><td><input type="text" id="iPaddingLeft" name="iPaddingLeft" value=""' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' /></td></tr>\';') . (in_array('title', $removedProperties) ? '' : '
421 sz+=\'<tr><td\'+bgColor+\'><label for="iTitle">' . $GLOBALS['LANG']->getLL('title') . ': </label></td><td><input type="text" id="iTitle" name="iTitle"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' /></td></tr>\';') . (in_array('alt', $removedProperties) ? '' : '
422 sz+=\'<tr><td\'+bgColor+\'><label for="iAlt">' . $GLOBALS['LANG']->getLL('alt') . ': </label></td><td><input type="text" id="iAlt" name="iAlt"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' /></td></tr>\';') . (in_array('lang', $removedProperties) ? '' : '
423 if (plugin.getButton("Language")) {
424 sz+=\'<tr><td\'+bgColor+\'><label for="iLang">\' + plugin.editor.getPlugin("Language").localize(\'Language-Tooltip\') + \': </label></td><td>\' + languageSelector + \'</td></tr>\';
425 }') . (in_array('clickenlarge', $removedProperties) || in_array('data-htmlarea-clickenlarge', $removedProperties) ? '' : '
426 sz+=\'<tr><td\'+bgColor+\'><label for="iClickEnlarge">' . $GLOBALS['LANG']->sL('LLL:EXT:cms/locallang_ttc.xlf:image_zoom', TRUE) . ' </label></td><td><input type="checkbox" name="iClickEnlarge" id="iClickEnlarge" value="0" /></td></tr>\';') . '
427 sz+=\'<tr><td><input type="submit" value="' . $GLOBALS['LANG']->getLL('update') . '" onClick="return setImageProperties();"></td></tr>\';
428 sz+=\'</form></table>\';
429 return sz;
430 }
431 function setImageProperties() {
432 var classesImage = ' . ($this->buttonConfig['properties.']['class.']['allowedClasses'] || $this->thisConfig['classesImage'] ? 'true' : 'false') . ';
433 if (selectedImageRef) {
434 if (document.imageData.iWidth) {
435 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) {
436 selectedImageRef.style.width = "";
437 selectedImageRef.width = parseInt(document.imageData.iWidth.value);
438 }
439 }
440 if (document.imageData.iHeight) {
441 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) {
442 selectedImageRef.style.height = "";
443 selectedImageRef.height = parseInt(document.imageData.iHeight.value);
444 }
445 }
446 if (document.imageData.iPaddingTop) {
447 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) {
448 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px";
449 } else {
450 selectedImageRef.style.paddingTop = "";
451 }
452 }
453 if (document.imageData.iPaddingRight) {
454 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) {
455 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px";
456 } else {
457 selectedImageRef.style.paddingRight = "";
458 }
459 }
460 if (document.imageData.iPaddingBottom) {
461 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) {
462 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px";
463 } else {
464 selectedImageRef.style.paddingBottom = "";
465 }
466 }
467 if (document.imageData.iPaddingLeft) {
468 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) {
469 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px";
470 } else {
471 selectedImageRef.style.paddingLeft = "";
472 }
473 }
474 if (document.imageData.iTitle) {
475 selectedImageRef.title=document.imageData.iTitle.value;
476 }
477 if (document.imageData.iAlt) {
478 selectedImageRef.alt=document.imageData.iAlt.value;
479 }
480 if (document.imageData.iBorder) {
481 selectedImageRef.style.borderStyle = "";
482 selectedImageRef.style.borderWidth = "";
483 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1
484 selectedImageRef.style.borderTopStyle = "";
485 selectedImageRef.style.borderRightStyle = "";
486 selectedImageRef.style.borderBottomStyle = "";
487 selectedImageRef.style.borderLeftStyle = "";
488 selectedImageRef.style.borderTopWidth = "";
489 selectedImageRef.style.borderRightWidth = "";
490 selectedImageRef.style.borderBottomWidth = "";
491 selectedImageRef.style.borderLeftWidth = "";
492 if(document.imageData.iBorder.checked) {
493 selectedImageRef.style.borderStyle = "solid";
494 selectedImageRef.style.borderWidth = "thin";
495 }
496 selectedImageRef.removeAttribute("border");
497 }
498 if (document.imageData.iFloat) {
499 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
500 if (document.all) {
501 selectedImageRef.style.styleFloat = iFloat ? iFloat : "";
502 } else {
503 selectedImageRef.style.cssFloat = iFloat ? iFloat : "";
504 }
505 }
506 if (classesImage && document.imageData.iClass) {
507 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
508 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) {
509 selectedImageRef.className = iClass;
510 } else {
511 selectedImageRef.className = "";
512 }
513 }
514 if (document.imageData.iLang) {
515 var iLang = document.imageData.iLang.options[document.imageData.iLang.selectedIndex].value;
516 var languageObject = plugin.editor.getPlugin("Language");
517 if (iLang || languageObject.getLanguageAttribute(selectedImageRef)) {
518 languageObject.setLanguageAttributes(selectedImageRef, iLang);
519 } else {
520 languageObject.setLanguageAttributes(selectedImageRef, "none");
521 }
522 }
523 if (document.imageData.iClickEnlarge) {
524 if (document.imageData.iClickEnlarge.checked) {
525 selectedImageRef.setAttribute("data-htmlarea-clickenlarge","1");
526 } else {
527 selectedImageRef.removeAttribute("data-htmlarea-clickenlarge");
528 selectedImageRef.removeAttribute("clickenlarge");
529 }
530 }
531 plugin.close();
532 }
533 return false;
534 }
535 function insertImagePropertiesInForm() {
536 var classesImage = ' . ($this->buttonConfig['properties.']['class.']['allowedClasses'] || $this->thisConfig['classesImage'] ? 'true' : 'false') . ';
537 if (selectedImageRef) {
538 var styleWidth, styleHeight, padding;
539 if (document.imageData.iWidth) {
540 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
541 styleWidth = parseInt(styleWidth);
542 if (!(isNaN(styleWidth) || styleWidth == 0)) {
543 document.imageData.iWidth.value = styleWidth;
544 }
545 }
546 if (document.imageData.iHeight) {
547 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
548 styleHeight = parseInt(styleHeight);
549 if (!(isNaN(styleHeight) || styleHeight == 0)) {
550 document.imageData.iHeight.value = styleHeight;
551 }
552 }
553 if (document.imageData.iPaddingTop) {
554 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
555 var padding = parseInt(padding);
556 if (isNaN(padding) || padding <= 0) { padding = ""; }
557 document.imageData.iPaddingTop.value = padding;
558 }
559 if (document.imageData.iPaddingRight) {
560 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
561 var padding = parseInt(padding);
562 if (isNaN(padding) || padding <= 0) { padding = ""; }
563 document.imageData.iPaddingRight.value = padding;
564 }
565 if (document.imageData.iPaddingBottom) {
566 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace;
567 var padding = parseInt(padding);
568 if (isNaN(padding) || padding <= 0) { padding = ""; }
569 document.imageData.iPaddingBottom.value = padding;
570 }
571 if (document.imageData.iPaddingLeft) {
572 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace;
573 var padding = parseInt(padding);
574 if (isNaN(padding) || padding <= 0) { padding = ""; }
575 document.imageData.iPaddingLeft.value = padding;
576 }
577 if (document.imageData.iTitle) {
578 document.imageData.iTitle.value = selectedImageRef.title;
579 }
580 if (document.imageData.iAlt) {
581 document.imageData.iAlt.value = selectedImageRef.alt;
582 }
583 if (document.imageData.iBorder) {
584 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
585 document.imageData.iBorder.checked = 1;
586 }
587 }
588 if (document.imageData.iFloat) {
589 var fObj=document.imageData.iFloat;
590 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
591 var l=fObj.length;
592 for (var a=0;a<l;a++) {
593 if (fObj.options[a].value == value) {
594 fObj.selectedIndex = a;
595 }
596 }
597 }
598 if (classesImage && document.imageData.iClass) {
599 var fObj=document.imageData.iClass;
600 var value=selectedImageRef.className;
601 var l=fObj.length;
602 for (var a=0;a < l; a++) {
603 if (fObj.options[a].value == value) {
604 fObj.selectedIndex = a;
605 }
606 }
607 }
608 if (document.imageData.iLang) {
609 var fObj=document.imageData.iLang;
610 var value=plugin.editor.getPlugin("Language").getLanguageAttribute(selectedImageRef);
611 for (var i = 0, n = fObj.length; i < n; i++) {
612 if (fObj.options[i].value == value) {
613 fObj.selectedIndex = i;
614 if (i) {
615 fObj.options[0].text = plugin.editor.getPlugin("Language").localize("Remove language mark");
616 }
617 }
618 }
619 }
620 if (document.imageData.iClickEnlarge) {
621 if (selectedImageRef.getAttribute("data-htmlarea-clickenlarge") == "1" || selectedImageRef.getAttribute("clickenlarge") == "1") {
622 document.imageData.iClickEnlarge.checked = 1;
623 } else {
624 document.imageData.iClickEnlarge.checked = 0;
625 }
626 }
627 return false;
628 }
629 }
630
631 var selectedImageRef = getCurrentImageRef();';
632 // Setting this to a reference to the image object.
633 return $JScode;
634 }
635
636 /**
637 * Session data for this class can be set from outside with this method.
638 * Call after init()
639 *
640 * @param array Session data array
641 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed
642 * @todo Define visibility
643 */
644 public function processSessionData($data) {
645 $store = FALSE;
646 if ($this->act != 'image') {
647 if (isset($this->act)) {
648 $data['act'] = $this->act;
649 $store = TRUE;
650 } else {
651 $this->act = $data['act'];
652 }
653 }
654 if (isset($this->expandFolder)) {
655 $data['expandFolder'] = $this->expandFolder;
656 $store = TRUE;
657 } else {
658 $this->expandFolder = $data['expandFolder'];
659 }
660 return array($data, $store);
661 }
662
663 /**
664 * [Describe function...]
665 *
666 * @return [type] ...
667 * @todo Define visibility
668 */
669 public function main_rte() {
670 // Starting content:
671 $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('Insert Image', TRUE));
672 // Making menu in top:
673 $menuDef = array();
674 if (in_array('image', $this->allowedItems) && ($this->act === 'image' || GeneralUtility::_GP('cWidth'))) {
675 $menuDef['image']['isActive'] = FALSE;
676 $menuDef['image']['label'] = $GLOBALS['LANG']->getLL('currentImage', TRUE);
677 $menuDef['image']['url'] = '#';
678 $menuDef['image']['addParams'] = 'onClick="jumpToUrl(\'?act=image&bparams=' . $this->bparams . '\');return false;"';
679 }
680 if (in_array('magic', $this->allowedItems)) {
681 $menuDef['magic']['isActive'] = FALSE;
682 $menuDef['magic']['label'] = $GLOBALS['LANG']->getLL('magicImage', TRUE);
683 $menuDef['magic']['url'] = '#';
684 $menuDef['magic']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&bparams=' . $this->bparams . '\');return false;"';
685 }
686 if (in_array('plain', $this->allowedItems)) {
687 $menuDef['plain']['isActive'] = FALSE;
688 $menuDef['plain']['label'] = $GLOBALS['LANG']->getLL('plainImage', TRUE);
689 $menuDef['plain']['url'] = '#';
690 $menuDef['plain']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&bparams=' . $this->bparams . '\');return false;"';
691 }
692 if (in_array('dragdrop', $this->allowedItems)) {
693 $menuDef['dragdrop']['isActive'] = FALSE;
694 $menuDef['dragdrop']['label'] = $GLOBALS['LANG']->getLL('dragDropImage', TRUE);
695 $menuDef['dragdrop']['url'] = '#';
696 $menuDef['dragdrop']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&bparams=' . $this->bparams . '\');return false;"';
697 }
698 // Call hook for extra options
699 foreach ($this->hookObjects as $hookObject) {
700 $menuDef = $hookObject->modifyMenuDefinition($menuDef);
701 }
702 // Order the menu items as specified in Page TSconfig
703 $menuDef = $this->orderMenuDefinition($menuDef);
704 // Set active menu item
705 reset($menuDef);
706 if ($this->act === FALSE || !in_array($this->act, $this->allowedItems)) {
707 $this->act = key($menuDef);
708 }
709 $menuDef[$this->act]['isActive'] = TRUE;
710 $this->content .= $this->doc->getTabMenuRaw($menuDef);
711 switch ($this->act) {
712 case 'image':
713 $JScode = '
714 document.write(printCurrentImageOptions());
715 insertImagePropertiesInForm();';
716 $this->content .= '<br />' . $this->doc->wrapScriptTags($JScode);
717 break;
718 case 'plain':
719
720 case 'magic':
721 // Create folder tree:
722 $foldertree = GeneralUtility::makeInstance('TYPO3\\CMS\\Rtehtmlarea\\ImageFolderTree');
723 $foldertree->thisScript = $this->thisScript;
724 $tree = $foldertree->getBrowsableTree();
725 // Get currently selected folder
726 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
727 $cmpPath = '';
728 } else {
729 $cmpPath = $this->curUrlInfo['value'];
730 if (!isset($this->expandFolder)) {
731 $this->expandFolder = $cmpPath;
732 }
733 }
734 // Get the selected folder
735 if ($this->expandFolder) {
736 $selectedFolder = FALSE;
737 $fileOrFolderObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
738 if ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\Folder) {
739 // it's a folder
740 $selectedFolder = $fileOrFolderObject;
741 } elseif ($fileOrFolderObject instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
742 // it's a file
743 // @todo: find the parent folder, right now done a bit ugly, because the file does not
744 // support finding the parent folder of a file on purpose
745 $folderIdentifier = dirname($fileOrFolderObject->getIdentifier());
746 $selectedFolder = $fileOrFolderObject->getStorage()->getFolder($folderIdentifier);
747 }
748 }
749 // If no folder is selected, get the user's default upload folder
750 if (!$selectedFolder) {
751 $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
752 }
753 // Build the file upload and folder creation form
754 $uploadForm = '';
755 $createFolder = '';
756 if ($selectedFolder) {
757 $uploadForm = $this->uploadForm($selectedFolder);
758 $createFolder = $this->createFolder($selectedFolder);
759 }
760 // Insert the upload form on top, if so configured
761 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
762 $this->content .= $uploadForm;
763 }
764 // Render the filelist if there is a folder selected
765 if ($selectedFolder) {
766 $files = $this->TBE_expandFolder($selectedFolder, $this->act === 'plain' ? 'jpg,jpeg,gif,png' : $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $GLOBALS['BE_USER']->getTSConfigVal('options.noThumbsInRTEimageSelect'));
767 }
768 // Setup filelist indexed elements:
769 $this->doc->JScode .= $this->doc->wrapScriptTags('BrowseLinks.addElements(' . json_encode($this->elements) . ');');
770 // Wrap tree
771 $this->content .= '
772
773 <!--
774 Wrapper table for folder tree / file/folder list:
775 -->
776 <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkFiles">
777 <tr>
778 <td class="c-wCell" valign="top">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':')) . $tree . '</td>
779 <td class="c-wCell" valign="top">' . $files . '</td>
780 </tr>
781 </table>
782 ';
783 // Add help message
784 $helpMessage = $this->getHelpMessage($this->act);
785 if ($helpMessage) {
786 $this->content .= $this->getMsgBox($helpMessage);
787 }
788 // Adding create folder + upload form if applicable
789 if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
790 $this->content .= $uploadForm;
791 }
792 $this->content .= $createFolder;
793 $this->content .= '<br />';
794 break;
795 case 'dragdrop':
796 $foldertree = GeneralUtility::makeInstance('TBE_FolderTree');
797 $foldertree->thisScript = $this->thisScript;
798 $foldertree->ext_noTempRecyclerDirs = TRUE;
799 $tree = $foldertree->getBrowsableTree();
800 // Get currently selected folder
801 if (!$this->curUrlInfo['value'] || $this->curUrlInfo['act'] != $this->act) {
802 $cmpPath = '';
803 } else {
804 $cmpPath = $this->curUrlInfo['value'];
805 if (!isset($this->expandFolder)) {
806 $this->expandFolder = $cmpPath;
807 }
808 }
809 if ($this->expandFolder) {
810 try {
811 $selectedFolder = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($this->expandFolder);
812 } catch (Exception $e) {
813 $selectedFolder = FALSE;
814 }
815 }
816 // Render the filelist if there is a folder selected
817 if ($selectedFolder) {
818 $files = $this->TBE_dragNDrop($selectedFolder, implode(',', $this->allowedFileTypes));
819 }
820 // Wrap tree
821 $this->content .= '<table border="0" cellpadding="0" cellspacing="0">
822 <tr>
823 <td style="vertical-align: top;">' . $this->barheader(($GLOBALS['LANG']->getLL('folderTree') . ':')) . $tree . '</td>
824 <td>&nbsp;</td>
825 <td style="vertical-align: top;">' . $files . '</td>
826 </tr>
827 </table>';
828 break;
829 default:
830 // Call hook
831 foreach ($this->hookObjects as $hookObject) {
832 $this->content .= $hookObject->getTab($this->act);
833 }
834 }
835 $this->content .= $this->doc->endPage();
836 $this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode($this->act, $this->editorNo, $this->sys_language_content);
837 $this->content = $this->doc->insertStylesAndJS($this->content);
838 return $this->content;
839 }
840
841 /**
842 * Initializes the configuration variables
843 *
844 * @return void
845 */
846 public function initConfiguration() {
847 $this->thisConfig = $this->getRTEConfig();
848 $this->buttonConfig = $this->getButtonConfig();
849 $this->imgPath = $this->getImgPath();
850 $this->defaultClass = $this->getDefaultClass();
851 $this->setMaximumImageDimensions();
852 }
853
854 /**
855 * Get the RTE configuration from Page TSConfig
856 *
857 * @return array RTE configuration array
858 */
859 protected function getRTEConfig() {
860 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
861 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($RTEtsConfigParts[5]));
862 return \TYPO3\CMS\Backend\Utility\BackendUtility::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
863 }
864
865 /**
866 * Get the path of the image to be inserted or modified
867 *
868 * @return string path to the image
869 */
870 protected function getImgPath() {
871 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
872 return $RTEtsConfigParts[6];
873 }
874
875 /**
876 * Get the configuration of the image button
877 *
878 * @return array the configuration array of the image button
879 */
880 protected function getButtonConfig() {
881 return is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.']) ? $this->thisConfig['buttons.']['image.'] : array();
882 }
883
884 /**
885 * Get the allowed items or tabs
886 *
887 * @param string $items: initial list of possible items
888 * @return array the allowed items
889 */
890 public function getAllowedItems($items) {
891 $allowedItems = explode(',', $items);
892 $clientInfo = GeneralUtility::clientInfo();
893 if ($clientInfo['BROWSER'] !== 'opera') {
894 $allowedItems[] = 'dragdrop';
895 }
896 // Call hook for extra options
897 foreach ($this->hookObjects as $hookObject) {
898 $allowedItems = $hookObject->addAllowedItems($allowedItems);
899 }
900 // Remove tab "image" if there is no current image
901 if ($this->act !== 'image') {
902 $allowedItems = array_diff($allowedItems, array('image'));
903 }
904 // Remove options according to RTE configuration
905 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
906 $allowedItems = array_diff($allowedItems, GeneralUtility::trimExplode(',', $this->buttonConfig['options.']['removeItems'], TRUE));
907 }
908 return $allowedItems;
909 }
910
911 /**
912 * Order the definition of menu items according to configured order
913 *
914 * @param array $menuDefinition: definition of menu items
915 * @return array ordered menu definition
916 */
917 public function orderMenuDefinition($menuDefinition) {
918 $orderedMenuDefinition = array();
919 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['orderItems']) {
920 $orderItems = GeneralUtility::trimExplode(',', $this->buttonConfig['options.']['orderItems'], TRUE);
921 $orderItems = array_intersect($orderItems, $this->allowedItems);
922 foreach ($orderItems as $item) {
923 $orderedMenuDefinition[$item] = $menuDefinition[$item];
924 }
925 } else {
926 $orderedMenuDefinition = $menuDefinition;
927 }
928 return $orderedMenuDefinition;
929 }
930
931 /**
932 * Get the default image class
933 *
934 * @return string the default class, if any
935 */
936 protected function getDefaultClass() {
937 $defaultClass = '';
938 if (is_array($this->buttonConfig['properties.'])) {
939 if (is_array($this->buttonConfig['properties.']['class.']) && trim($this->buttonConfig['properties.']['class.']['default'])) {
940 $defaultClass = trim($this->buttonConfig['properties.']['class.']['default']);
941 }
942 }
943 return $defaultClass;
944 }
945
946 /**
947 * Set variables for maximum image dimensions
948 *
949 * @return void
950 */
951 protected function setMaximumImageDimensions() {
952 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {
953 if ($this->buttonConfig['options.']['plain.']['maxWidth']) {
954 $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];
955 }
956 if ($this->buttonConfig['options.']['plain.']['maxHeight']) {
957 $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];
958 }
959 }
960 if (!$this->plainMaxWidth) {
961 $this->plainMaxWidth = 640;
962 }
963 if (!$this->plainMaxHeight) {
964 $this->plainMaxHeight = 680;
965 }
966 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {
967 if ($this->buttonConfig['options.']['magic.']['maxWidth']) {
968 $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];
969 }
970 if ($this->buttonConfig['options.']['magic.']['maxHeight']) {
971 $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];
972 }
973 }
974 // 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
975 if (!$this->magicMaxWidth) {
976 $this->magicMaxWidth = 300;
977 }
978 if (!$this->magicMaxHeight) {
979 $this->magicMaxHeight = 1000;
980 }
981 }
982
983 /**
984 * Get the help message to be displayed on a given tab
985 *
986 * @param string $act: the identifier of the tab
987 * @return string the text of the message
988 */
989 public function getHelpMessage($act) {
990 switch ($act) {
991 case 'plain':
992 return sprintf($GLOBALS['LANG']->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight);
993 break;
994 case 'magic':
995 return sprintf($GLOBALS['LANG']->getLL('magicImage_msg'));
996 break;
997 default:
998 return '';
999 }
1000 }
1001
1002 }