Added feature #16430: Optimize stdWrap usage for TypoScript content element GIFBUILDE...
authorSusanne Moog <typo3@susannemoog.de>
Wed, 17 Nov 2010 14:22:30 +0000 (14:22 +0000)
committerSusanne Moog <typo3@susannemoog.de>
Wed, 17 Nov 2010 14:22:30 +0000 (14:22 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9456 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_gifbuilder.php

index f8235d8..b266339 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -40,6 +40,7 @@
        * Added feature #15916: Display a link to list module on sysfolders when in page module (Thanks to Georg Ringer)
        * Fixed bug #16107: listNum = 0 not working anymore due to stdWrap changes (Thanks to Jo Hasenau)
        * Added feature #16282: Optimize stdWrap usage for TypoScript content element IMAGE (Thanks to Jo Hasenau)
+       * Added feature #16430: Optimize stdWrap usage for TypoScript content element GIFBUILDER (Thanks to Jo Hasenau)
 
 2010-11-17  Oliver Hader  <oliver@typo3.org>
 
index 8ea129e..8b6fafa 100644 (file)
@@ -131,6 +131,8 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                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
@@ -170,25 +172,34 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
 
                                // 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';}
 
 
@@ -204,7 +215,10 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                                                        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
                                                                }
 
@@ -250,7 +264,15 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
 
                                // 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) {
@@ -260,45 +282,63 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                                        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);
@@ -367,8 +407,15 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                        $sKeyArray=t3lib_TStemplate::sortedKeyList($this->setup);
                        foreach($sKeyArray as $theKey)  {
                                $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':
@@ -383,12 +430,36 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                                                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;
@@ -440,7 +511,7 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                                                case 'ELLIPSE':
                                                        $this->makeEllipse($this->im, $conf, $this->workArea);
                                                break;
-                                       }
+                                       }                                       
                                }
                        }
                }
@@ -496,6 +567,14 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
         * @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;}
@@ -507,8 +586,7 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                $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']);
@@ -768,4 +846,4 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_gifbuilder.php']);
 }
 
-?>
\ No newline at end of file
+?>