class.t3lib_iconworks.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Contains class for icon generation in the backend
00029  *
00030  * $Id: class.t3lib_iconworks.php 4593 2008-12-22 16:30:24Z steffenk $
00031  * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
00032  * XHTML compliant
00033  *
00034  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00035  */
00036 /**
00037  * [CLASS/FUNCTION INDEX of SCRIPT]
00038  *
00039  *
00040  *
00041  *   85: class t3lib_iconWorks
00042  *  100:     function getIconImage($table,$row=array(),$backPath,$params='',$shaded=FALSE)
00043  *  118:     function getIcon($table,$row=array(),$shaded=FALSE)
00044  *  264:     function skinImg($backPath,$src,$wHattribs='',$outputMode=0)
00045  *
00046  *              SECTION: Other functions
00047  *  353:     function makeIcon($iconfile,$mode, $user, $protectSection,$absFile,$iconFileName_stateTagged)
00048  *  475:     function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h)
00049  *  505:     function imagecreatefrom($file)
00050  *  522:     function imagemake($im, $path)
00051  *
00052  * TOTAL FUNCTIONS: 7
00053  * (This index is automatically created/updated by the extension "extdeveval")
00054  *
00055  */
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 /**
00067  * Icon generation, backend
00068  * This library has functions that returns - and if necessary creates - the icon for an element in TYPO3
00069  *
00070  * Expects global vars:
00071  * - $BACK_PATH
00072  * - PATH_typo3
00073  * - $TCA, $PAGES_TYPES
00074  *
00075  *
00076  * Notes:
00077  * These functions are strongly related to the interface of TYPO3.
00078  * The class is included in eg. init.php
00079  * ALL functions called without making a class instance, eg. "t3lib_iconWorks::getIconImage()"
00080  *
00081  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00082  * @package TYPO3
00083  * @subpackage t3lib
00084  */
00085 final class t3lib_iconWorks {
00086 
00087     /**
00088      * Returns an icon image tag, 18x16 pixels, based on input information.
00089      * This function is recommended to use in your backend modules.
00090      * Usage: 60
00091      *
00092      * @param   string      The table name
00093      * @param   array       The table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
00094      * @param   string      The backpath to the main TYPO3 directory (relative path back to PATH_typo3)
00095      * @param   string      Additional attributes for the image tag
00096      * @param   boolean     If set, the icon will be grayed/shaded
00097      * @return  string      <img>-tag
00098      * @see getIcon()
00099      */
00100     public static function getIconImage($table, $row = array(), $backPath, $params = '', $shaded = FALSE) {
00101         $str = '<img'.t3lib_iconWorks::skinImg($backPath, t3lib_iconWorks::getIcon($table, $row, $shaded), 'width="18" height="16"').(trim($params)?' '.trim($params):'');
00102         if (!stristr($str, 'alt="')) {
00103             $str.=' alt=""';
00104         }
00105         $str.=' />';
00106         return $str;
00107     }
00108 
00109     /**
00110      * Creates the icon for input table/row
00111      * Returns filename for the image icon, relative to PATH_typo3
00112      * Usage: 24
00113      *
00114      * @param   string      The table name
00115      * @param   array       The table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
00116      * @param   boolean     If set, the icon will be grayed/shaded
00117      * @return  string      Icon filename
00118      * @see getIconImage()
00119      */
00120     public static function getIcon($table, $row = array(), $shaded = FALSE) {
00121         global $TCA, $PAGES_TYPES, $ICON_TYPES;
00122 
00123             // Flags:
00124         $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]
00125         $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...
00126 
00127             // Shadow:
00128         if ($TCA[$table]['ctrl']['versioningWS']) {
00129             switch((int)$row['t3ver_state']) {
00130                 case 1:
00131                     return 'gfx/i/shadow_hide.png';
00132                 break;
00133                 case 2:
00134                     return 'gfx/i/shadow_delete.png';
00135                 break;
00136                 case 3:
00137                     return 'gfx/i/shadow_moveto_plh.png';
00138                 break;
00139                 case 4:
00140                     return 'gfx/i/shadow_moveto_pointer.png';
00141                 break;
00142             }
00143         }
00144 
00145             // First, find the icon file name. This can depend on configuration in TCA, field values and more:
00146         if ($table=='pages') {
00147                 // @TODO: RFC #7370: doktype 2&5 are deprecated since TYPO3 4.2-beta1
00148             if ($row['nav_hide'] && ($row['doktype']==1||$row['doktype']==2))   $row['doktype'] = 5;    // Workaround to change the icon if "Hide in menu" was set
00149 
00150             if (!$iconfile = $PAGES_TYPES[$row['doktype']]['icon']) {
00151                 $iconfile = $PAGES_TYPES['default']['icon'];
00152             }
00153             if ($row['module'] && $ICON_TYPES[$row['module']]['icon']) {
00154                 $iconfile = $ICON_TYPES[$row['module']]['icon'];
00155             }
00156         } else {
00157             if (!$iconfile = $TCA[$table]['ctrl']['typeicons'][$row[$TCA[$table]['ctrl']['typeicon_column']]]) {
00158                 $iconfile = (($TCA[$table]['ctrl']['iconfile']) ? $TCA[$table]['ctrl']['iconfile'] : $table.'.gif');
00159             }
00160         }
00161 
00162             // Setting path of iconfile if not already set. Default is "gfx/i/"
00163         if (!strstr($iconfile, '/')) {
00164             $iconfile = 'gfx/i/'.$iconfile;
00165         }
00166 
00167             // Setting the absolute path where the icon should be found as a file:
00168         if (substr($iconfile, 0, 3)=='../') {
00169             $absfile = PATH_site.substr($iconfile, 3);
00170         } else {
00171             $absfile = PATH_typo3.$iconfile;
00172         }
00173 
00174             // Initializing variables, all booleans except otherwise stated:
00175         $hidden = FALSE;
00176         $timing = FALSE;
00177         $futuretiming = FALSE;
00178         $user = FALSE;              // In fact an integer value...
00179         $deleted = FALSE;
00180         $protectSection = FALSE;    // Set, if a page-record (only pages!) has the extend-to-subpages flag set.
00181         $noIconFound = $row['_NO_ICON_FOUND'] ? TRUE : FALSE;
00182         // + $shaded which is also boolean!
00183 
00184             // Icon state based on "enableFields":
00185         if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
00186             $enCols = $TCA[$table]['ctrl']['enablecolumns'];
00187                 // If "hidden" is enabled:
00188             if ($enCols['disabled'])    { if ($row[$enCols['disabled']]) { $hidden = TRUE; }}
00189                 // If a "starttime" is set and higher than current time:
00190             if ($enCols['starttime'])   { if (time() < intval($row[$enCols['starttime']]))  { $timing = TRUE; }}
00191                 // If an "endtime" is set:
00192             if ($enCols['endtime']) {
00193                 if (intval($row[$enCols['endtime']]) > 0) {
00194                     if (intval($row[$enCols['endtime']]) < time()) {
00195                         $timing = TRUE; // End-timing applies at this point.
00196                     } else {
00197                         $futuretiming = TRUE;       // End-timing WILL apply in the future for this element.
00198                     }
00199                 }
00200             }
00201                 // If a user-group field is set:
00202             if ($enCols['fe_group']) {
00203                 $user = $row[$enCols['fe_group']];
00204                 if ($user && $doNotRenderUserGroupNumber)   $user = 100;    // Limit for user number rendering!
00205             }
00206         }
00207 
00208             // If "deleted" flag is set (only when listing records which are also deleted!)
00209         if ($col = $row[$TCA[$table]['ctrl']['delete']]) {
00210             $deleted = TRUE;
00211         }
00212             // Detecting extendToSubpages (for pages only)
00213         if ($table=='pages' && $row['extendToSubpages'] && ($hidden || $timing || $futuretiming || $user)) {
00214             $protectSection = TRUE;
00215         }
00216 
00217             // If ANY of the booleans are set it means we have to alter the icon:
00218         if ($hidden || $timing || $futuretiming || $user || $deleted || $shaded || $noIconFound) {
00219             $flags = '';
00220             $string = '';
00221             if ($deleted) {
00222                 $string = 'deleted';
00223                 $flags = 'd';
00224             } elseif ($noIconFound) {   // This is ONLY for creating icons with "?" on easily...
00225                 $string = 'no_icon_found';
00226                 $flags = 'x';
00227             } else {
00228                 if ($hidden) $string.='hidden';
00229                 if ($timing) $string.='timing';
00230                 if (!$string && $futuretiming) {
00231                     $string = 'futuretiming';
00232                 }
00233 
00234                 $flags.=
00235                     ($hidden ? 'h' : '').
00236                     ($timing ? 't' : '').
00237                     ($futuretiming ? 'f' : '').
00238                     ($user ? 'u' : '').
00239                     ($protectSection ? 'p' : '').
00240                     ($shaded ? 's' : '');
00241             }
00242 
00243                 // Create tagged icon file name:
00244             $iconFileName_stateTagged = ereg_replace('.([[:alnum:]]+)$', '__'.$flags.'.\1', basename($iconfile));
00245 
00246                 // 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)
00247             if (@is_file(dirname($absfile).'/'.$iconFileName_stateTagged))  {   // Look for [iconname]_xxxx.[ext]
00248                 return dirname($iconfile).'/'.$iconFileName_stateTagged;
00249             } elseif ($doNotGenerateIcon)   {       // If no icon generation can be done, try to look for the _X icon:
00250                 $iconFileName_X = ereg_replace('.([[:alnum:]]+)$', '__x.\1', basename($iconfile));
00251                 if (@is_file(dirname($absfile).'/'.$iconFileName_X)) {
00252                     return dirname($iconfile).'/'.$iconFileName_X;
00253                 } else {
00254                     return 'gfx/i/no_icon_found.gif';
00255                 }
00256             } else {    // Otherwise, create the icon:
00257                 $theRes = t3lib_iconWorks::makeIcon($GLOBALS['BACK_PATH'].$iconfile, $string, $user, $protectSection, $absfile, $iconFileName_stateTagged);
00258                 return $theRes;
00259             }
00260         } else {
00261             return $iconfile;
00262         }
00263     }
00264 
00265     /**
00266      * Returns the src=... for the input $src value OR any alternative found in $TBE_STYLES['skinImg']
00267      * Used for skinning the TYPO3 backend with an alternative set of icons
00268      * Usage: 336
00269      *
00270      * @param   string      Current backpath to PATH_typo3 folder
00271      * @param   string      Icon file name relative to PATH_typo3 folder
00272      * @param   string      Default width/height, defined like 'width="12" height="14"'
00273      * @param   integer     Mode: 0 (zero) is default and returns src/width/height. 1 returns value of src+backpath, 2 returns value of w/h.
00274      * @return  string      Returns ' src="[backPath][src]" [wHattribs]'
00275      * @see skinImgFile()
00276      */
00277     public static function skinImg($backPath, $src, $wHattribs = '', $outputMode = 0)   {
00278 
00279             // Setting source key. If the icon is refered to inside an extension, we homogenize the prefix to "ext/":
00280         $srcKey = ereg_replace('^(\.\.\/typo3conf\/ext|sysext|ext)\/', 'ext/', $src);
00281 #if ($src!=$srcKey)debug(array($src, $srcKey));
00282 
00283             // LOOKING for alternative icons:
00284         if ($GLOBALS['TBE_STYLES']['skinImg'][$srcKey]) {   // Slower or faster with is_array()? Could be used.
00285             list($src, $wHattribs) = $GLOBALS['TBE_STYLES']['skinImg'][$srcKey];
00286         } elseif ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']) {   // Otherwise, test if auto-detection is enabled:
00287 
00288                 // Search for alternative icon automatically:
00289             $fExt = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['forceFileExtension'];
00290             $scaleFactor = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] : 1;   // Scaling factor
00291             $lookUpName = $fExt ? ereg_replace('\.[[:alnum:]]+$', '', $srcKey).'.'.$fExt : $srcKey; // Set filename to look for
00292      
00293             if ($fExt && !@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName)) {
00294                 // fallback to original filename if icon with forced extension doesn't exists
00295                 $lookUpName = $srcKey;  
00296             }
00297                 // If file is found:
00298             if (@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'].$lookUpName))   {   // If there is a file...
00299                 $iInfo = @getimagesize($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'].$lookUpName); // Get width/height:
00300 
00301                     // Set $src and $wHattribs:
00302                 $src = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'].$lookUpName;
00303                 $wHattribs = 'width="'.round($iInfo[0]*$scaleFactor).'" height="'.round($iInfo[1]*$scaleFactor).'"';
00304             }
00305 
00306                 // 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.
00307             $GLOBALS['TBE_STYLES']['skinImg'][$srcKey] = array($src, $wHattribs);       // Set default...
00308         }
00309 
00310             // DEBUG: This doubles the size of all icons - for testing/debugging:
00311 #       if (ereg('^width="([0-9]+)" height="([0-9]+)"$', $wHattribs, $reg)) $wHattribs='width="'.($reg[1]*2).'" height="'.($reg[2]*2).'"';
00312 
00313 
00314             // rendering disabled (greyed) icons using _i (inactive) as name suffix ("_d" is already used)
00315         $matches = array();
00316         $srcBasename = basename($src);
00317         if (preg_match('/(.*)_i(\....)$/', $srcBasename, $matches)) {
00318             $temp_path = dirname(PATH_thisScript).'/';
00319             if(!@is_file($temp_path.$backPath.$src)) {
00320                 $srcOrg = preg_replace('/_i'.preg_quote($matches[2]).'$/', $matches[2], $src);
00321                 $src = t3lib_iconWorks::makeIcon($backPath.$srcOrg, 'disabled', 0, false, $temp_path.$backPath.$srcOrg, $srcBasename);
00322             }
00323         }
00324 
00325 
00326             // Return icon source/wHattributes:
00327         $output = '';
00328         switch($outputMode) {
00329             case 0:
00330                 $output = ' src="'.$backPath.$src.'" '.$wHattribs;
00331             break;
00332             case 1:
00333                 $output = $backPath.$src;
00334             break;
00335             case 2:
00336                 $output = $wHattribs;
00337             break;
00338         }
00339         return $output;
00340     }
00341 
00342 
00343 
00344 
00345 
00346 
00347 
00348 
00349 
00350 
00351 
00352     /***********************************
00353      *
00354      * Other functions
00355      *
00356      ***********************************/
00357 
00358     /**
00359      * Creates the icon file for the function getIcon()
00360      *
00361      * @param   string      Original unprocessed Icon file, relative path to PATH_typo3
00362      * @param   string      Mode string, eg. "deleted" or "futuretiming" determining how the icon will look
00363      * @param   integer     The number of the fe_group record uid if applicable
00364      * @param   boolean     Flag determines if the protected-section icon should be applied.
00365      * @param   string      Absolute path to file from which to create the icon.
00366      * @param   string      The filename that this icon should have had, basically [icon base name]_[flags].[extension] - used for part of temporary filename
00367      * @return  string      Filename relative to PATH_typo3
00368      * @access private
00369      */
00370     public static function makeIcon($iconfile, $mode, $user, $protectSection, $absFile, $iconFileName_stateTagged) {
00371         $iconFileName = 'icon_'.t3lib_div::shortMD5($iconfile.'|'.$mode.'|-'.$user.'|'.$protectSection).'_'.$iconFileName_stateTagged.'.'.($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']?'png':'gif');
00372         $mainpath = '../typo3temp/'.$iconFileName;
00373         $path = PATH_site.'typo3temp/'.$iconFileName;
00374 
00375 
00376         if (file_exists(PATH_typo3.'icons/'.$iconFileName)) {   // Returns if found in typo3/icons/
00377             return 'icons/'.$iconFileName;
00378         } elseif (file_exists($path))   {   // Returns if found in ../typo3temp/icons/
00379             return $mainpath;
00380         } else {    // Makes icon:
00381             if (file_exists($absFile)) {
00382                 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'])    {
00383 
00384                         // Create image pointer, if possible
00385                     $im = t3lib_iconworks::imagecreatefrom($absFile);
00386                     if ($im<0)  return $iconfile;
00387 
00388                         // Converting to gray scale, dimming the icon:
00389                     if (($mode=='disabled') OR ($mode!='futuretiming' && $mode!='no_icon_found' && !(!$mode && $user))) {
00390                         for ($c = 0; $c<ImageColorsTotal($im); $c++) {
00391                             $cols = ImageColorsForIndex($im, $c);
00392                             $newcol = round(($cols['red']+$cols['green']+$cols['blue'])/3);
00393                             $lighten = ($mode=='disabled') ? 2.5 : 2;
00394                             $newcol = round(255-((255-$newcol)/$lighten));
00395                             ImageColorSet($im, $c, $newcol, $newcol, $newcol);
00396                         }
00397                     }
00398                         // Applying user icon, if there are access control on the item:
00399                     if ($user) {
00400                         if ($user < 100)    {   // Apply user number only if lower than 100
00401                             $black = ImageColorAllocate($im, 0, 0, 0);
00402                             imagefilledrectangle($im, 0, 0, (($user>10)?9:5), 8, $black);
00403 
00404                             $white = ImageColorAllocate($im, 255, 255, 255);
00405                             imagestring($im, 1, 1, 1, $user, $white);
00406                         }
00407 
00408                         $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_group.gif');
00409                         if ($ol_im<0)   return $iconfile;
00410 
00411                         t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
00412                     }
00413                         // Applying overlay based on mode:
00414                     if ($mode) {
00415                         unset($ol_im);
00416                         switch($mode) {
00417                             case 'deleted':
00418                                 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_deleted.gif');
00419                             break;
00420                             case 'futuretiming':
00421                                 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_timing.gif');
00422                             break;
00423                             case 'timing':
00424                                 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_timing.gif');
00425                             break;
00426                             case 'hiddentiming':
00427                                 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_hidden_timing.gif');
00428                             break;
00429                             case 'no_icon_found':
00430                                 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_no_icon_found.gif');
00431                             break;
00432                             case 'disabled':
00433                                     // is already greyed - nothing more
00434                                 $ol_im = 0;
00435                             break;
00436                             case 'hidden':
00437                             default:
00438                                 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_hidden.gif');
00439                             break;
00440                         }
00441                         if ($ol_im<0)   return $iconfile;
00442                         if ($ol_im) {
00443                             t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
00444                         }
00445                     }
00446                         // Protect-section icon:
00447                     if ($protectSection) {
00448                         $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_sub5.gif');
00449                         if ($ol_im<0)   return $iconfile;
00450                         t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
00451                     }
00452 
00453                         // Create the image as file, destroy GD image and return:
00454                     @t3lib_iconWorks::imagemake($im, $path);
00455                     t3lib_div::gif_compress($path, 'IM');
00456                     ImageDestroy($im);
00457                     return $mainpath;
00458                 } else {
00459                     return $iconfile;
00460                 }
00461             } else {
00462                 return $GLOBALS['BACK_PATH'].'gfx/fileicons/default.gif';
00463             }
00464         }
00465     }
00466 
00467     /**
00468      * The necessity of using this function for combining two images if GD is version 2 is that
00469      * GD2 cannot manage to combine two indexed-color images without totally spoiling everything.
00470      * In class.t3lib_stdgraphic this was solved by combining the images onto a first created true color image
00471      * However it has turned out that this method will not work if the indexed png-files contains transparency.
00472      * So I had to turn my attention to ImageMagick - my 'enemy of death'.
00473      * And so it happend - ImageMagick is now used to combine my two indexed-color images with transparency. And that works.
00474      * 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+)
00475      * 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.
00476      *
00477      * For parameters, see PHP function "imagecopyresized()"
00478      *
00479      * @param   pointer     see PHP function "imagecopyresized()"
00480      * @param   pointer     see PHP function "imagecopyresized()"
00481      * @param   integer     see PHP function "imagecopyresized()"
00482      * @param   integer     see PHP function "imagecopyresized()"
00483      * @param   integer     see PHP function "imagecopyresized()"
00484      * @param   integer     see PHP function "imagecopyresized()"
00485      * @param   integer     see PHP function "imagecopyresized()"
00486      * @param   integer     see PHP function "imagecopyresized()"
00487      * @param   integer     see PHP function "imagecopyresized()"
00488      * @param   integer     see PHP function "imagecopyresized()"
00489      * @return  void
00490      * @access private
00491      */
00492     public static function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h) {
00493         imagecopyresized($im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h);
00494     }
00495 
00496     /**
00497      * Create new image pointer from input file (either gif/png, in case the wrong format it is converted by t3lib_div::read_png_gif())
00498      *
00499      * @param   string      Absolute filename of the image file from which to start the icon creation.
00500      * @return  mixed       If success, image pointer, otherwise "-1"
00501      * @access private
00502      * @see t3lib_div::read_png_gif
00503      */
00504     public static function imagecreatefrom($file) {
00505         $file = t3lib_div::read_png_gif($file, $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']);
00506         if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
00507             return $file ? imagecreatefrompng($file) : -1;
00508         } else {
00509             return $file ? imagecreatefromgif($file) : -1;
00510         }
00511     }
00512 
00513     /**
00514      * Write the icon in $im pointer to $path
00515      *
00516      * @param   pointer     Pointer to GDlib image resource
00517      * @param   string      Absolute path to the filename in which to write the icon.
00518      * @return  void
00519      * @access private
00520      */
00521     public static function imagemake($im, $path) {
00522         if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
00523             @ImagePng($im, $path);
00524         } else {
00525             @ImageGif($im, $path);
00526         }
00527     }
00528 }
00529 ?>

Generated on Sat Jan 3 04:23:26 2009 for TYPO3 API by  doxygen 1.4.7