[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/typo3/sysext/rtehtmlarea/mod4/ -> class.tx_rtehtmlarea_select_image.php (source)

   1  <?php
   2  /***************************************************************
   3  *  Copyright notice
   4  *
   5  *  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
   6  *  (c) 2004-2006 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
   7  *  All rights reserved
   8  *
   9  *  This script is part of the TYPO3 project. The TYPO3 project is
  10  *  free software; you can redistribute it and/or modify
  11  *  it under the terms of the GNU General Public License as published by
  12  *  the Free Software Foundation; either version 2 of the License, or
  13  *  (at your option) any later version.
  14  *
  15  *  The GNU General Public License can be found at
  16  *  http://www.gnu.org/copyleft/gpl.html.
  17  *  A copy is found in the textfile GPL.txt and important notices to the license
  18  *  from the author is found in LICENSE.txt distributed with these scripts.
  19  *
  20  *
  21  *  This script is distributed in the hope that it will be useful,
  22  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  23  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24  *  GNU General Public License for more details.
  25  *
  26  *  This copyright notice MUST APPEAR in all copies of the script!
  27  ***************************************************************/
  28  /**
  29   * Displays image selector for the RTE
  30   *
  31   * @author    Kasper Skaarhoj <kasper@typo3.com>
  32   * @author    Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
  33   *
  34   * $Id: class.tx_rtehtmlarea_select_image.php 1997 2007-02-05 18:24:44Z ingmars $  *
  35   */
  36  require_once(PATH_typo3.'class.browse_links.php');
  37  require_once(PATH_t3lib.'class.t3lib_foldertree.php');
  38  require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
  39  require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
  40  
  41  /**
  42   * Local Folder Tree
  43   *
  44   * @author    Kasper Skaarhoj <kasper@typo3.com>
  45   * @package TYPO3
  46   * @subpackage tx_rte
  47   */
  48  class tx_rtehtmlarea_image_folderTree extends t3lib_folderTree {
  49      var $ext_IconMode=1;
  50  
  51      /**
  52       * Wrapping the title in a link, if applicable.
  53       *
  54       * @param    string        Title, ready for output.
  55       * @param    array        The "record"
  56       * @return    string        Wrapping title string.
  57       */
  58  	function wrapTitle($title,$v)    {
  59          if ($this->ext_isLinkable($v))    {
  60              $aOnClick = 'return jumpToUrl(\'?editorNo='.$GLOBALS['SOBE']->browser->editorNo.'&expandFolder='.rawurlencode($v['path']).'\');';
  61              return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$title.'</a>';
  62          } else {
  63              return '<span class="typo3-dimmed">'.$title.'</span>';
  64          }
  65      }
  66  
  67      /**
  68       * Returns true if the input "record" contains a folder which can be linked.
  69       *
  70       * @param    array        Array with information about the folder element. Contains keys like title, uid, path, _title
  71       * @return    boolean        True is returned if the path is found in the web-part of the the server and is NOT a recycler or temp folder
  72       */
  73  	function ext_isLinkable($v)    {
  74          $webpath=t3lib_BEfunc::getPathType_web_nonweb($v['path']);
  75          if ($GLOBALS['SOBE']->browser->act=='magic') return 1;    //$webpath='web';    // The web/non-web path does not matter if the mode is 'magic'
  76  
  77          if (strstr($v['path'],'_recycler_') || strstr($v['path'],'_temp_') || $webpath!='web')    {
  78              return 0;
  79          }
  80          return 1;
  81      }
  82  
  83      /**
  84       * Wrap the plus/minus icon in a link
  85       *
  86       * @param    string        HTML string to wrap, probably an image tag.
  87       * @param    string        Command for 'PM' get var
  88       * @param    boolean        If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
  89       * @return    string        Link-wrapped input string
  90       * @access private
  91       */
  92  	function PM_ATagWrap($icon,$cmd,$bMark='')    {
  93          if ($bMark)    {
  94              $anchor = '#'.$bMark;
  95              $name=' name="'.$bMark.'"';
  96          }
  97          $aOnClick = 'return jumpToUrl(\'?PM='.$cmd.'\',\''.$anchor.'\');';
  98          return '<a href="#"'.$name.' onclick="'.htmlspecialchars($aOnClick).'">'.$icon.'</a>';
  99      }
 100  
 101      /**
 102       * Print tree.
 103       *
 104       * @param    mixed        Input tree array. If not array, then $this->tree is used.
 105       * @return    string        HTML output of the tree.
 106       */
 107  	function printTree($treeArr='')    {
 108          $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
 109  
 110          if (!is_array($treeArr))    $treeArr=$this->tree;
 111  
 112          $out='';
 113          $c=0;
 114  
 115              // Traverse rows for the tree and print them into table rows:
 116          foreach($treeArr as $k => $v) {
 117              $c++;
 118              $bgColor=' class="'.(($c+1)%2 ? 'bgColor' : 'bgColor-10').'"';
 119              $out.='<tr'.$bgColor.'><td nowrap="nowrap">'.$v['HTML'].$this->wrapTitle(t3lib_div::fixed_lgd($v['row']['title'],$titleLen),$v['row']).'</td></tr>';
 120          }
 121  
 122          $out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>';
 123          return $out;
 124      }
 125  }
 126  
 127  
 128  /**
 129   * Script Class
 130   *
 131   * @author    Kasper Skaarhoj <kasper@typo3.com>
 132   * @package TYPO3
 133   * @subpackage tx_rte
 134   */
 135  class tx_rtehtmlarea_select_image extends browse_links {
 136      var $extKey = 'rtehtmlarea';
 137      var $content;
 138      var $act;
 139      var $allowedItems;
 140      var $plainMaxWidth;
 141      var $plainMaxHeight;
 142      var $magicMaxWidth;
 143      var $magicMaxHeight;
 144      var $imgPath;
 145      var $classesImageJSOptions;
 146      var $editorNo;
 147      var $buttonConfig = array();
 148      
 149      /**
 150       * Initialisation
 151       *
 152       * @return    [type]        ...
 153       */
 154  	function init()    {
 155          global $BE_USER,$BACK_PATH,$TYPO3_CONF_VARS;
 156  
 157              // Main GPvars:
 158          $this->siteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
 159          $this->act = t3lib_div::_GP('act');
 160          $this->editorNo = t3lib_div::_GP('editorNo');
 161          $this->expandPage = t3lib_div::_GP('expandPage');
 162          $this->expandFolder = t3lib_div::_GP('expandFolder');
 163          
 164              // Find "mode"
 165          $this->mode = t3lib_div::_GP('mode');
 166          if (!$this->mode)    {
 167              $this->mode='rte';
 168          }
 169  
 170              // Site URL
 171          $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');    // Current site url
 172  
 173              // the script to link to
 174          $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
 175          
 176          if (!$this->act)    {
 177              $this->act='magic';
 178          }
 179          
 180          $RTEtsConfigParts = explode(':',t3lib_div::_GP('RTEtsConfigParams'));
 181          $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
 182          $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
 183          $this->imgPath = $RTEtsConfigParts[6];
 184          
 185          if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['image.'])) {
 186              $this->buttonConfig = $this->thisConfig['buttons.']['image.'];
 187          }
 188          
 189          $this->allowedItems = explode(',','magic,plain,dragdrop,image');
 190          if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) {
 191              $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1));
 192          } else {
 193              $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindImageOptions'],1));
 194          }
 195          reset($this->allowedItems);
 196          if (!in_array($this->act,$this->allowedItems))    {
 197              $this->act = current($this->allowedItems);
 198          }
 199          
 200          if ($this->act == 'plain') {
 201              if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth']) $this->plainMaxWidth = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxWidth'];
 202              if ($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight']) $this->plainMaxHeight = $TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['plainImageMaxHeight'];
 203              if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['plain.'])) {
 204                  if ($this->buttonConfig['options.']['plain.']['maxWidth']) $this->plainMaxWidth = $this->buttonConfig['options.']['plain.']['maxWidth'];
 205                  if ($this->buttonConfig['options.']['plain.']['maxHeight']) $this->plainMaxHeight = $this->buttonConfig['options.']['plain.']['maxHeight'];
 206              }
 207              if (!$this->plainMaxWidth) $this->plainMaxWidth = 640;
 208              if (!$this->plainMaxHeight) $this->plainMaxHeight = 680;
 209          } elseif ($this->act == 'magic') {
 210              if (is_array($this->buttonConfig['options.']) && is_array($this->buttonConfig['options.']['magic.'])) {
 211                  if ($this->buttonConfig['options.']['magic.']['maxWidth']) $this->magicMaxWidth = $this->buttonConfig['options.']['magic.']['maxWidth'];
 212                  if ($this->buttonConfig['options.']['magic.']['maxHeight']) $this->magicMaxHeight = $this->buttonConfig['options.']['magic.']['maxHeight'];
 213              }
 214                  // 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
 215              if (!$this->magicMaxWidth) $this->magicMaxWidth = 300;
 216              if (!$this->magicMaxHeight) $this->magicMaxHeight = 1000;
 217          }
 218          
 219          if($this->thisConfig['classesImage']) {
 220              $classesImageArray = t3lib_div::trimExplode(',',$this->thisConfig['classesImage'],1);
 221              $this->classesImageJSOptions = '<option value=""></option>';
 222              reset($classesImageArray);
 223              while(list(,$class)=each($classesImageArray)) {
 224                  $this->classesImageJSOptions .= '<option value="' .$class . '">' . $class . '</option>';
 225              }
 226          }
 227          
 228          $this->magicProcess();
 229          
 230              // Creating backend template object:
 231          $this->doc = t3lib_div::makeInstance('template');
 232          $this->doc->docType= 'xhtml_trans';
 233          $this->doc->backPath = $BACK_PATH;
 234          
 235          $this->getJSCode();
 236      }
 237  
 238      /**
 239       * [Describe function...]
 240       *
 241       * @return    [type]        ...
 242       */
 243  	function rteImageStorageDir()    {
 244          $dir = $this->imgPath ? $this->imgPath : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];;
 245          return $dir;
 246      }
 247  
 248      /**
 249       * [Describe function...]
 250       *
 251       * @return    [type]        ...
 252       */
 253  	function magicProcess()    {
 254          global $TYPO3_CONF_VARS;
 255  
 256          if ($this->act=='magic' && t3lib_div::_GP('insertMagicImage'))    {
 257              $filepath = t3lib_div::_GP('insertMagicImage');
 258  
 259              $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
 260              $imgObj->init();
 261              $imgObj->mayScaleUp=0;
 262              $imgObj->tempPath=PATH_site.$imgObj->tempPath;
 263  
 264              $imgInfo = $imgObj->getImageDimensions($filepath);
 265  
 266              if (is_array($imgInfo) && count($imgInfo)==4 && $this->rteImageStorageDir())    {
 267                  $fI=pathinfo($imgInfo[3]);
 268                  $fileFunc = t3lib_div::makeInstance('t3lib_basicFileFunctions');
 269                  $basename = $fileFunc->cleanFileName('RTEmagicP_'.$fI['basename']);
 270                  $destPath =PATH_site.$this->rteImageStorageDir();
 271                  if (@is_dir($destPath))    {
 272                      $destName = $fileFunc->getUniqueName($basename,$destPath);
 273                      @copy($imgInfo[3],$destName);
 274                      
 275                      $cWidth = t3lib_div::intInRange(t3lib_div::_GP('cWidth'),0,$this->magicMaxWidth);
 276                      $cHeight = t3lib_div::intInRange(t3lib_div::_GP('cHeight'),0,$this->magicMaxHeight);
 277                      if (!$cWidth)    $cWidth = $this->magicMaxWidth;
 278                      if (!$cHeight)    $cHeight = $this->magicMaxHeight;
 279                      
 280                      $imgI = $imgObj->imageMagickConvert($filepath,'WEB',$cWidth.'m',$cHeight.'m');    // ($imagefile,$newExt,$w,$h,$params,$frame,$options,$mustCreate=0)
 281                      if ($imgI[3])    {
 282                          $fI=pathinfo($imgI[3]);
 283                          $mainBase='RTEmagicC_'.substr(basename($destName),10).'.'.$fI['extension'];
 284                          $destName = $fileFunc->getUniqueName($mainBase,$destPath);
 285                          @copy($imgI[3],$destName);
 286  
 287                          $destName = dirname($destName).'/'.rawurlencode(basename($destName));
 288                          $iurl = $this->siteUrl.substr($destName,strlen(PATH_site));
 289                          echo'
 290  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 291  <html>
 292  <head>
 293      <title>Untitled</title>
 294  </head>
 295  <script language="javascript" type="text/javascript">
 296  /*<![CDATA[*/
 297      var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
 298      var HTMLArea = window.opener.HTMLArea;
 299  	function insertImage(file,width,height,origFile)    {
 300          var styleWidth, styleHeight;
 301          styleWidth = parseInt(width);
 302          if (isNaN(styleWidth) || styleWidth == 0) {
 303              styleWidth = "auto";
 304          } else {
 305              styleWidth += "px";
 306          }
 307          styleHeight = parseInt(height);
 308          if (isNaN(styleHeight) || styleHeight == 0) {
 309              styleHeight = "auto";
 310          } else {
 311              styleHeight += "px";
 312          }
 313          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"':'').' />\');
 314      }
 315  /*]]>*/
 316  </script>
 317  <body>
 318  <script type="text/javascript">
 319  /*<![CDATA[*/
 320      insertImage(\''.$iurl.'\','.$imgI[0].','.$imgI[1].',\''.substr($imgInfo[3],strlen(PATH_site)).'\');
 321  /*]]>*/
 322  </script>
 323  </body>
 324  </html>';
 325                      }
 326  
 327                  }
 328              }
 329              exit;
 330          }
 331      }
 332  
 333      /**
 334       * [Describe function...]
 335       *
 336       * @return    [type]        ...
 337       */
 338  	function getJSCode()    {
 339          global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
 340  
 341          $JScode='
 342              var editor = window.opener.RTEarea[' . $this->editorNo . ']["editor"];
 343              var HTMLArea = window.opener.HTMLArea;
 344  			function jumpToUrl(URL,anchor)    {    //
 345                  var add_act = URL.indexOf("act=")==-1 ? "&act='.$this->act.'" : "";
 346                  var add_editorNo = URL.indexOf("editorNo=")==-1 ? "&editorNo='.$this->editorNo.'" : "";
 347                  var RTEtsConfigParams = "&RTEtsConfigParams='.rawurlencode(t3lib_div::_GP('RTEtsConfigParams')).'";
 348  
 349                  var cur_width = selectedImageRef ? "&cWidth="+selectedImageRef.style.width : "";
 350                  var cur_height = selectedImageRef ? "&cHeight="+selectedImageRef.style.height : "";
 351  
 352                  var theLocation = URL+add_act+add_editorNo+RTEtsConfigParams+cur_width+cur_height+(anchor?anchor:"");
 353                  window.location.href = theLocation;
 354                  return false;
 355              }
 356  			function insertImage(file,width,height,origFile)    {
 357                  var styleWidth, styleHeight;
 358                  styleWidth = parseInt(width);
 359                  if (isNaN(styleWidth) || styleWidth == 0) {
 360                      styleWidth = "auto";
 361                  } else {
 362                      styleWidth += "px";
 363                  }
 364                  styleHeight = parseInt(height);
 365                  if (isNaN(styleHeight) || styleHeight == 0) {
 366                      styleHeight = "auto";
 367                  } else {
 368                      styleHeight += "px";
 369                  }
 370                  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"':'').' />\');
 371              }
 372  			function launchView(url) {
 373                  var thePreviewWindow="";
 374                  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");
 375                  if (thePreviewWindow && thePreviewWindow.focus)    {
 376                      thePreviewWindow.focus();
 377                  }
 378              }
 379  			function getCurrentImageRef() {
 380                  if (editor._selectedImage) {
 381                      return editor._selectedImage;
 382                  } else {
 383                      return null;
 384                  }
 385              }
 386  			function printCurrentImageOptions() {
 387                  var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
 388                  if(classesImage) var styleSelector=\'<select name="iClass" style="width:140px;">' . $this->classesImageJSOptions  . '</select>\';
 389                  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>\';
 390                  var bgColor=\' class="bgColor4"\';
 391                  var sz="";
 392                  sz+=\'<table border=0 cellpadding=1 cellspacing=1><form action="" name="imageData">\';
 393                  if(classesImage) {
 394                      sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('class').': </td><td>\'+styleSelector+\'</td></tr>\';
 395                  }
 396                  sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('width').': </td><td><input type="text" name="iWidth" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
 397                  sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('height').': </td><td><input type="text" name="iHeight" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
 398                  sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('border').': </td><td><input type="checkbox" name="iBorder" value="1" /></td></tr>\';
 399                  sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('float').': </td><td>\'+floatSelector+\'</td></tr>\';
 400                  sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('margin_lr').': </td><td><input type="text" name="iHspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).'></td></tr>\';
 401                  sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('margin_tb').': </td><td><input type="text" name="iVspace" value=""'.$GLOBALS['TBE_TEMPLATE']->formWidth(4).' /></td></tr>\';
 402                  sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('title').': </td><td><input type="text" name="iTitle"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
 403                  sz+=\'<tr><td\'+bgColor+\'>'.$LANG->getLL('alt').': </td><td><input type="text" name="iAlt"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /></td></tr>\';
 404                  '.(($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>\';
 405                  sz+=\'</form></table>\';
 406                  return sz;
 407              }
 408  			function setImageProperties() {
 409                  var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
 410                  if (selectedImageRef)    {
 411                      if(document.imageData.iWidth.value && document.imageData.iWidth.value != "auto") {
 412                          selectedImageRef.style.width = document.imageData.iWidth.value + "px";
 413                      } else {
 414                          selectedImageRef.style.width = "auto";
 415                      }
 416                      selectedImageRef.removeAttribute("width");
 417                      if(document.imageData.iHeight.value && document.imageData.iHeight.value != "auto") {
 418                          selectedImageRef.style.height=document.imageData.iHeight.value + "px";
 419                      } else {
 420                          selectedImageRef.style.height = "auto";
 421                      }
 422                      selectedImageRef.removeAttribute("height");
 423  
 424                      selectedImageRef.style.paddingTop = "0px";
 425                      selectedImageRef.style.paddingBottom = "0px";
 426                      selectedImageRef.style.paddingRight = "0px";
 427                      selectedImageRef.style.paddingLeft = "0px";
 428                      selectedImageRef.style.padding = "";  // this statement ignored by Mozilla 1.3.1
 429                      if(document.imageData.iVspace.value != "" && !isNaN(parseInt(document.imageData.iVspace.value))) {
 430                          selectedImageRef.style.paddingTop = parseInt(document.imageData.iVspace.value) + "px";
 431                          selectedImageRef.style.paddingBottom = selectedImageRef.style.paddingTop;
 432                      }
 433                      if(document.imageData.iHspace.value != "" && !isNaN(parseInt(document.imageData.iHspace.value))) {
 434                          selectedImageRef.style.paddingRight = parseInt(document.imageData.iHspace.value) + "px";
 435                          selectedImageRef.style.paddingLeft = selectedImageRef.style.paddingRight;
 436                      }
 437                      selectedImageRef.removeAttribute("vspace");
 438                      selectedImageRef.removeAttribute("hspace");
 439  
 440                      selectedImageRef.title=document.imageData.iTitle.value;
 441                      selectedImageRef.alt=document.imageData.iAlt.value;
 442  
 443                      selectedImageRef.style.borderStyle = "none";
 444                      selectedImageRef.style.borderWidth = "0px";
 445                      selectedImageRef.style.border = "";  // this statement ignored by Mozilla 1.3.1
 446                      if(document.imageData.iBorder.checked) {
 447                          selectedImageRef.style.borderStyle = "solid";
 448                          selectedImageRef.style.borderWidth = "thin";
 449                      }
 450                      selectedImageRef.removeAttribute("border");
 451  
 452                      var iFloat = document.imageData.iFloat.options[document.imageData.iFloat.selectedIndex].value;
 453                      if (iFloat || selectedImageRef.style.cssFloat || selectedImageRef.style.styleFloat)    {
 454                          if(document.all) {
 455                              selectedImageRef.style.styleFloat = iFloat;
 456                          } else {
 457                              selectedImageRef.style.cssFloat = iFloat;
 458                          }
 459                      }
 460  
 461                      if(classesImage) {
 462                          var iClass = document.imageData.iClass.options[document.imageData.iClass.selectedIndex].value;
 463                          if (iClass || (selectedImageRef.attributes["class"] && selectedImageRef.attributes["class"].value))    {
 464                              selectedImageRef.className = iClass;
 465                          }
 466                      }
 467                      
 468                      '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'
 469                      if (document.imageData.iClickEnlarge && document.imageData.iClickEnlarge.checked) selectedImageRef.setAttribute("clickenlarge","1");
 470                          else selectedImageRef.setAttribute("clickenlarge","0");':'').'
 471                      
 472                      HTMLArea.edHidePopup();
 473                  }
 474                  return false;
 475              }
 476  			function insertImagePropertiesInForm()    {
 477                  var classesImage = ' . ($this->thisConfig['classesImage']?'true':'false') . ';
 478                  if (selectedImageRef)    {
 479                      var styleWidth, styleHeight, paddingTop, paddingRight;
 480                      styleWidth = selectedImageRef.style.width ? selectedImageRef.style.width : selectedImageRef.width;
 481                      styleWidth = parseInt(styleWidth);
 482                      if (isNaN(styleWidth) || styleWidth == 0) { styleWidth = "auto"; }
 483                      document.imageData.iWidth.value = styleWidth;
 484                      styleHeight = selectedImageRef.style.height ? selectedImageRef.style.height : selectedImageRef.height;
 485                      styleHeight = parseInt(styleHeight);
 486                      if (isNaN(styleHeight) || styleHeight == 0) { styleHeight = "auto"; }
 487                      document.imageData.iHeight.value = styleHeight;
 488  
 489                      paddingTop = selectedImageRef.style.paddingTop ? selectedImageRef.style.paddingTop : selectedImageRef.vspace;
 490                      paddingTop = parseInt(paddingTop);
 491                      if (isNaN(paddingTop) || paddingTop < 0) { paddingTop = ""; }
 492                      document.imageData.iVspace.value = paddingTop;
 493                      paddingRight = selectedImageRef.style.paddingRight ? selectedImageRef.style.paddingRight : selectedImageRef.hspace;
 494                      paddingRight = parseInt(paddingRight);
 495                      if (isNaN(paddingRight) || paddingRight < 0) { paddingRight = ""; }
 496                      document.imageData.iHspace.value = paddingRight;
 497  
 498                      document.imageData.iTitle.value = selectedImageRef.title;
 499                      document.imageData.iAlt.value = selectedImageRef.alt;
 500  
 501                      if((selectedImageRef.style.borderStyle && selectedImageRef.style.borderStyle != "none" && selectedImageRef.style.borderStyle != "none none none none") || selectedImageRef.border) {
 502                          document.imageData.iBorder.checked = 1;
 503                      }
 504  
 505                      var fObj=document.imageData.iFloat;
 506                      var value = (selectedImageRef.style.cssFloat ? selectedImageRef.style.cssFloat : selectedImageRef.style.styleFloat);
 507                      var l=fObj.length;
 508                      for (a=0;a<l;a++)    {
 509                          if (fObj.options[a].value == value)    {
 510                              fObj.selectedIndex = a;
 511                          }
 512                      }
 513  
 514                      if(classesImage) {
 515                          var fObj=document.imageData.iClass;
 516                          var value=selectedImageRef.className;
 517                          var l=fObj.length;
 518                          for (a=0;a<l;a++)    {
 519                              if (fObj.options[a].value == value)    {
 520                                  fObj.selectedIndex = a;
 521                              }
 522                          }
 523                      }
 524                      
 525                      '.(($TYPO3_CONF_VARS['EXTCONF'][$this->extKey]['enableClickEnlarge'] && !(is_array($this->buttonConfig['clickEnlarge.']) && $this->buttonConfig['clickEnlarge.']['disabled']))?'if (selectedImageRef.getAttribute("clickenlargesrc")) {
 526                          if (selectedImageRef.getAttribute("clickenlarge") == "1") document.imageData.iClickEnlarge.checked = 1;
 527                              else document.imageData.iClickEnlarge.removeAttribute("checked");
 528                      }':'').'
 529                  }
 530                  return false;
 531              }
 532  
 533  			function openDragDrop()    {
 534                  var url = "' . $BACK_PATH . t3lib_extMgm::extRelPath($this->extKey) . 'mod3/browse_links.php?mode=filedrag&editorNo='.$this->editorNo.'&bparams=|||"+escape("gif,jpg,jpeg,png");
 535                  window.opener.browserWin = window.open(url,"Typo3WinBrowser","height=350,width=600,status=0,menubar=0,resizable=1,scrollbars=1");
 536                  HTMLArea.edHidePopup();
 537              }
 538  
 539              var selectedImageRef = getCurrentImageRef();    // Setting this to a reference to the image object.
 540  
 541              '.($this->act=='dragdrop'?'openDragDrop();':'');
 542  
 543              // Finally, add the accumulated JavaScript to the template object:
 544          $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
 545      }
 546      
 547      /**
 548       * Session data for this class can be set from outside with this method.
 549       * Call after init()
 550       *
 551       * @param    array        Session data array
 552       * @return    array        Session data and boolean which indicates that data needs to be stored in session because it's changed
 553       */
 554  	function processSessionData($data) {
 555          $store = false;
 556          
 557          if ($this->act != 'image') {
 558              if (isset($this->act))    {
 559                  $data['act'] = $this->act;
 560                  $store = true;
 561              } else {
 562                  $this->act = $data['act'];
 563              }
 564          }
 565          
 566          if (isset($this->expandFolder))    {
 567              $data['expandFolder'] = $this->expandFolder;
 568              $store = true;
 569          } else {
 570              $this->expandFolder = $data['expandFolder'];
 571          }
 572          
 573          return array($data, $store);
 574      }
 575      
 576      /**
 577       * [Describe function...]
 578       *
 579       * @return    [type]        ...
 580       */
 581  	function main_rte()    {
 582          global $LANG, $TYPO3_CONF_VARS, $FILEMOUNTS, $BE_USER;
 583          
 584              // Starting content:
 585          $this->content = $this->doc->startPage($LANG->getLL('Insert Image',1));
 586          
 587              // Making menu in top:
 588          $menuDef = array();
 589          if (in_array('image',$this->allowedItems) && ($this->act=='image' || t3lib_div::_GP('cWidth'))) {
 590              $menuDef['page']['isActive'] = $this->act=='image';
 591              $menuDef['page']['label'] = $LANG->getLL('currentImage',1);
 592              $menuDef['page']['url'] = '#';
 593              $menuDef['page']['addParams'] = 'onClick="jumpToUrl(\'?act=image&editorNo='.$this->editorNo.'\');return false;"';
 594          }
 595          if (in_array('magic',$this->allowedItems)){
 596              $menuDef['file']['isActive'] = $this->act=='magic';
 597              $menuDef['file']['label'] = $LANG->getLL('magicImage',1);
 598              $menuDef['file']['url'] = '#';
 599              $menuDef['file']['addParams'] = 'onClick="jumpToUrl(\'?act=magic&editorNo='.$this->editorNo.'\');return false;"';
 600          }
 601          if (in_array('plain',$this->allowedItems)) {
 602              $menuDef['url']['isActive'] = $this->act=='plain';
 603              $menuDef['url']['label'] = $LANG->getLL('plainImage',1);
 604              $menuDef['url']['url'] = '#';
 605              $menuDef['url']['addParams'] = 'onClick="jumpToUrl(\'?act=plain&editorNo='.$this->editorNo.'\');return false;"';
 606          }
 607          if (in_array('dragdrop',$this->allowedItems)) {
 608              $menuDef['mail']['isActive'] = $this->act=='dragdrop';
 609              $menuDef['mail']['label'] = $LANG->getLL('dragDropImage',1);
 610              $menuDef['mail']['url'] = '#';
 611              $menuDef['mail']['addParams'] = 'onClick="openDragDrop();return false;"';
 612          }
 613          $this->content .= $this->doc->getTabMenuRaw($menuDef);
 614          
 615          if ($this->act!='image')    {
 616              
 617              // ***************************
 618              // Upload
 619              // ***************************
 620                  // Create upload/create folder forms, if a path is given:
 621              if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
 622                  $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
 623                  $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
 624                  $path=$this->expandFolder;
 625                  if (!$path || !@is_dir($path))    {
 626                      $path = $fileProcessor->findTempFolder().'/';    // The closest TEMP-path is found
 627                  }
 628                  if ($path!='/' && @is_dir($path))    {
 629                      $uploadForm=$this->uploadForm($path);
 630                      $createFolder=$this->createFolder($path);
 631                  } else {
 632                      $createFolder='';
 633                      $uploadForm='';
 634                  }
 635                  $this->content .= $uploadForm;
 636                  if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
 637                      $this->content.=$createFolder;
 638                  }
 639              }
 640  
 641                  // Getting flag for showing/not showing thumbnails:
 642              $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect');
 643  
 644              if (!$noThumbs)    {
 645                      // MENU-ITEMS, fetching the setting for thumbnails from File>List module:
 646                  $_MOD_MENU = array('displayThumbs' => '');
 647                  $_MCONF['name']='file_list';
 648                  $_MOD_SETTINGS = t3lib_BEfunc::getModuleData($_MOD_MENU, t3lib_div::_GP('SET'), $_MCONF['name']);
 649                  $addParams = '&act='.$this->act.'&editorNo='.$this->editorNo.'&expandFolder='.rawurlencode($this->expandFolder);
 650                  $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>';
 651              } else {
 652                  $thumbNailCheck='';
 653              }
 654  
 655                  // File-folders:
 656              $foldertree = t3lib_div::makeInstance('tx_rtehtmlarea_image_folderTree');
 657              $tree=$foldertree->getBrowsableTree();
 658              list(,,$specUid) = explode('_',t3lib_div::_GP('PM'));
 659              $files = $this->expandFolder($foldertree->specUIDmap[$specUid],$this->act=='plain',$noThumbs?$noThumbs:!$_MOD_SETTINGS['displayThumbs']);
 660              
 661              $this->content.= '<table border=0 cellpadding=0 cellspacing=0>
 662              <tr>
 663                  <td valign=top>'.$this->barheader($LANG->getLL('folderTree').':').$tree.'</td>
 664                  <td>&nbsp;</td>
 665                  <td valign=top>'.$files.'</td>
 666              </tr>
 667              </table>
 668              <br />'.$thumbNailCheck;
 669              
 670              // ***************************
 671              // Help
 672              // ***************************
 673              if ($this->act=='magic')    {
 674                  $this->content .= $this->getMsgBox($LANG->getLL('magicImage_msg'));
 675              }
 676              if ($this->act=='plain')    {
 677                  $this->content .= $this->getMsgBox(sprintf($LANG->getLL('plainImage_msg'), $this->plainMaxWidth, $this->plainMaxHeight));
 678              }
 679          } else {
 680              $JScode = '
 681                  document.write(printCurrentImageOptions());
 682                  insertImagePropertiesInForm();';
 683              $this->content.= '<br />'.$this->doc->wrapScriptTags($JScode);
 684          }
 685          $this->content.= $this->doc->endPage();
 686          return $this->content;
 687      }
 688      
 689      /***************************
 690       *
 691       * OTHER FUNCTIONS:
 692       *
 693       ***************************/
 694      /**
 695       * @param    [type]        $expandFolder: ...
 696       * @param    [type]        $plainFlag: ...
 697       * @return    [type]        ...
 698       */
 699  	function expandFolder($expandFolder=0,$plainFlag=0,$noThumbs=0)    {
 700          global $LANG, $BE_USER, $BACK_PATH;
 701  
 702          $expandFolder = $expandFolder ? $expandFolder :t3lib_div::_GP('expandFolder');
 703          $out='';
 704  
 705          if ($expandFolder && $this->checkFolder($expandFolder))    {
 706              $files = t3lib_div::getFilesInDir($expandFolder,($plainFlag?'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1);    // $extensionList="",$prependPath=0,$order="")
 707              if (is_array($files))    {
 708                  reset($files);
 709  
 710                  $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
 711  
 712                  $titleLen = intval($BE_USER->uc['titleLen']);
 713                  $picon='<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/_icon_webfolders.gif','width="18" height="16"').' alt="" />';
 714                  $picon.=htmlspecialchars(t3lib_div::fixed_lgd(basename($expandFolder),$titleLen));
 715                  $out.='<span class="nobr">'.$picon.'</span><br />';
 716  
 717                  $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
 718                  $imgObj->init();
 719                  $imgObj->mayScaleUp=0;
 720                  $imgObj->tempPath=PATH_site.$imgObj->tempPath;
 721                  
 722                  $lines=array();
 723                  while(list(,$filepath)=each($files))    {
 724                      $fI=pathinfo($filepath);
 725                      
 726                      $origFile = t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site)));
 727                      $iurl = $this->siteUrl.$origFile;
 728                      $imgInfo = $imgObj->getImageDimensions($filepath);
 729                          // File icon:
 730                      $icon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
 731                      $pDim = $imgInfo[0].'x'.$imgInfo[1].' '.$LANG->getLL('pixels',1);
 732                      $size=' ('.t3lib_div::formatSize(filesize($filepath)).$LANG->getLL('bytes',1).', '.$pDim.')';
 733                      $icon = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/fileicons/'.$icon.'','width="18" height="16"').' title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />';
 734                      if (!$plainFlag)    {
 735                          $ATag = '<a href="#" onclick="return jumpToUrl(\'?editorNo='.$this->editorNo.'&insertMagicImage='.rawurlencode($filepath).'\');">';
 736                      } else {
 737                          $ATag = '<a href="#" onclick="return insertImage(\''.$iurl.'\','.$imgInfo[0].','.$imgInfo[1].',\''.$origFile.'\');">';
 738                      }
 739                      $ATag_e='</a>';
 740                      if ($plainFlag && (($imgInfo[0] > $this->plainMaxWidth) || ($imgInfo[1] > $this->plainMaxHeight)))    {
 741                          $ATag='';
 742                          $ATag_e='';
 743                          $ATag2='';
 744                          $ATag2_e='';
 745                      } else {
 746                          $ATag2='<a href="#" onClick="launchView(\''.rawurlencode($filepath).'\'); return false;">';
 747                          $ATag2_e='</a>';
 748                      }
 749  
 750                      $filenameAndIcon=$ATag.$icon.htmlspecialchars(t3lib_div::fixed_lgd(basename($filepath),$titleLen)).$ATag_e;
 751  
 752  
 753                      $lines[]='<tr class="bgColor4"><td nowrap="nowrap">'.$filenameAndIcon.'&nbsp;</td><td nowrap="nowrap">'.$pDim.'&nbsp;</td></tr>';
 754                      $lines[]='<tr><td colspan="2">'.($noThumbs ? '' : $ATag2.t3lib_BEfunc::getThumbNail($this->doc->backPath.'thumbs.php',$filepath,'hspace="5" vspace="5" border="1"').$ATag2_e).
 755                          '</td></tr>';
 756                      $lines[]='<tr><td colspan="2"><img src="clear.gif" width="1" height="3"></td></tr>';
 757                  }
 758                  $out.='<table border="0" cellpadding="0" cellspacing="1">'.implode('',$lines).'</table>';
 759              }
 760          }
 761          return $out;
 762      }
 763      
 764      /**
 765       * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
 766       * The files are uploaded to the tce_file.php script in the core which will handle the upload.
 767       *
 768       * @param    string        Absolute filepath on server to which to upload.
 769       * @return    string        HTML for an upload form.
 770       */
 771  	function uploadForm($path)    {
 772          global $BACK_PATH;
 773          $count=3;
 774  
 775              // Create header, showing upload path:
 776          $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
 777          $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
 778          $code.='
 779  
 780              <!--
 781                  Form, for uploading files:
 782              -->
 783              <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
 784                  <table border="0" cellpadding="0" cellspacing="3" id="typo3-uplFiles">
 785                      <tr>
 786                          <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
 787                      </tr>
 788                      <tr>
 789                          <td>';
 790  
 791              // Traverse the number of upload fields (default is 3):
 792          for ($a=1;$a<=$count;$a++)    {
 793              $code.='<input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" />
 794                  <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($path).'" />
 795                  <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br />';
 796          }
 797  
 798              // Make footer of upload form, including the submit button:
 799          $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
 800          $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
 801                  '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />';
 802  
 803          $code.='
 804              <div id="c-override">
 805                  <input type="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> <label for="overwriteExistingFiles">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles',1).'</label>
 806              </div>
 807          ';
 808  
 809  
 810          $code.='</td>
 811                      </tr>
 812                  </table>
 813              </form>';
 814  
 815          return $code;
 816      }
 817      
 818          
 819      /**
 820       * For TBE: Makes a form for creating new folders in the filemount the user is browsing.
 821       * The folder creation request is sent to the tce_file.php script in the core which will handle the creation.
 822       *
 823       * @param    string        Absolute filepath on server in which to create the new folder.
 824       * @return    string        HTML for the create folder form.
 825       */
 826  	function createFolder($path)    {
 827          global $BACK_PATH;
 828              // Create header, showing upload path:
 829          $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
 830          $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle').':');
 831          $code.='
 832  
 833              <!--
 834                  Form, for creating new folders:
 835              -->
 836              <form action="'.$BACK_PATH.'tce_file.php" method="post" name="editform2">
 837                  <table border="0" cellpadding="0" cellspacing="3" id="typo3-crFolder">
 838                      <tr>
 839                          <td><strong>'.$GLOBALS['LANG']->getLL('path',1).':</strong> '.htmlspecialchars($header).'</td>
 840                      </tr>
 841                      <tr>
 842                          <td>';
 843  
 844              // Create the new-folder name field:
 845          $a=1;
 846          $code.='<input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" />'.
 847                  '<input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($path).'" />';
 848  
 849              // Make footer of upload form, including the submit button:
 850          $redirectValue = $this->thisScript.'?act='.$this->act.'&editorNo='.$this->editorNo.'&mode='.$this->mode.'&expandFolder='.rawurlencode($path).'&bparams='.rawurlencode($this->bparams);
 851          $code.='<input type="hidden" name="redirect" value="'.htmlspecialchars($redirectValue).'" />'.
 852                  '<input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />';
 853  
 854          $code.='</td>
 855                      </tr>
 856                  </table>
 857              </form>';
 858  
 859          return $code;
 860      }
 861  
 862  
 863  }
 864  
 865  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php'])    {
 866      include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php']);
 867  }
 868  
 869  ?>


Généré le : Sun Nov 25 17:13:16 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics