TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SpriteGenerator Class Reference

Public Member Functions

 __construct ($spriteName)
 
 setNamespace ($nameSpace)
 
 setSpriteName ($spriteName)
 
 setSpriteFolder ($folder)
 
 setCSSFolder ($folder)
 
 setEnableHighDensitySprite ($enable=true)
 
 setOmitSpriteNameInIconName ($value)
 
 setIconSpace ($value)
 
 setIncludeTimestampInCSS ($value)
 
 generateSpriteFromFolder (array $inputFolder)
 
 generateSpriteFromArray (array $files)
 

Protected Member Functions

 resolveSpritePath ()
 
 generateGraphic ()
 
 generateHighDensityGraphic ()
 
 calculateSpritePositions ()
 
 getFolder ($directoryPath)
 
 buildFileInformationCache (array $files)
 
 explodeSizeTag ($tag= '')
 

Protected Attributes

 $templateSprite
 
 $templateSpriteHighDensity
 
 $templateIcon
 
 $enableHighDensitySprite = true
 
 $defaultWidth = 0
 
 $defaultHeight = 0
 
 $spriteWidth = 0
 
 $spriteHeight = 0
 
 $spriteName = ''
 
 $spriteFolder = 'typo3temp/sprites/'
 
 $cssFolder = 'typo3temp/sprites/'
 
 $omitSpriteNameInIconName = false
 
 $nameSpace = 't3-icon'
 
 $includeTimestampInCSS = true
 
 $spriteBases = array()
 
 $iconsData = array()
 
 $iconSizes = array()
 
 $iconNamesPerSize = array()
 
 $space = 2
 

Detailed Description

Sprite generator

Definition at line 23 of file SpriteGenerator.php.

Constructor & Destructor Documentation

__construct (   $spriteName)

Initializes the configuration of the spritegenerator

Parameters
string$spriteNameThe name of the sprite to be generated

Definition at line 177 of file SpriteGenerator.php.

References SpriteGenerator\$spriteName.

Member Function Documentation

buildFileInformationCache ( array  $files)
protected

Generates file information cache from file array

Parameters
array$filesList of all files with their icon name
Returns
void

Definition at line 567 of file SpriteGenerator.php.

References SpriteGenerator\explodeSizeTag(), and GeneralUtility\trimExplode().

Referenced by SpriteGenerator\generateSpriteFromArray().

calculateSpritePositions ( )
protected

Arranges icons in sprites, afterwards all icons have information about the position in sprite

Definition at line 480 of file SpriteGenerator.php.

References SpriteGenerator\$space, SpriteGenerator\$spriteWidth, elseif, and SpriteGenerator\explodeSizeTag().

Referenced by SpriteGenerator\generateSpriteFromArray().

explodeSizeTag (   $tag = '')
protected

Transforms size tag into size array

Parameters
string$tagA size tag at the cache arrays
Returns
array

Definition at line 616 of file SpriteGenerator.php.

References GeneralUtility\trimExplode().

Referenced by SpriteGenerator\buildFileInformationCache(), and SpriteGenerator\calculateSpritePositions().

generateGraphic ( )
protected

The actual sprite generator, renders the command for Im/GM and executes

Returns
void

Definition at line 421 of file SpriteGenerator.php.

References GeneralUtility\tempnam(), GeneralUtility\unlink_tempfile(), and GeneralUtility\upload_copy_move().

Referenced by SpriteGenerator\generateSpriteFromArray().

generateHighDensityGraphic ( )
protected

The actual sprite generator, renders the command for IM/GM and executes

Returns
void

Definition at line 448 of file SpriteGenerator.php.

References GeneralUtility\tempnam(), GeneralUtility\unlink_tempfile(), and GeneralUtility\upload_copy_move().

Referenced by SpriteGenerator\generateSpriteFromArray().

generateSpriteFromArray ( array  $files)

Method processes an array of files into an sprite, the array can be build from files within an folder or by hand (as the SpriteManager does)

Parameters
array$filesarray(icon name => icon file)
Returns
array

Definition at line 304 of file SpriteGenerator.php.

References SpriteGenerator\$spriteName, SpriteGenerator\buildFileInformationCache(), SpriteGenerator\calculateSpritePositions(), SpriteGenerator\generateGraphic(), and SpriteGenerator\generateHighDensityGraphic().

Referenced by SpriteGenerator\generateSpriteFromFolder().

generateSpriteFromFolder ( array  $inputFolder)

Reads all png,gif,jpg files from the passed folder name (including 1 subfolder level) extracts size information and stores data in internal array, afterwards triggers sprite generation.

Parameters
array$inputFolderFolder from which files are read
Returns
array

Definition at line 286 of file SpriteGenerator.php.

References SpriteGenerator\generateSpriteFromArray(), and SpriteGenerator\getFolder().

getFolder (   $directoryPath)
protected

Function getFolder traverses the target directory, locates all iconFiles and collects them into an array

Parameters
string$directoryPathPath to an folder which contains images
Returns
array Returns an array with all files key: iconname, value: fileName

Definition at line 535 of file SpriteGenerator.php.

References GeneralUtility\get_dirs(), and GeneralUtility\getFilesInDir().

Referenced by SpriteGenerator\generateSpriteFromFolder().

resolveSpritePath ( )
protected

Compares image path to CSS path and creates the relative backpath from css to the sprites

Returns
string

Definition at line 395 of file SpriteGenerator.php.

References GeneralUtility\resolveBackPath(), and GeneralUtility\trimExplode().

setCSSFolder (   $folder)

Sets the sprite-css target-folder

Parameters
string$folderthe target folder where the generated CSS files are stored
Returns
SpriteGenerator An instance of $this, to enable "chaining".

Definition at line 224 of file SpriteGenerator.php.

setEnableHighDensitySprite (   $enable = true)

Enables/Disables HighDensitySprite Generation

Parameters
bool$enable
Returns
SpriteGenerator An instance of $this, to enable "chaining".

Definition at line 236 of file SpriteGenerator.php.

setIconSpace (   $value)

Setter to adjust how much space is between to icons in the sprite

Parameters
int$value
Returns
SpriteGenerator An instance of $this, to enable "chaining".

Definition at line 260 of file SpriteGenerator.php.

setIncludeTimestampInCSS (   $value)

Setter for timestamp inclusion: imageFiles will be included with ?timestamp

Parameters
bool$value
Returns
SpriteGenerator An instance of $this, to enable "chaining".

Definition at line 272 of file SpriteGenerator.php.

setNamespace (   $nameSpace)

Sets namespace of css code

Parameters
string$nameSpace
Returns
SpriteGenerator An instance of $this, to enable "chaining".

Definition at line 188 of file SpriteGenerator.php.

References SpriteGenerator\$nameSpace.

setOmitSpriteNameInIconName (   $value)

Setter do enable the exclusion of the sprites-name from iconnames

Parameters
bool$value
Returns
SpriteGenerator An instance of $this, to enable "chaining".

Definition at line 248 of file SpriteGenerator.php.

setSpriteFolder (   $folder)

Sets the sprite-graphics target-folder

Parameters
string$folderThe target folder where the generated sprite is stored
Returns
SpriteGenerator An instance of $this, to enable "chaining".

Definition at line 212 of file SpriteGenerator.php.

setSpriteName (   $spriteName)

Sets the spritename

Parameters
string$spriteNameThe name of the sprite to be generated
Returns
SpriteGenerator An instance of $this, to enable "chaining".

Definition at line 200 of file SpriteGenerator.php.

References SpriteGenerator\$spriteName.

Member Data Documentation

$cssFolder = 'typo3temp/sprites/'
protected

Definition at line 112 of file SpriteGenerator.php.

$defaultHeight = 0
protected

Definition at line 77 of file SpriteGenerator.php.

$defaultWidth = 0
protected

Definition at line 70 of file SpriteGenerator.php.

$enableHighDensitySprite = true
protected

Definition at line 63 of file SpriteGenerator.php.

$iconNamesPerSize = array()
protected

Definition at line 163 of file SpriteGenerator.php.

$iconsData = array()
protected

Definition at line 149 of file SpriteGenerator.php.

$iconSizes = array()
protected

Definition at line 156 of file SpriteGenerator.php.

$includeTimestampInCSS = true
protected

Definition at line 134 of file SpriteGenerator.php.

$nameSpace = 't3-icon'
protected

Definition at line 126 of file SpriteGenerator.php.

Referenced by SpriteGenerator\setNamespace().

$omitSpriteNameInIconName = false
protected

Definition at line 119 of file SpriteGenerator.php.

$space = 2
protected

Definition at line 170 of file SpriteGenerator.php.

Referenced by SpriteGenerator\calculateSpritePositions().

$spriteBases = array()
protected

Definition at line 142 of file SpriteGenerator.php.

$spriteFolder = 'typo3temp/sprites/'
protected

Definition at line 105 of file SpriteGenerator.php.

$spriteHeight = 0
protected

Definition at line 91 of file SpriteGenerator.php.

$spriteName = ''
protected
$spriteWidth = 0
protected

Definition at line 84 of file SpriteGenerator.php.

Referenced by SpriteGenerator\calculateSpritePositions().

$templateIcon
protected
Initial value:
= '.###NAMESPACE###-###ICONNAME### {
background-position: -###LEFT###px -###TOP###px !important;
###SIZE_INFO###
}
'

Definition at line 54 of file SpriteGenerator.php.

$templateSprite
protected
Initial value:
= '
.###NAMESPACE###-###SPRITENAME### {
background-image: url(\'###SPRITEURL###\') !important;
height: ###DEFAULTHEIGHT###px;
width: ###DEFAULTWIDTH###px;
}
'

Definition at line 30 of file SpriteGenerator.php.

$templateSpriteHighDensity
protected
Initial value:
= '
.backgroundsize .###NAMESPACE###-###SPRITENAME### {
background-image: url(\'###SPRITEURL###\') !important;
background-size:###BGWIDTH### ###BGHEIGHT###;
}
'

Definition at line 43 of file SpriteGenerator.php.