[TASK] Rename and deprecate config.minifyJS / config.minifyCSS
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_gifbuilder.php
index 1c47f09..1c87d82 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * Generating gif/png-files from TypoScript
  * Used by the menu-objects and imgResource in TypoScript.
  *
- * $Id$
- * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
- *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- *  102: class tslib_gifBuilder extends t3lib_stdGraphic
- *  129:     function start($conf,$data)
- *  315:     function gifBuild()
- *  343:     function make()
- *
- *              SECTION: Various helper functions
- *  486:     function checkTextObj($conf)
- *  566:     function calcOffset($string)
- *  615:     function getResource($file,$fileArray)
- *  632:     function checkFile($file)
- *  643:     function fileName($pre)
- *  659:     function extension()
- *
- * TOTAL FUNCTIONS: 9
- * (This index is automatically created/updated by the extension "extdeveval")
+ * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
  *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 
 
  * }
  * return $gifCreator->getImageDimensions($theImage);
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage tslib
- * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=377&cHash=e00ac666f3
  */
 class tslib_gifBuilder extends t3lib_stdGraphic {
 
@@ -131,6 +107,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 +148,29 @@ 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'])))        {
-                               $this->truecolor = false;
-                       }
+                       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.']);
+                       }
 
                                // 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 +186,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 +235,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,29 +253,48 @@ 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']);
                                                        }
@@ -292,11 +304,15 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                        }
                                // Get trivial data
                        $XY = t3lib_div::intExplode(',',$this->setup['XY']);
-                       $maxWidth = intval($this->setup['maxWidth']);
-                       $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);
+                       $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_utility_Math::forceIntegerInRange($XY[0],1, $maxWidth?$maxWidth:2000);
+                       $XY[1] = t3lib_utility_Math::forceIntegerInRange($XY[1],1, $maxHeight?$maxHeight:2000);
                        $this->XY = $XY;
                        $this->w = $XY[0];
                        $this->h = $XY[1];
@@ -308,7 +324,7 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
        }
 
        /**
-        * Initiates the image file generation if ->setup is true and if the file did not exist already.
+        * Initiates the image file generation if ->setup is TRUE and if the file did not exist already.
         * Gets filename from fileName() and if file exists in typo3temp/ dir it will - of course - not be rendered again.
         * Otherwise rendering means calling ->make(), then ->output(), then ->destroy()
         *
@@ -341,29 +357,60 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
         * @return      void
         * @access private
         * @see gifBuild()
-        * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=378&cHash=3c2ae4a1ab
         */
        function make() {
                        // Get trivial data
                $XY = $this->XY;
 
+                       // Reset internal properties
+               $this->saveAlphaLayer = FALSE;
+
                        // Gif-start
-               $this->im = $this->imagecreate($XY[0],$XY[1]);
+               $this->im = imagecreatetruecolor($XY[0], $XY[1]);
                $this->w = $XY[0];
                $this->h = $XY[1];
 
-                       // backColor is set
-               $BGcols = $this->convertColor($this->setup['backColor']);
-               $Bcolor = ImageColorAllocate($this->im, $BGcols[0],$BGcols[1],$BGcols[2]);
-               ImageFilledRectangle($this->im, 0, 0, $XY[0], $XY[1], $Bcolor);
+                       // Transparent layer as background if set and requirements are met
+               if (!empty($this->setup['backColor'])
+                       && $this->setup['backColor'] === 'transparent'
+                       && $this->png_truecolor
+                       && !$this->setup['reduceColors']
+                       && (empty($this->setup['format']) || $this->setup['format'] === 'png')) {
+
+                               // Set transparency properties
+                       imagealphablending($this->im, FALSE);
+                       imagesavealpha($this->im, TRUE);
+
+                               // Fill with a transparent background
+                       $transparentColor = imagecolorallocatealpha($this->im, 0, 0, 0, 127);
+                       imagefill($this->im, 0, 0, $transparentColor);
+
+                               // Set internal properties to keep the transparency over the rendering process
+                       $this->saveAlphaLayer = TRUE;
+                               // Force PNG in case no format is set
+                       $this->setup['format'] = 'png';
+               } else {
+
+                               // Fill the background with the given color
+                       $BGcols = $this->convertColor($this->setup['backColor']);
+                       $Bcolor = ImageColorAllocate($this->im, $BGcols[0],$BGcols[1],$BGcols[2]);
+                       ImageFilledRectangle($this->im, 0, 0, $XY[0], $XY[1], $Bcolor);
+               }
 
                        // Traverse the GIFBUILDER objects an render each one:
                if (is_array($this->setup))     {
                        $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':
@@ -378,12 +425,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;
@@ -432,24 +503,34 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                                                                $this->workArea = $this->defaultWorkArea;       // this sets the current to the default;
                                                        }
                                                break;
+                                               case 'ELLIPSE':
+                                                       $this->makeEllipse($this->im, $conf, $this->workArea);
+                                               break;
                                        }
                                }
                        }
                }
 
-
-               if ($this->setup['transparentBackground'])      {
-                               // Auto transparent background is set
-                       $Bcolor = ImageColorExact($this->im, $BGcols[0],$BGcols[1],$BGcols[2]);
-                       imagecolortransparent($this->im, $Bcolor);
-               } elseif (is_array($this->setup['transparentColor_array']))     {
-                               // Multiple transparent colors are set. This is done via the trick that all transparent colors get converted to one color and then this one gets set as transparent as png/gif can just have one transparent color.
-                       $Tcolor = $this->unifyColors($this->im, $this->setup['transparentColor_array'], intval($this->setup['transparentColor.']['closest']));
-                       if ($Tcolor>=0) {
-                               imagecolortransparent($this->im, $Tcolor);
+                       // preserve alpha transparency
+               if (!$this->saveAlphaLayer) {
+                       if ($this->setup['transparentBackground']) {
+                                       // Auto transparent background is set
+                               $Bcolor = ImageColorClosest($this->im, $BGcols[0], $BGcols[1], $BGcols[2]);
+                               imagecolortransparent($this->im, $Bcolor);
+                       } elseif (is_array($this->setup['transparentColor_array'])) {
+                                       // Multiple transparent colors are set. This is done via the trick that all transparent colors get
+                                       // converted to one color and then this one gets set as transparent as png/gif can just have one
+                                       // transparent color.
+                               $Tcolor = $this->unifyColors(
+                                       $this->im,
+                                       $this->setup['transparentColor_array'],
+                                       intval($this->setup['transparentColor.']['closest'])
+                               );
+                               if ($Tcolor >= 0) {
+                                       imagecolortransparent($this->im, $Tcolor);
+                               }
                        }
                }
-
        }
 
 
@@ -488,6 +569,17 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
         * @access private
         */
        function checkTextObj($conf)    {
+               $cObj = t3lib_div::makeInstance('tslib_cObj');
+               $cObj->start($this->data);
+
+               $isStdWrapped = array();
+               foreach($conf as $key => $value) {
+                       $parameter = rtrim($key,'.');
+                       if(!$isStdWrapped[$parameter] && isset($conf[$parameter.'.'])) {
+                               $conf[$parameter] = $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;}
@@ -496,11 +588,8 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                        $conf['angle']=0;
                }
                if (!isset($conf['antiAlias'])){$conf['antiAlias']=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']);
@@ -510,7 +599,11 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                        // Max length = 100 if automatic line braks are not defined:
                if (!isset($conf['breakWidth']) || !$conf['breakWidth']) {
                        $tlen = (intval($conf['textMaxLength']) ? intval($conf['textMaxLength']) : 100);
-                       $conf['text'] = substr($conf['text'], 0, $tlen);
+                       if ($this->nativeCharset) {
+                               $conf['text'] = $this->csConvObj->substr($this->nativeCharset, $conf['text'], 0, $tlen);
+                       } else {
+                               $conf['text'] = substr($conf['text'], 0 , $tlen);
+                       }
                }
                if ((string)$conf['text']!='')  {
 
@@ -590,11 +683,9 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
         *
         * @param       string          Filename value OR the string "GIFBUILDER", see documentation in TSref for the "datatype" called "imgResource"
         * @param       array           TypoScript properties passed to the function. Either GIFBUILDER properties or imgResource properties, depending on the value of $file (whether that is "GIFBUILDER" or a file reference)
-        * @return      array           Returns an array with file information if an image was returned. Otherwise false.
+        * @return      array           Returns an array with file information if an image was returned. Otherwise FALSE.
         * @access private
         * @see tslib_cObj::getImgResource()
-        * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=315&cHash=63b593a934
-        * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=282&cHash=831a95115d
         */
        function getResource($file,$fileArray)  {
                if (!t3lib_div::inList($this->imageFileExt, $fileArray['ext'])) {
@@ -629,18 +720,20 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                $meaningfulPrefix = '';
 
                if ($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']) {
+                       /** @var $basicFileFunctions t3lib_basicFileFunctions */
+                       $basicFileFunctions = t3lib_div::makeInstance('t3lib_basicFileFunctions');
+
                        $meaningfulPrefix = implode('_', array_merge($this->combinedTextStrings, $this->combinedFileNames));
-                               // strip everything non-ascii
-                       $meaningfulPrefix = preg_replace('/[^A-Za-z0-9_-]/', '', trim($meaningfulPrefix));
+                       $meaningfulPrefix = $basicFileFunctions->cleanFileName($meaningfulPrefix);
                        $meaningfulPrefix = substr($meaningfulPrefix, 0, intval($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix'])) . '_';
                }
 
                        // WARNING: In PHP5 I discovered that rendering with freetype of Japanese letters was totally corrupt. Not only the wrong glyphs are printed but also some memory stack overflow resulted in strange additional chars - and finally the reason for this investigation: The Bounding box data was changing all the time resulting in new images being generated all the time. With PHP4 it works fine.
-               return $this->tempPath.
-                               $pre.
+               return $this->tempPath .
+                               $pre .
                                $meaningfulPrefix .
-                               t3lib_div::shortMD5(serialize($this->setup)).
-                               '.'.$this->extension();
+                               t3lib_div::shortMD5(serialize($this->setup)) .
+                               '.' . $this->extension();
        }
 
        /**
@@ -749,15 +842,15 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
         * @return      integer         The maxium value of the given comma separated and calculated values
         */
        protected function calculateMaximum($string) {
-               $parts = t3lib_div::trimExplode(',', $this->calcOffset($string), true);
+               $parts = t3lib_div::trimExplode(',', $this->calcOffset($string), TRUE);
                $maximum = (count($parts) ? max($parts) : 0);
                return $maximum;
        }
 }
 
 
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_gifbuilder.php'])       {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_gifbuilder.php']);
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_gifbuilder.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/class.tslib_gifbuilder.php']);
 }
 
 ?>
\ No newline at end of file