Icons API

New methods have been added for the purpose of icons generation. The HTML should not be written manually but rather should be generated by the means of the API. The official format for icons is PNG 24 bits. There is a special fix for IE6 that solves the PNG transparency’s issue.

The tables bellow gives an overview of the most common classes that are involved in the icons API.

Classes

Classes

Description

Description

Classes

final t3lib_iconWorks t3lib/class.t3lib_iconworks.php

Description

Icon generation, backend

This library has functions that returns - and if necessary creates - the icon for an element in TYPO3

Classes

t3lib_SpriteManager t3lib/class.t3lib_spritemanager.php

Description

TYPO3 sprite manager, used in BE and in FE if a BE user is logged in.

This class builds CSS definitions of registered icons, writes TCA definitions and registers sprite icons in a cache file.

A configurable handler class does the business task.

Classes

interface t3lib_spritemanager_SpriteIconGenerator t3lib/interfac es/interface.t3lib_spritemanager_spriteicongenerator.php

Description

Interface all handlers for t3lib_spritemanager have to implement.

Classes

t3lib_spritemanager_SimpleHandler t3lib/spritemanager/class.t3lib_spritemanager_simplehandler.php

Description

A class with an concrete implementation of t3lib_spritemanager_SpriteIconGenerator.

It is the standard / fallback handler of the sprite manager. This implementation won’t generate sprites at all. It will just render css- definitions for all registered icons so that they may be used through t3lib_iconWorks::getSpriteIcon. Without the css classes generated here, icons of for example TCA records would be empty.

The section below gives examples how to use method of t3lib_iconWorks

Method name

Method name

Description

Description

Method name

t3lib_iconWorks::getSpriteIconClasses($iconName)

Description

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

((generated))

Example

####
t3lib_iconWorks::getSpriteIconClasses('actions-document-new')
Result:
t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-new

Method name

Method name

Description

Description

Method name

t3lib_iconWorks::getSpriteIcon($iconName, array $options = array(), array $overlays = array())

Description

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

Examples

####
t3lib_iconWorks::getSpriteIcon('actions-document-new')
Result:
<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-new"></span>

####
t3lib_iconWorks::getSpriteIcon('actions-document-new', array('title' => 'foo'))
Result:
<span title="foo" class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-new"></span>

####
t3lib_iconWorks::getSpriteIcon('actions-document-new', array(), array('status-overlay-hidden' => array()))
Result: notice the additional "t3-icon-overlay" class
<span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-new">
  <span class="t3-icon t3-icon-status t3-icon-status-overlay t3-icon-overlay-hidden t3-icon-overlay"></span>
</span>

Method name

Method name

Description

Description

Method name

t3lib_iconWorks::getSpriteIconForRecord($table, array $row, array $options = array())

Description

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.

Examples

####
t3lib_iconWorks::getSpriteIconForRecord('tt_content', array())
Result:
<span class="t3-icon t3-icon-mimetypes t3-icon-mimetypes-x t3-icon-x-content-text"></span>
####
t3lib_iconWorks::getSpriteIconForRecord('tt_content', array('hidden' => 1))
Result:
<span class="t3-icon t3-icon-mimetypes t3-icon-mimetypes-x t3-icon-x-content-text">
 <span class="t3-icon t3-icon-status t3-icon-status-overlay t3-icon-overlay-hidden t3-icon-overlay"></span>
</span>
####
t3lib_iconWorks::getSpriteIconForRecord('tt_content', array(), array('class' => 'foo', 'title' => 'bar'))
Result:
<span class="t3-icon t3-icon-mimetypes t3-icon-mimetypes-x t3-icon-x-content-text foo" title="bar"></span>

Method name

Method name

Description

Description

Method name

t3lib_iconWorks::getSpriteIconForFile($file, array $options = array())

Description

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.

Examples

####
t3lib_iconWorks::getSpriteIconForFile('pdf')
Result:
<span class="t3-icon t3-icon-mimetypes t3-icon-mimetypes-pdf t3-icon-pdf"></span>
####
t3lib_iconWorks::getSpriteIconForFile('filename.pdf')
Result:
<span class="t3-icon t3-icon-mimetypes t3-icon-mimetypes-pdf t3-icon-pdf"></span>
####
t3lib_iconWorks::getSpriteIconForFile('pdf', array('title' => 'bar'))
Result:
<span title="bar" class="t3-icon t3-icon-mimetypes t3-icon-mimetypes-pdf t3-icon-pdf"></span>