TYPO3  7.6
Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Static Protected Attributes | List of all members
IconUtility Class Reference
Inheritance diagram for IconUtility:
IconUtilityFixture

Static Public Member Functions

static getIcon ($table, $row=array(), $shaded=false)
 
static skinImg ($backPath, $src, $wHattribs= '', $outputMode=0)
 
static makeIcon ($iconfile, $mode, $user, $protectSection, $absFile, $iconFileName_stateTagged)
 
static imagecopyresized (&$destinationImage, $sourceImage, $destinationX, $destinationY, $sourceX, $sourceY, $destinationWidth, $destinationHeight, $sourceWidth, $sourceHeight)
 
static imagecreatefrom ($file)
 
static imagemake ($im, $path)
 
static getSpriteIcon ($iconName, array $options=array(), array $overlays=array())
 
static getSpriteIconForFile ($fileExtension, array $options=null)
 
static mapFileExtensionToSpriteIconClass ($fileExtension)
 
static mapFileExtensionToSpriteIconName ($fileExtension)
 
static getSpriteIconForRecord ($table, array $row, array $options=null)
 
static getSpriteIconForResource (\TYPO3\CMS\Core\Resource\ResourceInterface $resource, array $options=array(), array $overlays=null)
 
static mapRecordTypeToSpriteIconClass ($table, array $row)
 
static mapRecordTypeToSpriteIconName ($table, array $row)
 
static getSpriteIconClasses ($iconName)
 

Static Public Attributes

static $fileSpriteIconNames
 

Static Protected Member Functions

static buildSpriteHtmlIconTag (array $tagAttributes, $innerHtml=null, $tagName=null)
 

Static Protected Attributes

static $spriteIconCache = array()
 

Detailed Description

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:

Notes: These functions are strongly related to the interface of TYPO3. Static class, functions called without making a class instance.

Deprecated:
since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use IconFactory instead

Definition at line 38 of file IconUtility.php.

Member Function Documentation

static buildSpriteHtmlIconTag ( array  $tagAttributes,
  $innerHtml = null,
  $tagName = null 
)
staticprotected

low level function that generates the HTML tag for the sprite icon is usually called by the three API classes (getSpriteIcon, getSpriteIconForFile, getSpriteIconForRecord) it does not care about classes or anything else, but just plainly builds the HTML tag

Parameters
array$tagAttributesAn associative array of additional tagAttributes for the HTML tag
string$innerHtmlThe content within the tag, a " " by default
string$tagNameThe name of the HTML element that should be used (span by default)
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
Returns
string The sprite html icon tag

Definition at line 908 of file IconUtility.php.

References GeneralUtility\logDeprecatedFunction().

static getIcon (   $table,
  $row = array(),
  $shaded = false 
)
static

Creates the icon for input table/row Returns filename for the image icon, relative to PATH_typo3

Parameters
string$tableThe table name
array$rowThe table row ("enablefields" are at least needed for correct icon display and for pages records some more fields in addition!)
bool$shadedIf set, the icon will be grayed/shaded
Returns
string Icon filename
Deprecated:
since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use IconUtility::getSpriteIcon() instead

Definition at line 133 of file IconUtility.php.

References $GLOBALS, Enumeration\cast(), VersionState\DELETE_PLACEHOLDER, elseif, GeneralUtility\logDeprecatedFunction(), VersionState\MOVE_PLACEHOLDER, VersionState\MOVE_POINTER, and VersionState\NEW_PLACEHOLDER.

static getSpriteIcon (   $iconName,
array  $options = array(),
array  $overlays = array() 
)
static

This generic method is used throughout the TYPO3 Backend to show icons in any variation which are not bound to any resource object (see getSpriteIconForResource) or database record (see getSpriteIconForRecord)

Generates a HTML tag with proper CSS classes. The TYPO3 skin has defined these CSS classes already to have a pre-defined background image, and the correct background-position to show the necessary icon.

If no options or overlays are given, the icon will be cached in $spriteIconCache.

Parameters
string$iconNameThe name of the icon to fetch
array$optionsAn associative array with additional options and attributes for the tag. by default, the key is the name of the attribute, and the value is the parameter string that is set. However, there are some additional special reserved keywords that can be used as keys: "html" (which is the HTML that will be inside the icon HTML tag), "tagName" (which is an alternative tagName than "span"), and "class" (additional class names that will be merged with the sprite icon CSS classes)
array$overlaysAn associative array with the icon-name as key, and the options for this overlay as an array again (see the parameter $options again)
Returns
string The full HTML tag (usually a )
Deprecated:
since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use IconFactory->getIcon instead public

Definition at line 586 of file IconUtility.php.

References $GLOBALS, and GeneralUtility\logDeprecatedFunction().

static getSpriteIconClasses (   $iconName)
static

generic method to create the final CSS classes based on the sprite icon name with the base class and splits the name into parts is usually called by the methods that are responsible for fetching the names out of the file name, or the record type

Parameters
string$iconNameIconname like 'actions-document-new'
Returns
string A list of all CSS classes needed for the HTML tag
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8

Definition at line 880 of file IconUtility.php.

References GeneralUtility\logDeprecatedFunction().

Referenced by IconUtilityTest\getSpriteIconClassesWithEmptyStringReturnsT3Icon(), IconUtilityTest\getSpriteIconClassesWithFourPartsReturnsT3IconAndCombinedParts(), IconUtilityTest\getSpriteIconClassesWithOnePartReturnsT3Icon(), IconUtilityTest\getSpriteIconClassesWithThreePartsReturnsT3IconAndCombinedParts(), and IconUtilityTest\getSpriteIconClassesWithTwoPartsReturnsT3IconAndCombinedParts().

static getSpriteIconForFile (   $fileExtension,
array  $options = null 
)
static

This method is used throughout the TYPO3 Backend to show icons for a file type

Generates a HTML tag with proper CSS classes. The TYPO3 skin has defined these CSS classes already to have a pre-defined background image, and the correct background-position to show the necessary icon.

Parameters
string$fileExtensionThe name of the icon to fetch, can be a file extension, full file path or one of the special keywords "folder" or "mount
array$optionsnot used anymore
Returns
string The full HTML tag public
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use IconFactory::getIconForFile directly

Definition at line 642 of file IconUtility.php.

References GeneralUtility\deprecationLog(), GeneralUtility\logDeprecatedFunction(), and GeneralUtility\makeInstance().

static getSpriteIconForRecord (   $table,
array  $row,
array  $options = null 
)
static

This method is used throughout the TYPO3 Backend to show icons for a DB record

Generates a HTML tag with proper CSS classes. The TYPO3 skin has defined these CSS classes already to have a pre-defined background image, and the correct background-position to show the necessary icon.

Parameters
string$tableThe TCA table name
array$rowThe DB record of the TCA table
array$optionsnot used anymore
Returns
string The full HTML tag (usually a ) public
Deprecated:
since TYPO3 CMS 7, will be removed with TYPO3 CMS 8

Definition at line 716 of file IconUtility.php.

References GeneralUtility\deprecationLog(), GeneralUtility\logDeprecatedFunction(), GeneralUtility\makeInstance(), and Icon\SIZE_SMALL.

static getSpriteIconForResource ( \TYPO3\CMS\Core\Resource\ResourceInterface  $resource,
array  $options = array(),
array  $overlays = null 
)
static

This method is used throughout the TYPO3 Backend to show icons for files and folders

The method takes care of the translation of file extension to proper icon and for folders it will return the icon depending on the role of the folder.

If the given resource is a folder there are some additional options that can be used:

  • mount-root => TRUE (to indicate this is the root of a mount)
  • folder-open => TRUE (to indicate that the folder is opened in the file tree)

There is a hook in place to manipulate the icon name and overlays.

Parameters
\TYPO3\CMS\Core\Resource\ResourceInterface$resource
array$optionsAn associative array with additional options and attributes for the tag. See self::getSpriteIcon()
array$overlaysnot used anymore
Returns
string
Exceptions
\UnexpectedValueException
Deprecated:
since TYPO3 CMS 7, will be removed with TYPO3 CMS 8

Definition at line 746 of file IconUtility.php.

References GeneralUtility\deprecationLog(), GeneralUtility\logDeprecatedFunction(), GeneralUtility\makeInstance(), and Icon\SIZE_SMALL.

static imagecopyresized ( $destinationImage,
  $sourceImage,
  $destinationX,
  $destinationY,
  $sourceX,
  $sourceY,
  $destinationWidth,
  $destinationHeight,
  $sourceWidth,
  $sourceHeight 
)
static

The necessity of using this function for combining two images if GD is version 2 is that GD2 cannot manage to combine two indexed-color images without totally spoiling everything. In class this was solved by combining the images onto a first created true color image. However it has turned out that this method will not work if the indexed png-files contains transparency. So I had to turn my attention to ImageMagick - my 'enemy of death'. And so it happened - ImageMagick is now used to combine my two indexed-color images with transparency. And that works. 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.

Parameters
resource$destinationImageDestination image
resource$sourceImageSource image
int$destinationXDestination x-coordinate
int$destinationYDestination y-coordinate
int$sourceXSource x-coordinate
int$sourceYSource y-coordinate
int$destinationWidthDestination width
int$destinationHeightDestination height
int$sourceWidthSource width
int$sourceHeightSource height
Returns
void private
See Also
::imagecopyresized()

Definition at line 502 of file IconUtility.php.

static imagecreatefrom (   $file)
static

Create new image pointer from input file (either gif/png, in case the wrong format it is converted by ::readPngGif())

Parameters
string$fileAbsolute filename of the image file from which to start the icon creation.
Returns
resource|int If success, image pointer, otherwise -1 private
See Also
::readPngGif

Definition at line 515 of file IconUtility.php.

References $GLOBALS, and GraphicalFunctions\readPngGif().

static imagemake (   $im,
  $path 
)
static

Write the icon in $im pointer to $path

Parameters
resource$imPointer to GDlib image resource
string$pathAbsolute path to the filename in which to write the icon.
Returns
void private

Definition at line 533 of file IconUtility.php.

References $GLOBALS, and GeneralUtility\fixPermissions().

Referenced by IconUtilityTest\imagemakeFixesPermissionsOnNewFiles().

static makeIcon (   $iconfile,
  $mode,
  $user,
  $protectSection,
  $absFile,
  $iconFileName_stateTagged 
)
static

Creates the icon file for the function getIcon()

Parameters
string$iconfileOriginal unprocessed Icon file, relative path to PATH_typo3
string$modeMode string, eg. "deleted" or "futuretiming" determining how the icon will look
int$userThe number of the fe_group record uid if applicable
bool$protectSectionFlag determines if the protected-section icon should be applied.
string$absFileAbsolute path to file from which to create the icon.
string$iconFileName_stateTaggedThe filename that this icon should have had, basically [icon base name]_[flags].[extension] - used for part of temporary filename
Returns
string Filename relative to PATH_typo3 private

Definition at line 372 of file IconUtility.php.

References $GLOBALS, GraphicalFunctions\gifCompress(), GeneralUtility\mkdir(), and GeneralUtility\shortMD5().

static mapFileExtensionToSpriteIconClass (   $fileExtension)
static

Generates the spriteicon css classes name for a given path or fileExtension usually called from getSpriteIconForFile or ExtJs Provider

Parameters
string$fileExtensionFileExtension can be jpg, gif etc, but also be 'mount' or 'folder', but can also be a full path which will be resolved then
Returns
string The string of the CSS class, see ::$fileSpriteIconNames private

Definition at line 661 of file IconUtility.php.

static mapFileExtensionToSpriteIconName (   $fileExtension)
static

Generates the spriteicon name for a given path or fileExtension usually called from mapFileExtensionToSpriteIconClass and tceforms

Parameters
string$fileExtensionFileExtension can be jpg, gif etc, but also be 'mount' or 'folder', but can also be a full path which will be resolved then
Returns
string The string of the CSS class, see ::$fileSpriteIconNames private

Definition at line 674 of file IconUtility.php.

References $GLOBALS, GeneralUtility\getIndpEnv(), and GeneralUtility\resolveBackPath().

static mapRecordTypeToSpriteIconClass (   $table,
array  $row 
)
static

this helper functions looks up the column that is used for the type of the chosen TCA table. And then fetches the corresponding class 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 classes for ExtJS iconCls.

see ext:core/Configuration/TCA/pages.php for an example with the TCA table "pages"

Parameters
string$tableThe TCA table
array$rowThe selected record
Returns
string The CSS class for the sprite icon of that DB record private
Deprecated:
since TYPO3 CMS 7, will be removed with TYPO3 CMS 8

Definition at line 776 of file IconUtility.php.

References GeneralUtility\logDeprecatedFunction().

static mapRecordTypeToSpriteIconName (   $table,
array  $row 
)
static

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 ext:core/Configuration/TCA/pages.php for an example with the TCA table "pages"

Parameters
string$tableThe TCA table
array$rowThe selected record
Returns
string The CSS class for the sprite icon of that DB record private

Definition at line 800 of file IconUtility.php.

References $GLOBALS, and GeneralUtility\callUserFunction().

static skinImg (   $backPath,
  $src,
  $wHattribs = '',
  $outputMode = 0 
)
static

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

Parameters
string$backPathCurrent backpath to PATH_typo3 folder
string$srcIcon file name relative to PATH_typo3 folder
string$wHattribsDefault width/height, defined like 'width="12" height="14"'
int$outputModeMode: 0 (zero) is default and returns src/width/height. 1 returns value of src+backpath, 2 returns value of w/h.
Returns
string Returns ' src="[backPath][src]" [wHattribs]'
Deprecated:
since TYPO3 CMS 7, will be removed with TYPO3 CMS 8
See Also
skinImgFile()

Definition at line 288 of file IconUtility.php.

References $GLOBALS, elseif, and GeneralUtility\logDeprecatedFunction().

Member Data Documentation

$fileSpriteIconNames
static

Definition at line 43 of file IconUtility.php.

$spriteIconCache = array()
staticprotected

Definition at line 121 of file IconUtility.php.