TYPO3 API  SVNRelease
class.t3lib_spritemanager_spritebuildinghandler.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2010-2011 Steffen Ritter <info@steffen-ritter.net>
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *  A copy is found in the textfile GPL.txt and important notices to the license
00017  *  from the author is found in LICENSE.txt distributed with these scripts.
00018  *
00019  *
00020  *  This script is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  This copyright notice MUST APPEAR in all copies of the script!
00026  ***************************************************************/
00027 
00028 
00029 /**
00030  *
00031  * @author  Steffen Ritter <info@steffen-ritter.net>
00032  * @package TYPO3
00033  * @subpackage t3lib
00034  */
00035 class t3lib_spritemanager_SpriteBuildingHandler extends t3lib_spritemanager_AbstractHandler {
00036 
00037     /**
00038      * @var t3lib_spritemanager_SpriteGenerator
00039      */
00040     protected $generatorInstance = NULL;
00041 
00042     /**
00043      * Interface function. This will be called from the sprite manager to
00044      * refresh all caches.
00045      *
00046      * @return void
00047      */
00048     public function generate() {
00049         $this->generatorInstance = t3lib_div::makeInstance('t3lib_spritemanager_SpriteGenerator', 'GeneratorHandler');
00050         $this->generatorInstance
00051                 ->setOmmitSpriteNameInIconName(TRUE)
00052                 ->setIncludeTimestampInCSS(TRUE)
00053                 ->setSpriteFolder(t3lib_SpriteManager::$tempPath)
00054                 ->setCSSFolder(t3lib_SpriteManager::$tempPath);
00055 
00056         $iconsToProcess = array_merge(
00057             (array) $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons'],
00058             $this->collectTcaSpriteIcons()
00059         );
00060 
00061         foreach ($iconsToProcess as $iconName => $iconFile) {
00062             $iconsToProcess[$iconName] = t3lib_div::resolveBackPath('typo3/' . $iconFile);
00063         }
00064 
00065         $generatorResponse = $this->generatorInstance->generateSpriteFromArray($iconsToProcess);
00066 
00067         if (!is_dir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6')) {
00068             t3lib_div::mkdir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6');
00069         }
00070 
00071         t3lib_div::upload_copy_move(
00072             $generatorResponse['spriteGifImage'],
00073             t3lib_div::dirname($generatorResponse['spriteGifImage']) . '/ie6/' . basename($generatorResponse['spriteGifImage'])
00074         );
00075         unlink($generatorResponse['spriteGifImage']);
00076 
00077         t3lib_div::upload_copy_move(
00078             $generatorResponse['cssGif'],
00079             t3lib_div::dirname($generatorResponse['cssGif']) . '/ie6/' . basename($generatorResponse['cssGif'])
00080         );
00081         unlink($generatorResponse['cssGif']);
00082 
00083         $this->iconNames = array_merge($this->iconNames, $generatorResponse['iconNames']);
00084 
00085         parent::generate();
00086     }
00087 }
00088 
00089 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/spritemanager/class.t3lib_spritemanager_autogeneratinghandler.php'])) {
00090     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/spritemanager/class.t3lib_spritemanager_autogeneratinghandler.php']);
00091 }
00092 ?>