[ Index ]
 

Code source de Typo3 4.1.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/t3lib/ -> class.t3lib_iconworks.php (source)

   1  <?php
   2  /***************************************************************
   3  *  Copyright notice
   4  *
   5  *  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6  *  All rights reserved
   7  *
   8  *  This script is part of the TYPO3 project. The TYPO3 project is
   9  *  free software; you can redistribute it and/or modify
  10  *  it under the terms of the GNU General Public License as published by
  11  *  the Free Software Foundation; either version 2 of the License, or
  12  *  (at your option) any later version.
  13  *
  14  *  The GNU General Public License can be found at
  15  *  http://www.gnu.org/copyleft/gpl.html.
  16  *  A copy is found in the textfile GPL.txt and important notices to the license
  17  *  from the author is found in LICENSE.txt distributed with these scripts.
  18  *
  19  *
  20  *  This script is distributed in the hope that it will be useful,
  21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23  *  GNU General Public License for more details.
  24  *
  25  *  This copyright notice MUST APPEAR in all copies of the script!
  26  ***************************************************************/
  27  /**
  28   * Contains class for icon generation in the backend
  29   *
  30   * $Id: class.t3lib_iconworks.php 1421 2006-04-10 09:27:15Z mundaun $
  31   * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
  32   * XHTML compliant
  33   *
  34   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  35   */
  36  /**
  37   * [CLASS/FUNCTION INDEX of SCRIPT]
  38   *
  39   *
  40   *
  41   *   85: class t3lib_iconWorks
  42   *  100:     function getIconImage($table,$row=array(),$backPath,$params='',$shaded=FALSE)
  43   *  118:     function getIcon($table,$row=array(),$shaded=FALSE)
  44   *  264:     function skinImg($backPath,$src,$wHattribs='',$outputMode=0)
  45   *
  46   *              SECTION: Other functions
  47   *  353:     function makeIcon($iconfile,$mode, $user, $protectSection,$absFile,$iconFileName_stateTagged)
  48   *  475:     function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h)
  49   *  505:     function imagecreatefrom($file)
  50   *  522:     function imagemake($im, $path)
  51   *
  52   * TOTAL FUNCTIONS: 7
  53   * (This index is automatically created/updated by the extension "extdeveval")
  54   *
  55   */
  56  
  57  
  58  
  59  
  60  
  61  
  62  
  63  
  64  
  65  
  66  /**
  67   * Icon generation, backend
  68   * This library has functions that returns - and if necessary creates - the icon for an element in TYPO3
  69   *
  70   * Expects global vars:
  71   * - $BACK_PATH
  72   * - PATH_typo3
  73   * - $TCA, $PAGES_TYPES
  74   *
  75   *
  76   * Notes:
  77   * These functions are strongly related to the interface of TYPO3.
  78   * The class is included in eg. init.php
  79   * ALL functions called without making a class instance, eg. "t3lib_iconWorks::getIconImage()"
  80   *
  81   * @author    Kasper Skaarhoj <kasperYYYY@typo3.com>
  82   * @package TYPO3
  83   * @subpackage t3lib
  84   */
  85  class t3lib_iconWorks    {
  86  
  87      /**
  88       * Returns an icon image tag, 18x16 pixels, based on input information.
  89       * This function is recommended to use in your backend modules.
  90       * Usage: 60
  91       *
  92       * @param    string        The table name
  93       * @param    array        The table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
  94       * @param    string        The backpath to the main TYPO3 directory (relative path back to PATH_typo3)
  95       * @param    string        Additional attributes for the image tag
  96       * @param    boolean        If set, the icon will be grayed/shaded
  97       * @return    string        <img>-tag
  98       * @see getIcon()
  99       */
 100  	function getIconImage($table,$row=array(),$backPath,$params='',$shaded=FALSE)    {
 101          $str='<img'.t3lib_iconWorks::skinImg($backPath,t3lib_iconWorks::getIcon($table,$row,$shaded),'width="18" height="16"').(trim($params)?' '.trim($params):'');
 102          if (!stristr($str,'alt="'))    $str.=' alt=""';
 103          $str.=' />';
 104          return $str;
 105      }
 106  
 107      /**
 108       * Creates the icon for input table/row
 109       * Returns filename for the image icon, relative to PATH_typo3
 110       * Usage: 24
 111       *
 112       * @param    string        The table name
 113       * @param    array        The table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
 114       * @param    boolean        If set, the icon will be grayed/shaded
 115       * @return    string        Icon filename
 116       * @see getIconImage()
 117       */
 118  	function getIcon($table,$row=array(),$shaded=FALSE)    {
 119          global $TCA, $PAGES_TYPES, $ICON_TYPES;
 120  
 121              // Flags:
 122          $doNotGenerateIcon = $GLOBALS['TYPO3_CONF_VARS']['GFX']['noIconProc'];    // If set, the icon will NOT be generated with GDlib. Rather the icon will be looked for as [iconfilename]_X.[extension]
 123          $doNotRenderUserGroupNumber = TRUE;    // If set, then the usergroup number will NOT be printed unto the icon. NOTICE. the icon is generated only if a default icon for groups is not found... So effectively this is ineffective...
 124  
 125              // Shadow:
 126          if ($TCA[$table]['ctrl']['versioningWS'] && (int)$row['t3ver_state']===1)    {
 127              return 'gfx/i/shadow_hide.png';
 128          }
 129          if ($TCA[$table]['ctrl']['versioningWS'] && (int)$row['t3ver_state']===2)    {
 130              return 'gfx/i/shadow_delete.png';
 131          }
 132  
 133              // First, find the icon file name. This can depend on configuration in TCA, field values and more:
 134          if ($table=='pages')    {
 135              if ($row['nav_hide'] && ($row['doktype']==1||$row['doktype']==2))    $row['doktype']=5;    // Workaround to change the icon if "Hide in menu" was set
 136  
 137              if (!$iconfile = $PAGES_TYPES[$row['doktype']]['icon'])    {
 138                  $iconfile = $PAGES_TYPES['default']['icon'];
 139              }
 140              if ($row['module'] && $ICON_TYPES[$row['module']]['icon'])    {
 141                  $iconfile = $ICON_TYPES[$row['module']]['icon'];
 142              }
 143          } else {
 144              if (!$iconfile = $TCA[$table]['ctrl']['typeicons'][$row[$TCA[$table]['ctrl']['typeicon_column']]])    {
 145                  $iconfile = (($TCA[$table]['ctrl']['iconfile']) ? $TCA[$table]['ctrl']['iconfile'] : $table.'.gif');
 146              }
 147          }
 148  
 149              // Setting path of iconfile if not already set. Default is "gfx/i/"
 150          if (!strstr($iconfile,'/'))    {
 151              $iconfile = 'gfx/i/'.$iconfile;
 152          }
 153  
 154              // Setting the absolute path where the icon should be found as a file:
 155          if (substr($iconfile,0,3)=='../')    {
 156              $absfile=PATH_site.substr($iconfile,3);
 157          } else {
 158              $absfile=PATH_typo3.$iconfile;
 159          }
 160  
 161              // Initializing variables, all booleans except otherwise stated:
 162          $hidden = FALSE;
 163          $timing = FALSE;
 164          $futuretiming = FALSE;
 165          $user = FALSE;                // In fact an integer value...
 166          $deleted = FALSE;
 167          $protectSection = FALSE;    // Set, if a page-record (only pages!) has the extend-to-subpages flag set.
 168          $noIconFound = $row['_NO_ICON_FOUND'] ? TRUE : FALSE;
 169          // + $shaded which is also boolean!
 170  
 171              // Icon state based on "enableFields":
 172          if (is_array($TCA[$table]['ctrl']['enablecolumns']))    {
 173              $enCols = $TCA[$table]['ctrl']['enablecolumns'];
 174                  // If "hidden" is enabled:
 175              if ($enCols['disabled'])    { if ($row[$enCols['disabled']]) { $hidden = TRUE; }}
 176                  // If a "starttime" is set and higher than current time:
 177              if ($enCols['starttime'])    { if (time() < intval($row[$enCols['starttime']]))    { $timing = TRUE; }}
 178                  // If an "endtime" is set:
 179              if ($enCols['endtime'])    {
 180                  if (intval($row[$enCols['endtime']]) > 0)    {
 181                      if (intval($row[$enCols['endtime']]) < time())    {
 182                          $timing = TRUE;    // End-timing applies at this point.
 183                      } else {
 184                          $futuretiming = TRUE;        // End-timing WILL apply in the future for this element.
 185                      }
 186                  }
 187              }
 188                  // If a user-group field is set:
 189              if ($enCols['fe_group'])    {
 190                  $user = $row[$enCols['fe_group']];
 191                  if ($user && $doNotRenderUserGroupNumber)    $user=100;    // Limit for user number rendering!
 192              }
 193          }
 194  
 195              // If "deleted" flag is set (only when listing records which are also deleted!)
 196          if ($col=$row[$TCA[$table]['ctrl']['delete']])    {
 197              $deleted = TRUE;
 198          }
 199              // Detecting extendToSubpages (for pages only)
 200          if ($table=='pages' && $row['extendToSubpages'] && ($hidden || $timing || $futuretiming || $user))    {
 201              $protectSection = TRUE;
 202          }
 203  
 204              // If ANY of the booleans are set it means we have to alter the icon:
 205          if ($hidden || $timing || $futuretiming || $user || $deleted || $shaded || $noIconFound)    {
 206              $flags='';
 207              $string='';
 208              if ($deleted)    {
 209                  $string='deleted';
 210                  $flags='d';
 211              } elseif ($noIconFound) {    // This is ONLY for creating icons with "?" on easily...
 212                  $string='no_icon_found';
 213                  $flags='x';
 214              } else {
 215                  if ($hidden) $string.='hidden';
 216                  if ($timing) $string.='timing';
 217                  if (!$string && $futuretiming) {
 218                      $string='futuretiming';
 219                  }
 220  
 221                  $flags.=
 222                      ($hidden ? 'h' : '').
 223                      ($timing ? 't' : '').
 224                      ($futuretiming ? 'f' : '').
 225                      ($user ? 'u' : '').
 226                      ($protectSection ? 'p' : '').
 227                      ($shaded ? 's' : '');
 228              }
 229  
 230                  // Create tagged icon file name:
 231              $iconFileName_stateTagged = ereg_replace('.([[:alnum:]]+)$','__'.$flags.'.\1',basename($iconfile));
 232  
 233                  // Check if tagged icon file name exists (a tagget icon means the icon base name with the flags added between body and extension of the filename, prefixed with underscore)
 234              if (@is_file(dirname($absfile).'/'.$iconFileName_stateTagged))    {    // Look for [iconname]_xxxx.[ext]
 235                  return dirname($iconfile).'/'.$iconFileName_stateTagged;
 236              } elseif ($doNotGenerateIcon)    {        // If no icon generation can be done, try to look for the _X icon:
 237                  $iconFileName_X = ereg_replace('.([[:alnum:]]+)$','__x.\1',basename($iconfile));
 238                  if (@is_file(dirname($absfile).'/'.$iconFileName_X))    {
 239                      return dirname($iconfile).'/'.$iconFileName_X;
 240                  } else {
 241                      return 'gfx/i/no_icon_found.gif';
 242                  }
 243              } else {    // Otherwise, create the icon:
 244                  $theRes = t3lib_iconWorks::makeIcon($GLOBALS['BACK_PATH'].$iconfile, $string, $user, $protectSection, $absfile, $iconFileName_stateTagged);
 245                  return $theRes;
 246              }
 247          } else {
 248              return $iconfile;
 249          }
 250      }
 251  
 252      /**
 253       * Returns the src=... for the input $src value OR any alternative found in $TBE_STYLES['skinImg']
 254       * Used for skinning the TYPO3 backend with an alternative set of icons
 255       * Usage: 336
 256       *
 257       * @param    string        Current backpath to PATH_typo3 folder
 258       * @param    string        Icon file name relative to PATH_typo3 folder
 259       * @param    string        Default width/height, defined like 'width="12" height="14"'
 260       * @param    integer        Mode: 0 (zero) is default and returns src/width/height. 1 returns value of src+backpath, 2 returns value of w/h.
 261       * @return    string        Returns ' src="[backPath][src]" [wHattribs]'
 262       * @see skinImgFile()
 263       */
 264  	function skinImg($backPath,$src,$wHattribs='',$outputMode=0)    {
 265  
 266              // Setting source key. If the icon is refered to inside an extension, we homogenize the prefix to "ext/":
 267          $srcKey = ereg_replace('^(\.\.\/typo3conf\/ext|sysext|ext)\/','ext/',$src);
 268  #if ($src!=$srcKey)debug(array($src,$srcKey));
 269  
 270              // LOOKING for alternative icons:
 271          if ($GLOBALS['TBE_STYLES']['skinImg'][$srcKey])    {    // Slower or faster with is_array()? Could be used.
 272              list($src,$wHattribs) = $GLOBALS['TBE_STYLES']['skinImg'][$srcKey];
 273          } elseif ($GLOBALS['TBE_STYLES']['skinImgAutoCfg'])    {    // Otherwise, test if auto-detection is enabled:
 274  
 275                  // Search for alternative icon automatically:
 276              $fExt = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['forceFileExtension'];
 277              $scaleFactor = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] : 1;    // Scaling factor
 278              $lookUpName = $fExt ? ereg_replace('\.[[:alnum:]]+$','',$srcKey).'.'.$fExt : $srcKey;    // Set filename to look for
 279  
 280                  // If file is found:
 281              if (@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'].$lookUpName))    {    // If there is a file...
 282                  $iInfo = @getimagesize($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'].$lookUpName);    // Get width/height:
 283  
 284                      // Set $src and $wHattribs:
 285                  $src = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'].$lookUpName;
 286                  $wHattribs = 'width="'.round($iInfo[0]*$scaleFactor).'" height="'.round($iInfo[1]*$scaleFactor).'"';
 287              }
 288  
 289                  // In anycase, set currect src / wHattrib - this way we make sure that an entry IS found next time we hit the function, regardless of whether it points to a alternative icon or just the current.
 290              $GLOBALS['TBE_STYLES']['skinImg'][$srcKey] = array($src,$wHattribs);        // Set default...
 291          }
 292  
 293              // DEBUG: This doubles the size of all icons - for testing/debugging:
 294  #        if (ereg('^width="([0-9]+)" height="([0-9]+)"$',$wHattribs,$reg))    $wHattribs='width="'.($reg[1]*2).'" height="'.($reg[2]*2).'"';
 295  
 296  
 297              // rendering disabled (greyed) icons using _i (inactive) as name suffix ("_d" is already used)
 298          $matches = array();
 299          $srcBasename = basename($src);
 300          if (preg_match('/(.*)_i(\....)$/', $srcBasename, $matches)) {
 301              $temp_path = dirname(PATH_thisScript).'/';
 302              if(!@is_file($temp_path.$backPath.$src)) {
 303                  $srcOrg = preg_replace('/_i'.preg_quote($matches[2]).'$/', $matches[2], $src);
 304                  $src = t3lib_iconWorks::makeIcon($backPath.$srcOrg, 'disabled', 0, false, $temp_path.$backPath.$srcOrg, $srcBasename);
 305              }
 306          }
 307  
 308  
 309              // Return icon source/wHattributes:
 310          $output = '';
 311          switch($outputMode)    {
 312              case 0:
 313                  $output = ' src="'.$backPath.$src.'" '.$wHattribs;
 314              break;
 315              case 1:
 316                  $output = $backPath.$src;
 317              break;
 318              case 2:
 319                  $output = $wHattribs;
 320              break;
 321          }
 322          return $output;
 323      }
 324  
 325  
 326  
 327  
 328  
 329  
 330  
 331  
 332  
 333  
 334  
 335      /***********************************
 336       *
 337       * Other functions
 338       *
 339       ***********************************/
 340  
 341      /**
 342       * Creates the icon file for the function getIcon()
 343       *
 344       * @param    string        Original unprocessed Icon file, relative path to PATH_typo3
 345       * @param    string        Mode string, eg. "deleted" or "futuretiming" determining how the icon will look
 346       * @param    integer        The number of the fe_group record uid if applicable
 347       * @param    boolean        Flag determines if the protected-section icon should be applied.
 348       * @param    string        Absolute path to file from which to create the icon.
 349       * @param    string        The filename that this icon should have had, basically [icon base name]_[flags].[extension] - used for part of temporary filename
 350       * @return    string        Filename relative to PATH_typo3
 351       * @access private
 352       */
 353  	function makeIcon($iconfile,$mode, $user, $protectSection,$absFile,$iconFileName_stateTagged)    {
 354          $iconFileName = 'icon_'.t3lib_div::shortMD5($iconfile.'|'.$mode.'|-'.$user.'|'.$protectSection).'_'.$iconFileName_stateTagged.'.'.($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']?'png':'gif');
 355          $mainpath = '../typo3temp/'.$iconFileName;
 356          $path = PATH_site.'typo3temp/'.$iconFileName;
 357  
 358  
 359          if (@file_exists(PATH_typo3.'icons/'.$iconFileName))    {    // Returns if found in typo3/icons/
 360              return 'icons/'.$iconFileName;
 361          } elseif (@file_exists($path))    {    // Returns if found in ../typo3temp/icons/
 362              return $mainpath;
 363          } else {    // Makes icon:
 364              if (@file_exists($absFile))    {
 365                  if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'])    {
 366  
 367                          // Create image pointer, if possible
 368                      $im = t3lib_iconworks::imagecreatefrom($absFile);
 369                      if ($im<0)    return $iconfile;
 370  
 371                          // Converting to gray scale, dimming the icon:
 372                      if (($mode=='disabled') OR ($mode!='futuretiming' && $mode!='no_icon_found' && !(!$mode && $user)))    {
 373                          for ($c=0; $c<ImageColorsTotal($im); $c++)    {
 374                              $cols = ImageColorsForIndex($im,$c);
 375                              $newcol = round(($cols['red']+$cols['green']+$cols['blue'])/3);
 376                              $lighten = ($mode=='disabled') ? 2.5 : 2;
 377                              $newcol = round(255-((255-$newcol)/$lighten));
 378                              ImageColorSet($im,$c,$newcol,$newcol,$newcol);
 379                          }
 380                      }
 381                          // Applying user icon, if there are access control on the item:
 382                      if ($user)    {
 383                          if ($user < 100)    {    // Apply user number only if lower than 100
 384                              $black = ImageColorAllocate($im, 0,0,0);
 385                              imagefilledrectangle($im, 0,0,(($user>10)?9:5),8,$black);
 386  
 387                              $white = ImageColorAllocate($im, 255,255,255);
 388                              imagestring($im, 1, 1, 1, $user, $white);
 389                          }
 390  
 391                          $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_group.gif');
 392                          if ($ol_im<0)    return $iconfile;
 393  
 394                          t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
 395                      }
 396                          // Applying overlay based on mode:
 397                      if ($mode)    {
 398                          unset($ol_im);
 399                          switch($mode)    {
 400                              case 'deleted':
 401                                  $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_deleted.gif');
 402                              break;
 403                              case 'futuretiming':
 404                                  $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_timing.gif');
 405                              break;
 406                              case 'timing':
 407                                  $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_timing.gif');
 408                              break;
 409                              case 'hiddentiming':
 410                                  $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_hidden_timing.gif');
 411                              break;
 412                              case 'no_icon_found':
 413                                  $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_no_icon_found.gif');
 414                              break;
 415                              case 'disabled':
 416                                      // is already greyed - nothing more
 417                                  $ol_im = 0;
 418                              break;
 419                              case 'hidden':
 420                              default:
 421                                  $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_hidden.gif');
 422                              break;
 423                          }
 424                          if ($ol_im<0)    return $iconfile;
 425                          if ($ol_im) {
 426                              t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
 427                          }
 428                      }
 429                          // Protect-section icon:
 430                      if ($protectSection)    {
 431                          $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_sub5.gif');
 432                          if ($ol_im<0)    return $iconfile;
 433                          t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
 434                      }
 435  
 436                          // Create the image as file, destroy GD image and return:
 437                      @t3lib_iconWorks::imagemake($im, $path);
 438                      t3lib_div::gif_compress($path, 'IM');
 439                      ImageDestroy($im);
 440                      return $mainpath;
 441                  } else {
 442                      return $iconfile;
 443                  }
 444              } else {
 445                  return $GLOBALS['BACK_PATH'].'gfx/fileicons/default.gif';
 446              }
 447          }
 448      }
 449  
 450      /**
 451       * The necessity of using this function for combining two images if GD is version 2 is that
 452       * GD2 cannot manage to combine two indexed-color images without totally spoiling everything.
 453       * In class.t3lib_stdgraphic this was solved by combining the images onto a first created true color image
 454       * However it has turned out that this method will not work if the indexed png-files contains transparency.
 455       * So I had to turn my attention to ImageMagick - my 'enemy of death'.
 456       * And so it happend - ImageMagick is now used to combine my two indexed-color images with transparency. And that works.
 457       * Of course it works only if ImageMagick is able to create valid png-images - which you cannot be sure of with older versions (still 5+)
 458       * The only drawback is (apparently) that IM creates true-color png's. The transparency of these will not be shown by MSIE on windows at this time (although it's straight 0%/100% transparency!) and the file size may be larger.
 459       *
 460       * For parameters, see PHP function "imagecopyresized()"
 461       *
 462       * @param    pointer        see PHP function "imagecopyresized()"
 463       * @param    pointer        see PHP function "imagecopyresized()"
 464       * @param    integer        see PHP function "imagecopyresized()"
 465       * @param    integer        see PHP function "imagecopyresized()"
 466       * @param    integer        see PHP function "imagecopyresized()"
 467       * @param    integer        see PHP function "imagecopyresized()"
 468       * @param    integer        see PHP function "imagecopyresized()"
 469       * @param    integer        see PHP function "imagecopyresized()"
 470       * @param    integer        see PHP function "imagecopyresized()"
 471       * @param    integer        see PHP function "imagecopyresized()"
 472       * @return    void
 473       * @access private
 474       */
 475  	function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h)    {
 476          if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_2'] && $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'])    {    // Maybe I'll have to change this if GD2/gif does not work either...
 477              if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'])    {
 478  
 479                  $tempBaseName = PATH_site.'typo3temp/ICRZ_'.md5(uniqid('.'));
 480  
 481                  ImagePng($im, $tempBaseName.'_im.png');
 482                  ImagePng($cpImg, $tempBaseName.'_cpImg.png');
 483  
 484                  $cmd = t3lib_div::imageMagickCommand('combine', '-compose over '.$tempBaseName.'_cpImg.png '.$tempBaseName.'_im.png '.$tempBaseName.'_out.png ');
 485                  exec($cmd);
 486  
 487                  $im = imagecreatefrompng($tempBaseName.'_out.png');
 488                  unlink($tempBaseName.'_im.png');
 489                  unlink($tempBaseName.'_cpImg.png');
 490                  unlink($tempBaseName.'_out.png');
 491              }
 492          } else {
 493              imagecopyresized($im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h);
 494          }
 495      }
 496  
 497      /**
 498       * Create new image pointer from input file (either gif/png, in case the wrong format it is converted by t3lib_div::read_png_gif())
 499       *
 500       * @param    string        Absolute filename of the image file from which to start the icon creation.
 501       * @return    mixed        If success, image pointer, otherwise "-1"
 502       * @access private
 503       * @see t3lib_div::read_png_gif
 504       */
 505  	function imagecreatefrom($file)    {
 506          $file = t3lib_div::read_png_gif($file,$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']);
 507          if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'])    {
 508              return $file ? imagecreatefrompng($file) : -1;
 509          } else {
 510              return $file ? imagecreatefromgif($file) : -1;
 511          }
 512      }
 513  
 514      /**
 515       * Write the icon in $im pointer to $path
 516       *
 517       * @param    pointer        Pointer to GDlib image resource
 518       * @param    string        Absolute path to the filename in which to write the icon.
 519       * @return    void
 520       * @access private
 521       */
 522  	function imagemake($im, $path)    {
 523          if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'])    {
 524              @ImagePng($im, $path);
 525          } else {
 526              @ImageGif($im, $path);
 527          }
 528      }
 529  }
 530  ?>


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