127 if (is_array($conf)) {
128 $this->setup = $conf;
131 $this->cObj->start($this->data);
138 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_gifbuilder.php'][
'gifbuilder-ConfPreProcess'])) {
139 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'tslib/class.tslib_gifbuilder.php'][
'gifbuilder-ConfPreProcess'] as $_funcRef) {
145 $this->charRangeMap = array();
146 if (is_array(
$GLOBALS[
'TSFE']->tmpl->setup[
'_GIFBUILDER.'][
'charRangeMap.'])) {
147 foreach (
$GLOBALS[
'TSFE']->tmpl->setup[
'_GIFBUILDER.'][
'charRangeMap.'] as $cRMcfgkey => $cRMcfg) {
148 if (is_array($cRMcfg)) {
150 $cRMkey =
$GLOBALS[
'TSFE']->tmpl->setup[
'_GIFBUILDER.'][
'charRangeMap.'][substr($cRMcfgkey, 0, -1)];
151 $this->charRangeMap[$cRMkey] = array();
152 $this->charRangeMap[$cRMkey][
'charMapConfig'] = $cRMcfg[
'charMapConfig.'];
153 $this->charRangeMap[$cRMkey][
'cfgKey'] = substr($cRMcfgkey, 0, -1);
154 $this->charRangeMap[$cRMkey][
'multiplicator'] = (double) $cRMcfg[
'fontSizeMultiplicator'];
155 $this->charRangeMap[$cRMkey][
'pixelSpace'] = (int)$cRMcfg[
'pixelSpaceFontSizeRef'];
162 if ($conf[
'backColor.'] || $conf[
'backColor']) {
163 $this->setup[
'backColor'] = isset($this->setup[
'backColor.']) ? trim($this->cObj->stdWrap($this->setup[
'backColor'], $this->setup[
'backColor.'])) : $this->setup[
'backColor'];
165 if (!$this->setup[
'backColor']) {
166 $this->setup[
'backColor'] =
'white';
168 if ($conf[
'transparentColor.'] || $conf[
'transparentColor']) {
169 $this->setup[
'transparentColor_array'] = isset($this->setup[
'transparentColor.']) ? explode(
'|', trim($this->cObj->stdWrap($this->setup[
'transparentColor'], $this->setup[
'transparentColor.']))) : explode(
'|', trim($this->setup[
'transparentColor']));
171 if (isset($this->setup[
'transparentBackground.'])) {
172 $this->setup[
'transparentBackground'] = $this->cObj->stdWrap($this->setup[
'transparentBackground'], $this->setup[
'transparentBackground.']);
174 if (isset($this->setup[
'reduceColors.'])) {
175 $this->setup[
'reduceColors'] = $this->cObj->stdWrap($this->setup[
'reduceColors'], $this->setup[
'reduceColors.']);
178 if (isset($this->setup[
'XY.'])) {
179 $this->setup[
'XY'] = $this->cObj->stdWrap($this->setup[
'XY'], $this->setup[
'XY.']);
181 if (!$this->setup[
'XY']) {
182 $this->setup[
'XY'] =
'120,50';
186 foreach ($sKeyArray as $theKey) {
187 $theValue = $this->setup[$theKey];
188 if ((
int)$theKey && ($conf = $this->setup[$theKey .
'.'])) {
192 if ($this->setup[$theKey .
'.'] = $this->
checkTextObj($conf)) {
194 $maxWidth = isset($this->setup[$theKey .
'.'][
'maxWidth.']) ? $this->cObj->stdWrap($this->setup[$theKey .
'.'][
'maxWidth'], $this->setup[$theKey .
'.'][
'maxWidth.']) : $this->setup[$theKey .
'.'][
'maxWidth'];
196 $this->setup[$theKey .
'.'][
'fontSize'] = $this->
fontResize($this->setup[$theKey .
'.']);
199 $txtInfo = $this->
calcBBox($this->setup[$theKey .
'.']);
200 $this->setup[$theKey .
'.'][
'BBOX'] = $txtInfo;
201 $this->objBB[$theKey] = $txtInfo;
202 $this->setup[$theKey .
'.'][
'imgMap'] = 0;
206 $fileInfo = $this->getResource($conf[
'file'], $conf[
'file.']);
208 $this->combinedFileNames[] = preg_replace(
'/\\.[[:alnum:]]+$/',
'', basename($fileInfo[3]));
209 if ($fileInfo[
'processedFile'] instanceof \
TYPO3\CMS\Core\Resource\ProcessedFile) {
211 $this->setup[$theKey .
'.'][
'file'] = $fileInfo[
'processedFile']->getForLocalProcessing(FALSE);
212 } elseif (!isset($fileInfo[
'origFile']) && $fileInfo[
'originalFile'] instanceof \
TYPO3\CMS\Core\Resource\File) {
214 $this->setup[$theKey .
'.'][
'file'] = $fileInfo[
'originalFile']->getForLocalProcessing(FALSE);
217 $this->setup[$theKey .
'.'][
'file'] = $fileInfo[3];
219 $this->setup[$theKey .
'.'][
'BBOX'] = $fileInfo;
220 $this->objBB[$theKey] = $fileInfo;
222 $maskInfo = $this->getResource($conf[
'mask'], $conf[
'mask.']);
225 if ($maskInfo[
'processedFile'] instanceof \
TYPO3\CMS\Core\Resource\ProcessedFile) {
226 $this->setup[$theKey .
'.'][
'mask'] = $maskInfo[
'processedFile']->getForLocalProcessing(FALSE);
227 } elseif (!isset($maskInfo[
'origFile']) && $maskInfo[
'originalFile'] instanceof \
TYPO3\CMS\Core\Resource\File) {
228 $this->setup[$theKey .
'.'][
'mask'] = $maskInfo[
'originalFile']->getForLocalProcessing(FALSE);
230 $this->setup[$theKey .
'.'][
'mask'] = $maskInfo[3];
233 $this->setup[$theKey .
'.'][
'mask'] =
'';
237 unset($this->setup[$theKey .
'.']);
244 $cObj->start($this->data);
245 if (!$cObj->checkIf($conf[
'if.'])) {
246 unset($this->setup[$theKey]);
247 unset($this->setup[$theKey .
'.']);
248 unset($this->objBB[$theKey]);
254 $this->setup[
'XY'] = $this->
calcOffset($this->setup[
'XY']);
255 if (isset($this->setup[
'offset.'])) {
256 $this->setup[
'offset'] = $this->cObj->stdWrap($this->setup[
'offset'], $this->setup[
'offset.']);
258 $this->setup[
'offset'] = $this->
calcOffset($this->setup[
'offset']);
259 if (isset($this->setup[
'workArea.'])) {
260 $this->setup[
'workArea'] = $this->cObj->stdWrap($this->setup[
'workArea'], $this->setup[
'workArea.']);
262 $this->setup[
'workArea'] = $this->
calcOffset($this->setup[
'workArea']);
263 foreach ($sKeyArray as $theKey) {
264 $theValue = $this->setup[$theKey];
265 if ((
int)$theKey && ($conf = $this->setup[$theKey .
'.'])) {
270 if (isset($this->setup[$theKey .
'.'][
'offset.'])) {
271 $this->setup[$theKey .
'.'][
'offset'] = $this->cObj->stdWrap($this->setup[$theKey .
'.'][
'offset'], $this->setup[$theKey .
'.'][
'offset.']);
272 unset($this->setup[$theKey .
'.'][
'offset.']);
274 if ($this->setup[$theKey .
'.'][
'offset']) {
275 $this->setup[$theKey .
'.'][
'offset'] = $this->
calcOffset($this->setup[$theKey .
'.'][
'offset']);
281 if (isset($this->setup[$theKey .
'.'][
'dimensions.'])) {
282 $this->setup[$theKey .
'.'][
'dimensions'] = $this->cObj->stdWrap($this->setup[$theKey .
'.'][
'dimensions'], $this->setup[$theKey .
'.'][
'dimensions.']);
283 unset($this->setup[$theKey .
'.'][
'dimensions.']);
285 if ($this->setup[$theKey .
'.'][
'dimensions']) {
286 $this->setup[$theKey .
'.'][
'dimensions'] = $this->
calcOffset($this->setup[$theKey .
'.'][
'dimensions']);
290 if (isset($this->setup[$theKey .
'.'][
'set.'])) {
291 $this->setup[$theKey .
'.'][
'set'] = $this->cObj->stdWrap($this->setup[$theKey .
'.'][
'set'], $this->setup[$theKey .
'.'][
'set.']);
292 unset($this->setup[$theKey .
'.'][
'set.']);
294 if ($this->setup[$theKey .
'.'][
'set']) {
295 $this->setup[$theKey .
'.'][
'set'] = $this->
calcOffset($this->setup[$theKey .
'.'][
'set']);
299 if (isset($this->setup[$theKey .
'.'][
'crop.'])) {
300 $this->setup[$theKey .
'.'][
'crop'] = $this->cObj->stdWrap($this->setup[$theKey .
'.'][
'crop'], $this->setup[$theKey .
'.'][
'crop.']);
301 unset($this->setup[$theKey .
'.'][
'crop.']);
303 if ($this->setup[$theKey .
'.'][
'crop']) {
304 $this->setup[$theKey .
'.'][
'crop'] = $this->
calcOffset($this->setup[$theKey .
'.'][
'crop']);
308 if (isset($this->setup[$theKey .
'.'][
'width.'])) {
309 $this->setup[$theKey .
'.'][
'width'] = $this->cObj->stdWrap($this->setup[$theKey .
'.'][
'width'], $this->setup[$theKey .
'.'][
'width.']);
310 unset($this->setup[$theKey .
'.'][
'width.']);
312 if ($this->setup[$theKey .
'.'][
'width']) {
313 $this->setup[$theKey .
'.'][
'width'] = $this->
calcOffset($this->setup[$theKey .
'.'][
'width']);
315 if (isset($this->setup[$theKey .
'.'][
'height.'])) {
316 $this->setup[$theKey .
'.'][
'height'] = $this->cObj->stdWrap($this->setup[$theKey .
'.'][
'height'], $this->setup[$theKey .
'.'][
'height.']);
317 unset($this->setup[$theKey .
'.'][
'height.']);
319 if ($this->setup[$theKey .
'.'][
'height']) {
320 $this->setup[$theKey .
'.'][
'height'] = $this->
calcOffset($this->setup[$theKey .
'.'][
'height']);
328 $maxWidth = isset($this->setup[
'maxWidth.']) ? (int)$this->cObj->stdWrap($this->setup[
'maxWidth'], $this->setup[
'maxWidth.']) : (int)$this->setup[
'maxWidth'];
329 $maxHeight = isset($this->setup[
'maxHeight.']) ? (int)$this->cObj->stdWrap($this->setup[
'maxHeight'], $this->setup[
'maxHeight.']) : (int)$this->setup[
'maxHeight'];
355 $gifFileName = $this->fileName(
'GB/');
357 if (!file_exists($gifFileName)) {
362 $this->
output($gifFileName);
384 $this->saveAlphaLayer = FALSE;
386 $this->im = imagecreatetruecolor($XY[0], $XY[1]);
390 if (!empty($this->setup[
'backColor']) && $this->setup[
'backColor'] ===
'transparent' && $this->png_truecolor && !$this->setup[
'reduceColors'] && (empty($this->setup[
'format']) || $this->setup[
'format'] ===
'png')) {
392 imagesavealpha($this->im, TRUE);
394 $transparentColor = imagecolorallocatealpha($this->im, 0, 0, 0, 127);
395 imagefill($this->im, 0, 0, $transparentColor);
397 $this->saveAlphaLayer = TRUE;
399 $this->setup[
'format'] =
'png';
402 $BGcols = $this->
convertColor($this->setup[
'backColor']);
403 $Bcolor = ImageColorAllocate($this->im, $BGcols[0], $BGcols[1], $BGcols[2]);
404 ImageFilledRectangle($this->im, 0, 0, $XY[0], $XY[1], $Bcolor);
407 if (is_array($this->setup)) {
409 foreach ($sKeyArray as $theKey) {
410 $theValue = $this->setup[$theKey];
411 if ((
int)$theKey && ($conf = $this->setup[$theKey .
'.'])) {
415 if ($theValue !==
'TEXT') {
416 $isStdWrapped = array();
417 foreach ($conf as $key => $value) {
418 $parameter = rtrim($key,
'.');
419 if (!$isStdWrapped[$parameter] && isset($conf[$parameter .
'.'])) {
420 $conf[$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter .
'.']);
421 $isStdWrapped[$parameter] = 1;
435 if (!$conf[
'hide']) {
436 if (is_array($conf[
'shadow.'])) {
437 $isStdWrapped = array();
438 foreach ($conf[
'shadow.'] as $key => $value) {
439 $parameter = rtrim($key,
'.');
440 if (!$isStdWrapped[$parameter] && isset($conf[$parameter .
'.'])) {
441 $conf[
'shadow.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter .
'.']);
442 $isStdWrapped[$parameter] = 1;
445 $this->
makeShadow($this->im, $conf[
'shadow.'], $this->workArea, $conf);
447 if (is_array($conf[
'emboss.'])) {
448 $isStdWrapped = array();
449 foreach ($conf[
'emboss.'] as $key => $value) {
450 $parameter = rtrim($key,
'.');
451 if (!$isStdWrapped[$parameter] && isset($conf[$parameter .
'.'])) {
452 $conf[
'emboss.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter .
'.']);
453 $isStdWrapped[$parameter] = 1;
456 $this->
makeEmboss($this->im, $conf[
'emboss.'], $this->workArea, $conf);
458 if (is_array($conf[
'outline.'])) {
459 $isStdWrapped = array();
460 foreach ($conf[
'outline.'] as $key => $value) {
461 $parameter = rtrim($key,
'.');
462 if (!$isStdWrapped[$parameter] && isset($conf[$parameter .
'.'])) {
463 $conf[
'outline.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter .
'.']);
464 $isStdWrapped[$parameter] = 1;
467 $this->
makeOutline($this->im, $conf[
'outline.'], $this->workArea, $conf);
470 $this->
makeText($this->im, $conf, $this->workArea);
474 if ($this->setup[$conf[
'textObjNum']] ==
'TEXT' && ($txtConf = $this->
checkTextObj($this->setup[$conf[
'textObjNum'] .
'.']))) {
475 $this->
makeOutline($this->im, $conf, $this->workArea, $txtConf);
479 if ($this->setup[$conf[
'textObjNum']] ==
'TEXT' && ($txtConf = $this->
checkTextObj($this->setup[$conf[
'textObjNum'] .
'.']))) {
480 $this->
makeEmboss($this->im, $conf, $this->workArea, $txtConf);
484 if ($this->setup[$conf[
'textObjNum']] ==
'TEXT' && ($txtConf = $this->
checkTextObj($this->setup[$conf[
'textObjNum'] .
'.']))) {
485 $this->
makeShadow($this->im, $conf, $this->workArea, $txtConf);
489 $this->
makeBox($this->im, $conf, $this->workArea);
495 $this->
adjust($this->im, $conf);
498 $this->
crop($this->im, $conf);
501 $this->
scale($this->im, $conf);
508 if (isset($conf[
'clear'])) {
510 $this->workArea = $this->defaultWorkArea;
514 $this->
makeEllipse($this->im, $conf, $this->workArea);
521 if (!$this->saveAlphaLayer) {
522 if ($this->setup[
'transparentBackground']) {
524 $Bcolor = ImageColorClosest($this->im, $BGcols[0], $BGcols[1], $BGcols[2]);
525 imagecolortransparent($this->im, $Bcolor);
526 } elseif (is_array($this->setup[
'transparentColor_array'])) {
530 $Tcolor = $this->
unifyColors($this->im, $this->setup[
'transparentColor_array'], (
int)$this->setup[
'transparentColor.'][
'closest']);
532 imagecolortransparent($this->im, $Tcolor);
557 $cObj->start($this->data);
558 $isStdWrapped = array();
559 foreach ($conf as $key => $value) {
560 $parameter = rtrim($key,
'.');
561 if (!$isStdWrapped[$parameter] && isset($conf[$parameter .
'.'])) {
562 $conf[$parameter] = $cObj->stdWrap($conf[$parameter], $conf[$parameter .
'.']);
563 $isStdWrapped[$parameter] = 1;
566 $conf[
'fontFile'] = $this->
checkFile($conf[
'fontFile']);
567 if (!$conf[
'fontFile']) {
568 $conf[
'fontFile'] =
'typo3/sysext/core/Resources/Private/Font/nimbus.ttf';
570 if (!$conf[
'iterations']) {
571 $conf[
'iterations'] = 1;
573 if (!$conf[
'fontSize']) {
574 $conf[
'fontSize'] = 12;
577 if ($conf[
'spacing'] || $conf[
'wordSpacing']) {
580 if (!isset($conf[
'antiAlias'])) {
581 $conf[
'antiAlias'] = 1;
583 $conf[
'fontColor'] = trim($conf[
'fontColor']);
585 if (!$conf[
'doNotStripHTML']) {
586 $conf[
'text'] = strip_tags($conf[
'text']);
588 $this->combinedTextStrings[] = strip_tags($conf[
'text']);
590 if (!isset($conf[
'breakWidth']) || !$conf[
'breakWidth']) {
591 $tlen = (int)$conf[
'textMaxLength'] ?: 100;
592 if ($this->nativeCharset) {
593 $conf[
'text'] = $this->csConvObj->substr($this->nativeCharset, $conf[
'text'], 0, $tlen);
595 $conf[
'text'] = substr($conf[
'text'], 0, $tlen);
598 if ((
string) $conf[
'text'] !=
'') {
600 $fontBaseName = basename($conf[
'fontFile']);
601 if (is_array($this->charRangeMap[$fontBaseName])) {
603 if (!is_array($conf[
'splitRendering.'])) {
604 $conf[
'splitRendering.'] = array();
606 $cfgK = $this->charRangeMap[$fontBaseName][
'cfgKey'];
608 if (!isset($conf[
'splitRendering.'][$cfgK])) {
610 $conf[
'splitRendering.'][$cfgK] =
'charRange';
611 $conf[
'splitRendering.'][$cfgK .
'.'] = $this->charRangeMap[$fontBaseName][
'charMapConfig'];
613 if ($this->charRangeMap[$fontBaseName][
'multiplicator']) {
614 $conf[
'splitRendering.'][$cfgK .
'.'][
'fontSize'] = round($conf[
'fontSize'] * $this->charRangeMap[$fontBaseName][
'multiplicator']);
617 if ($this->charRangeMap[$fontBaseName][
'pixelSpace']) {
618 $travKeys = array(
'xSpaceBefore',
'xSpaceAfter',
'ySpaceBefore',
'ySpaceAfter');
619 foreach ($travKeys as $pxKey) {
620 if (isset($conf[
'splitRendering.'][$cfgK .
'.'][$pxKey])) {
621 $conf[
'splitRendering.'][$cfgK .
'.'][$pxKey] = round($conf[
'splitRendering.'][($cfgK .
'.')][$pxKey] * ($conf[
'fontSize'] / $this->charRangeMap[$fontBaseName][
'pixelSpace']));
627 if (is_array($conf[
'splitRendering.'])) {
628 foreach ($conf[
'splitRendering.'] as $key => $value) {
629 if (is_array($conf[
'splitRendering.'][$key])) {
630 if (isset($conf[
'splitRendering.'][$key][
'fontFile'])) {
631 $conf[
'splitRendering.'][$key][
'fontFile'] = $this->
checkFile($conf[
'splitRendering.'][$key][
'fontFile']);
655 foreach ($numbers as $key => $val) {
656 if ((
string)$val == (
string)(
int)$val) {
657 $value[$key] = (int)$val;
662 $string = implode(
',', $value);
676 public function getResource($file, $fileArray) {
682 $cObj->start($this->data);
683 return $cObj->getImgResource($file, $fileArray);
696 return $GLOBALS[
'TSFE']->tmpl->getFileName($file);
707 public function fileName($pre) {
708 $meaningfulPrefix =
'';
709 if (
$GLOBALS[
'TSFE']->config[
'config'][
'meaningfulTempFilePrefix']) {
712 $meaningfulPrefix = implode(
'_', array_merge($this->combinedTextStrings, $this->combinedFileNames));
713 $meaningfulPrefix = $basicFileFunctions->cleanFileName($meaningfulPrefix);
714 $meaningfulPrefixLength = (int)
$GLOBALS[
'TSFE']->config[
'config'][
'meaningfulTempFilePrefix'];
715 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'UTF8filesystem']) {
718 $meaningfulPrefix = $t3libCsInstance->substr(
'utf-8', $meaningfulPrefix, 0, $meaningfulPrefixLength);
720 $meaningfulPrefix = substr($meaningfulPrefix, 0, $meaningfulPrefixLength);
722 $meaningfulPrefix .=
'_';
739 switch (strtolower($this->setup[
'format'])) {
764 $calculatedValue = 0;
766 foreach ($parts as $part) {
769 if (((
string)(
int)$theVal) == ((
string)$theVal)) {
770 $theVal = (int)$theVal;
771 } elseif (
'[' . substr($theVal, 1, -1) .
']' == $theVal) {
772 $objParts = explode(
'.', substr($theVal, 1, -1));
774 if (isset($this->objBB[$objParts[0]])) {
775 if ($objParts[1] ==
'w') {
776 $theVal = $this->objBB[$objParts[0]][0];
777 } elseif ($objParts[1] ==
'h') {
778 $theVal = $this->objBB[$objParts[0]][1];
779 } elseif ($objParts[1] ==
'lineHeight') {
780 $theVal = $this->objBB[$objParts[0]][2][
'lineHeight'];
782 $theVal = (int)$theVal;
784 } elseif (floatval($theVal)) {
785 $theVal = floatval($theVal);
790 $calculatedValue -= $theVal;
791 } elseif ($sign ==
'+') {
792 $calculatedValue += $theVal;
793 } elseif ($sign ==
'/' && $theVal) {
794 $calculatedValue = $calculatedValue / $theVal;
795 } elseif ($sign ==
'*') {
796 $calculatedValue = $calculatedValue * $theVal;
797 } elseif ($sign ==
'%' && $theVal) {
798 $calculatedValue %= $theVal;
801 return round($calculatedValue);
812 if (preg_match_all(
'#max\\(([^)]+)\\)#', $string, $matches)) {
813 foreach ($matches[1] as $index => $maxExpression) {
814 $string = str_replace($matches[0][$index], $this->
calculateMaximum($maxExpression), $string);
828 $maximum = count($parts) ? max($parts) : 0;
makeText(&$im, $conf, $workArea)
makeEmboss(&$im, $conf, $workArea, $txtConf)
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
makeEllipse(&$im, array $conf, array $workArea)
static intExplode($delimiter, $string, $removeEmptyValues=FALSE, $limit=0)
copyImageOntoImage(&$im, $conf, $workArea)
static makeInstance($className)
static shortMD5($input, $len=10)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
static callUserFunction($funcName, &$params, &$ref, $checkPrefix='', $errorMode=0)
makeShadow(&$im, $conf, $workArea, $txtConf)
makeOutline(&$im, $conf, $workArea, $txtConf)
maskImageOntoImage(&$im, $conf, $workArea)
createTempSubDir($dirName)
static splitCalc($string, $operators)
calculateFunctions($string)
unifyColors(&$img, $colArr, $closest=FALSE)
makeBox(&$im, $conf, $workArea)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static inList($list, $item)
static sortedKeyList($setupArr, $acceptOnlyProperties=FALSE)
calculateMaximum($string)