|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (kasper@typo3.com) 00006 * (c) 2004-2011 Stanislas Rolland <typo3(arobas)sjbr.ca> 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * A copy is found in the textfile GPL.txt and important notices to the license 00018 * from the author is found in LICENSE.txt distributed with these scripts. 00019 * 00020 * 00021 * This script is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * This copyright notice MUST APPEAR in all copies of the script! 00027 ***************************************************************/ 00028 /** 00029 * Displays image selector for the RTE 00030 * 00031 * @author Kasper Skårhøj <kasper@typo3.com> 00032 * @author Stanislas Rolland <typo3(arobas)sjbr.ca> 00033 * 00034 * $Id: class.tx_rtehtmlarea_select_image.php 10365 2011-02-01 21:13:22Z stan $ * 00035 */ 00036 require_once(PATH_typo3.'class.browse_links.php'); 00037 00038 /** 00039 * Local Folder Tree 00040 * 00041 * @author Kasper Skårhøj <kasper@typo3.com> 00042 * @package TYPO3 00043 * @subpackage tx_rte 00044 */ 00045 class tx_rtehtmlarea_image_folderTree extends t3lib_folderTree { 00046 var $ext_IconMode=1; 00047 00048 /** 00049 * Wrapping the title in a link, if applicable. 00050 * 00051 * @param string Title, ready for output. 00052 * @param array The "record" 00053 * @return string Wrapping title string. 00054 */ 00055 function wrapTitle($title,$v) { 00056 $title = htmlspecialchars($title); 00057 00058 if ($this->ext_isLinkable($v)) { 00059 $aOnClick = 'return jumpToUrl(\'?editorNo='.$GLOBALS['SOBE']->browser->editorNo.'&expandFolder='.rawurlencode($v['path']).'\');'; 00060 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>'; 00061 } else { 00062 return '<span class="typo3-dimmed">'.$title.'</span>'; 00063 } 00064 } 00065 00066 /** 00067 * Returns true if the input "record" contains a folder which can be linked. 00068 * 00069 * @param array Array with information about the folder element. Contains keys like title, uid, path, _title 00070 * @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 00071 */ 00072 function ext_isLinkable($v) { 00073 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']); 00074 if ($GLOBALS['SOBE']->browser->act=='magic') return 1; //$webpath='web'; // The web/non-web path does not matter if the mode is 'magic' 00075 00076 if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web') { 00077 return 0; 00078 } 00079 return 1; 00080 } 00081 00082 /** 00083 * Wrap the plus/minus icon in a link 00084 * 00085 * @param string HTML string to wrap, probably an image tag. 00086 * @param string Command for 'PM' get var 00087 * @param boolean If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark) 00088 * @return string Link-wrapped input string 00089 * @access private 00090 */ 00091 function PM_ATagWrap($icon,$cmd,$bMark='') { 00092 if ($bMark) { 00093 $anchor = '#'.$bMark; 00094 $name=' name="'.$bMark.'"'; 00095 } 00096 $aOnClick = 'return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');'; 00097 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>'; 00098 } 00099 00100 /** 00101 * Print tree. 00102 * 00103 * @param mixed Input tree array. If not array, then $this->tree is used. 00104 * @return string HTML output of the tree. 00105 */ 00106 function printTree($treeArr='') { 00107 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']); 00108 00109 if (!is_array($treeArr)) $treeArr=$this->tree; 00110 00111 $out=''; 00112 $c=0; 00113 00114 // Traverse rows for the tree and print them into table rows: 00115 foreach($treeArr as $k => $v) { 00116 $c++; 00117 $bgColor=' class="'.(($c+1)%2 ? 'bgColor' : 'bgColor-10').'"'; 00118 $out.='<tr'.$bgColor.'><td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd_cs($v['row']['title'],$titleLen),$v['row']).'</td></tr>'; 00119 } 00120 00121 $out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>'; 00122 return $out; 00123 } 00124 } 00125 00126 00127 /** 00128 * Script Class 00129 * 00130 * @author Kasper Skårhøj <kasper@typo3.com> 00131 * @package TYPO3 00132 * @subpackage tx_rte 00133 */ 00134 class tx_rtehtmlarea_select_image extends browse_links { 00135 var $extKey = 'rtehtmlarea'; 00136 var $content; 00137 00138 public $allowedItems; 00139 public $allowedFileTypes = array(); 00140 protected $defaultClass; 00141 protected $plainMaxWidth; 00142 protected $plainMaxHeight; 00143 protected $magicMaxWidth; 00144 protected $magicMaxHeight; 00145 protected $imgPath; 00146 protected $RTEImageStorageDir; 00147 00148 public $editorNo; 00149 public $sys_language_content; 00150 public $thisConfig; 00151 public $buttonConfig; 00152 00153 protected $imgObj; // Instance object of t3lib_stdGraphic 00154 00155 /** 00156 * Initialisation 00157 * 00158 * @return void 00159 */ 00160 function init() { 00161 global $BACK_PATH; 00162 00163 $this->initVariables(); 00164 $this->initConfiguration(); 00165 $this->initHookObjects(); 00166 00167 // init fileProcessor 00168 $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00169 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']); 00170 00171 $this->allowedItems = $this->getAllowedItems('magic,plain,image', $this->buttonConfig); 00172 reset($this->allowedItems); 00173 if (!in_array($this->act,$this->allowedItems)) { 00174 $this->act = current($this->allowedItems); 00175 } 00176 00177 $this->insertImage(); 00178 00179 // Creating backend template object: 00180 $this->doc = t3lib_div::makeInstance('template'); 00181 $this->doc->bodyTagAdditions = $this->getBodyTagAdditions(); 00182 $this->doc->backPath = $BACK_PATH; 00183 00184 // Load the Prototype library and browse_links.js 00185 $this->doc->getPageRenderer()->loadPrototype(); 00186 $this->doc->loadJavascriptLib('js/browse_links.js'); 00187 00188 $this->doc->getContextMenuCode(); 00189 } 00190 00191 /** 00192 * Initialize class variables 00193 * 00194 * @return void 00195 */ 00196 public function initVariables() { 00197 00198 // Process bparams 00199 $this->bparams = t3lib_div::_GP('bparams'); 00200 $pArr = explode('|', $this->bparams); 00201 $pRteArr = explode(':', $pArr[1]); 00202 $this->editorNo = $pRteArr[0]; 00203 $this->sys_language_content = $pRteArr[1]; 00204 $this->RTEtsConfigParams = $pArr[2]; 00205 if (!$this->editorNo) { 00206 $this->editorNo = t3lib_div::_GP('editorNo'); 00207 $this->sys_language_content = t3lib_div::_GP('sys_language_content'); 00208 $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams'); 00209 } 00210 $this->expandPage = t3lib_div::_GP('expandPage'); 00211 $this->expandFolder = t3lib_div::_GP('expandFolder'); 00212 $pArr[1] = implode(':', array($this->editorNo, $this->sys_language_content)); 00213 $pArr[2] = $this->RTEtsConfigParams; 00214 if ($this->act == 'dragdrop' || $this->act == 'plain') { 00215 $this->allowedFileTypes = explode(',','jpg,jpeg,gif,png'); 00216 } 00217 $pArr[3] = implode(',', $this->allowedFileTypes); 00218 $this->bparams = implode('|', $pArr); 00219 00220 // Find "mode" 00221 $this->mode = t3lib_div::_GP('mode'); 00222 if (!$this->mode) { 00223 $this->mode = 'rte'; 00224 } 00225 // Site URL 00226 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); // Current site url 00227 00228 // the script to link to 00229 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME'); 00230 00231 // Get "act" 00232 $this->act = t3lib_div::_GP('act'); 00233 if (!$this->act) { 00234 $this->act = 'magic'; 00235 } 00236 } 00237 00238 /** 00239 * Initialize hook objects implementing interface t3lib_browseLinksHook 00240 * 00241 * @return void 00242 */ 00243 protected function initHookObjects() { 00244 global $TYPO3_CONF_VARS; 00245 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'])) { 00246 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']['browseLinksHook'] as $classData) { 00247 $processObject = t3lib_div::getUserObj($classData); 00248 if(!($processObject instanceof t3lib_browseLinksHook)) { 00249 throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652); 00250 } 00251 $parameters = array(); 00252 $processObject->init($this, $parameters); 00253 $this->hookObjects[] = $processObject; 00254 } 00255 } 00256 } 00257 00258 /** 00259 * Provide the additional parameters to be included in the template body tag 00260 * 00261 * @return string the body tag additions 00262 */ 00263 public function getBodyTagAdditions() { 00264 return 'onload="initEventListeners();"'; 00265 } 00266 00267 /** 00268 * Get the path to the folder where RTE images are stored 00269 * 00270 * @return string the path to the folder where RTE images are stored 00271 */ 00272 protected function getRTEImageStorageDir() { 00273 return ($this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir']); 00274 } 00275 00276 /** 00277 * Insert the image in the editing area 00278 * 00279 * @return void 00280 */ 00281 protected function insertImage() { 00282 if (t3lib_div::_GP('insertImage')) { 00283 $filepath = t3lib_div::_GP('insertImage'); 00284 $imgInfo = $this->getImageInfo($filepath); 00285 switch ($this->act) { 00286 case 'magic': 00287 $this->insertMagicImage($filepath, $imgInfo); 00288 exit; 00289 break; 00290 case 'plain': 00291 $this->insertPlainImage($imgInfo); 00292 exit; 00293 break; 00294 default: 00295 // Call hook 00296 foreach ($this->hookObjects as $hookObject) { 00297 if (method_exists($hookObject, "insertElement")) { 00298 $hookObject->insertElement($this->act); 00299 } 00300 } 00301 break; 00302 } 00303 } 00304 } 00305 00306 /** 00307 * Get the information on the image file identified its path 00308 * 00309 * @param string $filepath: the path to the image file 00310 * 00311 * @return array a 4-elements information array about the file 00312 */ 00313 public function getImageInfo($filepath) { 00314 $this->imgObj = t3lib_div::makeInstance('t3lib_stdGraphic'); 00315 $this->imgObj->init(); 00316 $this->imgObj->mayScaleUp = 0; 00317 $this->imgObj->tempPath = PATH_site.$this->imgObj->tempPath; 00318 return $this->imgObj->getImageDimensions($filepath); 00319 } 00320 00321 /** 00322 * Insert a magic image 00323 * 00324 * @param string $filepath: the path to the image file 00325 * @param array $imgInfo: a 4-elements information array about the file 00326 * @param string $altText: text for the alt attribute of the image 00327 * @param string $titleText: text for the title attribute of the image 00328 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag 00329 * @return void 00330 */ 00331 public function insertMagicImage($filepath, $imgInfo, $altText='', $titleText='', $additionalParams='') { 00332 if (is_array($imgInfo) && count($imgInfo) == 4) { 00333 if ($this->RTEImageStorageDir) { 00334 $fI = pathinfo($imgInfo[3]); 00335 $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00336 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']); 00337 $destPath =PATH_site.$this->RTEImageStorageDir; 00338 if (@is_dir($destPath)) { 00339 $destName = $fileFunc->getUniqueName($basename,$destPath); 00340 @copy($imgInfo[3],$destName); 00341 t3lib_div::fixPermissions($destName); 00342 $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'), 0, $this->magicMaxWidth); 00343 $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'), 0, $this->magicMaxHeight); 00344 if (!$cWidth) $cWidth = $this->magicMaxWidth; 00345 if (!$cHeight) $cHeight = $this->magicMaxHeight; 00346 00347 $imgI = $this->imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m'); // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0) 00348 if ($imgI[3]) { 00349 $fI=pathinfo($imgI[3]); 00350 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension']; 00351 $destName = $fileFunc->getUniqueName($mainBase,$destPath); 00352 @copy($imgI[3],$destName); 00353 t3lib_div::fixPermissions($destName); 00354 $destName = dirname($destName).'/'.rawurlencode(basename($destName)); 00355 $iurl = $this->siteURL.substr($destName,strlen(PATH_site)); 00356 $this->imageInsertJS($iurl, $imgI[0], $imgI[1], $altText, $titleText, $additionalParams); 00357 } else { 00358 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); 00359 } 00360 } else { 00361 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); 00362 } 00363 } else { 00364 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); 00365 } 00366 } else { 00367 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); 00368 } 00369 } 00370 00371 /** 00372 * Insert a plain image 00373 * 00374 * @param array $imgInfo: a 4-elements information array about the file 00375 * @param string $altText: text for the alt attribute of the image 00376 * @param string $titleText: text for the title attribute of the image 00377 * @param string $additionalParams: text representing more HTML attributes to be added on the img tag 00378 * @return void 00379 */ 00380 public function insertPlainImage($imgInfo, $altText='', $titleText='', $additionalParams='') { 00381 if (is_array($imgInfo) && count($imgInfo)==4) { 00382 $iurl = $this->siteURL.substr($imgInfo[3],strlen(PATH_site)); 00383 $this->imageInsertJS($iurl, $imgInfo[0], $imgInfo[1], $altText, $titleText, $additionalParams); 00384 } 00385 } 00386 00387 /** 00388 * Echo the HTML page and JS that will insert the image 00389 * 00390 * @param string $url: the url of the image 00391 * @param integer $width: the width of the image 00392 * @param integer $height: the height of the image 00393 * @param string $altText: text for the alt attribute of the image 00394 * @param string $titleText: text for the title attribute of the image 00395 * @param string $additionalParams: text representing more html attributes to be added on the img tag 00396 * @return void 00397 */ 00398 protected function imageInsertJS($url, $width, $height, $altText='', $titleText='', $additionalParams='') { 00399 echo' 00400 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 00401 <html> 00402 <head> 00403 <title>Untitled</title> 00404 <script type="text/javascript"> 00405 /*<![CDATA[*/ 00406 var plugin = window.parent.RTEarea["' . $this->editorNo . '"].editor.getPlugin("TYPO3Image"); 00407 function insertImage(file,width,height,alt,title,additionalParams) { 00408 plugin.insertImage(\'<img src="\'+file+\'" width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'"\'' . ($this->defaultClass?('+\' class="'.$this->defaultClass.'"\''):'') . 00409 '+(alt?\' alt="\'+alt+\'"\':\'\')+(title?\' title="\'+title+\'"\':\'\')+(additionalParams?\' \'+additionalParams:\'\')+\' />\'); 00410 } 00411 /*]]>*/ 00412 </script> 00413 </head> 00414 <body> 00415 <script type="text/javascript"> 00416 /*<![CDATA[*/ 00417 insertImage('.t3lib_div::quoteJSvalue($url,1).','.$width.','.$height.','.t3lib_div::quoteJSvalue($altText,1).','.t3lib_div::quoteJSvalue($titleText,1).','.t3lib_div::quoteJSvalue($additionalParams, 1).'); 00418 /*]]>*/ 00419 </script> 00420 </body> 00421 </html>'; 00422 } 00423 00424 /** 00425 * Generate JS code to be used on the image insert/modify dialogue 00426 * 00427 * @param string $act: the action to be performed 00428 * @param string $editorNo: the number of the RTE instance on the page 00429 * @param string $sys_language_content: the language of the content element 00430 * 00431 * @return string the generated JS code 00432 */ 00433 function getJSCode($act, $editorNo, $sys_language_content) { 00434 global $LANG, $TYPO3_CONF_VARS; 00435 00436 $removedProperties = array(); 00437 if (is_array($this->buttonConfig['properties.'])) { 00438 if ($this->buttonConfig['properties.']['removeItems']) { 00439 $removedProperties = t3lib_div::trimExplode(',',$this->buttonConfig['properties.']['removeItems'],1); 00440 } 00441 } 00442 00443 if ($this->thisConfig['classesImage']) { 00444 $classesImageArray = t3lib_div::trimExplode(',', $this->thisConfig['classesImage'], 1); 00445 $classesImageJSOptions = '<option value=""></option>'; 00446 foreach ($classesImageArray as $class) { 00447 $classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>'; 00448 } 00449 } 00450 00451 $lockPlainWidth = 'false'; 00452 $lockPlainHeight = 'false'; 00453 if (is_array($this->thisConfig['proc.']) && $this->thisConfig['proc.']['plainImageMode']) { 00454 $plainImageMode = $this->thisConfig['proc.']['plainImageMode']; 00455 $lockPlainWidth = ($plainImageMode == 'lockDimensions')?'true':'false'; 00456 $lockPlainHeight = ($lockPlainWidth || $plainImageMode == 'lockRatio' || ($plainImageMode == 'lockRatioWhenSmaller'))?'true':'false'; 00457 } 00458 00459 $JScode=' 00460 var plugin = window.parent.RTEarea["' . $editorNo . '"].editor.getPlugin("TYPO3Image"); 00461 var HTMLArea = window.parent.HTMLArea; 00462 function initEventListeners() { 00463 if (Ext.isWebKit) { 00464 Ext.EventManager.addListener(window.document.body, "dragend", plugin.onDrop, plugin, { single: true }); 00465 } 00466 } 00467 function jumpToUrl(URL,anchor) { 00468 var add_act = URL.indexOf("act=")==-1 ? "&act='.$act.'" : ""; 00469 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$editorNo.'" : ""; 00470 var add_sys_language_content = URL.indexOf("sys_language_content=")==-1 ? "&sys_language_content='.$sys_language_content.'" : ""; 00471 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams).'"; 00472 00473 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : ""; 00474 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : ""; 00475 00476 var theLocation = URL+add_act+add_editorNo+add_sys_language_content+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:""); 00477 window.location.href = theLocation; 00478 return false; 00479 } 00480 function insertImage(file,width,height) { 00481 plugin.insertImage(\'<img src="\'+file+\'"' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):'') . ' width="\'+parseInt(width)+\'" height="\'+parseInt(height)+\'" />\'); 00482 } 00483 function launchView(url) { 00484 var thePreviewWindow=""; 00485 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"); 00486 if (thePreviewWindow && thePreviewWindow.focus) { 00487 thePreviewWindow.focus(); 00488 } 00489 } 00490 function getCurrentImageRef() { 00491 if (plugin.image) { 00492 return plugin.image; 00493 } else { 00494 return null; 00495 } 00496 } 00497 function printCurrentImageOptions() { 00498 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . '; 00499 if (classesImage) var styleSelector=\'<select id="iClass" name="iClass" style="width:140px;">' . $classesImageJSOptions . '</select>\'; 00500 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>\'; 00501 if (plugin.getButton("Language")) { 00502 var languageSelector = \'<select id="iLang" name="iLang">\'; 00503 plugin.getButton("Language").getStore().each(function (record) { 00504 languageSelector +=\'<option value="\' + record.get("value") + \'">\' + record.get("text") + \'</option>\'; 00505 }); 00506 languageSelector += \'</select>\'; 00507 } 00508 var bgColor=\' class="bgColor4"\'; 00509 var sz=""; 00510 sz+=\'<table border="0" cellpadding="1" cellspacing="1"><form action="" name="imageData">\'; 00511 '.(in_array('class', $removedProperties)?'':' 00512 if(classesImage) { 00513 sz+=\'<tr><td\'+bgColor+\'><label for="iClass">'.$LANG->getLL('class').': </label></td><td>\'+styleSelector+\'</td></tr>\'; 00514 }') 00515 .(in_array('width', $removedProperties)?'':' 00516 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $lockPlainWidth .')) { 00517 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>\'; 00518 }') 00519 .(in_array('height', $removedProperties)?'':' 00520 if (!(selectedImageRef && selectedImageRef.src.indexOf("RTEmagic") == -1 && '. $lockPlainHeight .')) { 00521 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>\'; 00522 }') 00523 .(in_array('border', $removedProperties)?'':' 00524 sz+=\'<tr><td\'+bgColor+\'><label for="iBorder">'.$LANG->getLL('border').': </label></td><td><input type="checkbox" id="iBorder" name="iBorder" value="1" /></td></tr>\';') 00525 .(in_array('float', $removedProperties)?'':' 00526 sz+=\'<tr><td\'+bgColor+\'><label for="iFloat">'.$LANG->getLL('float').': </label></td><td>\'+floatSelector+\'</td></tr>\';') 00527 .(in_array('paddingTop', $removedProperties)?'':' 00528 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>\';') 00529 .(in_array('paddingRight', $removedProperties)?'':' 00530 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>\';') 00531 .(in_array('paddingBottom', $removedProperties)?'':' 00532 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>\';') 00533 .(in_array('paddingLeft', $removedProperties)?'':' 00534 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>\';') 00535 .(in_array('title', $removedProperties)?'':' 00536 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>\';') 00537 .(in_array('alt', $removedProperties)?'':' 00538 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>\';') 00539 .(in_array('lang', $removedProperties)?'':' 00540 if (plugin.getButton("Language")) { 00541 sz+=\'<tr><td\'+bgColor+\'><label for="iLang">\' + plugin.editor.getPlugin("Language").localize(\'Language-Tooltip\') + \': </label></td><td>\' + languageSelector + \'</td></tr>\'; 00542 }') 00543 .(in_array('clickenlarge', $removedProperties)?'':' 00544 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>\';').' 00545 sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\'; 00546 sz+=\'</form></table>\'; 00547 return sz; 00548 } 00549 function setImageProperties() { 00550 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . '; 00551 if (selectedImageRef) { 00552 if (document.imageData.iWidth) { 00553 if (document.imageData.iWidth.value && parseInt(document.imageData.iWidth.value)) { 00554 selectedImageRef.style.width = ""; 00555 selectedImageRef.width = parseInt(document.imageData.iWidth.value); 00556 } 00557 } 00558 if (document.imageData.iHeight) { 00559 if (document.imageData.iHeight.value && parseInt(document.imageData.iHeight.value)) { 00560 selectedImageRef.style.height = ""; 00561 selectedImageRef.height = parseInt(document.imageData.iHeight.value); 00562 } 00563 } 00564 if (document.imageData.iPaddingTop) { 00565 if (document.imageData.iPaddingTop.value != "" && !isNaN(parseInt(document.imageData.iPaddingTop.value))) { 00566 selectedImageRef.style.paddingTop = parseInt(document.imageData.iPaddingTop.value) + "px"; 00567 } else { 00568 selectedImageRef.style.paddingTop = ""; 00569 } 00570 } 00571 if (document.imageData.iPaddingRight) { 00572 if (document.imageData.iPaddingRight.value != "" && !isNaN(parseInt(document.imageData.iPaddingRight.value))) { 00573 selectedImageRef.style.paddingRight = parseInt(document.imageData.iPaddingRight.value) + "px"; 00574 } else { 00575 selectedImageRef.style.paddingRight = ""; 00576 } 00577 } 00578 if (document.imageData.iPaddingBottom) { 00579 if (document.imageData.iPaddingBottom.value != "" && !isNaN(parseInt(document.imageData.iPaddingBottom.value))) { 00580 selectedImageRef.style.paddingBottom = parseInt(document.imageData.iPaddingBottom.value) + "px"; 00581 } else { 00582 selectedImageRef.style.paddingBottom = ""; 00583 } 00584 } 00585 if (document.imageData.iPaddingLeft) { 00586 if (document.imageData.iPaddingLeft.value != "" && !isNaN(parseInt(document.imageData.iPaddingLeft.value))) { 00587 selectedImageRef.style.paddingLeft = parseInt(document.imageData.iPaddingLeft.value) + "px"; 00588 } else { 00589 selectedImageRef.style.paddingLeft = ""; 00590 } 00591 } 00592 if (document.imageData.iTitle) { 00593 selectedImageRef.title=document.imageData.iTitle.value; 00594 } 00595 if (document.imageData.iAlt) { 00596 selectedImageRef.alt=document.imageData.iAlt.value; 00597 } 00598 if (document.imageData.iBorder) { 00599 selectedImageRef.style.borderStyle = ""; 00600 selectedImageRef.style.borderWidth = ""; 00601 selectedImageRef.style.border = ""; // this statement ignored by Mozilla 1.3.1 00602 selectedImageRef.style.borderTopStyle = ""; 00603 selectedImageRef.style.borderRightStyle = ""; 00604 selectedImageRef.style.borderBottomStyle = ""; 00605 selectedImageRef.style.borderLeftStyle = ""; 00606 selectedImageRef.style.borderTopWidth = ""; 00607 selectedImageRef.style.borderRightWidth = ""; 00608 selectedImageRef.style.borderBottomWidth = ""; 00609 selectedImageRef.style.borderLeftWidth = ""; 00610 if(document.imageData.iBorder.checked) { 00611 selectedImageRef.style.borderStyle = "solid"; 00612 selectedImageRef.style.borderWidth = "thin"; 00613 } 00614 selectedImageRef.removeAttribute("border"); 00615 } 00616 if (document.imageData.iFloat) { 00617 var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value; 00618 if (document.all) { 00619 selectedImageRef.style.styleFloat = iFloat ? iFloat : ""; 00620 } else { 00621 selectedImageRef.style.cssFloat = iFloat ? iFloat : ""; 00622 } 00623 } 00624 if (classesImage && document.imageData.iClass) { 00625 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value; 00626 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value)) { 00627 selectedImageRef.className = iClass; 00628 } else { 00629 selectedImageRef.className = ""; 00630 } 00631 } 00632 if (document.imageData.iLang) { 00633 var iLang = document.imageData.iLang.options[document.imageData.iLang.selectedIndex].value; 00634 var languageObject = plugin.editor.getPlugin("Language"); 00635 if (iLang || languageObject.getLanguageAttribute(selectedImageRef)) { 00636 languageObject.setLanguageAttributes(selectedImageRef, iLang); 00637 } else { 00638 languageObject.setLanguageAttributes(selectedImageRef, "none"); 00639 } 00640 } 00641 if (document.imageData.iClickEnlarge) { 00642 if (document.imageData.iClickEnlarge.checked) { 00643 selectedImageRef.setAttribute("clickenlarge","1"); 00644 } else { 00645 selectedImageRef.removeAttribute("clickenlarge"); 00646 } 00647 } 00648 plugin.close(); 00649 } 00650 return false; 00651 } 00652 function insertImagePropertiesInForm() { 00653 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . '; 00654 if (selectedImageRef) { 00655 var styleWidth, styleHeight, padding; 00656 if (document.imageData.iWidth) { 00657 styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width; 00658 styleWidth = parseInt(styleWidth); 00659 if (!(isNaN(styleWidth) || styleWidth == 0)) { 00660 document.imageData.iWidth.value = styleWidth; 00661 } 00662 } 00663 if (document.imageData.iHeight) { 00664 styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height; 00665 styleHeight = parseInt(styleHeight); 00666 if (!(isNaN(styleHeight) || styleHeight == 0)) { 00667 document.imageData.iHeight.value = styleHeight; 00668 } 00669 } 00670 if (document.imageData.iPaddingTop) { 00671 var padding = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace; 00672 var padding = parseInt(padding); 00673 if (isNaN(padding) || padding <= 0) { padding = ""; } 00674 document.imageData.iPaddingTop.value = padding; 00675 } 00676 if (document.imageData.iPaddingRight) { 00677 padding = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace; 00678 var padding = parseInt(padding); 00679 if (isNaN(padding) || padding <= 0) { padding = ""; } 00680 document.imageData.iPaddingRight.value = padding; 00681 } 00682 if (document.imageData.iPaddingBottom) { 00683 var padding = selectedImageRef.style.paddingBottom ? selectedImageRef.style.paddingBottom : selectedImageRef.vspace; 00684 var padding = parseInt(padding); 00685 if (isNaN(padding) || padding <= 0) { padding = ""; } 00686 document.imageData.iPaddingBottom.value = padding; 00687 } 00688 if (document.imageData.iPaddingLeft) { 00689 var padding = selectedImageRef.style.paddingLeft ? selectedImageRef.style.paddingLeft : selectedImageRef.hspace; 00690 var padding = parseInt(padding); 00691 if (isNaN(padding) || padding <= 0) { padding = ""; } 00692 document.imageData.iPaddingLeft.value = padding; 00693 } 00694 if (document.imageData.iTitle) { 00695 document.imageData.iTitle.value = selectedImageRef.title; 00696 } 00697 if (document.imageData.iAlt) { 00698 document.imageData.iAlt.value = selectedImageRef.alt; 00699 } 00700 if (document.imageData.iBorder) { 00701 if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) { 00702 document.imageData.iBorder.checked = 1; 00703 } 00704 } 00705 if (document.imageData.iFloat) { 00706 var fObj=document.imageData.iFloat; 00707 var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat); 00708 var l=fObj.length; 00709 for (var a=0;a<l;a++) { 00710 if (fObj.options[a].value == value) { 00711 fObj.selectedIndex = a; 00712 } 00713 } 00714 } 00715 if (classesImage && document.imageData.iClass) { 00716 var fObj=document.imageData.iClass; 00717 var value=selectedImageRef.className; 00718 var l=fObj.length; 00719 for (var a=0;a < l; a++) { 00720 if (fObj.options[a].value == value) { 00721 fObj.selectedIndex = a; 00722 } 00723 } 00724 } 00725 if (document.imageData.iLang) { 00726 var fObj=document.imageData.iLang; 00727 var value=plugin.editor.getPlugin("Language").getLanguageAttribute(selectedImageRef); 00728 for (var i = 0, n = fObj.length; i < n; i++) { 00729 if (fObj.options[i].value == value) { 00730 fObj.selectedIndex = i; 00731 if (i) { 00732 fObj.options[0].text = plugin.editor.getPlugin("Language").localize("Remove language mark"); 00733 } 00734 } 00735 } 00736 } 00737 if (document.imageData.iClickEnlarge) { 00738 if (selectedImageRef.getAttribute("clickenlarge") == "1") { 00739 document.imageData.iClickEnlarge.checked = 1; 00740 } else { 00741 document.imageData.iClickEnlarge.checked = 0; 00742 } 00743 } 00744 return false; 00745 } 00746 } 00747 00748 var selectedImageRef = getCurrentImageRef();'; // Setting this to a reference to the image object. 00749 return $JScode; 00750 } 00751 00752 /** 00753 * Session data for this class can be set from outside with this method. 00754 * Call after init() 00755 * 00756 * @param array Session data array 00757 * @return array Session data and boolean which indicates that data needs to be stored in session because it's changed 00758 */ 00759 function processSessionData($data) { 00760 $store = false; 00761 00762 if ($this->act != 'image') { 00763 if (isset($this->act)) { 00764 $data['act'] = $this->act; 00765 $store = true; 00766 } else { 00767 $this->act = $data['act']; 00768 } 00769 } 00770 00771 if (isset($this->expandFolder)) { 00772 $data['expandFolder'] = $this->expandFolder; 00773 $store = true; 00774 } else { 00775 $this->expandFolder = $data['expandFolder']; 00776 } 00777 00778 return array($data, $store); 00779 } 00780 00781 /** 00782 * [Describe function...] 00783 * 00784 * @return [type] ... 00785 */ 00786 function main_rte() { 00787 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER; 00788 00789 // Starting content: 00790 $this->content = $this->doc->startPage($LANG->getLL('Insert Image',1)); 00791 00792 // Making menu in top: 00793 $menuDef = array(); 00794 if (in_array('image',$this->allowedItems) && ($this->act=='image' || t3lib_div::_GP('cWidth'))) { 00795 $menuDef['page']['isActive'] = $this->act=='image'; 00796 $menuDef['page']['label'] = $LANG->getLL('currentImage',1); 00797 $menuDef['page']['url'] = '#'; 00798 $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&bparams='.$this->bparams.'\');return false;"'; 00799 } 00800 if (in_array('magic',$this->allowedItems)){ 00801 $menuDef['file']['isActive'] = $this->act=='magic'; 00802 $menuDef['file']['label'] = $LANG->getLL('magicImage',1); 00803 $menuDef['file']['url'] = '#'; 00804 $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&bparams='.$this->bparams.'\');return false;"'; 00805 } 00806 if (in_array('plain',$this->allowedItems)) { 00807 $menuDef['url']['isActive'] = $this->act=='plain'; 00808 $menuDef['url']['label'] = $LANG->getLL('plainImage',1); 00809 $menuDef['url']['url'] = '#'; 00810 $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&bparams='.$this->bparams.'\');return false;"'; 00811 } 00812 if (in_array('dragdrop',$this->allowedItems)) { 00813 $menuDef['mail']['isActive'] = $this->act=='dragdrop'; 00814 $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1); 00815 $menuDef['mail']['url'] = '#'; 00816 $menuDef['mail']['addParams'] = 'onClick="jumpToUrl(\'?act=dragdrop&bparams='.$this->bparams.'\');return false;"'; 00817 } 00818 00819 // Call hook for extra options 00820 foreach ($this->hookObjects as $hookObject) { 00821 $menuDef = $hookObject->modifyMenuDefinition($menuDef); 00822 } 00823 00824 $this->content .= $this->doc->getTabMenuRaw($menuDef); 00825 00826 switch($this->act) { 00827 case 'image': 00828 $JScode = ' 00829 document.write(printCurrentImageOptions()); 00830 insertImagePropertiesInForm();'; 00831 $this->content.= '<br />'.$this->doc->wrapScriptTags($JScode); 00832 break; 00833 case 'plain': 00834 case 'magic': 00835 // Adding upload form, if allowed 00836 $this->content .= $this->insertUploadForm($this->expandFolder); 00837 // Getting flag for showing/not showing thumbnails: 00838 $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect'); 00839 if (!$noThumbs) { 00840 // MENU-ITEMS, fetching the setting for thumbnails from File>List module: 00841 $_MOD_MENU = array('displayThumbs' => ''); 00842 $_MCONF['name']='file_list'; 00843 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']); 00844 $addParams = '&act='.$this->act.'&editorNo='.$this->editorNo.'&expandFolder='.rawurlencode($this->expandFolder); 00845 $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>'; 00846 } else { 00847 $thumbNailCheck=''; 00848 } 00849 // Create folder tree: 00850 $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_image_folderTree'); 00851 $tree = $foldertree->getBrowsableTree(); 00852 list(,,$specUid) = explode('_',t3lib_div::_GP('PM')); 00853 $files = $this->expandFolder($foldertree->specUIDmap[$specUid],$this->act=='plain',$noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs']); 00854 $this->content.= '<table border="0" cellpadding="0" cellspacing="0"> 00855 <tr> 00856 <td style="vertical-align: top;">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td> 00857 <td> </td> 00858 <td style="vertical-align: top;">'.$files.'</td> 00859 </tr> 00860 </table> 00861 <br />'.$thumbNailCheck; 00862 // Add help message 00863 $helpMessage = $this->getHelpMessage($this->act); 00864 if ($helpMessage) { 00865 $this->content .= $this->getMsgBox($helpMessage); 00866 } 00867 break; 00868 case 'dragdrop': 00869 $foldertree = t3lib_div::makeInstance('TBE_FolderTree'); 00870 $foldertree->thisScript=$this->thisScript; 00871 $foldertree->ext_noTempRecyclerDirs = true; 00872 $tree = $foldertree->getBrowsableTree(); 00873 list(,,$specUid) = explode('_',t3lib_div::_GP('PM')); 00874 $files = $this->TBE_dragNDrop($foldertree->specUIDmap[$specUid], implode(',', $this->allowedFileTypes)); 00875 $this->content.= '<table border="0" cellpadding="0" cellspacing="0"> 00876 <tr> 00877 <td style="vertical-align: top;">'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td> 00878 <td> </td> 00879 <td style="vertical-align: top;">'.$files.'</td> 00880 </tr> 00881 </table>'; 00882 break; 00883 default: 00884 // Call hook 00885 foreach ($this->hookObjects as $hookObject) { 00886 $this->content.= $hookObject->getTab($this->act); 00887 } 00888 break; 00889 } 00890 $this->content.= $this->doc->endPage(); 00891 $this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode($this->act, $this->editorNo, $this->sys_language_content); 00892 $this->content = $this->doc->insertStylesAndJS($this->content); 00893 return $this->content; 00894 } 00895 00896 /** 00897 * Create upload/create folder forms, if a path is given 00898 * 00899 * @param string $folderPath: the selected path , if any 00900 * 00901 * @return string the html content for the upload form 00902 */ 00903 protected function insertUploadForm($folderPath) { 00904 $content = ''; 00905 if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB') && !$this->readOnly && count($GLOBALS['FILEMOUNTS'])) { 00906 $path = $folderPath; 00907 if (!$path || !@is_dir($path)) { 00908 // The closest TEMP-path is found 00909 $path = $this->fileProcessor->findTempFolder().'/'; 00910 } 00911 if ($path!='/' && @is_dir($path)) { 00912 $uploadForm=$this->uploadForm($path); 00913 $createFolder=$this->createFolder($path); 00914 } else { 00915 $createFolder=''; 00916 $uploadForm=''; 00917 } 00918 $content .= $uploadForm; 00919 if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) { 00920 $content.=$createFolder; 00921 } 00922 } 00923 return $content; 00924 } 00925 00926 /*************************** 00927 * 00928 * OTHER FUNCTIONS: 00929 * 00930 ***************************/ 00931 /** 00932 * @param [type] $expandFolder: ... 00933 * @param [type] $plainFlag: ... 00934 * @return [type] ... 00935 */ 00936 function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) { 00937 global $LANG, $BE_USER, $BACK_PATH; 00938 00939 $expandFolder = $expandFolder ? $expandFolder :t3lib_div::_GP('expandFolder'); 00940 $out=''; 00941 00942 if ($expandFolder && $this->checkFolder($expandFolder)) { 00943 $files = t3lib_div::getFilesInDir($expandFolder,($plainFlag?'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1); // $extensionList="",$prependPath=0,$order="") 00944 if (is_array($files)) { 00945 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files))); 00946 00947 $titleLen = intval($BE_USER->uc['titleLen']); 00948 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />'; 00949 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen)); 00950 $out.='<span class="nobr">'.$picon.'</span><br />'; 00951 00952 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic'); 00953 $imgObj->init(); 00954 $imgObj->mayScaleUp=0; 00955 $imgObj->tempPath=PATH_site.$imgObj->tempPath; 00956 00957 $lines=array(); 00958 foreach ($files as $filepath) { 00959 $fI=pathinfo($filepath); 00960 00961 $origFile = t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site))); 00962 $iurl = $this->siteURL.$origFile; 00963 $imgInfo = $imgObj->getImageDimensions($filepath); 00964 // File icon: 00965 $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension'])); 00966 $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1); 00967 $size=' ('.t3lib_div::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')'; 00968 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />'; 00969 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo.'&insertImage='.rawurlencode($filepath).'\');">'; 00970 $ATag_e='</a>'; 00971 if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth) || ($imgInfo[1] > $this->plainMaxHeight))) { 00972 $ATag=''; 00973 $ATag_e=''; 00974 $ATag2=''; 00975 $ATag2_e=''; 00976 } else { 00977 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">'; 00978 $ATag2_e='</a>'; 00979 } 00980 00981 $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)).$ATag_e; 00982 00983 00984 $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.' </td><td nowrap="nowrap">'.$pDim.' </td></tr>'; 00985 $lines[]='<tr><td colspan="2">'.($noThumbs ? '' : $ATag2.t3lib_BEfunc::getThumbNail($this->doc->backPath.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e). 00986 '</td></tr>'; 00987 $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>'; 00988 } 00989 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>'; 00990 } 00991 } 00992 return $out; 00993 } 00994 00995 /** 00996 * For RTE: This displays all IMAGES (gif,png,jpg) (from extensionList) from folder. Thumbnails are shown for images. 00997 * This listing is of images located in the web-accessible paths ONLY - the listing is for drag-n-drop use in the RTE 00998 * 00999 * @param string The folder path to expand 01000 * @param string List of fileextensions to show 01001 * @return string HTML output 01002 */ 01003 function TBE_dragNDrop($expandFolder=0,$extensionList='') { 01004 global $BACK_PATH; 01005 01006 $expandFolder = $expandFolder ? $expandFolder : t3lib_div::_GP('expandFolder'); 01007 $out=''; 01008 if ($expandFolder && $this->checkFolder($expandFolder)) { 01009 if ($this->isWebFolder($expandFolder)) { 01010 01011 // Read files from directory: 01012 $files = t3lib_div::getFilesInDir($expandFolder,$extensionList,1,1); // $extensionList="",$prependPath=0,$order='') 01013 if (is_array($files)) { 01014 $out.=$this->barheader(sprintf($GLOBALS['LANG']->getLL('files').' (%s):',count($files))); 01015 01016 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']); 01017 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />'; 01018 $picon.=htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($expandFolder),$titleLen)); 01019 $out.=$picon.'<br />'; 01020 01021 // Init row-array: 01022 $lines=array(); 01023 01024 // Add "drag-n-drop" message: 01025 $lines[]=' 01026 <tr> 01027 <td colspan="2">'.$this->getMsgBox($GLOBALS['LANG']->getLL('findDragDrop')).'</td> 01028 </tr>'; 01029 01030 // Traverse files: 01031 foreach ($files as $filepath) { 01032 $fI = pathinfo($filepath); 01033 01034 // URL of image: 01035 $iurl = $this->siteURL.t3lib_div::rawurlencodeFP(substr($filepath,strlen(PATH_site))); 01036 01037 // Show only web-images 01038 if (t3lib_div::inList('gif,jpeg,jpg,png',strtolower($fI['extension']))) { 01039 $imgInfo = @getimagesize($filepath); 01040 $pDim = $imgInfo[0].'x'.$imgInfo[1].' pixels'; 01041 01042 $ficon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension'])); 01043 $size=' ('.t3lib_div::formatSize(filesize($filepath)).'bytes'.($pDim?', '.$pDim:'').')'; 01044 $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$ficon,'width="18" height="16"').' class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />'; 01045 $filenameAndIcon=$icon.htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($filepath),$titleLen)); 01046 01047 if (t3lib_div::_GP('noLimit')) { 01048 $maxW=10000; 01049 $maxH=10000; 01050 } else { 01051 $maxW=380; 01052 $maxH=500; 01053 } 01054 $IW = $imgInfo[0]; 01055 $IH = $imgInfo[1]; 01056 if ($IW>$maxW) { 01057 $IH=ceil($IH/$IW*$maxW); 01058 $IW=$maxW; 01059 } 01060 if ($IH>$maxH) { 01061 $IW=ceil($IW/$IH*$maxH); 01062 $IH=$maxH; 01063 } 01064 01065 // Make row: 01066 $lines[]=' 01067 <tr class="bgColor4"> 01068 <td nowrap="nowrap">'.$filenameAndIcon.' </td> 01069 <td nowrap="nowrap">'. 01070 ($imgInfo[0]!=$IW ? '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('noLimit'=>'1'))).'">'. 01071 '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/icon_warning2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('clickToRedrawFullSize',1).'" alt="" />'. 01072 '</a>':''). 01073 $pDim.' </td> 01074 </tr>'; 01075 // Remove hardcoded border="1" 01076 // Add default class for images 01077 $lines[]=' 01078 <tr> 01079 <td colspan="2"><img src="'.$iurl.'" width="'.$IW.'" height="'.$IH.'" alt=""' . ($this->defaultClass?(' class="'.$this->defaultClass.'"'):''). ' style="cursor:move;" /></td> 01080 </tr>'; 01081 $lines[]=' 01082 <tr> 01083 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td> 01084 </tr>'; 01085 } 01086 } 01087 01088 // Finally, wrap all rows in a table tag: 01089 $out.=' 01090 01091 01092 <!-- 01093 File listing / Drag-n-drop 01094 --> 01095 <table border="0" cellpadding="0" cellspacing="1" id="typo3-dragBox"> 01096 '.implode('',$lines).' 01097 </table>'; 01098 } 01099 } else { 01100 // Print this warning if the folder is NOT a web folder: 01101 $out.=$this->barheader($GLOBALS['LANG']->getLL('files')); 01102 $out.=$this->getMsgBox($GLOBALS['LANG']->getLL('noWebFolder'),'icon_warning2'); 01103 } 01104 } 01105 return $out; 01106 } 01107 01108 /** 01109 * Initializes the configuration variables 01110 * 01111 * @return void 01112 */ 01113 public function initConfiguration() { 01114 $this->thisConfig = $this->getRTEConfig(); 01115 $this->buttonConfig = $this->getButtonConfig(); 01116 $this->imgPath = $this->getImgPath(); 01117 $this->RTEImageStorageDir = $this->getRTEImageStorageDir(); 01118 $this->defaultClass = $this->getDefaultClass(); 01119 $this->setMaximumImageDimensions(); 01120 } 01121 01122 /** 01123 * Get the RTE configuration from Page TSConfig 01124 * 01125 * @return array RTE configuration array 01126 */ 01127 protected function getRTEConfig() { 01128 global $BE_USER; 01129 01130 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams); 01131 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5])); 01132 return t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]); 01133 } 01134 01135 /** 01136 * Get the path of the image to be inserted or modified 01137 * 01138 * @return string path to the image 01139 */ 01140 protected function getImgPath() { 01141 $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams); 01142 return $RTEtsConfigParts[6]; 01143 } 01144 01145 /** 01146 * Get the configuration of the image button 01147 * 01148 * @return array the configuration array of the image button 01149 */ 01150 protected function getButtonConfig() { 01151 return ((is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) ? $this->thisConfig['buttons.']['image.'] : array()); 01152 } 01153 01154 /** 01155 * Get the allowed items or tabs 01156 * 01157 * @param string $items: initial list of possible items 01158 * @return array the allowed items 01159 */ 01160 public function getAllowedItems($items) { 01161 $allowedItems = explode(',', $items); 01162 $clientInfo = t3lib_div::clientInfo(); 01163 if ($clientInfo['BROWSER'] !== 'opera') { 01164 $allowedItems[] = 'dragdrop'; 01165 } 01166 // Call hook for extra options 01167 foreach ($this->hookObjects as $hookObject) { 01168 $allowedItems = $hookObject->addAllowedItems($allowedItems); 01169 } 01170 // Remove tab "image" if there is no current image 01171 if ($this->act !== 'image') { 01172 $allowedItems = array_diff($allowedItems, array('image')); 01173 } 01174 // Remove options according to RTE configuration 01175 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) { 01176 $allowedItems = array_diff($allowedItems, t3lib_div::trimExplode(',', $this->buttonConfig['options.']['removeItems'], 1)); 01177 } else { 01178 $allowedItems = array_diff($allowedItems, t3lib_div::trimExplode(',', $this->thisConfig['blindImageOptions'], 1)); 01179 } 01180 return $allowedItems; 01181 } 01182 01183 /** 01184 * Get the default image class 01185 * 01186 * @return string the default class, if any 01187 */ 01188 protected function getDefaultClass() { 01189 $defaultClass = ''; 01190 if (is_array($this->buttonConfig['properties.'])) { 01191 if (is_array($this->buttonConfig['properties.']['class.']) && trim($this->buttonConfig['properties.']['class.']['default'])) { 01192 $defaultClass = trim($this->buttonConfig['properties.']['class.']['default']); 01193 } 01194 } 01195 return $defaultClass; 01196 } 01197 01198 /** 01199 * Set variables for maximum image dimensions 01200 * 01201 * @return void 01202 */ 01203 protected function setMaximumImageDimensions() { 01204 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) { 01205 if ($this->buttonConfig['options.']['plain.']['maxWidth']) $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth']; 01206 if ($this->buttonConfig['options.']['plain.']['maxHeight']) $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight']; 01207 } 01208 if (!$this->plainMaxWidth) $this->plainMaxWidth = 640; 01209 if (!$this->plainMaxHeight) $this->plainMaxHeight = 680; 01210 if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) { 01211 if ($this->buttonConfig['options.']['magic.']['maxWidth']) $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth']; 01212 if ($this->buttonConfig['options.']['magic.']['maxHeight']) $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight']; 01213 } 01214 // 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 01215 if (!$this->magicMaxWidth) $this->magicMaxWidth = 300; 01216 if (!$this->magicMaxHeight) $this->magicMaxHeight = 1000; 01217 } 01218 01219 /** 01220 * Get the help message to be displayed on a given tab 01221 * 01222 * @param string $act: the identifier of the tab 01223 * @return string the text of the message 01224 */ 01225 public function getHelpMessage($act) { 01226 global $LANG; 01227 switch ($act) { 01228 case 'plain': 01229 return sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight); 01230 break; 01231 case 'magic': 01232 return sprintf($LANG->getLL('magicImage_msg')); 01233 break; 01234 default: 01235 return ''; 01236 } 01237 } 01238 } 01239 01240 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php'])) { 01241 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']); 01242 } 01243 01244 ?>
1.8.0