[TYPO3-core] RFC #13379: Sprite Icon API
Benjamin Mack
benni at typo3.org
Sat May 1 05:39:09 CEST 2010
Hey everybody,
Alrighty, here we go, another round of the sprite icon API. The patch is
very straightforward to review (in my eyes ;-)). Basically, I took the
functionality that was there from Thomas, and rewrote parts of them to
reflect the API idea that Sebastian and I agreed on.
What do we have in this package:
1) t3lib_iconWorks
First of all, there is the list of the mapping of the file types (all
file extensions and their corresponding spriteIcon name). Then you'll
find three "high-level" API functions, which can be used throughout the
TYPO3 core and return ready-to-use <span> tags:
t3lib_iconWorks::getSpriteIcon('actions-document-edit');
t3lib_iconWorks::getSpriteIconForFile('jpg');
t3lib_iconWorks::getSpriteIconForRecord('pages', $row);
The first method is generic, and is used for any icon in the TYPO3
Backend. You can overlay any kind and any number of spriteIcons through
the last optional parameter $overlays.
The second one is used to fetch any icon for a file type. The first
parameter supports any file extension, a file name or a folder, or
"folder". No support for overlays here.
The third call is to fetch the icon for the DB record. It automatically
checks if there is a type possible (like with "pages" the "doktype=3"
which would be a shortcut, and thus needs a different icon). Also, it
checks if the record has a special status (checked from the ctrl section
of the TCA), if so, it gets an overlay image. So you don't have to worry
about this anymore. We agreed on having only one overlay for the DB
record method (everything else ain't used right now).
These three calls build the base, we have helper functions to get the
mapping information for a filetype/recordtype/recordstatus which return
the ready-to-use CSS classes. One functions builds these things together
in a HTML element (span by default).
2) config_default.php
Here we set some default options and also the mapping of the
DB-record-overlays to the statuses.
There were some options before that I decided to remove, which were
basically the option to set the base css class ("t3-icon"), and some
other default values.
3) stddb/tables.php and EXT:cms/ext_tables.php
Here we set the types (typecolumn) and the mapping of the different
types to spriteIconNames. When calling getSpriteIconForRecord() it looks
up that exact data in the TCA ctrl section to fetch the right
spriteIconName.
4) t3skin preparations
Adopted to our new skinning API (thanks to Steffen Gebert) to also
include the EXT:t3skin/stylesheets/sprites/ folder.
That's it! I haven't tested all use-cases but in principle, this
approach seems to work. If you have any ideas and modifications, feel
free to update the patch directly.
What's next to test?
Well, that's all nice and everything, a few things are still missing:
1) All the icons
Get the zip file from the bugtracker, in order to test it, unzip them
and make sure that there are two new folders:
"EXT:t3skin/images/sprites" and "EXT:t3skin/stylesheets/sprites". These
files will be commited with this API patch.
2) Extensive use throughout the core
Thomas already has this patch spriteReplace.patch in the bugtracker. but
that one doesn't use the new API methods. I will prepare an update on
this one and send it to this thread. However, the inclusion of that part
will be a separate RFC. But it's nice to test this API with that patch.
3) Updated documentation
Totally needed, also for the "TYPO3 Core APIs" document; to reflect the
new file structure. If anyone is up for it, feel free to help out.
What's still open then after that?
* As mentioned before, we need to update the parts of the core where
it makes sense.
* Sprite generation. Something we gotta think of. Personally, I'd like
to have a function within a module to generate the sprites. Maybe a
modfunc in "extdeveval" that takes care of it.
* Missing icons? I had something in the back of my mind
* Testing, testing, testing...
And after that, we have a fast flying backend :-D
Thanks again to everybody involved!
All the best,
Benni.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sprite_api_renewed.patch
Type: text/x-patch
Size: 22432 bytes
Desc: not available
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100501/0a11a38f/attachment-0001.bin>
More information about the TYPO3-team-core
mailing list