Index: t3lib/class.t3lib_iconworks.php =================================================================== --- t3lib/class.t3lib_iconworks.php (revision 9302) +++ t3lib/class.t3lib_iconworks.php (revision ) @@ -1,29 +1,29 @@ 'mimetypes-text-html', + 'htm' => 'mimetypes-text-html', - 'html' => 'mimetypes-text-html', + 'html' => 'mimetypes-text-html', - 'css' => 'mimetypes-text-css', + 'css' => 'mimetypes-text-css', - 'js' => 'mimetypes-text-js', + 'js' => 'mimetypes-text-js', - 'csv' => 'mimetypes-text-csv', + 'csv' => 'mimetypes-text-csv', - 'php' => 'mimetypes-text-php', + 'php' => 'mimetypes-text-php', - 'php6' => 'mimetypes-text-php', + 'php6' => 'mimetypes-text-php', - 'php5' => 'mimetypes-text-php', + 'php5' => 'mimetypes-text-php', - 'php4' => 'mimetypes-text-php', + 'php4' => 'mimetypes-text-php', - 'php3' => 'mimetypes-text-php', + 'php3' => 'mimetypes-text-php', - 'inc' => 'mimetypes-text-php', + 'inc' => 'mimetypes-text-php', - 'ts' => 'mimetypes-text-ts', + 'ts' => 'mimetypes-text-ts', - 'txt' => 'mimetypes-text-text', + 'txt' => 'mimetypes-text-text', 'class' => 'mimetypes-text-text', - 'tmpl' => 'mimetypes-text-text', + 'tmpl' => 'mimetypes-text-text', - 'jpg' => 'mimetypes-media-image', + 'jpg' => 'mimetypes-media-image', - 'jpeg' => 'mimetypes-media-image', + 'jpeg' => 'mimetypes-media-image', - 'gif' => 'mimetypes-media-image', + 'gif' => 'mimetypes-media-image', - 'png' => 'mimetypes-media-image', + 'png' => 'mimetypes-media-image', - 'bmp' => 'mimetypes-media-image', + 'bmp' => 'mimetypes-media-image', - 'tif' => 'mimetypes-media-image', + 'tif' => 'mimetypes-media-image', - 'tga' => 'mimetypes-media-image', + 'tga' => 'mimetypes-media-image', - 'psd' => 'mimetypes-media-image', + 'psd' => 'mimetypes-media-image', - 'eps' => 'mimetypes-media-image', + 'eps' => 'mimetypes-media-image', - 'avi' => 'mimetypes-media-video', + 'avi' => 'mimetypes-media-video', - 'mpg' => 'mimetypes-media-video', + 'mpg' => 'mimetypes-media-video', - 'mpeg' => 'mimetypes-media-video', + 'mpeg' => 'mimetypes-media-video', - 'mov' => 'mimetypes-media-video', + 'mov' => 'mimetypes-media-video', - 'wav' => 'mimetypes-media-audio', + 'wav' => 'mimetypes-media-audio', - 'mp3' => 'mimetypes-media-audio', + 'mp3' => 'mimetypes-media-audio', - 'mid' => 'mimetypes-media-audio', + 'mid' => 'mimetypes-media-audio', - 'swf' => 'mimetypes-media-flash', + 'swf' => 'mimetypes-media-flash', - 'swa' => 'mimetypes-media-flash', + 'swa' => 'mimetypes-media-flash', - 'exe' => 'mimetypes-executable-executable', + 'exe' => 'mimetypes-executable-executable', - 'com' => 'mimetypes-executable-executable', + 'com' => 'mimetypes-executable-executable', - 't3x' => 'mimetypes-compressed', + 't3x' => 'mimetypes-compressed', - 't3d' => 'mimetypes-compressed', + 't3d' => 'mimetypes-compressed', - 'zip' => 'mimetypes-compressed', + 'zip' => 'mimetypes-compressed', - 'tgz' => 'mimetypes-compressed', + 'tgz' => 'mimetypes-compressed', - 'gz' => 'mimetypes-compressed', + 'gz' => 'mimetypes-compressed', - 'pdf' => 'mimetypes-pdf', + 'pdf' => 'mimetypes-pdf', - 'doc' => 'mimetypes-word', + 'doc' => 'mimetypes-word', - 'sxw' => 'mimetypes-word', + 'sxw' => 'mimetypes-word', - 'rtf' => 'mimetypes-word', + 'rtf' => 'mimetypes-word', - 'xls' => 'mimetypes-excel', + 'xls' => 'mimetypes-excel', - 'sxc' => 'mimetypes-excel', + 'sxc' => 'mimetypes-excel', - 'ppt' => 'mimetypes-powerpoint', + 'ppt' => 'mimetypes-powerpoint', 'mount' => 'apps-filetree-mount', - 'folder' => 'apps-filetree-folder-default', + 'folder' => 'apps-filetree-folder-default', 'default' => 'mimetypes-other-other' ); @@ -152,12 +144,12 @@ */ public static function getIconImage($table, $row = array(), $backPath, $params = '', $shaded = FALSE) { $str = ' 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! } } @@ -275,7 +273,7 @@ $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; } @@ -286,39 +284,43 @@ 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.= + $flags .= - ($hidden ? 'h' : ''). + ($hidden ? 'h' : '') . - ($timing ? 't' : ''). + ($timing ? 't' : '') . - ($futuretiming ? 'f' : ''). + ($futuretiming ? 'f' : '') . - ($user ? 'u' : ''). + ($user ? 'u' : '') . - ($protectSection ? 'p' : ''). + ($protectSection ? 'p' : '') . - ($shaded ? 's' : ''); + ($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] + 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; + return dirname($iconfile) . '/' . $iconFileName_stateTagged; - } elseif ($doNotGenerateIcon) { // If no icon generation can be done, try to look for the _X icon: + } 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)) { + if (@is_file(dirname($absfile) . '/' . $iconFileName_X)) { - return dirname($iconfile).'/'.$iconFileName_X; + return dirname($iconfile) . '/' . $iconFileName_X; } else { return 'gfx/i/no_icon_found.gif'; } - } else { // Otherwise, create the icon: + } else { // Otherwise, create the icon: $theRes = self::makeIcon($GLOBALS['BACK_PATH'] . $iconfile, $string, $user, $protectSection, $absfile, $iconFileName_stateTagged); return $theRes; } @@ -339,7 +341,7 @@ * @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(); @@ -353,22 +355,22 @@ #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 + $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 + $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... + 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: + $iInfo = @getimagesize($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['absDir'] . $lookUpName); // Get width/height: // Set $src and $wHattribs: $src = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'] . $lookUpName; @@ -377,11 +379,11 @@ // 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) @@ -391,14 +393,14 @@ $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; @@ -415,15 +417,6 @@ } - - - - - - - - - /*********************************** * * Other functions @@ -443,52 +436,56 @@ * @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'); + $iconFileName = 'icon_' . t3lib_div::shortMD5($iconfile . '|' . $mode . '|-' . $user . '|' . $protectSection) . '_' . $iconFileName_stateTagged . '.' . ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'] ? 'png' : 'gif'); - $mainpath = '../typo3temp/'.$iconFileName; + $mainpath = '../typo3temp/' . $iconFileName; - $path = PATH_site.'typo3temp/'.$iconFileName; + $path = PATH_site . 'typo3temp/' . $iconFileName; - if (file_exists(PATH_typo3.'icons/'.$iconFileName)) { // Returns if found in typo3/icons/ + if (file_exists(PATH_typo3 . 'icons/' . $iconFileName)) { // Returns if found in typo3/icons/ - return 'icons/'.$iconFileName; + return 'icons/' . $iconFileName; - } elseif (file_exists($path)) { // Returns if found in ../typo3temp/icons/ + } 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))) { + if (($mode == 'disabled') OR ($mode != 'futuretiming' && $mode != 'no_icon_found' && !(!$mode && $user))) { - for ($c = 0; $c10)?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; @@ -513,7 +510,9 @@ $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)); } @@ -521,7 +520,9 @@ // 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)); } @@ -534,7 +535,7 @@ return $iconfile; } } else { - return $GLOBALS['BACK_PATH'].'gfx/fileicons/default.gif'; + return $GLOBALS['BACK_PATH'] . 'gfx/fileicons/default.gif'; } } } @@ -603,7 +604,7 @@ /********************************************** - * 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 tag with corresponding CSS classes that @@ -612,13 +613,13 @@ * 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'); * **********************************************/ @@ -637,14 +638,14 @@ * @access public */ public static function getSpriteIcon($iconName, array $options = array(), array $overlays = array()) { - $innerHtml = (isset($options['html']) ? $options['html'] : NULL); + $innerHtml = (isset($options['html']) ? $options['html'] : NULL); - $tagName = (isset($options['tagName']) ? $options['tagName'] : NULL); + $tagName = (isset($options['tagName']) ? $options['tagName'] : NULL); // deal with the overlays if (count($overlays)) { foreach ($overlays as $overlayIconName => $overlayOptions) { - $overlayOptions['html'] = $innerHtml; + $overlayOptions['html'] = $innerHtml; - $overlayOptions['class'] = (isset($overlayOptions['class']) ? $overlayOptions['class'] . ' ': '') . 't3-icon-overlay'; + $overlayOptions['class'] = (isset($overlayOptions['class']) ? $overlayOptions['class'] . ' ' : '') . 't3-icon-overlay'; $innerHtml = self::getSpriteIcon($overlayIconName, $overlayOptions); } } @@ -674,8 +675,8 @@ * @access public */ public static function getSpriteIconForFile($fileExtension, array $options = array()) { - $innerHtml = (isset($options['html']) ? $options['html'] : NULL); + $innerHtml = (isset($options['html']) ? $options['html'] : NULL); - $tagName = (isset($options['tagName']) ? $options['tagName'] : NULL); + $tagName = (isset($options['tagName']) ? $options['tagName'] : NULL); // create the CSS class $options['class'] = self::mapFileExtensionToSpriteIconClass($fileExtension) . (isset($options['class']) ? ' ' . $options['class'] : ''); @@ -717,12 +718,14 @@ $path = t3lib_div::resolveBackPath($filePath); if (is_dir($path) || substr($fileExtension, -1) === '/' || substr($fileExtension, -1) === '\\') { $fileExtension = 'folder'; - } else if (($pos = strrpos($fileExtension, '.')) !== FALSE) { + } else { + if (($pos = strrpos($fileExtension, '.')) !== FALSE) { - $fileExtension = strtolower(substr($fileExtension, $pos + 1)); - } else { - $fileExtension = 'default'; - } - } + $fileExtension = strtolower(substr($fileExtension, $pos + 1)); + } else { + $fileExtension = 'default'; + } + } + } // if the file extension is not valid // then use the default one @@ -731,7 +734,7 @@ } $iconName = self::$fileSpriteIconNames[$fileExtension]; - return $iconName; + return $iconName; } @@ -749,17 +752,17 @@ * @access public */ public static function getSpriteIconForRecord($table, array $row, array $options = array()) { - $innerHtml = (isset($options['html']) ? $options['html'] : NULL); + $innerHtml = (isset($options['html']) ? $options['html'] : NULL); - $tagName = (isset($options['tagName']) ? $options['tagName'] : 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 @@ -813,6 +816,7 @@ **/ 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']; @@ -850,7 +854,7 @@ $recordType[5] = str_replace('###TYPE###', $row[$column], $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['mask']); } if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['userFunc'])) { - $recordType[6] = t3lib_div::callUserFunction($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['userFunc'], array('row' => $row)); + $recordType[6] = t3lib_div::callUserFunction($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['userFunc'], array('row' => $row), $ref); } } else { foreach ($recordType AS $key => $type) { @@ -900,15 +904,15 @@ // Calculate for a given record the actual visibility at the moment $status = array( - 'hidden' => FALSE, + 'hidden' => FALSE, - 'starttime' => FALSE, + 'starttime' => FALSE, - 'endtime' => FALSE, + 'endtime' => FALSE, - 'futureendtime' => FALSE, + 'futureendtime' => FALSE, - 'fe_group' => FALSE, + 'fe_group' => FALSE, - 'deleted' => FALSE, + 'deleted' => FALSE, 'protectedSection' => FALSE, - 'nav_hide' => ($row['nav_hide'] ? TRUE : FALSE), + 'nav_hide' => ($row['nav_hide'] ? TRUE : FALSE), - 'noIconFound' => ($row['_NO_ICON_FOUND'] ? TRUE : FALSE), + 'noIconFound' => ($row['_NO_ICON_FOUND'] ? TRUE : FALSE), ); // Icon state based on "enableFields": @@ -967,7 +971,6 @@ } - /** * generic method to create the final CSS classes based on the sprite icon name * with the base class and splits the name into parts