[CLEANUP] Add phpDoc to properties in ext:backend
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Sprite / SimpleSpriteHandler.php
1 <?php
2 namespace TYPO3\CMS\Backend\Sprite;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * A class with an concrete implementation of AbspractSpriteHandler.
19 * It is the standard / fallback handler of the sprite manager.
20 * This implementation won't generate sprites at all. It will just render css-definitions
21 * for all registered icons so that they may be used through
22 * \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon* Without the css classes
23 * generated here, icons of for example tca records would be empty.
24 *
25 * @author Steffen Ritter <info@steffen-ritter.net>
26 */
27 class SimpleSpriteHandler extends AbstractSpriteHandler {
28
29 /**
30 * css template for single Icons registered by extension authors
31 *
32 * @var string
33 */
34 protected $styleSheetTemplateExtIcons = '
35 .t3-icon-###NAME### {
36 background-position: 0px 0px !important;
37 background-image: url(\'###IMAGE###\') !important;
38 }
39 ';
40
41 /**
42 * Interface function. This will be called from the sprite manager to
43 * refresh all caches.
44 *
45 * @return void
46 */
47 public function generate() {
48 // Generate IconData for single Icons registered
49 $this->buildCssAndRegisterIcons();
50 parent::generate();
51 }
52
53 /**
54 * This function builds an css class for every single icon registered via
55 * \TYPO3\CMS\Backend\Utility\IconUtility::addSingleIcons to use them via
56 * \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon and TCA-Icons for
57 * "classic" record Icons to be uses via
58 * \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord
59 * In the simpleHandler the icon just will be added as css-background-image.
60 *
61 * @return void
62 */
63 protected function buildCssAndRegisterIcons() {
64 // Backpath from the stylesheet file ($cssTcaFile) to PATH_site dir
65 // in order to set the background-image URL paths correct
66 $iconPath = '../../' . TYPO3_mainDir;
67 $iconsToProcess = array_merge((array)$GLOBALS['TBE_STYLES']['spritemanager']['singleIcons'], $this->collectTcaSpriteIcons());
68 foreach ($iconsToProcess as $iconName => $iconFile) {
69 $css = str_replace('###NAME###', str_replace(array('extensions-', 'tcarecords-'), array('', ''), $iconName), $this->styleSheetTemplateExtIcons);
70 $css = str_replace('###IMAGE###', \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($iconPath . $iconFile), $css);
71 $this->iconNames[] = $iconName;
72 $this->styleSheetData .= $css;
73 }
74 }
75
76 }