33 .###NAMESPACE###-###SPRITENAME### { 34 background-image: url(\'###SPRITEURL###\') !important; 35 height: ###DEFAULTHEIGHT###px; 36 width: ###DEFAULTWIDTH###px; 46 .backgroundsize .###NAMESPACE###-###SPRITENAME### { 47 background-image: url(\'###SPRITEURL###\') !important; 48 background-size:###BGWIDTH### ###BGHEIGHT###; 57 background-position: -###LEFT###px -###TOP###px !important; 212 $this->spriteFolder = $folder;
223 $this->cssFolder = $folder;
234 $this->enableHighDensitySprite = $enable;
257 $this->omitSpriteNameInIconName = is_bool($value) ? $value : FALSE;
268 $this->space = (int)$value;
279 $this->includeTimestampInCSS = is_bool($value) ? $value : TRUE;
292 $iconArray = array();
293 foreach ($inputFolder as $folder) {
295 $iconArray = array_merge($iconArray, $this->
getFolder($folder));
309 if (!$this->omitSpriteNameInIconName) {
316 if ($this->enableHighDensitySprite) {
320 $iconNames = array_keys($this->iconsData);
323 'spriteImage' => PATH_site . $this->spriteFolder . $this->spriteName .
'.png',
324 'cssFile' => PATH_site . $this->cssFolder . $this->spriteName .
'.css',
325 'iconNames' => $iconNames
336 if ($this->includeTimestampInCSS) {
337 $timestamp =
'?' . time();
342 $markerArray = array(
343 '###NAMESPACE###' => $this->nameSpace,
344 '###DEFAULTWIDTH###' => $this->defaultWidth,
345 '###DEFAULTHEIGHT###' => $this->defaultHeight,
346 '###SPRITENAME###' =>
'',
347 '###SPRITEURL###' => $spritePathForCSS ? $spritePathForCSS .
'/' :
'' 349 $markerArray[
'###SPRITEURL###'] .= $this->spriteName .
'.png' . $timestamp;
350 foreach ($this->spriteBases as $base) {
351 $markerArray[
'###SPRITENAME###'] = $base;
354 if ($this->enableHighDensitySprite) {
355 $highDensityMarkerArray = array_merge($markerArray, array(
356 '###BGWIDTH###' => $this->spriteWidth .
'px',
357 '###BGHEIGHT###' => $this->spriteHeight .
'px',
358 '###SPRITEURL###' => str_replace(
359 $this->spriteName .
'.png',
360 $this->spriteName .
'@x2.png',
361 $markerArray[
'###SPRITEURL###']
368 foreach ($this->iconsData as $data) {
369 $temp = $data[
'iconNameParts'];
371 $cssName = implode(
'-', $temp);
372 $markerArrayIcons = array(
373 '###NAMESPACE###' => $this->nameSpace,
374 '###ICONNAME###' => $cssName,
375 '###LEFT###' => $data[
'left'],
376 '###TOP###' => $data[
'top'],
377 '###SIZE_INFO###' =>
'' 379 if ($data[
'height'] != $this->defaultHeight) {
380 $markerArrayIcons[
'###SIZE_INFO###'] .= TAB .
'height: ' . $data[
'height'] .
'px;' . LF;
382 if ($data[
'width'] != $this->defaultWidth) {
383 $markerArrayIcons[
'###SIZE_INFO###'] .= TAB .
'width: ' . $data[
'width'] .
'px;' . LF;
397 $this->cssFolder = str_replace(
'\\',
'/', $this->cssFolder);
398 $this->spriteFolder = str_replace(
'\\',
'/', $this->spriteFolder);
402 while (isset($cssPathSegments[$i]) && isset($graphicPathSegments[$i]) && $cssPathSegments[$i] == $graphicPathSegments[$i]) {
403 unset($cssPathSegments[$i]);
404 unset($graphicPathSegments[$i]);
407 foreach ($cssPathSegments as $key => $value) {
408 $cssPathSegments[$key] =
'..';
410 $completePath = array_merge($cssPathSegments, $graphicPathSegments);
411 $path = implode(
'/', $completePath);
422 $filePath = PATH_site . $this->spriteFolder . $this->spriteName .
'.png';
425 $newSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);
426 imagesavealpha($newSprite, TRUE);
428 imagefill($newSprite, 0, 0, imagecolorallocatealpha($newSprite, 0, 255, 255, 127));
429 foreach ($this->iconsData as $icon) {
430 $function =
'imagecreatefrom' . strtolower($icon[
'fileExtension']);
431 if (function_exists($function)) {
432 $currentIcon = $function($icon[
'fileName']);
433 imagecopy($newSprite, $currentIcon, $icon[
'left'], $icon[
'top'], 0, 0, $icon[
'width'], $icon[
'height']);
436 imagepng($newSprite, $tempSprite);
448 $filePath = PATH_site . $this->spriteFolder . $this->spriteName .
'@x2.png';
451 $newSprite = imagecreatetruecolor($this->spriteWidth * 2, $this->spriteHeight * 2);
452 imagesavealpha($newSprite, TRUE);
454 imagefill($newSprite, 0, 0, imagecolorallocatealpha($newSprite, 0, 255, 255, 127));
455 foreach ($this->iconsData as $icon) {
456 $function =
'imagecreatefrom' . strtolower($icon[
'fileExtension']);
457 if (function_exists($function)) {
458 if ($icon[
'fileNameHighDensity'] !== FALSE) {
460 $currentIcon = $function($icon[
'fileNameHighDensity']);
461 imagecopy($newSprite, $currentIcon, $icon[
'left'] * 2, $icon[
'top'] * 2, 0, 0, $icon[
'width'] * 2, $icon[
'height'] * 2);
464 $currentIcon = $function($icon[
'fileName']);
465 imagecopyresized($newSprite, $currentIcon, $icon[
'left'] * 2, $icon[
'top'] * 2, 0, 0, $icon[
'width'] * 2, $icon[
'height'] * 2, $icon[
'width'], $icon[
'height']);
469 imagepng($newSprite, $tempSprite);
480 foreach ($this->iconSizes as $sizeTag => $count) {
482 $rowWidth = (int)ceil(sqrt($count)) * $size[
'width'];
483 while (isset($sizes[$rowWidth])) {
486 $sizes[$rowWidth] = $sizeTag;
492 foreach ($sizes as $sizeTag) {
496 $rowSize = ceil(sqrt($this->iconSizes[$sizeTag]));
497 $rowWidth = $rowSize * $size[
'width'] + ($rowSize - 1) * $this->space;
500 natsort($this->iconNamesPerSize[$sizeTag]);
501 foreach ($this->iconNamesPerSize[$sizeTag] as $iconName) {
502 if ($rowCounter == $rowSize - 1) {
504 } elseif ($rowCounter == 0) {
506 $currentTop += $size[
'height'];
512 $this->iconsData[$iconName][
'left'] = $currentLeft;
513 $this->iconsData[$iconName][
'top'] = $currentTop;
514 $currentLeft += $size[
'width'];
518 $currentTop += $size[
'height'];
521 $this->spriteHeight = $currentTop;
533 if (!$this->omitSpriteNameInIconName) {
536 $resultArray = array();
537 foreach ($subFolders as $folder) {
538 if ($folder !==
'.svn') {
540 if (!in_array($folder, $this->spriteBases) && count(
$icons) && $folder !==
'') {
541 $this->spriteBases[] = $folder;
543 foreach (
$icons as $icon) {
544 $fileInfo = pathinfo($icon);
545 $iconName = ($folder ? $folder .
'-' :
'') . $fileInfo[
'filename'];
546 if (!$this->omitSpriteNameInIconName) {
547 $iconName = $this->spriteName .
'-' . $iconName;
549 $resultArray[$iconName] = $directoryPath . $folder .
'/' . $icon;
563 foreach ($files as $iconName => $iconFile) {
565 if (!in_array($iconNameParts[0], $this->spriteBases)) {
566 $this->spriteBases[] = $iconNameParts[0];
568 $fileInfo = @pathinfo((PATH_site . $iconFile));
569 $imageInfo = @getimagesize((PATH_site . $iconFile));
570 $this->iconsData[$iconName] = array(
571 'iconName' => $iconName,
572 'iconNameParts' => $iconNameParts,
573 'singleName' => $fileInfo[
'filename'],
574 'fileExtension' => $fileInfo[
'extension'],
575 'fileName' => PATH_site . $iconFile,
576 'width' => $imageInfo[0],
577 'height' => $imageInfo[1],
580 'fileNameHighDensity' => FALSE
582 if ($this->enableHighDensitySprite) {
583 $highDensityFile = str_replace(
'.' . $fileInfo[
'extension'],
'@x2.' . $fileInfo[
'extension'], $iconFile);
584 if (@file_exists(PATH_site . $highDensityFile)) {
585 $this->iconsData[$iconName][
'fileNameHighDensity'] = $highDensityFile;
588 $sizeTag = $imageInfo[0] .
'x' . $imageInfo[1];
589 if (isset($this->iconSizes[$sizeTag])) {
590 $this->iconSizes[$sizeTag] += 1;
592 $this->iconSizes[$sizeTag] = 1;
593 $this->iconNamesPerSize[$sizeTag] = array();
595 $this->iconNamesPerSize[$sizeTag][] = $iconName;
598 asort($this->iconSizes);
599 $defaultSize = $this->
explodeSizeTag(array_pop(array_keys($this->iconSizes)));
600 $this->defaultWidth = $defaultSize[
'width'];
601 $this->defaultHeight = $defaultSize[
'height'];
setOmitSpriteNameInIconName($value)
static unlink_tempfile($uploadedTempFileName)
static writeFile($file, $content, $changePermissions=FALSE)
buildFileInformationCache(array $files)
calculateSpritePositions()
static logDeprecatedFunction()
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
generateSpriteFromArray(array $files)
getFolder($directoryPath)
if(!defined('TYPO3_MODE')) if(TYPO3_MODE=='BE' &&!(TYPO3_REQUESTTYPE &TYPO3_REQUESTTYPE_INSTALL)) $icons
$omitSpriteNameInIconName
setIncludeTimestampInCSS($value)
setEnableHighDensitySprite($enable=TRUE)
setOmmitSpriteNameInIconName($value)
setSpriteName($spriteName)
static substituteMarkerArray($content, $markContentArray, $wrap='', $uppercase=FALSE, $deleteUnused=FALSE)
static tempnam($filePrefix, $fileSuffix='')
static getFilesInDir($path, $extensionList='', $prependPath=FALSE, $order='', $excludePattern='')
$templateSpriteHighDensity
static resolveBackPath($pathStr)
generateHighDensityGraphic()
generateSpriteFromFolder(array $inputFolder)
static upload_copy_move($source, $destination)