Fixed bug #13486: Wrong icon-state returned from 'getIcon' (thanks to Stephan Kellermayr)
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_iconworks.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 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$
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 final 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 public static 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="')) {
103 $str.=' alt=""';
104 }
105 $str.=' />';
106 return $str;
107 }
108
109 /**
110 * Creates the icon for input table/row
111 * Returns filename for the image icon, relative to PATH_typo3
112 * Usage: 24
113 *
114 * @param string The table name
115 * @param array The table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
116 * @param boolean If set, the icon will be grayed/shaded
117 * @return string Icon filename
118 * @see getIconImage()
119 */
120 public static function getIcon($table, $row = array(), $shaded = FALSE) {
121 global $TCA, $PAGES_TYPES, $ICON_TYPES;
122
123 // Flags:
124 $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]
125 $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...
126
127 // Shadow:
128 if ($TCA[$table]['ctrl']['versioningWS']) {
129 switch((int)$row['t3ver_state']) {
130 case 1:
131 return 'gfx/i/shadow_hide.png';
132 break;
133 case 2:
134 return 'gfx/i/shadow_delete.png';
135 break;
136 case 3:
137 return 'gfx/i/shadow_moveto_plh.png';
138 break;
139 case 4:
140 return 'gfx/i/shadow_moveto_pointer.png';
141 break;
142 }
143 }
144
145 // First, find the icon file name. This can depend on configuration in TCA, field values and more:
146 if ($table=='pages') {
147 // @TODO: RFC #7370: doktype 2&5 are deprecated since TYPO3 4.2-beta1
148 if ($row['nav_hide'] && ($row['doktype']==1||$row['doktype']==2)) $row['doktype'] = 5; // Workaround to change the icon if "Hide in menu" was set
149
150 if (!$iconfile = $PAGES_TYPES[$row['doktype']]['icon']) {
151 $iconfile = $PAGES_TYPES['default']['icon'];
152 }
153 if ($row['module'] && $ICON_TYPES[$row['module']]['icon']) {
154 $iconfile = $ICON_TYPES[$row['module']]['icon'];
155 }
156 } else {
157 if (!$iconfile = $TCA[$table]['ctrl']['typeicons'][$row[$TCA[$table]['ctrl']['typeicon_column']]]) {
158 $iconfile = (($TCA[$table]['ctrl']['iconfile']) ? $TCA[$table]['ctrl']['iconfile'] : $table.'.gif');
159 }
160 }
161
162 // Setting path of iconfile if not already set. Default is "gfx/i/"
163 if (!strstr($iconfile, '/')) {
164 $iconfile = 'gfx/i/'.$iconfile;
165 }
166
167 // Setting the absolute path where the icon should be found as a file:
168 if (substr($iconfile, 0, 3)=='../') {
169 $absfile = PATH_site.substr($iconfile, 3);
170 } else {
171 $absfile = PATH_typo3.$iconfile;
172 }
173
174 // Initializing variables, all booleans except otherwise stated:
175 $hidden = FALSE;
176 $timing = FALSE;
177 $futuretiming = FALSE;
178 $user = FALSE; // In fact an integer value...
179 $deleted = FALSE;
180 $protectSection = FALSE; // Set, if a page-record (only pages!) has the extend-to-subpages flag set.
181 $noIconFound = $row['_NO_ICON_FOUND'] ? TRUE : FALSE;
182 // + $shaded which is also boolean!
183
184 // Icon state based on "enableFields":
185 if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
186 $enCols = $TCA[$table]['ctrl']['enablecolumns'];
187 // If "hidden" is enabled:
188 if ($enCols['disabled']) { if ($row[$enCols['disabled']]) { $hidden = TRUE; }}
189 // If a "starttime" is set and higher than current time:
190 if ($enCols['starttime']) {
191 if ($GLOBALS['EXEC_TIME'] < intval($row[$enCols['starttime']])) {
192 $timing = TRUE;
193 // ...And if "endtime" is NOT set:
194 if (intval($row[$enCols['endtime']]) == 0) {
195 $futuretiming = TRUE;
196 }
197 }
198 }
199 // If an "endtime" is set:
200 if ($enCols['endtime']) {
201 if (intval($row[$enCols['endtime']]) > 0) {
202 if (intval($row[$enCols['endtime']]) < $GLOBALS['EXEC_TIME']) {
203 $timing = TRUE; // End-timing applies at this point.
204 } else {
205 $futuretiming = TRUE; // End-timing WILL apply in the future for this element.
206 }
207 }
208 }
209 // If a user-group field is set:
210 if ($enCols['fe_group']) {
211 $user = $row[$enCols['fe_group']];
212 if ($user && $doNotRenderUserGroupNumber) $user = 100; // Limit for user number rendering!
213 }
214 }
215
216 // If "deleted" flag is set (only when listing records which are also deleted!)
217 if ($col = $row[$TCA[$table]['ctrl']['delete']]) {
218 $deleted = TRUE;
219 }
220 // Detecting extendToSubpages (for pages only)
221 if ($table=='pages' && $row['extendToSubpages'] && ($hidden || $timing || $futuretiming || $user)) {
222 $protectSection = TRUE;
223 }
224
225 // If ANY of the booleans are set it means we have to alter the icon:
226 if ($hidden || $timing || $futuretiming || $user || $deleted || $shaded || $noIconFound) {
227 $flags = '';
228 $string = '';
229 if ($deleted) {
230 $string = 'deleted';
231 $flags = 'd';
232 } elseif ($noIconFound) { // This is ONLY for creating icons with "?" on easily...
233 $string = 'no_icon_found';
234 $flags = 'x';
235 } else {
236 if ($hidden) $string.='hidden';
237 if ($timing) $string.='timing';
238 if (!$string && $futuretiming) {
239 $string = 'futuretiming';
240 }
241
242 $flags.=
243 ($hidden ? 'h' : '').
244 ($timing ? 't' : '').
245 ($futuretiming ? 'f' : '').
246 ($user ? 'u' : '').
247 ($protectSection ? 'p' : '').
248 ($shaded ? 's' : '');
249 }
250
251 // Create tagged icon file name:
252 $iconFileName_stateTagged = preg_replace('/.([[:alnum:]]+)$/', '__'.$flags.'.\1', basename($iconfile));
253
254 // 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)
255 if (@is_file(dirname($absfile).'/'.$iconFileName_stateTagged)) { // Look for [iconname]_xxxx.[ext]
256 return dirname($iconfile).'/'.$iconFileName_stateTagged;
257 } elseif ($doNotGenerateIcon) { // If no icon generation can be done, try to look for the _X icon:
258 $iconFileName_X = preg_replace('/.([[:alnum:]]+)$/', '__x.\1', basename($iconfile));
259 if (@is_file(dirname($absfile).'/'.$iconFileName_X)) {
260 return dirname($iconfile).'/'.$iconFileName_X;
261 } else {
262 return 'gfx/i/no_icon_found.gif';
263 }
264 } else { // Otherwise, create the icon:
265 $theRes = t3lib_iconWorks::makeIcon($GLOBALS['BACK_PATH'].$iconfile, $string, $user, $protectSection, $absfile, $iconFileName_stateTagged);
266 return $theRes;
267 }
268 } else {
269 return $iconfile;
270 }
271 }
272
273 /**
274 * Returns the src=... for the input $src value OR any alternative found in $TBE_STYLES['skinImg']
275 * Used for skinning the TYPO3 backend with an alternative set of icons
276 * Usage: 336
277 *
278 * @param string Current backpath to PATH_typo3 folder
279 * @param string Icon file name relative to PATH_typo3 folder
280 * @param string Default width/height, defined like 'width="12" height="14"'
281 * @param integer Mode: 0 (zero) is default and returns src/width/height. 1 returns value of src+backpath, 2 returns value of w/h.
282 * @return string Returns ' src="[backPath][src]" [wHattribs]'
283 * @see skinImgFile()
284 */
285 public static function skinImg($backPath, $src, $wHattribs = '', $outputMode = 0) {
286
287 static $cachedSkinImages = array();
288
289 $imageId = md5($backPath . $src . $wHattribs . $outputMode);
290
291 if (isset($cachedSkinImages[$imageId])) {
292 return $cachedSkinImages[$imageId];
293 }
294 // Setting source key. If the icon is refered to inside an extension, we homogenize the prefix to "ext/":
295 $srcKey = preg_replace('/^(\.\.\/typo3conf\/ext|sysext|ext)\//', 'ext/', $src);
296 #if ($src!=$srcKey)debug(array($src, $srcKey));
297
298 // LOOKING for alternative icons:
299 if ($GLOBALS['TBE_STYLES']['skinImg'][$srcKey]) { // Slower or faster with is_array()? Could be used.
300 list($src, $wHattribs) = $GLOBALS['TBE_STYLES']['skinImg'][$srcKey];
301 } elseif ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']) { // Otherwise, test if auto-detection is enabled:
302
303 // Search for alternative icon automatically:
304 $fExt = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['forceFileExtension'];
305 $scaleFactor = ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] : 1); // Scaling factor
306 $lookUpName = ($fExt ? preg_replace('/\.[[:alnum:]]+$/', '', $srcKey) . '.' . $fExt : $srcKey); // Set filename to look for
307
308 if ($fExt && !@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName)) {
309 // fallback to original filename if icon with forced extension doesn't exists
310 $lookUpName = $srcKey;
311 }
312 // If file is found:
313 if (@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'].$lookUpName)) { // If there is a file...
314 $iInfo = @getimagesize($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName); // Get width/height:
315
316 // Set $src and $wHattribs:
317 $src = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'] . $lookUpName;
318 $wHattribs = 'width="' . round($iInfo[0] * $scaleFactor) . '" height="' . round($iInfo[1] * $scaleFactor) . '"';
319 }
320
321 // In any case, set currect src / wHattrib - this way we make sure that an entry IS found next time we hit the function,
322 // regardless of whether it points to a alternative icon or just the current.
323 $GLOBALS['TBE_STYLES']['skinImg'][$srcKey] = array($src, $wHattribs); // Set default...
324 }
325
326 // DEBUG: This doubles the size of all icons - for testing/debugging:
327 # if (preg_match('/^width="([0-9]+)" height="([0-9]+)"$/', $wHattribs, $reg)) $wHattribs='width="'.($reg[1]*2).'" height="'.($reg[2]*2).'"';
328
329
330 // rendering disabled (greyed) icons using _i (inactive) as name suffix ("_d" is already used)
331 $matches = array();
332 $srcBasename = basename($src);
333 if (preg_match('/(.*)_i(\....)$/', $srcBasename, $matches)) {
334 $temp_path = dirname(PATH_thisScript) . '/';
335 if (!@is_file($temp_path . $backPath . $src)) {
336 $srcOrg = preg_replace('/_i' . preg_quote($matches[2]) . '$/', $matches[2], $src);
337 $src = t3lib_iconWorks::makeIcon($backPath . $srcOrg, 'disabled', 0, false, $temp_path . $backPath . $srcOrg, $srcBasename);
338 }
339 }
340
341
342 // Return icon source/wHattributes:
343 $output = '';
344 switch($outputMode) {
345 case 0:
346 $output = ' src="' . $backPath . $src . '" ' . $wHattribs;
347 break;
348 case 1:
349 $output = $backPath . $src;
350 break;
351 case 2:
352 $output = $wHattribs;
353 break;
354 }
355
356 $cachedSkinImages[$imageId] = $output;
357 return $output;
358 }
359
360
361
362
363
364
365
366
367
368
369
370 /***********************************
371 *
372 * Other functions
373 *
374 ***********************************/
375
376 /**
377 * Creates the icon file for the function getIcon()
378 *
379 * @param string Original unprocessed Icon file, relative path to PATH_typo3
380 * @param string Mode string, eg. "deleted" or "futuretiming" determining how the icon will look
381 * @param integer The number of the fe_group record uid if applicable
382 * @param boolean Flag determines if the protected-section icon should be applied.
383 * @param string Absolute path to file from which to create the icon.
384 * @param string The filename that this icon should have had, basically [icon base name]_[flags].[extension] - used for part of temporary filename
385 * @return string Filename relative to PATH_typo3
386 * @access private
387 */
388 public static function makeIcon($iconfile, $mode, $user, $protectSection, $absFile, $iconFileName_stateTagged) {
389 $iconFileName = 'icon_'.t3lib_div::shortMD5($iconfile.'|'.$mode.'|-'.$user.'|'.$protectSection).'_'.$iconFileName_stateTagged.'.'.($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']?'png':'gif');
390 $mainpath = '../typo3temp/'.$iconFileName;
391 $path = PATH_site.'typo3temp/'.$iconFileName;
392
393
394 if (file_exists(PATH_typo3.'icons/'.$iconFileName)) { // Returns if found in typo3/icons/
395 return 'icons/'.$iconFileName;
396 } elseif (file_exists($path)) { // Returns if found in ../typo3temp/icons/
397 return $mainpath;
398 } else { // Makes icon:
399 if (file_exists($absFile)) {
400 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
401
402 // Create image pointer, if possible
403 $im = t3lib_iconworks::imagecreatefrom($absFile);
404 if ($im<0) return $iconfile;
405
406 // Converting to gray scale, dimming the icon:
407 if (($mode=='disabled') OR ($mode!='futuretiming' && $mode!='no_icon_found' && !(!$mode && $user))) {
408 for ($c = 0; $c<ImageColorsTotal($im); $c++) {
409 $cols = ImageColorsForIndex($im, $c);
410 $newcol = round(($cols['red']+$cols['green']+$cols['blue'])/3);
411 $lighten = ($mode=='disabled') ? 2.5 : 2;
412 $newcol = round(255-((255-$newcol)/$lighten));
413 ImageColorSet($im, $c, $newcol, $newcol, $newcol);
414 }
415 }
416 // Applying user icon, if there are access control on the item:
417 if ($user) {
418 if ($user < 100) { // Apply user number only if lower than 100
419 $black = ImageColorAllocate($im, 0, 0, 0);
420 imagefilledrectangle($im, 0, 0, (($user>10)?9:5), 8, $black);
421
422 $white = ImageColorAllocate($im, 255, 255, 255);
423 imagestring($im, 1, 1, 1, $user, $white);
424 }
425
426 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_group.gif');
427 if ($ol_im<0) return $iconfile;
428
429 t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
430 }
431 // Applying overlay based on mode:
432 if ($mode) {
433 unset($ol_im);
434 switch($mode) {
435 case 'deleted':
436 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_deleted.gif');
437 break;
438 case 'futuretiming':
439 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_timing.gif');
440 break;
441 case 'timing':
442 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_timing.gif');
443 break;
444 case 'hiddentiming':
445 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_hidden_timing.gif');
446 break;
447 case 'no_icon_found':
448 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_no_icon_found.gif');
449 break;
450 case 'disabled':
451 // is already greyed - nothing more
452 $ol_im = 0;
453 break;
454 case 'hidden':
455 default:
456 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_hidden.gif');
457 break;
458 }
459 if ($ol_im<0) return $iconfile;
460 if ($ol_im) {
461 t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
462 }
463 }
464 // Protect-section icon:
465 if ($protectSection) {
466 $ol_im = t3lib_iconworks::imagecreatefrom($GLOBALS['BACK_PATH'].'gfx/overlay_sub5.gif');
467 if ($ol_im<0) return $iconfile;
468 t3lib_iconworks::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
469 }
470
471 // Create the image as file, destroy GD image and return:
472 @t3lib_iconWorks::imagemake($im, $path);
473 t3lib_div::gif_compress($path, 'IM');
474 ImageDestroy($im);
475 return $mainpath;
476 } else {
477 return $iconfile;
478 }
479 } else {
480 return $GLOBALS['BACK_PATH'].'gfx/fileicons/default.gif';
481 }
482 }
483 }
484
485 /**
486 * The necessity of using this function for combining two images if GD is version 2 is that
487 * GD2 cannot manage to combine two indexed-color images without totally spoiling everything.
488 * In class.t3lib_stdgraphic this was solved by combining the images onto a first created true color image
489 * However it has turned out that this method will not work if the indexed png-files contains transparency.
490 * So I had to turn my attention to ImageMagick - my 'enemy of death'.
491 * And so it happend - ImageMagick is now used to combine my two indexed-color images with transparency. And that works.
492 * 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+)
493 * 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.
494 *
495 * For parameters, see PHP function "imagecopyresized()"
496 *
497 * @param pointer see PHP function "imagecopyresized()"
498 * @param pointer see PHP function "imagecopyresized()"
499 * @param integer see PHP function "imagecopyresized()"
500 * @param integer see PHP function "imagecopyresized()"
501 * @param integer see PHP function "imagecopyresized()"
502 * @param integer see PHP function "imagecopyresized()"
503 * @param integer see PHP function "imagecopyresized()"
504 * @param integer see PHP function "imagecopyresized()"
505 * @param integer see PHP function "imagecopyresized()"
506 * @param integer see PHP function "imagecopyresized()"
507 * @return void
508 * @access private
509 */
510 public static function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h) {
511 imagecopyresized($im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h);
512 }
513
514 /**
515 * Create new image pointer from input file (either gif/png, in case the wrong format it is converted by t3lib_div::read_png_gif())
516 *
517 * @param string Absolute filename of the image file from which to start the icon creation.
518 * @return mixed If success, image pointer, otherwise "-1"
519 * @access private
520 * @see t3lib_div::read_png_gif
521 */
522 public static function imagecreatefrom($file) {
523 $file = t3lib_div::read_png_gif($file, $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']);
524 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
525 return $file ? imagecreatefrompng($file) : -1;
526 } else {
527 return $file ? imagecreatefromgif($file) : -1;
528 }
529 }
530
531 /**
532 * Write the icon in $im pointer to $path
533 *
534 * @param pointer Pointer to GDlib image resource
535 * @param string Absolute path to the filename in which to write the icon.
536 * @return void
537 * @access private
538 */
539 public static function imagemake($im, $path) {
540 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) {
541 @ImagePng($im, $path);
542 } else {
543 @ImageGif($im, $path);
544 }
545 }
546 }
547 ?>