Documentation TYPO3 par Ameos

class.tx_rtehtmlarea_select_image.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
00006 *  (c) 2004-2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.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 ***************************************************************/
00036 require_once(PATH_typo3.'class.browse_links.php');
00037 require_once(PATH_t3lib.'class.t3lib_foldertree.php');
00038 require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
00039 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
00040 
00048 class tx_rtehtmlarea_image_folderTree extends t3lib_folderTree {
00049         var $ext_IconMode=1;
00050 
00058         function wrapTitle($title,$v)   {
00059                 if ($this->ext_isLinkable($v))  {
00060                         $aOnClick = 'return jumpToUrl(\'?editorNo='.$GLOBALS['SOBE']->browser->editorNo.'&expandFolder='.rawurlencode($v['path']).'\');';
00061                         return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
00062                 } else {
00063                         return '<span class="typo3-dimmed">'.$title.'</span>';
00064                 }
00065         }
00066 
00073         function ext_isLinkable($v)     {
00074                 $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']);
00075                 if ($GLOBALS['SOBE']->browser->act=='magic') return 1;  //$webpath='web';       // The web/non-web path does not matter if the mode is 'magic'
00076 
00077                 if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web')  {
00078                         return 0;
00079                 }
00080                 return 1;
00081         }
00082 
00092         function PM_ATagWrap($icon,$cmd,$bMark='')      {
00093                 if ($bMark)     {
00094                         $anchor = '#'.$bMark;
00095                         $name=' name="'.$bMark.'"';
00096                 }
00097                 $aOnClick = 'return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');';
00098                 return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
00099         }
00100 
00107         function printTree($treeArr='') {
00108                 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00109 
00110                 if (!is_array($treeArr))        $treeArr=$this->tree;
00111 
00112                 $out='';
00113                 $c=0;
00114 
00115                         // Traverse rows for the tree and print them into table rows:
00116                 foreach($treeArr as $k => $v) {
00117                         $c++;
00118                         $bgColor=' class="'.(($c+1)%2 ? 'bgColor' : 'bgColor-10').'"';
00119                         $out.='<tr'.$bgColor.'><td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd($v['row']['title'],$titleLen),$v['row']).'</td></tr>';
00120                 }
00121 
00122                 $out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>';
00123                 return $out;
00124         }
00125 }
00126 
00127 
00135 class tx_rtehtmlarea_select_image extends browse_links {
00136         var $extKey = 'rtehtmlarea';
00137         var $content;
00138         var $act;
00139         var $allowedItems;
00140         var $plainMaxWidth;
00141         var $plainMaxHeight;
00142         var $magicMaxWidth;
00143         var $magicMaxHeight;
00144         var $imgPath;
00145         var $classesImageJSOptions;
00146         var $editorNo;
00147         var $buttonConfig = array();
00148         
00154         function init() {
00155                 global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;
00156 
00157                         // Main GPvars:
00158                 $this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
00159                 $this->act = t3lib_div::_GP('act');
00160                 $this->editorNo = t3lib_div::_GP('editorNo');
00161                 $this->expandPage = t3lib_div::_GP('expandPage');
00162                 $this->expandFolder = t3lib_div::_GP('expandFolder');
00163                 
00164                         // Find "mode"
00165                 $this->mode = t3lib_div::_GP('mode');
00166                 if (!$this->mode)       {
00167                         $this->mode='rte';
00168                 }
00169 
00170                         // Site URL
00171                 $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');       // Current site url
00172 
00173                         // the script to link to
00174                 $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
00175                 
00176                 if (!$this->act)        {
00177                         $this->act='magic';
00178                 }
00179                 
00180                 $RTEtsConfigParts = explode(':',t3lib_div::_GP('RTEtsConfigParams'));
00181                 $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
00182                 $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
00183                 $this->imgPath = $RTEtsConfigParts[6];
00184                 
00185                 if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {
00186                         $this->buttonConfig = $this->thisConfig['buttons.']['image.'];
00187                 }
00188                 
00189                 $this->allowedItems = explode(',','magic,plain,dragdrop,image');
00190                 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
00191                         $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
00192                 } else {
00193                         $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindImageOptions'],1));
00194                 }
00195                 reset($this->allowedItems);
00196                 if (!in_array($this->act,$this->allowedItems))  {
00197                         $this->act = current($this->allowedItems);
00198                 }
00199                 
00200                 if ($this->act == 'plain') {
00201                         if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth']) $this->plainMaxWidth = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth'];
00202                         if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight']) $this->plainMaxHeight = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight'];
00203                         if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {
00204                                 if ($this->buttonConfig['options.']['plain.']['maxWidth']) $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];
00205                                 if ($this->buttonConfig['options.']['plain.']['maxHeight']) $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];
00206                         }
00207                         if (!$this->plainMaxWidth) $this->plainMaxWidth = 640;
00208                         if (!$this->plainMaxHeight) $this->plainMaxHeight = 680;
00209                 } elseif ($this->act == 'magic') {
00210                         if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {
00211                                 if ($this->buttonConfig['options.']['magic.']['maxWidth']) $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];
00212                                 if ($this->buttonConfig['options.']['magic.']['maxHeight']) $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];
00213                         }
00214                                 // 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
00215                         if (!$this->magicMaxWidth) $this->magicMaxWidth = 300;
00216                         if (!$this->magicMaxHeight) $this->magicMaxHeight = 1000;
00217                 }
00218                 
00219                 if($this->thisConfig['classesImage']) {
00220                         $classesImageArray = t3lib_div::trimExplode(',',$this->thisConfig['classesImage'],1);
00221                         $this->classesImageJSOptions = '<option value=""></option>';
00222                         reset($classesImageArray);
00223                         while(list(,$class)=each($classesImageArray)) {
00224                                 $this->classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
00225                         }
00226                 }
00227                 
00228                 $this->magicProcess();
00229                 
00230                         // Creating backend template object:
00231                 $this->doc = t3lib_div::makeInstance('template');
00232                 $this->doc->docType= 'xhtml_trans';
00233                 $this->doc->backPath = $BACK_PATH;
00234                 
00235                 $this->getJSCode();
00236         }
00237 
00243         function rteImageStorageDir()   {
00244                 $dir = $this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
00245                 return $dir;
00246         }
00247 
00253         function magicProcess() {
00254                 global $TYPO3_CONF_VARS;
00255 
00256                 if ($this->act=='magic' && t3lib_div::_GP('insertMagicImage'))  {
00257                         $filepath = t3lib_div::_GP('insertMagicImage');
00258 
00259                         $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
00260                         $imgObj->init();
00261                         $imgObj->mayScaleUp=0;
00262                         $imgObj->tempPath=PATH_site.$imgObj->tempPath;
00263 
00264                         $imgInfo = $imgObj->getImageDimensions($filepath);
00265 
00266                         if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir())    {
00267                                 $fI=pathinfo($imgInfo[3]);
00268                                 $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00269                                 $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
00270                                 $destPath =PATH_site.$this->rteImageStorageDir();
00271                                 if (@is_dir($destPath)) {
00272                                         $destName = $fileFunc->getUniqueName($basename,$destPath);
00273                                         @copy($imgInfo[3],$destName);
00274                                         
00275                                         $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);
00276                                         $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'),0,$this->magicMaxHeight);
00277                                         if (!$cWidth)   $cWidth = $this->magicMaxWidth;
00278                                         if (!$cHeight)  $cHeight = $this->magicMaxHeight;
00279                                         
00280                                         $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m');  // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
00281                                         if ($imgI[3])   {
00282                                                 $fI=pathinfo($imgI[3]);
00283                                                 $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
00284                                                 $destName = $fileFunc->getUniqueName($mainBase,$destPath);
00285                                                 @copy($imgI[3],$destName);
00286 
00287                                                 $destName = dirname($destName).'/'.rawurlencode(basename($destName));
00288                                                 $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
00289                                                 echo'
00290 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00291 <html>
00292 <head>
00293         <title>Untitled</title>
00294 </head>
00295 <script language="javascript" type="text/javascript">
00296 /*<![CDATA[*/
00297         var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
00298         var HTMLArea = window.opener.HTMLArea;
00299         function insertImage(file,width,height,origFile)        {
00300                 var styleWidth, styleHeight;
00301                 styleWidth = parseInt(width);
00302                 if (isNaN(styleWidth) || styleWidth == 0) {
00303                         styleWidth = "auto";
00304                 } else {
00305                         styleWidth += "px";
00306                 }
00307                 styleHeight = parseInt(height);
00308                 if (isNaN(styleHeight) || styleHeight == 0) {
00309                         styleHeight = "auto";
00310                 } else {
00311                         styleHeight += "px";
00312                 }
00313                 editor.renderPopup_insertImage(\'<img src="\'+file+\'" style="width: \'+styleWidth+\'; height: \'+styleHeight+\';"'.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?' clickenlargesrc="\'+origFile+\'" clickenlarge="0"':'').' />\');
00314         }
00315 /*]]>*/
00316 </script>
00317 <body>
00318 <script type="text/javascript">
00319 /*<![CDATA[*/
00320         insertImage(\''.$iurl.'\','.$imgI[0].','.$imgI[1].',\''.substr($imgInfo[3],strlen(PATH_site)).'\');
00321 /*]]>*/
00322 </script>
00323 </body>
00324 </html>';
00325                                         }
00326 
00327                                 }
00328                         }
00329                         exit;
00330                 }
00331         }
00332 
00338         function getJSCode()    {
00339                 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
00340 
00341                 $JScode='
00342                         var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
00343                         var HTMLArea = window.opener.HTMLArea;
00344                         function jumpToUrl(URL,anchor)  {       //
00345                                 var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
00346                                 var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
00347                                 var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div::_GP('RTEtsConfigParams')).'";
00348 
00349                                 var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
00350                                 var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
00351 
00352                                 var theLocation = URL+add_act+add_editorNo+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
00353                                 window.location.href = theLocation;
00354                                 return false;
00355                         }
00356                         function insertImage(file,width,height,origFile)        {
00357                                 var styleWidth, styleHeight;
00358                                 styleWidth = parseInt(width);
00359                                 if (isNaN(styleWidth) || styleWidth == 0) {
00360                                         styleWidth = "auto";
00361                                 } else {
00362                                         styleWidth += "px";
00363                                 }
00364                                 styleHeight = parseInt(height);
00365                                 if (isNaN(styleHeight) || styleHeight == 0) {
00366                                         styleHeight = "auto";
00367                                 } else {
00368                                         styleHeight += "px";
00369                                 }
00370                                 editor.renderPopup_insertImage(\'<img src="\'+file+\'" style="width: \'+styleWidth+\'; height: \'+styleHeight+\';"'.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?' clickenlargesrc="\'+origFile+\'" clickenlarge="0"':'').' />\');
00371                         }
00372                         function launchView(url) {
00373                                 var thePreviewWindow="";
00374                                 thePreviewWindow = window.open("'.$this->siteUrl.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");
00375                                 if (thePreviewWindow && thePreviewWindow.focus) {
00376                                         thePreviewWindow.focus();
00377                                 }
00378                         }
00379                         function getCurrentImageRef() {
00380                                 if (editor._selectedImage) {
00381                                         return editor._selectedImage;
00382                                 } else {
00383                                         return null;
00384                                 }
00385                         }
00386                         function printCurrentImageOptions() {
00387                                 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
00388                                 if(classesImage) var styleSelector=\'<select name="iClass" style="width:140px;">' . $this->classesImageJSOptions  . '</select>\';
00389                                 var floatSelector=\'<select 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>\';
00390                                 var bgColor=\' class="bgColor4"\';
00391                                 var sz="";
00392                                 sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
00393                                 if(classesImage) {
00394                                         sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('class').': </td><td>\'+styleSelector+\'</td></tr>\';
00395                                 }
00396                                 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('width').': </td><td><input type="text" name="iWidth" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
00397                                 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('height').': </td><td><input type="text" name="iHeight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
00398                                 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('border').': </td><td><input type="checkbox" name="iBorder" value="1" /></td></tr>\';
00399                                 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('float').': </td><td>\'+floatSelector+\'</td></tr>\';
00400                                 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('margin_lr').': </td><td><input type="text" name="iHspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).'></td></tr>\';
00401                                 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('margin_tb').': </td><td><input type="text" name="iVspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
00402                                 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('title').': </td><td><input type="text" name="iTitle"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
00403                                 sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('alt').': </td><td><input type="text" name="iAlt"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
00404                                 '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'if (selectedImageRef && selectedImageRef.getAttribute("clickenlargesrc")) 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="1" /></td></tr>\';':'').'                            sz+=\'<tr><td><input type="submit" value="'.$LANG->getLL('update').'" onClick="return setImageProperties();"></td></tr>\';
00405                                 sz+=\'</form></table>\';
00406                                 return sz;
00407                         }
00408                         function setImageProperties() {
00409                                 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
00410                                 if (selectedImageRef)   {
00411                                         if(document.imageData.iWidth.value && document.imageData.iWidth.value != "auto") {
00412                                                 selectedImageRef.style.width = document.imageData.iWidth.value + "px";
00413                                         } else {
00414                                                 selectedImageRef.style.width = "auto";
00415                                         }
00416                                         selectedImageRef.removeAttribute("width");
00417                                         if(document.imageData.iHeight.value && document.imageData.iHeight.value != "auto") {
00418                                                 selectedImageRef.style.height=document.imageData.iHeight.value + "px";
00419                                         } else {
00420                                                 selectedImageRef.style.height = "auto";
00421                                         }
00422                                         selectedImageRef.removeAttribute("height");
00423 
00424                                         selectedImageRef.style.paddingTop = "0px";
00425                                         selectedImageRef.style.paddingBottom = "0px";
00426                                         selectedImageRef.style.paddingRight = "0px";
00427                                         selectedImageRef.style.paddingLeft = "0px";
00428                                         selectedImageRef.style.padding = "";  // this statement ignored by Mozilla 1.3.1
00429                                         if(document.imageData.iVspace.value != "" && !isNaN(parseInt(document.imageData.iVspace.value))) {
00430                                                 selectedImageRef.style.paddingTop = parseInt(document.imageData.iVspace.value) + "px";
00431                                                 selectedImageRef.style.paddingBottom = selectedImageRef.style.paddingTop;
00432                                         }
00433                                         if(document.imageData.iHspace.value != "" && !isNaN(parseInt(document.imageData.iHspace.value))) {
00434                                                 selectedImageRef.style.paddingRight = parseInt(document.imageData.iHspace.value) + "px";
00435                                                 selectedImageRef.style.paddingLeft = selectedImageRef.style.paddingRight;
00436                                         }
00437                                         selectedImageRef.removeAttribute("vspace");
00438                                         selectedImageRef.removeAttribute("hspace");
00439 
00440                                         selectedImageRef.title=document.imageData.iTitle.value;
00441                                         selectedImageRef.alt=document.imageData.iAlt.value;
00442 
00443                                         selectedImageRef.style.borderStyle = "none";
00444                                         selectedImageRef.style.borderWidth = "0px";
00445                                         selectedImageRef.style.border = "";  // this statement ignored by Mozilla 1.3.1
00446                                         if(document.imageData.iBorder.checked) {
00447                                                 selectedImageRef.style.borderStyle = "solid";
00448                                                 selectedImageRef.style.borderWidth = "thin";
00449                                         }
00450                                         selectedImageRef.removeAttribute("border");
00451 
00452                                         var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
00453                                         if (iFloat || selectedImageRef.style.cssFloat || selectedImageRef.style.styleFloat)     {
00454                                                 if(document.all) {
00455                                                         selectedImageRef.style.styleFloat = iFloat;
00456                                                 } else {
00457                                                         selectedImageRef.style.cssFloat = iFloat;
00458                                                 }
00459                                         }
00460 
00461                                         if(classesImage) {
00462                                                 var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
00463                                                 if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value))     {
00464                                                         selectedImageRef.className = iClass;
00465                                                 }
00466                                         }
00467                                         
00468                                         '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'
00469                                         if (document.imageData.iClickEnlarge && document.imageData.iClickEnlarge.checked) selectedImageRef.setAttribute("clickenlarge","1");
00470                                                 else selectedImageRef.setAttribute("clickenlarge","0");':'').'
00471                                         
00472                                         HTMLArea.edHidePopup();
00473                                 }
00474                                 return false;
00475                         }
00476                         function insertImagePropertiesInForm()  {
00477                                 var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
00478                                 if (selectedImageRef)   {
00479                                         var styleWidth, styleHeight, paddingTop, paddingRight;
00480                                         styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
00481                                         styleWidth = parseInt(styleWidth);
00482                                         if (isNaN(styleWidth) || styleWidth == 0) { styleWidth = "auto"; }
00483                                         document.imageData.iWidth.value = styleWidth;
00484                                         styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
00485                                         styleHeight = parseInt(styleHeight);
00486                                         if (isNaN(styleHeight) || styleHeight == 0) { styleHeight = "auto"; }
00487                                         document.imageData.iHeight.value = styleHeight;
00488 
00489                                         paddingTop = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
00490                                         paddingTop = parseInt(paddingTop);
00491                                         if (isNaN(paddingTop) || paddingTop < 0) { paddingTop = ""; }
00492                                         document.imageData.iVspace.value = paddingTop;
00493                                         paddingRight = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
00494                                         paddingRight = parseInt(paddingRight);
00495                                         if (isNaN(paddingRight) || paddingRight < 0) { paddingRight = ""; }
00496                                         document.imageData.iHspace.value = paddingRight;
00497 
00498                                         document.imageData.iTitle.value = selectedImageRef.title;
00499                                         document.imageData.iAlt.value = selectedImageRef.alt;
00500 
00501                                         if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
00502                                                 document.imageData.iBorder.checked = 1;
00503                                         }
00504 
00505                                         var fObj=document.imageData.iFloat;
00506                                         var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
00507                                         var l=fObj.length;
00508                                         for (a=0;a<l;a++)       {
00509                                                 if (fObj.options[a].value == value)     {
00510                                                         fObj.selectedIndex = a;
00511                                                 }
00512                                         }
00513 
00514                                         if(classesImage) {
00515                                                 var fObj=document.imageData.iClass;
00516                                                 var value=selectedImageRef.className;
00517                                                 var l=fObj.length;
00518                                                 for (a=0;a<l;a++)       {
00519                                                         if (fObj.options[a].value == value)     {
00520                                                                 fObj.selectedIndex = a;
00521                                                         }
00522                                                 }
00523                                         }
00524                                         
00525                                         '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'if (selectedImageRef.getAttribute("clickenlargesrc")) {
00526                                                 if (selectedImageRef.getAttribute("clickenlarge") == "1") document.imageData.iClickEnlarge.checked = 1;
00527                                                         else document.imageData.iClickEnlarge.removeAttribute("checked");
00528                                         }':'').'
00529                                 }
00530                                 return false;
00531                         }
00532 
00533                         function openDragDrop() {
00534                                 var url = "' . $BACK_PATH . t3lib_extMgm::extRelPath($this->extKey) . 'mod3/browse_links.php?mode=filedrag&editorNo='.$this->editorNo.'&bparams=|||"+escape("gif,jpg,jpeg,png");
00535                                 window.opener.browserWin = window.open(url,"Typo3WinBrowser","height=350,width=600,status=0,menubar=0,resizable=1,scrollbars=1");
00536                                 HTMLArea.edHidePopup();
00537                         }
00538 
00539                         var selectedImageRef = getCurrentImageRef();    // Setting this to a reference to the image object.
00540 
00541                         '.($this->act=='dragdrop'?'openDragDrop();':'');
00542 
00543                         // Finally, add the accumulated JavaScript to the template object:
00544                 $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
00545         }
00546         
00554         function processSessionData($data) {
00555                 $store = false;
00556                 
00557                 if ($this->act != 'image') {
00558                         if (isset($this->act))  {
00559                                 $data['act'] = $this->act;
00560                                 $store = true;
00561                         } else {
00562                                 $this->act = $data['act'];
00563                         }
00564                 }
00565                 
00566                 if (isset($this->expandFolder)) {
00567                         $data['expandFolder'] = $this->expandFolder;
00568                         $store = true;
00569                 } else {
00570                         $this->expandFolder = $data['expandFolder'];
00571                 }
00572                 
00573                 return array($data, $store);
00574         }
00575         
00581         function main_rte()     {
00582                 global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
00583                 
00584                         // Starting content:
00585                 $this->content = $this->doc->startPage($LANG->getLL('Insert Image',1));
00586                 
00587                         // Making menu in top:
00588                 $menuDef = array();
00589                 if (in_array('image',$this->allowedItems) && ($this->act=='image' || t3lib_div::_GP('cWidth'))) {
00590                         $menuDef['page']['isActive'] = $this->act=='image';
00591                         $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
00592                         $menuDef['page']['url'] = '#';
00593                         $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&editorNo='.$this->editorNo.'\');return false;"';
00594                 }
00595                 if (in_array('magic',$this->allowedItems)){
00596                         $menuDef['file']['isActive'] = $this->act=='magic';
00597                         $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
00598                         $menuDef['file']['url'] = '#';
00599                         $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&editorNo='.$this->editorNo.'\');return false;"';
00600                 }
00601                 if (in_array('plain',$this->allowedItems)) {
00602                         $menuDef['url']['isActive'] = $this->act=='plain';
00603                         $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
00604                         $menuDef['url']['url'] = '#';
00605                         $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&editorNo='.$this->editorNo.'\');return false;"';
00606                 }
00607                 if (in_array('dragdrop',$this->allowedItems)) {
00608                         $menuDef['mail']['isActive'] = $this->act=='dragdrop';
00609                         $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
00610                         $menuDef['mail']['url'] = '#';
00611                         $menuDef['mail']['addParams'] = 'onClick="openDragDrop();return false;"';
00612                 }
00613                 $this->content .= $this->doc->getTabMenuRaw($menuDef);
00614                 
00615                 if ($this->act!='image')        {
00616                         
00617                         // ***************************
00618                         // Upload
00619                         // ***************************
00620                                 // Create upload/create folder forms, if a path is given:
00621                         if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
00622                                 $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
00623                                 $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
00624                                 $path=$this->expandFolder;
00625                                 if (!$path || !@is_dir($path))  {
00626                                         $path = $fileProcessor->findTempFolder().'/';   // The closest TEMP-path is found
00627                                 }
00628                                 if ($path!='/' && @is_dir($path))       {
00629                                         $uploadForm=$this->uploadForm($path);
00630                                         $createFolder=$this->createFolder($path);
00631                                 } else {
00632                                         $createFolder='';
00633                                         $uploadForm='';
00634                                 }
00635                                 $this->content .= $uploadForm;
00636                                 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
00637                                         $this->content.=$createFolder;
00638                                 }
00639                         }
00640 
00641                                 // Getting flag for showing/not showing thumbnails:
00642                         $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect');
00643 
00644                         if (!$noThumbs) {
00645                                         // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
00646                                 $_MOD_MENU = array('displayThumbs' => '');
00647                                 $_MCONF['name']='file_list';
00648                                 $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
00649                                 $addParams = '&act='.$this->act.'&editorNo='.$this->editorNo.'&expandFolder='.rawurlencode($this->expandFolder);
00650                                 $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>';
00651                         } else {
00652                                 $thumbNailCheck='';
00653                         }
00654 
00655                                 // File-folders:
00656                         $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_image_folderTree');
00657                         $tree=$foldertree->getBrowsableTree();
00658                         list(,,$specUid) = explode('_',t3lib_div::_GP('PM'));
00659                         $files = $this->expandFolder($foldertree->specUIDmap[$specUid],$this->act=='plain',$noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
00660                         
00661                         $this->content.= '<table border=0 cellpadding=0 cellspacing=0>
00662                         <tr>
00663                                 <td valign=top>'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
00664                                 <td>&nbsp;</td>
00665                                 <td valign=top>'.$files.'</td>
00666                         </tr>
00667                         </table>
00668                         <br />'.$thumbNailCheck;
00669                         
00670                         // ***************************
00671                         // Help
00672                         // ***************************
00673                         if ($this->act=='magic')        {
00674                                 $this->content .= $this->getMsgBox($LANG->getLL('magicImage_msg'));
00675                         }
00676                         if ($this->act=='plain')        {
00677                                 $this->content .= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight));
00678                         }
00679                 } else {
00680                         $JScode = '
00681                                 document.write(printCurrentImageOptions());
00682                                 insertImagePropertiesInForm();';
00683                         $this->content.= '<br />'.$this->doc->wrapScriptTags($JScode);
00684                 }
00685                 $this->content.= $this->doc->endPage();
00686                 return $this->content;
00687         }
00688         
00689         /***************************
00690          *
00691          * OTHER FUNCTIONS:
00692          *
00693          ***************************/
00699         function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0) {
00700                 global $LANG, $BE_USER, $BACK_PATH;
00701 
00702                 $expandFolder = $expandFolder ? $expandFolder :t3lib_div::_GP('expandFolder');
00703                 $out='';
00704 
00705                 if ($expandFolder && $this->checkFolder($expandFolder)) {
00706                         $files = t3lib_div::getFilesInDir($expandFolder,($plainFlag?'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1);       // $extensionList="",$prependPath=0,$order="")
00707                         if (is_array($files))   {
00708                                 reset($files);
00709 
00710                                 $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
00711 
00712                                 $titleLen = intval($BE_USER->uc['titleLen']);
00713                                 $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
00714                                 $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
00715                                 $out.='<span class="nobr">'.$picon.'</span><br />';
00716 
00717                                 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
00718                                 $imgObj->init();
00719                                 $imgObj->mayScaleUp=0;
00720                                 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
00721                                 
00722                                 $lines=array();
00723                                 while(list(,$filepath)=each($files))    {
00724                                         $fI=pathinfo($filepath);
00725                                         
00726                                         $origFile = t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site)));
00727                                         $iurl = $this->siteUrl.$origFile;
00728                                         $imgInfo = $imgObj->getImageDimensions($filepath);
00729                                                 // File icon:
00730                                         $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
00731                                         $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
00732                                         $size=' ('.t3lib_div::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
00733                                         $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
00734                                         if (!$plainFlag)        {
00735                                                 $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo.'&insertMagicImage='.rawurlencode($filepath).'\');">';
00736                                         } else {
00737                                                 $ATag = '<a href="#" onclick="return insertImage(\''.$iurl.'\','.$imgInfo[0].','.$imgInfo[1].',\''.$origFile.'\');">';
00738                                         }
00739                                         $ATag_e='</a>';
00740                                         if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth) || ($imgInfo[1] > $this->plainMaxHeight)))      {
00741                                                 $ATag='';
00742                                                 $ATag_e='';
00743                                                 $ATag2='';
00744                                                 $ATag2_e='';
00745                                         } else {
00746                                                 $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
00747                                                 $ATag2_e='</a>';
00748                                         }
00749 
00750                                         $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
00751 
00752 
00753                                         $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td><td nowrap="nowrap">'.$pDim.'&nbsp;</td></tr>';
00754                                         $lines[]='<tr><td colspan="2">'.($noThumbs ? '' : $ATag2.t3lib_BEfunc::getThumbNail($this->doc->backPath.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
00755                                                 '</td></tr>';
00756                                         $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
00757                                 }
00758                                 $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
00759                         }
00760                 }
00761                 return $out;
00762         }
00763         
00771         function uploadForm($path)      {
00772                 global $BACK_PATH;
00773                 $count=3;
00774 
00775                         // Create header, showing upload path:
00776                 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
00777                 $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
00778                 $code.='
00779 
00780                         <!--
00781                                 Form, for uploading files:
00782                         -->
00783                         <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
00784                                 <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
00785                                         <tr>
00786                                                 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
00787                                         </tr>
00788                                         <tr>
00789                                                 <td>';
00790 
00791                         // Traverse the number of upload fields (default is 3):
00792                 for ($a=1;$a<=$count;$a++)      {
00793                         $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
00794                                 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
00795                                 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
00796                 }
00797 
00798                         // Make footer of upload form, including the submit button:
00799                 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
00800                 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
00801                                 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
00802 
00803                 $code.='
00804                         <div id="c-override">
00805                                 <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
00806                         </div>
00807                 ';
00808 
00809 
00810                 $code.='</td>
00811                                         </tr>
00812                                 </table>
00813                         </form>';
00814 
00815                 return $code;
00816         }
00817         
00818                 
00826         function createFolder($path)    {
00827                 global $BACK_PATH;
00828                         // Create header, showing upload path:
00829                 $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
00830                 $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
00831                 $code.='
00832 
00833                         <!--
00834                                 Form, for creating new folders:
00835                         -->
00836                         <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
00837                                 <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
00838                                         <tr>
00839                                                 <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
00840                                         </tr>
00841                                         <tr>
00842                                                 <td>';
00843 
00844                         // Create the new-folder name field:
00845                 $a=1;
00846                 $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
00847                                 '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
00848 
00849                         // Make footer of upload form, including the submit button:
00850                 $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
00851                 $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
00852                                 '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
00853 
00854                 $code.='</td>
00855                                         </tr>
00856                                 </table>
00857                         </form>';
00858 
00859                 return $code;
00860         }
00861 
00862 
00863 }
00864 
00865 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php'])      {
00866         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);
00867 }
00868 
00869 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6