Feature #24090 ยป tslib_gifbuilder_stdWrap_optimized.diff
typo3/sysext/cms/tslib/class.tslib_gifbuilder.php (revision ) | ||
---|---|---|
if (is_array($conf)) {
|
||
$this->setup = $conf;
|
||
$this->data = $data;
|
||
$this->cObj =t3lib_div::makeInstance('tslib_cObj');
|
||
$this->cObj->start($this->data);
|
||
|
||
|
||
/* Hook preprocess gifbuilder conf
|
||
... | ... | |
|
||
// Setting the background color, passing it through stdWrap
|
||
if ($conf['backColor.'] || $conf['backColor']) {
|
||
$cObj =t3lib_div::makeInstance('tslib_cObj');
|
||
$cObj->start($this->data);
|
||
$this->setup['backColor'] = trim($cObj->stdWrap($this->setup['backColor'], $this->setup['backColor.']));
|
||
$this->setup['backColor'] = isset($this->setup['backColor.'])
|
||
? trim($this->cObj->stdWrap($this->setup['backColor'], $this->setup['backColor.']))
|
||
: $this->setup['backColor'];
|
||
}
|
||
if (!$this->setup['backColor']) { $this->setup['backColor']='white'; }
|
||
|
||
if ($conf['transparentColor.'] || $conf['transparentColor']) {
|
||
$cObj =t3lib_div::makeInstance('tslib_cObj');
|
||
$cObj->start($this->data);
|
||
$this->setup['transparentColor_array'] = explode('|', trim($cObj->stdWrap($this->setup['transparentColor'], $this->setup['transparentColor.'])));
|
||
$this->setup['transparentColor_array'] = isset($this->setup['transparentColor.'])
|
||
? explode('|', trim($this->cObj->stdWrap($this->setup['transparentColor'], $this->setup['transparentColor.'])))
|
||
: explode('|', trim($this->setup['transparentColor']));
|
||
}
|
||
|
||
// Transparency does not properly work when, GIFs or 8-bit PNGs are generated or reduceColors is set -- disable truecolor flag so they get generated "natively" in 8-bit.
|
||
// not working with reduceColors and truecolor images
|
||
if (($this->setup['transparentBackground'] || is_array($this->setup['transparentColor_array'])) && ($this->gifExtension=='gif' || !$this->png_truecolor || isset($this->setup['reduceColors']))) {
|
||
if(isset($this->setup['transparentBackground.'])) {
|
||
$this->setup['transparentBackground'] = $this->cOjb->stdWrap($this->setup['transparentBackground'], $this->setup['transparentBackground.']);
|
||
}
|
||
if(isset($this->setup['reduceColors.'])) {
|
||
$this->setup['reduceColors'] = $this->cOjb->stdWrap($this->setup['reduceColors'], $this->setup['reduceColors.']);
|
||
}
|
||
if (($this->setup['transparentBackground'] || is_array($this->setup['transparentColor_array'])) && ($this->gifExtension=='gif' || !$this->png_truecolor || $this->setup['reduceColors'])) {
|
||
$this->truecolor = false;
|
||
}
|
||
|
||
// Set default dimensions
|
||
if (isset($this->setup['XY.'])) {
|
||
$this->setup['XY'] = $this->cObj->stdWrap($this->setup['XY'], $this->setup['XY.']);
|
||
}
|
||
if (!$this->setup['XY']) {$this->setup['XY']='120,50';}
|
||
|
||
|
||
... | ... | |
if ($this->setup[$theKey.'.'] = $this->checkTextObj($conf)) {
|
||
|
||
// Adjust font width if max size is set:
|
||
if ($this->setup[$theKey.'.']['maxWidth']) {
|
||
$maxWidth = isset($this->setup[$theKey.'.']['maxWidth.'])
|
||
? $this->cObj->stdWrap($this->setup[$theKey.'.']['maxWidth'], $this->setup[$theKey.'.']['maxWidth.'])
|
||
: $this->setup[$theKey.'.']['maxWidth'];
|
||
if ($maxWidth) {
|
||
$this->setup[$theKey.'.']['fontSize'] = $this->fontResize($this->setup[$theKey.'.']); //RTF - this has to be done before calcBBox
|
||
}
|
||
|
||
... | ... | |
|
||
// Calculate offsets on elements
|
||
$this->setup['XY'] = $this->calcOffset($this->setup['XY']);
|
||
|
||
if(isset($this->setup['offset.'])) {
|
||
$this->setup['offset'] = $this->cObj->stdWrap($this->setup['offset'], $this->setup['offset.']);
|
||
}
|
||
$this->setup['offset'] = $this->calcOffset($this->setup['offset']);
|
||
|
||
if(isset($this->setup['workArea.'])) {
|
||
$this->setup['workArea'] = $this->cObj->stdWrap($this->setup['workArea'], $this->setup['workArea.']);
|
||
}
|
||
$this->setup['workArea'] = $this->calcOffset($this->setup['workArea']);
|
||
|
||
foreach ($sKeyArray as $theKey) {
|
||
... | ... | |
switch($theValue) {
|
||
case 'TEXT':
|
||
case 'IMAGE':
|
||
if(isset($this->setup[$theKey.'.']['offset.'])) {
|
||
$this->setup[$theKey.'.']['offset'] = $this->cObj->stdWrap($this->setup[$theKey.'.']['offset'], $this->setup[$theKey.'.']['offset.']);
|
||
}
|
||
if ($this->setup[$theKey.'.']['offset']) {
|
||
$this->setup[$theKey.'.']['offset'] = $this->calcOffset($this->setup[$theKey.'.']['offset']);
|
||
}
|
||
break;
|
||
case 'BOX':
|
||
case 'ELLIPSE':
|
||
if(isset($this->setup[$theKey.'.']['dimensions.'])) {
|
||
$this->setup[$theKey.'.']['dimensions'] = $this->cObj->stdWrap($this->setup[$theKey.'.']['dimensions'], $this->setup[$theKey.'.']['dimensions.']);
|
||
}
|
||
if ($this->setup[$theKey.'.']['dimensions']) {
|
||
$this->setup[$theKey.'.']['dimensions'] = $this->calcOffset($this->setup[$theKey.'.']['dimensions']);
|
||
}
|
||
break;
|
||
case 'WORKAREA':
|
||
if(isset($this->setup[$theKey.'.']['set.'])) {
|
||
$this->setup[$theKey.'.']['set'] = $this->cObj->stdWrap($this->setup[$theKey.'.']['set'], $this->setup[$theKey.'.']['set.']);
|
||
}
|
||
if ($this->setup[$theKey.'.']['set']) {
|
||
$this->setup[$theKey.'.']['set'] = $this->calcOffset($this->setup[$theKey.'.']['set']);
|
||
}
|
||
break;
|
||
case 'CROP':
|
||
if(isset($this->setup[$theKey.'.']['crop.'])) {
|
||
$this->setup[$theKey.'.']['crop'] = $this->cObj->stdWrap($this->setup[$theKey.'.']['crop'], $this->setup[$theKey.'.']['crop.']);
|
||
}
|
||
if ($this->setup[$theKey.'.']['crop']) {
|
||
$this->setup[$theKey.'.']['crop'] = $this->calcOffset($this->setup[$theKey.'.']['crop']);
|
||
}
|
||
break;
|
||
case 'SCALE':
|
||
if(isset($this->setup[$theKey.'.']['width.'])) {
|
||
$this->setup[$theKey.'.']['width'] = $this->cObj->stdWrap($this->setup[$theKey.'.']['width'], $this->setup[$theKey.'.']['width.']);
|
||
}
|
||
if ($this->setup[$theKey.'.']['width']) {
|
||
$this->setup[$theKey.'.']['width'] = $this->calcOffset($this->setup[$theKey.'.']['width']);
|
||
}
|
||
if(isset($this->setup[$theKey.'.']['height.'])) {
|
||
$this->setup[$theKey.'.']['height'] = $this->cObj->stdWrap($this->setup[$theKey.'.']['height'], $this->setup[$theKey.'.']['height.']);
|
||
}
|
||
if ($this->setup[$theKey.'.']['height']) {
|
||
$this->setup[$theKey.'.']['height'] = $this->calcOffset($this->setup[$theKey.'.']['height']);
|
||
}
|
||
break;
|
||
case 'ELLIPSE':
|
||
if ($this->setup[$theKey . '.']['dimensions']) {
|
||
$this->setup[$theKey . '.']['dimensions'] = $this->calcOffset($this->setup[$theKey . '.']['dimensions']);
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// Get trivial data
|
||
$XY = t3lib_div::intExplode(',',$this->setup['XY']);
|
||
$maxWidth = intval($this->setup['maxWidth']);
|
||
$maxHeight = intval($this->setup['maxHeight']);
|
||
$maxWidth = isset($this->setup['maxWidth.'])
|
||
? intval($this->cObj->stdWrap($this->setup['maxWidth'], $this->setup['maxWidth.']))
|
||
: intval($this->setup['maxWidth']);
|
||
$maxHeight = isset($this->setup['maxHeight.'])
|
||
? intval($this->cObj->stdWrap($this->setup['maxHeight'], $this->setup['maxHeight.']))
|
||
: intval($this->setup['maxHeight']);
|
||
|
||
$XY[0] = t3lib_div::intInRange($XY[0],1, $maxWidth?$maxWidth:2000);
|
||
$XY[1] = t3lib_div::intInRange($XY[1],1, $maxHeight?$maxHeight:2000);
|
||
... | ... | |
$theValue=$this->setup[$theKey];
|
||
|
||
if (intval($theKey) && $conf=$this->setup[$theKey.'.']) {
|
||
$isStdWrapped = array();
|
||
foreach($conf as $key => $value) {
|
||
$parameter = rtrim($key,'.');
|
||
if(!$isStdWrapped[$parameter] && isset($conf[$parameter.'.'])) {
|
||
$conf[$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter.'.']);
|
||
$isStdWrapped[$parameter] = 1;
|
||
}
|
||
}
|
||
switch($theValue) {
|
||
// Images
|
||
case 'IMAGE':
|
||
... | ... | |
case 'TEXT':
|
||
if (!$conf['hide']) {
|
||
if (is_array($conf['shadow.'])) {
|
||
$isStdWrapped = array();
|
||
foreach($conf['shadow.'] as $key => $value) {
|
||
$parameter = rtrim($key,'.');
|
||
if(!$isStdWrapped[$parameter] && isset($conf[$parameter.'.'])) {
|
||
$conf['shadow.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter.'.']);
|
||
$isStdWrapped[$parameter] = 1;
|
||
}
|
||
}
|
||
$this->makeShadow($this->im,$conf['shadow.'],$this->workArea,$conf);
|
||
}
|
||
if (is_array($conf['emboss.'])) {
|
||
$isStdWrapped = array();
|
||
foreach($conf['emboss.'] as $key => $value) {
|
||
$parameter = rtrim($key,'.');
|
||
if(!$isStdWrapped[$parameter] && isset($conf[$parameter.'.'])) {
|
||
$conf['emboss.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter.'.']);
|
||
$isStdWrapped[$parameter] = 1;
|
||
}
|
||
}
|
||
$this->makeEmboss($this->im,$conf['emboss.'],$this->workArea,$conf);
|
||
}
|
||
if (is_array($conf['outline.'])) {
|
||
$isStdWrapped = array();
|
||
foreach($conf['outline.'] as $key => $value) {
|
||
$parameter = rtrim($key,'.');
|
||
if(!$isStdWrapped[$parameter] && isset($conf[$parameter.'.'])) {
|
||
$conf['outline.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter.'.']);
|
||
$isStdWrapped[$parameter] = 1;
|
||
}
|
||
}
|
||
$this->makeOutline($this->im,$conf['outline.'],$this->workArea,$conf);
|
||
}
|
||
$conf['imgMap']=1;
|
||
... | ... | |
case 'ELLIPSE':
|
||
$this->makeEllipse($this->im, $conf, $this->workArea);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
* @access private
|
||
*/
|
||
function checkTextObj($conf) {
|
||
$isStdWrapped = array();
|
||
foreach($conf as $key => $value) {
|
||
$parameter = rtrim($key,'.');
|
||
if(!$isStdWrapped[$parameter] && isset($conf[$parameter.'.'])) {
|
||
$conf[$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter.'.']);
|
||
$isStdWrapped[$parameter] = 1;
|
||
}
|
||
}
|
||
$conf['fontFile']=$this->checkFile($conf['fontFile']);
|
||
if (!$conf['fontFile']){$conf['fontFile']='t3lib/fonts/nimbus.ttf';}
|
||
if (!$conf['iterations']){$conf['iterations'] = 1;}
|
||
... | ... | |
$cObj =t3lib_div::makeInstance('tslib_cObj');
|
||
$cObj->start($this->data);
|
||
|
||
$conf['fontColor'] = trim($cObj->stdWrap($conf['fontColor'], $conf['fontColor.']));
|
||
$conf['text']=$cObj->stdWrap($conf['text'],$conf['text.']);
|
||
$conf['fontColor'] = trim($conf['fontColor']);
|
||
// Strip HTML
|
||
if (!$conf['doNotStripHTML']) {
|
||
$conf['text'] = strip_tags($conf['text']);
|