Fixed bug #10086: Core uses deprecated function t3lib_db->sql()
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_stdgraphic.php
index 115c0e5..c81b4b9 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2007 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -2010,7 +2010,8 @@ class t3lib_stdGraphic    {
 
                        // Recode string accoding to TTFLocaleConv. Deprecated.
                if ($this->TTFLocaleConv)       {
-                       $string = recode_string($this->TTFLocaleConv,$string);
+                       list($from, $to) = t3lib_div::trimExplode('..', $this->TTFLocaleConv, true);
+                       $string = $this->csConvObj->conv($string, $from, $to);
                }
 
                return $string;
@@ -2170,6 +2171,15 @@ class t3lib_stdGraphic   {
                                        $params = $this->cmds[$newExt];
                                }
 
+                                       // Cropscaling:
+                               if ($data['crs']) {
+                                       if (!$data['origW']) { $data['origW'] = $data[0]; }
+                                       if (!$data['origH']) { $data['origH'] = $data[1]; }
+                                       $offsetX = intval(($data[0] - $data['origW']) * ($data['cropH']+100)/200);
+                                       $offsetY = intval(($data[1] - $data['origH']) * ($data['cropV']+100)/200);
+                                       $params .= ' -crop '.$data['origW'].'x'.$data['origH'].'+'.$offsetX.'+'.$offsetY.' ';
+                               }
+
                                $command = $this->scalecmd.' '.$info[0].'x'.$info[1].'! '.$params.' ';
                                $cropscale = ($data['crs'] ? 'crs-V'.$data['cropV'].'H'.$data['cropH'] : '');
 
@@ -2190,35 +2200,10 @@ class t3lib_stdGraphic  {
                                        // Register temporary filename:
                                $GLOBALS['TEMP_IMAGES_ON_PAGE'][] = $output;
 
-                                       // Cropscaling:
-                               if ($data['crs'])       {
-                                       if ($this->dontCheckForExistingTempFile || !$this->file_exists_typo3temp_file($output, $imagefile))     {
-                                               $crsOutput = str_replace('pics/', 'pics/crs-', $output);
-                                               $this->imageMagickExec($imagefile.$frame, $crsOutput, $command);
-                                               $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
-                                               $gifCreator->init();
-                                               if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] !== 0)  {
-                                                       if (!$data['origW']) { $data['origW'] = $data[0]; }
-                                                       if (!$data['origH']) { $data['origH'] = $data[1]; }
-                                                       $ofX = intval(($data['origW'] - $data[0]) * ($data['cropH']+100)/200);
-                                                       $ofY = intval(($data['origH'] - $data[1]) * ($data['cropV']+100)/200);
-                                                       $tmpParm = Array('XY' => intval($data['origW']).','.intval($data['origH']),
-                                                                       '10' => 'IMAGE',
-                                                                       '10.' => array('file'=> $crsOutput, 'offset'=> $ofX.','.$ofY),
-                                                       );
-                                                       $gifCreator->start($tmpParm, array());
-                                                       $newoutput = $gifCreator->gifBuild();
-                                                       if (!copy($newoutput,$output)) {
-                                                               $output = $newoutput;
-                                                       }
-                                               } else {
-                                                       $output = $crsOutput;
-                                               }
-                                       }
-                               } elseif ($this->dontCheckForExistingTempFile || !$this->file_exists_typo3temp_file($output,$imagefile)) {
-                                       $this->imageMagickExec($imagefile.$frame,$output,$command);
+                               if ($this->dontCheckForExistingTempFile || !$this->file_exists_typo3temp_file($output, $imagefile))     {
+                                       $this->imageMagickExec($imagefile.$frame, $output, $command);
                                }
-                               if (@file_exists($output))      {
+                               if (file_exists($output))       {
                                        $info[3] = $output;
                                        $info[2] = $newExt;
                                        if ($params)    {       // params could realisticly change some imagedata!
@@ -2242,7 +2227,7 @@ class t3lib_stdGraphic    {
         */
        function getImageDimensions($imageFile) {
                ereg('([^\.]*)$',$imageFile,$reg);
-               if (@file_exists($imageFile) && t3lib_div::inList($this->imageFileExt,strtolower($reg[0])))     {
+               if (file_exists($imageFile) && t3lib_div::inList($this->imageFileExt,strtolower($reg[0])))      {
                        if ($returnArr = $this->getCachedImageDimensions($imageFile))   {
                                return $returnArr;
                        } else {
@@ -2434,7 +2419,7 @@ class t3lib_stdGraphic    {
         */
        function file_exists_typo3temp_file($output,$orig='')   {
                if ($this->enable_typo3temp_db_tracking)        {
-                       if (@file_exists($output))      {       // If file exists, then we return immediately
+                       if (file_exists($output))       {       // If file exists, then we return immediately
                                return 1;
                        } else {        // If not, we look up in the cache_typo3temp_log table to see if there is a image being rendered right now.
                                $md5Hash=md5($output);
@@ -2459,7 +2444,7 @@ class t3lib_stdGraphic    {
                                }
                        }
                } else {
-                       return @file_exists($output);
+                       return file_exists($output);
                }
        }
 
@@ -2767,47 +2752,47 @@ class t3lib_stdGraphic  {
         */
        function ImageWrite($destImg, $theImage, $quality=0)    {
                imageinterlace ($destImg,0);
-               $ext = strtolower(substr($theImage, strrpos($theImage, '.')+1));
-               switch ($ext)   {
-                       case 'jpg':
-                       case 'jpeg':
-                               if (function_exists('imageJpeg'))       {
+               $ext = strtolower(substr($theImage, strrpos($theImage, '.')+1));
+               switch ($ext)   {
+                       case 'jpg':
+                       case 'jpeg':
+                               if (function_exists('imageJpeg'))       {
                                        if ($quality == 0)      {
                                                $quality = $this->jpegQuality;
                                        }
-                                       return imageJpeg($destImg, $theImage, $quality);
-                               }
-                       break;
-                       case 'gif':
-                               if (function_exists('imageGif'))        {
+                                       return imageJpeg($destImg, $theImage, $quality);
+                               }
+                       break;
+                       case 'gif':
+                               if (function_exists('imageGif'))        {
                                        if ($this->truecolor)   {
                                                imagetruecolortopalette($destImg, true, 256);
                                        }
-                                       return imageGif($destImg, $theImage);
-                               }
-                       break;
-                       case 'png':
-                               if (function_exists('imagePng'))        {
-                                       return ImagePng($destImg, $theImage);
-                               }
-                       break;
-               }
-               return false;           // Extension invalid or write-function does not exist
-       }
-
-
-
-       /**
- * Writes the input GDlib image pointer to file. Now just a wrapper to ImageWrite.
- *
* @param      pointer         The GDlib image resource pointer
* @param      string          The filename to write to
* @return     mixed           The output of either imageGif, imagePng or imageJpeg based on the filename to write
- * @see imageWrite()
- * @deprecated
- */
-       function imageGif($destImg, $theImage)  {
-               return $this->imageWrite($destImg, $theImage);
+                                       return imageGif($destImg, $theImage);
+                               }
+                       break;
+                       case 'png':
+                               if (function_exists('imagePng'))        {
+                                       return ImagePng($destImg, $theImage);
+                               }
+                       break;
+               }
+               return false;           // Extension invalid or write-function does not exist
+       }
+
+
+
+       /**
       * Writes the input GDlib image pointer to file. Now just a wrapper to ImageWrite.
       *
       * @param       pointer         The GDlib image resource pointer
       * @param       string          The filename to write to
       * @return      mixed           The output of either imageGif, imagePng or imageJpeg based on the filename to write
       * @see imageWrite()
+        * @deprecated since TYPO3 4.0
       */
+       function imageGif($destImg, $theImage)  {
+               return $this->imageWrite($destImg, $theImage);
        }
 
        /**
@@ -2816,7 +2801,7 @@ class t3lib_stdGraphic    {
         *
         * @param       string          Image filename
         * @return      pointer         Image Resource pointer
-        * @deprecated
+        * @deprecated since TYPO3 4.0
         */
        function imageCreateFromGif($sourceImg) {
                return $this->imageCreateFromFile($sourceImg);
@@ -2952,4 +2937,5 @@ class t3lib_stdGraphic    {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_stdgraphic.php'])       {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_stdgraphic.php']);
 }
-?>
+
+?>
\ No newline at end of file