[TYPO3-core] RFC#15079 Feature: TYPO3 misses an SpriteGenerator

Xavier Perseguers typo3 at perseguers.ch
Sat Aug 7 16:08:59 CEST 2010


Hi,

> Note:
> in fact it is not as simple as "add one" implies.
> As this one should not only apply to internal use or current use case I
> tried to handly it as flexible as possible. Therefore there are many
> Class-Parameters and setters for them.
>
> How to test:
> Step 1: patch it :)
> Step 2: delete typo3/sysext/t3skin/stylesheets/sprites/t3-icon-*

should read "t3-icons-*"

> Step 3: delete typo3/sysext/t3skin/images/sprites/*

Lots of white cross over red background all over the BE. OK.

> Step 4:
> call:
> $generator =
> t3lib_div::makeInstance("t3lib_SpriteManager_SpriteGenerator",'t3skin');
> $data = $generator
> ->setSpriteFolder('typo3/sysext/t3skin/images/sprites/')
> ->setCSSFolder('typo3/sysext/t3skin/stylesheets/sprites/')
> ->setOmmitSpriteNameInIconName(TRUE)
> ->setIncludeTimestampInCSS(TRUE)
> ->setGenerateGifCopy(FALSE)
> ->generateSpriteFromFolder(array('typo3/sysext/t3skin/images/icons/'));
>
> you should have backend icons :)

After analyzing the generated sprite, 8 bit alpha channel is there, great!

I tried to generate my own sprite with my own icons (took famfamfam 
set). This works great as long as the directory you give contains 1 
level of subdirectories with categorized icons, just as info for others.

I tried to generate a sprite with icons of different sizes (yes I'm 
crazy). The set of icons had 16x16, 64x64 and 128x128 icons. No problem. 
I even tried to mix some non square icons 95x63 within the sprite)

I then tried (manually) to generate a html file that use random icons. 
They are correctly retrieved.

I found a bug:

- When you have a filename with spaces in it, you get an invalid CSS class:

.t3-icon-37-FireWire HD_128x128 {
	background-position: -390px -260px;
		height: 128px;
	width: 128px;

}

(furthermore, as nitpicking "height" is not well-aligned)

Still, you have my

_+1 by testing_

as spaces should never be used. Still, if you tackle with this problem, 
make sure there is no clash in generated names if for example adding a 
"_" results in another icon's name...

Remarks:

- nitpicking: there is an empty line in generated CSS when you have all 
your generated classes with background position. This is due to the 
removal of the "most common width/height combination".

- CSS could be even more optimized when all icons of a group do not have 
the most common size. In such case, let's take a few 128x128 icons, the 
base class that gives the image to use says 16x16 as size but then 
override in single sprite the height/width to use 128x128. This could be 
optimized to say 128x128 in the base definition and not override this 
after that.

- patch for core_autoload.php failed. I'd prefer having new line 
*before* t3lib_spritemanager_spriteicongenerator according to 
alphanumeric sorting

- There's a t3lib_div::debug() left in your patch (see below)

- In patch file:
	- Nitpicking: we normally have an upper case letter to start comments 
(methods or variables)
	- In phpDoc for methods, an empty line is systematically missing 
between description and @param/@return lines
	- line 56: delete this empty line
	- line 249: missing "@return $this". BTW, this is not the best naming 
in all your methods, I'd like to have same naming as Extbase did:

* @return Tx_Extbase_MVC_View_ViewInterface an instance of $this, to 
enable chaining.

	- line 256: "folder name", not "foldername"
	- line 265: add space after //
	- line 275: missing method description
	- line 283: here is the t3lib_div::debug()
	- line 312: missing space before parenthese in "if(..."
	- lines 457/458 and 460/461: keep only one empty line
	- line 464: use "TRUE" instead of "true"
	- line 470: "elseif" instead of "else if"
	- line 471: "if("
	- line 475: use "FALSE" instead of "false"
	- line 493: "getFiles traverses..." but you are commenting method 
"getFolder". What does mean "getFolder"?
	- line 494: non-terminated comment
	- line 506: use "!=="
	- line 527: "Generates file information cache from file array"
	- line 539: non-aligned =>
	- line 556: "image size" not "imagesize"

- first icon of last row of icons in the generated sprite does not have 
a transparent background, this is not related to your patch but should 
be fixed anyway.

- Could you generate some notice when files could not be written? I had 
no write access at beginning but did not get any error.

Question: as I did not keep track of all discussions regarding sprites, 
what is your spritegenerator in regards to interface 
t3lib_spritemanager_SpriteIconGenerator and the already existing 
"fall-back" for spritemanager which is in Core (other class from you).

Question 2: does the native t3lib_iconworks (or something like that) 
work with the generated patch? I guess so but documentation will be 
welcomed. Will you consider getting in touch with Tolleiv to enhance his 
already great article who describes the sprite system to enhance it with 
this generator?

_+1 by reading after those changes_


Thanks Steffen for this really great work!

Xavier


More information about the TYPO3-team-core mailing list