[TASK] Replace Space Indent into Tab indent (CGL Cleanup)
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_iconworks.php
index 706ee42..33417d9 100644 (file)
@@ -1,70 +1,32 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-/**
- * Contains class for icon generation in the backend
- *
- * $Id$
- * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
- * XHTML compliant
- *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
+ *  Copyright notice
  *
+ *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
  *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
  *
- *   85: class t3lib_iconWorks
- *  100:     function getIconImage($table,$row=array(),$backPath,$params='',$shaded=FALSE)
- *  118:     function getIcon($table,$row=array(),$shaded=FALSE)
- *  264:     function skinImg($backPath,$src,$wHattribs='',$outputMode=0)
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
  *
- *              SECTION: Other functions
- *  353:     function makeIcon($iconfile,$mode, $user, $protectSection,$absFile,$iconFileName_stateTagged)
- *  475:     function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h)
- *  505:     function imagecreatefrom($file)
- *  522:     function imagemake($im, $path)
  *
- * TOTAL FUNCTIONS: 7
- * (This index is automatically created/updated by the extension "extdeveval")
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
  *
- */
-
-
-
-
-
-
-
-
-
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 
 /**
- * Icon generation, backend
+ * Contains class for icon generation in the backend
  * This library has functions that returns - and if necessary creates - the icon for an element in TYPO3
  *
  * Expects global vars:
  * The class is included in eg. init.php
  * ALL functions called without making a class instance, eg. "t3lib_iconWorks::getIconImage()"
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  */
-final class t3lib_iconWorks    {
+final class t3lib_iconWorks {
 
        public static $fileSpriteIconNames = array(
-               'htm'   => 'mimetypes-text-html',
-               'html'  => 'mimetypes-text-html',
-               'css'   => 'mimetypes-text-css',
-               'js'    => 'mimetypes-text-js',
-               'csv'   => 'mimetypes-text-csv',
-               'php'   => 'mimetypes-text-php',
-               'php6'  => 'mimetypes-text-php',
-               'php5'  => 'mimetypes-text-php',
-               'php4'  => 'mimetypes-text-php',
-               'php3'  => 'mimetypes-text-php',
-               'inc'   => 'mimetypes-text-php',
-               'ts'    => 'mimetypes-text-ts',
-               'txt'   => 'mimetypes-text-text',
+               'htm' => 'mimetypes-text-html',
+               'html' => 'mimetypes-text-html',
+               'css' => 'mimetypes-text-css',
+               'js' => 'mimetypes-text-js',
+               'csv' => 'mimetypes-text-csv',
+               'php' => 'mimetypes-text-php',
+               'php6' => 'mimetypes-text-php',
+               'php5' => 'mimetypes-text-php',
+               'php4' => 'mimetypes-text-php',
+               'php3' => 'mimetypes-text-php',
+               'inc' => 'mimetypes-text-php',
+               'ts' => 'mimetypes-text-ts',
+               'txt' => 'mimetypes-text-text',
                'class' => 'mimetypes-text-text',
-               'tmpl'  => 'mimetypes-text-text',
-               'jpg'   => 'mimetypes-media-image',
-               'jpeg'  => 'mimetypes-media-image',
-               'gif'   => 'mimetypes-media-image',
-               'png'   => 'mimetypes-media-image',
-               'bmp'   => 'mimetypes-media-image',
-               'tif'   => 'mimetypes-media-image',
-               'tga'   => 'mimetypes-media-image',
-               'psd'   => 'mimetypes-media-image',
-               'eps'   => 'mimetypes-media-image',
-               'avi'   => 'mimetypes-media-video',
-               'mpg'   => 'mimetypes-media-video',
-               'mpeg'  => 'mimetypes-media-video',
-               'mov'   => 'mimetypes-media-video',
-               'wav'   => 'mimetypes-media-audio',
-               'mp3'   => 'mimetypes-media-audio',
-               'mid'   => 'mimetypes-media-audio',
-               'swf'   => 'mimetypes-media-flash',
-               'swa'   => 'mimetypes-media-flash',
-               'exe'   => 'mimetypes-executable-executable',
-               'com'   => 'mimetypes-executable-executable',
-               't3x'   => 'mimetypes-compressed',
-               't3d'   => 'mimetypes-compressed',
-               'zip'   => 'mimetypes-compressed',
-               'tgz'   => 'mimetypes-compressed',
-               'gz'    => 'mimetypes-compressed',
-               'pdf'   => 'mimetypes-pdf',
-               'doc'   => 'mimetypes-word',
-               'sxw'   => 'mimetypes-word',
-               'rtf'   => 'mimetypes-word',
-               'xls'   => 'mimetypes-excel',
-               'sxc'   => 'mimetypes-excel',
-               'ppt'   => 'mimetypes-powerpoint',
+               'tmpl' => 'mimetypes-text-text',
+               'jpg' => 'mimetypes-media-image',
+               'jpeg' => 'mimetypes-media-image',
+               'gif' => 'mimetypes-media-image',
+               'png' => 'mimetypes-media-image',
+               'bmp' => 'mimetypes-media-image',
+               'tif' => 'mimetypes-media-image',
+               'tga' => 'mimetypes-media-image',
+               'psd' => 'mimetypes-media-image',
+               'eps' => 'mimetypes-media-image',
+               'avi' => 'mimetypes-media-video',
+               'mpg' => 'mimetypes-media-video',
+               'mpeg' => 'mimetypes-media-video',
+               'mov' => 'mimetypes-media-video',
+               'wav' => 'mimetypes-media-audio',
+               'mp3' => 'mimetypes-media-audio',
+               'mid' => 'mimetypes-media-audio',
+               'swf' => 'mimetypes-media-flash',
+               'swa' => 'mimetypes-media-flash',
+               'exe' => 'mimetypes-executable-executable',
+               'com' => 'mimetypes-executable-executable',
+               't3x' => 'mimetypes-compressed',
+               't3d' => 'mimetypes-compressed',
+               'zip' => 'mimetypes-compressed',
+               'tgz' => 'mimetypes-compressed',
+               'gz' => 'mimetypes-compressed',
+               'pdf' => 'mimetypes-pdf',
+               'doc' => 'mimetypes-word',
+               'dot' => 'mimetypes-word',
+               'docm' => 'mimetypes-word',
+               'docx' => 'mimetypes-word',
+               'dotm' => 'mimetypes-word',
+               'dotx' => 'mimetypes-word',
+               'sxw' => 'mimetypes-word',
+               'rtf' => 'mimetypes-word',
+               'xls' => 'mimetypes-excel',
+               'xlsm' => 'mimetypes-excel',
+               'xlsx' => 'mimetypes-excel',
+               'xltm' => 'mimetypes-excel',
+               'xltx' => 'mimetypes-excel',
+               'sxc' => 'mimetypes-excel',
+               'ppt' => 'mimetypes-powerpoint',
+               'pptm' => 'mimetypes-powerpoint',
+               'pptx' => 'mimetypes-powerpoint',
+               'potm' => 'mimetypes-powerpoint',
+               'potx' => 'mimetypes-powerpoint',
                'mount' => 'apps-filetree-mount',
-               'folder'  => 'apps-filetree-folder-default',
+               'folder' => 'apps-filetree-folder-default',
                'default' => 'mimetypes-other-other'
        );
 
        /**
         * Returns an icon image tag, 18x16 pixels, based on input information.
         * This function is recommended to use in your backend modules.
-        * Usage: 60
         *
         * @param       string          The table name
         * @param       array           The table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
@@ -148,18 +122,22 @@ final class t3lib_iconWorks       {
         * @param       string          Additional attributes for the image tag
         * @param       boolean         If set, the icon will be grayed/shaded
         * @return      string          <img>-tag
-        * @deprecated  since TYPO3 4.4, use t3lib_iconWorks::getSpriteIconForRecord instead
         * @see getIcon()
         */
        public static function getIconImage($table, $row = array(), $backPath, $params = '', $shaded = FALSE) {
-               t3lib_div::logDeprecatedFunction();
-               return self::getSpriteIconForRecord($table,$row);
+               $str = '<img' .
+                       self::skinImg($backPath, self::getIcon($table, $row, $shaded), 'width="18" height="16"') .
+                       (trim($params) ? ' ' . trim($params) : '');
+               if (!stristr($str, 'alt="')) {
+                       $str .= ' alt=""';
+               }
+               $str .= ' />';
+               return $str;
        }
 
        /**
         * Creates the icon for input table/row
         * Returns filename for the image icon, relative to PATH_typo3
-        * Usage: 24
         *
         * @param       string          The table name
         * @param       array           The table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
@@ -168,15 +146,12 @@ final class t3lib_iconWorks       {
         * @see getIconImage()
         */
        public static function getIcon($table, $row = array(), $shaded = FALSE) {
-               global $TCA, $PAGES_TYPES, $ICON_TYPES;
-
                        // Flags:
-               $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]
-               $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...
+               $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...
 
                        // Shadow:
-               if ($TCA[$table]['ctrl']['versioningWS']) {
-                       switch((int)$row['t3ver_state']) {
+               if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
+                       switch ((int) $row['t3ver_state']) {
                                case 1:
                                        return 'gfx/i/shadow_hide.png';
                                break;
@@ -193,49 +168,48 @@ final class t3lib_iconWorks       {
                }
 
                        // First, find the icon file name. This can depend on configuration in TCA, field values and more:
-               if ($table=='pages') {
-                               // @TODO: RFC #7370: doktype 2&5 are deprecated since TYPO3 4.2-beta1
-                       if ($row['nav_hide'] && ($row['doktype']==1||$row['doktype']==2))       $row['doktype'] = 5;    // Workaround to change the icon if "Hide in menu" was set
-
-                       if (!$iconfile = $PAGES_TYPES[$row['doktype']]['icon']) {
-                               $iconfile = $PAGES_TYPES['default']['icon'];
-                       }
-                       if ($row['module'] && $ICON_TYPES[$row['module']]['icon']) {
-                               $iconfile = $ICON_TYPES[$row['module']]['icon'];
+               if ($table == 'pages') {
+                       $iconfile = $GLOBALS['PAGES_TYPES'][$row['doktype']]['icon'];
+                       if (!$iconfile) {
+                               $iconfile = $GLOBALS['PAGES_TYPES']['default']['icon'];
                        }
                } else {
-                       if (!$iconfile = $TCA[$table]['ctrl']['typeicons'][$row[$TCA[$table]['ctrl']['typeicon_column']]]) {
-                               $iconfile = (($TCA[$table]['ctrl']['iconfile']) ? $TCA[$table]['ctrl']['iconfile'] : $table.'.gif');
+                       if (!$iconfile = $GLOBALS['TCA'][$table]['ctrl']['typeicons'][$row[$GLOBALS['TCA'][$table]['ctrl']['typeicon_column']]]) {
+                               $iconfile = (($GLOBALS['TCA'][$table]['ctrl']['iconfile']) ? $GLOBALS['TCA'][$table]['ctrl']['iconfile'] : $table . '.gif');
                        }
                }
 
                        // Setting path of iconfile if not already set. Default is "gfx/i/"
                if (!strstr($iconfile, '/')) {
-                       $iconfile = 'gfx/i/'.$iconfile;
+                       $iconfile = 'gfx/i/' . $iconfile;
                }
 
                        // Setting the absolute path where the icon should be found as a file:
-               if (substr($iconfile, 0, 3)=='../') {
-                       $absfile = PATH_site.substr($iconfile, 3);
+               if (substr($iconfile, 0, 3) == '../') {
+                       $absfile = PATH_site . substr($iconfile, 3);
                } else {
-                       $absfile = PATH_typo3.$iconfile;
+                       $absfile = PATH_typo3 . $iconfile;
                }
 
                        // Initializing variables, all booleans except otherwise stated:
                $hidden = FALSE;
                $timing = FALSE;
                $futuretiming = FALSE;
-               $user = FALSE;                          // In fact an integer value...
+               $user = FALSE; // In fact an integer value...
                $deleted = FALSE;
-               $protectSection = FALSE;        // Set, if a page-record (only pages!) has the extend-to-subpages flag set.
+               $protectSection = FALSE; // Set, if a page-record (only pages!) has the extend-to-subpages flag set.
                $noIconFound = $row['_NO_ICON_FOUND'] ? TRUE : FALSE;
-               // + $shaded which is also boolean!
+                       // + $shaded which is also boolean!
 
                        // Icon state based on "enableFields":
-               if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
-                       $enCols = $TCA[$table]['ctrl']['enablecolumns'];
+               if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
+                       $enCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
                                // If "hidden" is enabled:
-                       if ($enCols['disabled'])        { if ($row[$enCols['disabled']]) { $hidden = TRUE; }}
+                       if ($enCols['disabled']) {
+                               if ($row[$enCols['disabled']]) {
+                                       $hidden = TRUE;
+                               }
+                       }
                                // If a "starttime" is set and higher than current time:
                        if ($enCols['starttime']) {
                                if ($GLOBALS['EXEC_TIME'] < intval($row[$enCols['starttime']])) {
@@ -250,25 +224,27 @@ final class t3lib_iconWorks       {
                        if ($enCols['endtime']) {
                                if (intval($row[$enCols['endtime']]) > 0) {
                                        if (intval($row[$enCols['endtime']]) < $GLOBALS['EXEC_TIME']) {
-                                               $timing = TRUE; // End-timing applies at this point.
+                                               $timing = TRUE; // End-timing applies at this point.
                                        } else {
-                                               $futuretiming = TRUE;           // End-timing WILL apply in the future for this element.
+                                               $futuretiming = TRUE; // End-timing WILL apply in the future for this element.
                                        }
                                }
                        }
                                // If a user-group field is set:
                        if ($enCols['fe_group']) {
                                $user = $row[$enCols['fe_group']];
-                               if ($user && $doNotRenderUserGroupNumber)       $user = 100;    // Limit for user number rendering!
+                               if ($user && $doNotRenderUserGroupNumber) {
+                                       $user = 100;
+                               } // Limit for user number rendering!
                        }
                }
 
                        // If "deleted" flag is set (only when listing records which are also deleted!)
-               if ($col = $row[$TCA[$table]['ctrl']['delete']]) {
+               if ($col = $row[$GLOBALS['TCA'][$table]['ctrl']['delete']]) {
                        $deleted = TRUE;
                }
                        // Detecting extendToSubpages (for pages only)
-               if ($table=='pages' && $row['extendToSubpages'] && ($hidden || $timing || $futuretiming || $user)) {
+               if ($table == 'pages' && $row['extendToSubpages'] && ($hidden || $timing || $futuretiming || $user)) {
                        $protectSection = TRUE;
                }
 
@@ -279,39 +255,36 @@ final class t3lib_iconWorks       {
                        if ($deleted) {
                                $string = 'deleted';
                                $flags = 'd';
-                       } elseif ($noIconFound) {       // This is ONLY for creating icons with "?" on easily...
+                       } elseif ($noIconFound) { // This is ONLY for creating icons with "?" on easily...
                                $string = 'no_icon_found';
                                $flags = 'x';
                        } else {
-                               if ($hidden) $string.='hidden';
-                               if ($timing) $string.='timing';
+                               if ($hidden) {
+                                       $string .= 'hidden';
+                               }
+                               if ($timing) {
+                                       $string .= 'timing';
+                               }
                                if (!$string && $futuretiming) {
                                        $string = 'futuretiming';
                                }
 
-                               $flags.=
-                                       ($hidden ? 'h' : '').
-                                       ($timing ? 't' : '').
-                                       ($futuretiming ? 'f' : '').
-                                       ($user ? 'u' : '').
-                                       ($protectSection ? 'p' : '').
-                                       ($shaded ? 's' : '');
+                               $flags .=
+                                               ($hidden ? 'h' : '') .
+                                               ($timing ? 't' : '') .
+                                               ($futuretiming ? 'f' : '') .
+                                               ($user ? 'u' : '') .
+                                               ($protectSection ? 'p' : '') .
+                                               ($shaded ? 's' : '');
                        }
 
                                // Create tagged icon file name:
-                       $iconFileName_stateTagged = preg_replace('/.([[:alnum:]]+)$/', '__'.$flags.'.\1', basename($iconfile));
+                       $iconFileName_stateTagged = preg_replace('/.([[:alnum:]]+)$/', '__' . $flags . '.\1', basename($iconfile));
 
                                // 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)
-                       if (@is_file(dirname($absfile) . '/' . $iconFileName_stateTagged) || @is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . '/' . dirname($iconfile) . '/' . $iconFileName_stateTagged)) {       // Look for [iconname]_xxxx.[ext]
-                               return dirname($iconfile).'/'.$iconFileName_stateTagged;
-                       } elseif ($doNotGenerateIcon)   {               // If no icon generation can be done, try to look for the _X icon:
-                               $iconFileName_X = preg_replace('/.([[:alnum:]]+)$/', '__x.\1', basename($iconfile));
-                               if (@is_file(dirname($absfile).'/'.$iconFileName_X)) {
-                                       return dirname($iconfile).'/'.$iconFileName_X;
-                               } else {
-                                       return 'gfx/i/no_icon_found.gif';
-                               }
-                       } else {        // Otherwise, create the icon:
+                       if (@is_file(dirname($absfile) . '/' . $iconFileName_stateTagged) || @is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . '/' . dirname($iconfile) . '/' . $iconFileName_stateTagged)) { // Look for [iconname]_xxxx.[ext]
+                               return dirname($iconfile) . '/' . $iconFileName_stateTagged;
+                       } else { // Otherwise, create the icon:
                                $theRes = self::makeIcon($GLOBALS['BACK_PATH'] . $iconfile, $string, $user, $protectSection, $absfile, $iconFileName_stateTagged);
                                return $theRes;
                        }
@@ -323,7 +296,6 @@ final class t3lib_iconWorks {
        /**
         * Returns the src=... for the input $src value OR any alternative found in $TBE_STYLES['skinImg']
         * Used for skinning the TYPO3 backend with an alternative set of icons
-        * Usage: 336
         *
         * @param       string          Current backpath to PATH_typo3 folder
         * @param       string          Icon file name relative to PATH_typo3 folder
@@ -332,7 +304,7 @@ final class t3lib_iconWorks {
         * @return      string          Returns ' src="[backPath][src]" [wHattribs]'
         * @see skinImgFile()
         */
-       public static function skinImg($backPath, $src, $wHattribs = '', $outputMode = 0)       {
+       public static function skinImg($backPath, $src, $wHattribs = '', $outputMode = 0) {
 
                static $cachedSkinImages = array();
 
@@ -346,22 +318,22 @@ final class t3lib_iconWorks       {
                #if ($src!=$srcKey)debug(array($src, $srcKey));
 
                        // LOOKING for alternative icons:
-               if ($GLOBALS['TBE_STYLES']['skinImg'][$srcKey]) {       // Slower or faster with is_array()? Could be used.
+               if ($GLOBALS['TBE_STYLES']['skinImg'][$srcKey]) { // Slower or faster with is_array()? Could be used.
                        list($src, $wHattribs) = $GLOBALS['TBE_STYLES']['skinImg'][$srcKey];
-               } elseif ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']) {   // Otherwise, test if auto-detection is enabled:
+               } elseif ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']) { // Otherwise, test if auto-detection is enabled:
 
                                // Search for alternative icon automatically:
                        $fExt = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['forceFileExtension'];
-                       $scaleFactor = ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] : 1); // Scaling factor
-                       $lookUpName = ($fExt ? preg_replace('/\.[[:alnum:]]+$/', '', $srcKey) . '.' . $fExt : $srcKey); // Set filename to look for
+                       $scaleFactor = ($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['scaleFactor'] : 1); // Scaling factor
+                       $lookUpName = ($fExt ? preg_replace('/\.[[:alnum:]]+$/', '', $srcKey) . '.' . $fExt : $srcKey); // Set filename to look for
 
                        if ($fExt && !@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName)) {
-                               // fallback to original filename if icon with forced extension doesn't exists
+                                       // fallback to original filename if icon with forced extension doesn't exists
                                $lookUpName = $srcKey;
                        }
                                // If file is found:
-                       if (@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'].$lookUpName)) { // If there is a file...
-                               $iInfo = @getimagesize($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName);       // Get width/height:
+                       if (@is_file($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName)) { // If there is a file...
+                               $iInfo = @getimagesize($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName); // Get width/height:
 
                                        // Set $src and $wHattribs:
                                $src = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'] . $lookUpName;
@@ -370,11 +342,11 @@ final class t3lib_iconWorks       {
 
                                // In any case, 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.
-                       $GLOBALS['TBE_STYLES']['skinImg'][$srcKey] = array($src, $wHattribs);           // Set default...
+                       $GLOBALS['TBE_STYLES']['skinImg'][$srcKey] = array($src, $wHattribs); // Set default...
                }
 
                        // DEBUG: This doubles the size of all icons - for testing/debugging:
-               # if (preg_match('/^width="([0-9]+)" height="([0-9]+)"$/', $wHattribs, $reg))   $wHattribs='width="'.($reg[1]*2).'" height="'.($reg[2]*2).'"';
+                       // if (preg_match('/^width="([0-9]+)" height="([0-9]+)"$/', $wHattribs, $reg))  $wHattribs='width="'.($reg[1]*2).'" height="'.($reg[2]*2).'"';
 
 
                        // rendering disabled (greyed) icons using _i (inactive) as name suffix ("_d" is already used)
@@ -384,14 +356,14 @@ final class t3lib_iconWorks       {
                        $temp_path = dirname(PATH_thisScript) . '/';
                        if (!@is_file($temp_path . $backPath . $src)) {
                                $srcOrg = preg_replace('/_i' . preg_quote($matches[2]) . '$/', $matches[2], $src);
-                               $src = self::makeIcon($backPath . $srcOrg, 'disabled', 0, false, $temp_path . $backPath . $srcOrg, $srcBasename);
+                               $src = self::makeIcon($backPath . $srcOrg, 'disabled', 0, FALSE, $temp_path . $backPath . $srcOrg, $srcBasename);
                        }
                }
 
 
                        // Return icon source/wHattributes:
                $output = '';
-               switch($outputMode) {
+               switch ($outputMode) {
                        case 0:
                                $output = ' src="' . $backPath . $src . '" ' . $wHattribs;
                        break;
@@ -408,15 +380,6 @@ final class t3lib_iconWorks        {
        }
 
 
-
-
-
-
-
-
-
-
-
        /***********************************
         *
         * Other functions
@@ -436,52 +399,56 @@ final class t3lib_iconWorks       {
         * @access private
         */
        public static function makeIcon($iconfile, $mode, $user, $protectSection, $absFile, $iconFileName_stateTagged) {
-               $iconFileName = 'icon_'.t3lib_div::shortMD5($iconfile.'|'.$mode.'|-'.$user.'|'.$protectSection).'_'.$iconFileName_stateTagged.'.'.($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']?'png':'gif');
-               $mainpath = '../typo3temp/'.$iconFileName;
-               $path = PATH_site.'typo3temp/'.$iconFileName;
+               $iconFileName = 'icon_' . t3lib_div::shortMD5($iconfile . '|' . $mode . '|-' . $user . '|' . $protectSection) . '_' . $iconFileName_stateTagged . '.' . ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'] ? 'png' : 'gif');
+               $mainpath = '../typo3temp/' . $iconFileName;
+               $path = PATH_site . 'typo3temp/' . $iconFileName;
 
 
-               if (file_exists(PATH_typo3.'icons/'.$iconFileName))     {       // Returns if found in typo3/icons/
-                       return 'icons/'.$iconFileName;
-               } elseif (file_exists($path))   {       // Returns if found in ../typo3temp/icons/
+               if (file_exists(PATH_typo3 . 'icons/' . $iconFileName)) { // Returns if found in typo3/icons/
+                       return 'icons/' . $iconFileName;
+               } elseif (file_exists($path)) { // Returns if found in ../typo3temp/icons/
                        return $mainpath;
-               } else {        // Makes icon:
+               } else { // Makes icon:
                        if (file_exists($absFile)) {
-                               if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'])        {
+                               if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
 
                                                // Create image pointer, if possible
                                        $im = self::imagecreatefrom($absFile);
-                                       if ($im<0)      return $iconfile;
+                                       if ($im < 0) {
+                                               return $iconfile;
+                                       }
 
                                                // Converting to gray scale, dimming the icon:
-                                       if (($mode=='disabled') OR ($mode!='futuretiming' && $mode!='no_icon_found' && !(!$mode && $user))) {
-                                               for ($c = 0; $c<ImageColorsTotal($im); $c++) {
+                                       if (($mode == 'disabled') OR ($mode != 'futuretiming' && $mode != 'no_icon_found' && !(!$mode && $user))) {
+                                               for ($c = 0; $c < ImageColorsTotal($im); $c++) {
                                                        $cols = ImageColorsForIndex($im, $c);
-                                                       $newcol = round(($cols['red']+$cols['green']+$cols['blue'])/3);
-                                                       $lighten = ($mode=='disabled') ? 2.5 : 2;
-                                                       $newcol = round(255-((255-$newcol)/$lighten));
+                                                       $newcol = round(($cols['red'] + $cols['green'] + $cols['blue']) / 3);
+                                                       $lighten = ($mode == 'disabled') ? 2.5 : 2;
+                                                       $newcol = round(255 - ((255 - $newcol) / $lighten));
                                                        ImageColorSet($im, $c, $newcol, $newcol, $newcol);
                                                }
                                        }
                                                // Applying user icon, if there are access control on the item:
                                        if ($user) {
-                                               if ($user < 100)        {       // Apply user number only if lower than 100
+                                               if ($user < 100) { // Apply user number only if lower than 100
                                                        $black = ImageColorAllocate($im, 0, 0, 0);
-                                                       imagefilledrectangle($im, 0, 0, (($user>10)?9:5), 8, $black);
+                                                       imagefilledrectangle($im, 0, 0, (($user > 10) ? 9 : 5), 8, $black);
 
                                                        $white = ImageColorAllocate($im, 255, 255, 255);
                                                        imagestring($im, 1, 1, 1, $user, $white);
                                                }
 
                                                $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_group.gif');
-                                               if ($ol_im<0)   return $iconfile;
+                                               if ($ol_im < 0) {
+                                                       return $iconfile;
+                                               }
 
                                                self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                                        }
                                                // Applying overlay based on mode:
                                        if ($mode) {
                                                unset($ol_im);
-                                               switch($mode) {
+                                               switch ($mode) {
                                                        case 'deleted':
                                                                $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_deleted.gif');
                                                        break;
@@ -506,7 +473,9 @@ final class t3lib_iconWorks {
                                                                $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_hidden.gif');
                                                        break;
                                                }
-                                               if ($ol_im<0)   return $iconfile;
+                                               if ($ol_im < 0) {
+                                                       return $iconfile;
+                                               }
                                                if ($ol_im) {
                                                        self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                                                }
@@ -514,7 +483,9 @@ final class t3lib_iconWorks {
                                                // Protect-section icon:
                                        if ($protectSection) {
                                                $ol_im = self::imagecreatefrom($GLOBALS['BACK_PATH'] . 'gfx/overlay_sub5.gif');
-                                               if ($ol_im<0)   return $iconfile;
+                                               if ($ol_im < 0) {
+                                                       return $iconfile;
+                                               }
                                                self::imagecopyresized($im, $ol_im, 0, 0, 0, 0, imagesx($ol_im), imagesy($ol_im), imagesx($ol_im), imagesy($ol_im));
                                        }
 
@@ -527,7 +498,7 @@ final class t3lib_iconWorks {
                                        return $iconfile;
                                }
                        } else {
-                               return $GLOBALS['BACK_PATH'].'gfx/fileicons/default.gif';
+                               return $GLOBALS['BACK_PATH'] . 'gfx/fileicons/default.gif';
                        }
                }
        }
@@ -542,23 +513,22 @@ final class t3lib_iconWorks       {
         * 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+)
         * 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.
         *
-        * For parameters, see PHP function "imagecopyresized()"
-        *
-        * @param       pointer         see PHP function "imagecopyresized()"
-        * @param       pointer         see PHP function "imagecopyresized()"
-        * @param       integer         see PHP function "imagecopyresized()"
-        * @param       integer         see PHP function "imagecopyresized()"
-        * @param       integer         see PHP function "imagecopyresized()"
-        * @param       integer         see PHP function "imagecopyresized()"
-        * @param       integer         see PHP function "imagecopyresized()"
-        * @param       integer         see PHP function "imagecopyresized()"
-        * @param       integer         see PHP function "imagecopyresized()"
-        * @param       integer         see PHP function "imagecopyresized()"
-        * @return      void
+        * @param resource $dstImg destination image
+        * @param resource $srcImg source image
+        * @param integer $dstX destination x-coordinate
+        * @param integer $dstY destination y-coordinate
+        * @param integer $srcX source x-coordinate
+        * @param integer $srcY source y-coordinate
+        * @param integer $dstWidth destination width
+        * @param integer $dstHeight destination height
+        * @param integer $srcWidth source width
+        * @param integer $srcHeight source height
+        * @return void
         * @access private
+        * @see t3lib_stdGraphic::imagecopyresized()
         */
-       public static function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h) {
-               imagecopyresized($im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h);
+       public static function imagecopyresized(&$dstImg, $srcImg, $dstX, $dstY, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight) {
+               imagecopyresized($dstImg, $srcImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $dstWidth, $dstHeight, $srcWidth, $srcHeight);
        }
 
        /**
@@ -592,11 +562,14 @@ final class t3lib_iconWorks       {
                } else {
                        @ImageGif($im, $path);
                }
+               if (@is_file($path)) {
+                       t3lib_div::fixPermissions($path);
+               }
        }
 
 
        /**********************************************
-        *         SPRITE ICON API
+        *               SPRITE ICON API
         *
         * The Sprite Icon API helps you to quickly get the HTML for any icon you want
         * this is typically wrapped in a <span> tag with corresponding CSS classes that
@@ -605,13 +578,13 @@ final class t3lib_iconWorks       {
         * There are three ways to use this API:
         *
         * 1) for any given TCA record
-        *    $spriteIconHtml = t3lib_iconWorks::getSpriteIconForRecord('pages', $row);
+        *      $spriteIconHtml = t3lib_iconWorks::getSpriteIconForRecord('pages', $row);
         *
         * 2) for any given file
-        *    $spriteIconHtml = t3lib_iconWorks::getSpriteIconForFile('myimage.png');
+        *      $spriteIconHtml = t3lib_iconWorks::getSpriteIconForFile('myimage.png');
         *
         * 3) for any other icon you know the name
-        *    $spriteIconHtml = t3lib_iconWorks::getSpriteIcon('actions-document-open');
+        *      $spriteIconHtml = t3lib_iconWorks::getSpriteIcon('actions-document-open');
         *
         **********************************************/
 
@@ -629,15 +602,15 @@ final class t3lib_iconWorks       {
         * @return      string  the full HTML tag (usually a <span>)
         * @access public
         */
-       public static function getSpriteIcon($iconName, $options = array(), $overlays = array()) {
-               $innerHtml = (isset($options['html'])    ? $options['html']    : '');
-               $tagName   = (isset($options['tagName']) ? $options['tagName'] : 'span');
+       public static function getSpriteIcon($iconName, array $options = array(), array $overlays = array()) {
+               $innerHtml = (isset($options['html']) ? $options['html'] : NULL);
+               $tagName = (isset($options['tagName']) ? $options['tagName'] : NULL);
 
                        // deal with the overlays
                if (count($overlays)) {
                        foreach ($overlays as $overlayIconName => $overlayOptions) {
-                               $overlayOptions['html']  = $innerHtml;
-                               $overlayOptions['class'] = (isset($overlayOptions['class']) ? $overlayOptions['class'] . ' ': '') . 't3-icon-overlay';
+                               $overlayOptions['html'] = $innerHtml;
+                               $overlayOptions['class'] = (isset($overlayOptions['class']) ? $overlayOptions['class'] . ' ' : '') . 't3-icon-overlay';
                                $innerHtml = self::getSpriteIcon($overlayIconName, $overlayOptions);
                        }
                }
@@ -666,9 +639,9 @@ final class t3lib_iconWorks {
         * @return      string  the full HTML tag (usually a <span>)
         * @access public
         */
-       public static function getSpriteIconForFile($fileExtension, $options = array()) {
-               $innerHtml = (isset($options['html'])    ? $options['html']    : '');
-               $tagName   = (isset($options['tagName']) ? $options['tagName'] : 'span');
+       public static function getSpriteIconForFile($fileExtension, array $options = array()) {
+               $innerHtml = (isset($options['html']) ? $options['html'] : NULL);
+               $tagName = (isset($options['tagName']) ? $options['tagName'] : NULL);
 
                        // create the CSS class
                $options['class'] = self::mapFileExtensionToSpriteIconClass($fileExtension) . (isset($options['class']) ? ' ' . $options['class'] : '');
@@ -680,13 +653,26 @@ final class t3lib_iconWorks       {
 
 
        /**
-        * Generates the spriteicon name for a given path or fileExtension
-        * usually called from getSpriteIconForFile
+        * Generates the spriteicon css classes name for a given path or fileExtension
+        * usually called from getSpriteIconForFile or ExtJs Provider
         *
         * @param       string          fileExtension can be jpg, gif etc, but also be 'mount' or 'folder', but can also be a full path which will be resolved then
         * @return      string          the string of the CSS class, see t3lib_iconworks::$fileSpriteIconNames
+        * @access private
         */
        public static function mapFileExtensionToSpriteIconClass($fileExtension) {
+               return self::getSpriteIconClasses(self::mapFileExtensionToSpriteIconName($fileExtension));
+       }
+
+       /**
+        * Generates the spriteicon name for a given path or fileExtension
+        * usually called from mapFileExtensionToSpriteIconClass and tceforms
+        *
+        * @param       string          fileExtension can be jpg, gif etc, but also be 'mount' or 'folder', but can also be a full path which will be resolved then
+        * @return      string          the string of the CSS class, see t3lib_iconworks::$fileSpriteIconNames
+        * @access private
+        */
+       public static function mapFileExtensionToSpriteIconName($fileExtension) {
 
                        // if the file is a whole file with name etc (mainly, if it has a "." or a "/"),
                        // then it is checked whether it is a valid directory
@@ -697,10 +683,12 @@ final class t3lib_iconWorks       {
                        $path = t3lib_div::resolveBackPath($filePath);
                        if (is_dir($path) || substr($fileExtension, -1) === '/' || substr($fileExtension, -1) === '\\') {
                                $fileExtension = 'folder';
-                       } else if (($pos = strrpos($fileExtension, '.')) !== FALSE) {
-                               $fileExtension = strtolower(substr($fileExtension, $pos + 1));
                        } else {
-                               $fileExtension = 'default';
+                               if (($pos = strrpos($fileExtension, '.')) !== FALSE) {
+                                       $fileExtension = strtolower(substr($fileExtension, $pos + 1));
+                               } else {
+                                       $fileExtension = 'default';
+                               }
                        }
                }
 
@@ -710,7 +698,8 @@ final class t3lib_iconWorks {
                        $fileExtension = 'default';
                }
                $iconName = self::$fileSpriteIconNames[$fileExtension];
-               return self::getSpriteIconClasses($iconName);
+
+               return $iconName;
        }
 
 
@@ -727,18 +716,18 @@ final class t3lib_iconWorks       {
         * @return      string  the full HTML tag (usually a <span>)
         * @access public
         */
-       public static function getSpriteIconForRecord($table, $row, $options = array()) {
-               $innerHtml = (isset($options['html'])    ? $options['html']    : '');
-               $tagName   = (isset($options['tagName']) ? $options['tagName'] : 'span');
+       public static function getSpriteIconForRecord($table, array $row, array $options = array()) {
+               $innerHtml = (isset($options['html']) ? $options['html'] : NULL);
+               $tagName = (isset($options['tagName']) ? $options['tagName'] : NULL);
 
                        // overlay this record icon with the status of the row
                $overlaySpriteIconName = self::mapRecordOverlayToSpriteIconName($table, $row);
                if ($overlaySpriteIconName) {
                        $overlayOptions = array(
-                               'html'  => $innerHtml,
+                               'html' => $innerHtml,
                                'class' => 't3-icon-overlay'
                        );
-                       $innerHtml = self::getSpriteIcon($overlaySpriteIconName, $overlayOptions);
+                       $innerHtml = self::getSpriteIcon($overlaySpriteIconName, $overlayOptions);
                }
 
                        // fetch the name for the CSS class, based on the $row
@@ -759,6 +748,7 @@ final class t3lib_iconWorks {
         *   -
         * This method solely takes care of the type of this record, not any
         * statuses, used for overlays.
+        * You should not use this directly besides if you need classes for ExtJS iconCls.
         *
         * see t3lib/stddb/tables.php for an example with the TCA table "pages"
         *
@@ -767,48 +757,98 @@ final class t3lib_iconWorks       {
         * @return      string  the CSS class for the sprite icon of that DB record
         * @access      private
         **/
-       protected static function mapRecordTypeToSpriteIconClass($table, $row) {
-               $iconName = '';
+       public static function mapRecordTypeToSpriteIconClass($table, array $row) {
+               return self::getSpriteIconClasses(self::mapRecordTypeToSpriteIconName($table, $row));
+       }
+
+       /**
+        * this helper functions looks up the column that is used for the type of
+        * the chosen TCA table. And then fetches the corresponding iconname
+        * based on the chosen iconsprite class in this TCA
+        * The TCA looks up
+        *   - [ctrl][typeicon_column]
+        *   -
+        * This method solely takes care of the type of this record, not any
+        * statuses, used for overlays.
+        * You should not use this directly besides if you need it in tceforms/core classes
+        *
+        * see t3lib/stddb/tables.php for an example with the TCA table "pages"
+        *
+        * @param       string  $table  the TCA table
+        * @param       array   $row    the selected record
+        * @return      string  the CSS class for the sprite icon of that DB record
+        * @access      private
+        **/
+       public static function mapRecordTypeToSpriteIconName($table, array $row) {
+               $recordType = array();
+               $ref = NULL;
                if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_column'])) {
                        $column = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
 
-                       if(isset($row[$column])) {
-                               $recordType = $row[$column];
+                       if (isset($row[$column])) {
+                               $recordType[1] = $row[$column];
                        } else {
-                               $recordType = 'default';
+                               $recordType[1] = 'default';
                        }
 
                                // workaround to give nav_hide pages a complete different icon
                                // although it's not a separate doctype
                                // and to give root-pages an own icon
-                       if ($table === 'pages' && $row['is_siteroot']) {
-                               $recordType .= '-root';
-                       } else if ($table === 'pages' && $row['nav_hide']) {
-                               $recordType .= '-hideinmenu';
+                       if ($table === 'pages') {
+                               if ($row['nav_hide']) {
+                                       $recordType[2] = $recordType[1] . '-hideinmenu';
+                               }
+                               if ($row['is_siteroot']) {
+                                       $recordType[3] = $recordType[1] . '-root';
+                               }
+                               if ($row['module']) {
+                                       $recordType[4] = 'contains-' . $row['module'];
+                               }
                        }
 
-                       if(is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) {
-                               if(isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$recordType])) {
-                                       $iconName = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$recordType];
-                               } else {
-                                       $iconName = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default'];
+                       if (is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) {
+                               foreach ($recordType AS $key => $type) {
+                                       if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$type])) {
+                                               $recordType[$key] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$type];
+                                       } else {
+                                               unset($recordType[$key]);
+                                       }
+                               }
+                               $recordType[0] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default'];
+                               if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['mask'])) {
+                                       $recordType[5] = str_replace('###TYPE###', $row[$column], $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['mask']);
+                               }
+                               if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['userFunc'])) {
+                                       $parameters = array('row' => $row);
+                                       $recordType[6] = t3lib_div::callUserFunction(
+                                               $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['userFunc'],
+                                               $parameters,
+                                               $ref
+                                       );
                                }
-
                        } else {
-                               if (in_array('tcarecords-' . $table . '-' . $recordType, $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'])) {
-                                       $iconName = 'tcarecords-' . $table . '-' . $recordType;
-                               } else {
-                                       $iconName = $iconName = 'tcarecords-' . $table . '-default';
+                               foreach ($recordType as &$type) {
+                                       $type = 'tcarecords-' . $table . '-' . $type;
                                }
+                               unset($type);
+                               $recordType[0] = 'tcarecords-' . $table . '-default';
                        }
                } else {
-                       if(is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) {
-                               $iconName = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default'];
-                       } else if (in_array('tcarecords-' . $table . '-default', $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'])) {
-                               $iconName = 'tcarecords-' . $table . '-default';
+                       if (is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) {
+                               $recordType[0] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default'];
+                       } else {
+                               $recordType[0] = 'tcarecords-' . $table . '-default';
+                       }
+               }
+               krsort($recordType);
+               if (is_array($GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'])) {
+                       foreach ($recordType as $iconName) {
+                               if (in_array($iconName, $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'])) {
+                                       return $iconName;
+                               }
                        }
                }
-               return self::getSpriteIconClasses(($iconName != '' ? $iconName : 'status-status-icon-missing'));
+               return 'status-status-icon-missing';
        }
 
 
@@ -832,20 +872,20 @@ final class t3lib_iconWorks       {
         * @return      string  the CSS class for the sprite icon of that DB record
         * @access      private
         */
-       protected static function mapRecordOverlayToSpriteIconName($table, $row) {
+       public static function mapRecordOverlayToSpriteIconName($table, array $row) {
                $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl'];
 
                        // Calculate for a given record the actual visibility at the moment
                $status = array(
-                       'hidden'           => FALSE,
-                       'starttime'        => FALSE,
-                       'endtime'          => FALSE,
-                       'futureendtime'    => FALSE,
-                       'fe_group'         => FALSE,
-                       'deleted'          => FALSE,
+                       'hidden' => FALSE,
+                       'starttime' => FALSE,
+                       'endtime' => FALSE,
+                       'futureendtime' => FALSE,
+                       'fe_group' => FALSE,
+                       'deleted' => FALSE,
                        'protectedSection' => FALSE,
-                       'nav_hide'         => ($row['nav_hide'] ? TRUE : FALSE),
-                       'noIconFound'      => ($row['_NO_ICON_FOUND'] ? TRUE : FALSE),
+                       'nav_hide' => ($row['nav_hide'] ? TRUE : FALSE),
+                       'noIconFound' => ($row['_NO_ICON_FOUND'] ? TRUE : FALSE),
                );
 
                        // Icon state based on "enableFields":
@@ -888,15 +928,28 @@ final class t3lib_iconWorks       {
                        $status['protectedSection'] = TRUE;
                }
 
+                       // Hook: allow some other process to influence the choice of icon overlay
+                       // The method called receives the table name, the current row and the current status array as parameters
+                       // The status array should be passed as a reference and in order to be modified within the hook
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_iconworks.php']['overrideIconOverlay'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_iconworks.php']['overrideIconOverlay'] as $classRef) {
+                               $hookObject = t3lib_div::getUserObj($classRef);
+                               if (method_exists($hookObject, 'overrideIconOverlay')) {
+                                       $hookObject->overrideIconOverlay($table, $row, $status);
+                               }
+                       }
+               }
 
                        // now only show the status with the highest priority
                $priorities = $GLOBALS['TBE_STYLES']['spriteIconApi']['spriteIconRecordOverlayPriorities'];
 
                $iconName = '';
-               foreach ($priorities as $priority) {
-                       if ($status[$priority]) {
-                               $iconName = $GLOBALS['TBE_STYLES']['spriteIconApi']['spriteIconRecordOverlayNames'][$priority];
-                               break;
+               if (is_array($priorities)) {
+                       foreach ($priorities as $priority) {
+                               if ($status[$priority]) {
+                                       $iconName = $GLOBALS['TBE_STYLES']['spriteIconApi']['spriteIconRecordOverlayNames'][$priority];
+                                       break;
+                               }
                        }
                }
 
@@ -904,7 +957,6 @@ final class t3lib_iconWorks {
        }
 
 
-
        /**
         * generic method to create the final CSS classes based on the sprite icon name
         * with the base class and splits the name into parts
@@ -940,7 +992,9 @@ final class t3lib_iconWorks {
         * @param       string  $innerHtml (optional)   the content within the tag, a "&nbsp;" by default
         * @param       string  $tagName (optional)     the name of the HTML element that should be used (span by default)
         */
-       protected static function buildSpriteHtmlIconTag($tagAttributes, $innerHtml = '&nbsp;', $tagName = 'span') {
+       protected static function buildSpriteHtmlIconTag(array $tagAttributes, $innerHtml = NULL, $tagName = NULL) {
+               $innerHtml = ($innerHtml === NULL ? '&nbsp;' : $innerHtml);
+               $tagName = ($tagName === NULL ? 'span' : $tagName);
                $attributes = '';
                foreach ($tagAttributes as $attribute => $value) {
                        $attributes .= ' ' . htmlspecialchars($attribute) . '="' . htmlspecialchars($value) . '"';