Added support for NULL fields in the database
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsparser_ext.php
index 6603804..ec3d768 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *  
-*  (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is 
@@ -42,8 +42,8 @@
  *  218:     function substituteConstants($all)        
  *  247:     function substituteCMarkers($all) 
  *  269:     function generateConfig_constants()       
- *  317:     function ext_getSetup($theSetup,$theKey)  
- *  348:     function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="")      
+ *  318:     function ext_getSetup($theSetup,$theKey)  
+ *  349:     function ext_getObjTree($arr, $depth_in, $depthData, $parentType="",$parentValue="")      
  *  437:     function makeHtmlspecialchars($theValue)
  *  450:     function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray)             
  *  490:     function ext_getRootlineNumber($pid)      
  *  625:     function ext_fixed_lgd($string,$chars)    
  *  641:     function ext_lnBreakPointWrap($ln,$str)   
  *  654:     function ext_formatTS($input, $ln, $comments=1, $crop=0)  
- *  702:     function ext_getFirstTemplate($id,$template_uid=0)                
- *  722:     function ext_getAllTemplates($id)         
- *  743:     function ext_compareFlatSetups($default)  
- *  809:     function ext_categorizeEditableConstants($editConstArray) 
- *  832:     function ext_getCategoryLabelArray()      
- *  849:     function ext_getTypeData($type)   
- *  890:     function ext_getTSCE_config($category)    
- *  929:     function ext_getKeyImage($key)    
- *  939:     function ext_getTSCE_config_image($imgConf)       
- *  963:     function ext_resourceDims()       
- *  993:     function ext_readDirResources($path)      
- * 1008:     function readDirectory($path,$type="file")        
- * 1033:     function ext_fNandV($params)      
- * 1051:     function ext_printFields($theConstants,$category) 
+ *  693:     function ext_getFirstTemplate($id,$template_uid=0)                
+ *  712:     function ext_getAllTemplates($id)         
+ *  732:     function ext_compareFlatSetups($default)  
+ *  798:     function ext_categorizeEditableConstants($editConstArray) 
+ *  821:     function ext_getCategoryLabelArray()      
+ *  838:     function ext_getTypeData($type)   
+ *  879:     function ext_getTSCE_config($category)    
+ *  918:     function ext_getKeyImage($key)    
+ *  928:     function ext_getTSCE_config_image($imgConf)       
+ *  952:     function ext_resourceDims()       
+ *  982:     function ext_readDirResources($path)      
+ *  997:     function readDirectory($path,$type="file")        
+ * 1022:     function ext_fNandV($params)      
+ * 1040:     function ext_printFields($theConstants,$category) 
  *
  *              SECTION: Processing input values
- * 1308:     function ext_regObjectPositions($constants)       
- * 1323:     function ext_regObjects($pre)     
- * 1368:     function ext_putValueInConf($key, $var)   
- * 1391:     function ext_removeValueInConf($key)      
- * 1407:     function ext_depthKeys($arr,$settings)    
- * 1442:     function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)  
- * 1569:     function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)   
- * 1610:     function ext_prevPageWithTemplate($id,$perms_clause)      
- * 1626:     function ext_setStar($val)        
- * 1638:     function ext_detectAndFixExtensionPrefix($value)  
+ * 1297:     function ext_regObjectPositions($constants)       
+ * 1312:     function ext_regObjects($pre)     
+ * 1357:     function ext_putValueInConf($key, $var)   
+ * 1380:     function ext_removeValueInConf($key)      
+ * 1396:     function ext_depthKeys($arr,$settings)    
+ * 1431:     function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow)  
+ * 1558:     function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name)   
+ * 1604:     function ext_prevPageWithTemplate($id,$perms_clause)      
+ * 1620:     function ext_setStar($val)        
+ * 1632:     function ext_detectAndFixExtensionPrefix($value)  
  *
  * TOTAL FUNCTIONS: 39
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -95,7 +95,7 @@ require_once(PATH_t3lib."class.t3lib_tstemplate.php");
 
 /**
  * TSParser extension class to t3lib_TStemplate
- * 
+ *
  * @author     Kasper Skaarhoj <kasper@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
@@ -182,7 +182,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
        /**
         * This flattens a hierarchical setuparray to $this->flatSetup
         * The original function fetched the resource-file if any ("file."). This functions doesn't.
-        * 
+        *
         * @param       [type]          $setupArray: ...
         * @param       [type]          $prefix: ...
         * @param       [type]          $resourceFlag: ...
@@ -211,7 +211,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $all: ...
         * @return      [type]          ...
         */
@@ -240,7 +240,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $all: ...
         * @return      [type]          ...
         */
@@ -263,7 +263,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @return      [type]          ...
         */
        function generateConfig_constants()     {
@@ -310,7 +310,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $theSetup: ...
         * @param       [type]          $theKey: ...
         * @return      [type]          ...
@@ -338,7 +338,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $arr: ...
         * @param       [type]          $depth_in: ...
         * @param       [type]          $depthData: ...
@@ -385,11 +385,12 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                $PM = is_array($arr[$key."."]) && !$this->ext_noPMicons ? ($deeper ? "minus":"plus") : "join";
        
                                $HTML.=$depthData;
-                               $theIcon='<IMG src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border=0>';
+                               $theIcon='<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />';
                                if ($PM=="join")        {
                                        $HTML.=$theIcon;
                                } else {
-                                       $HTML.='<a name="'.$goto.'" href="index.php?id='.$GLOBALS["SOBE"]->id.'&tsbr['.$depth.']='.($deeper?0:1).'#'.$goto.'">'.$theIcon.'</a>';
+                                       $aHref='index.php?id='.$GLOBALS["SOBE"]->id.'&tsbr['.$depth.']='.($deeper?0:1).'#'.$goto;
+                                       $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars($aHref).'">'.$theIcon.'</a>';
                                }
        
                                $label = $key;
@@ -397,19 +398,17 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                        $label='<font color="#666666">'.$label.'</font>';
                                } else {
                                        if ($this->linkObjects) {
-                                               $label = '<a href="index.php?id='.$GLOBALS["SOBE"]->id.'&sObj='.$depth.'">'.$label.'</a>';
+                                               $aHref = 'index.php?id='.$GLOBALS["SOBE"]->id.'&sObj='.$depth;
+                                               $label = '<a href="'.htmlspecialchars($aHref).'">'.$label.'</a>';
                                        }
                                }
-       //                      if (!isset($validate_info[$key]))       {
-       //                              $HTML.='<font color="red">['.$label.']</font>';
-       //                      } else {
-                                       $HTML.="[".$label."]";
-       //                      }
+
+                               $HTML.="[".$label."]";
+
                                if (isset($arr[$key]))  {
                                        $theValue = $arr[$key];
                                        if ($this->fixedLgd)    {
                                                $imgBlocks = ceil(1+strlen($depthData)/77);
-       //                                      debug($imgBlocks);
                                                $lgdChars = 68-ceil(strlen("[".$key."]")*0.8)-$imgBlocks*3;
                                                $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
                                        }
@@ -419,10 +418,10 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                $HTML.="=<b>".$this->makeHtmlspecialchars($theValue)."</b>";
                                        }
                                }
-                               $HTML.="<BR>";
+                               $HTML.="<br />";
                                        
                                if ($deeper)    {
-                                       $HTML.=$this->ext_getObjTree($arr[$key."."], $depth, $depthData.'<IMG src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$LN.'.gif" width="18" height="16" align="top">', $validate_info[$key], $arr[$key]);
+                                       $HTML.=$this->ext_getObjTree($arr[$key."."], $depth, $depthData.'<img src="'.$GLOBALS["BACK_PATH"].'t3lib/gfx/ol/'.$LN.'.gif" width="18" height="16" align="top" alt="" />', $validate_info[$key], $arr[$key]);
                                }
                        }
                }
@@ -431,7 +430,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $theValue: ...
         * @return      [type]          ...
         */
@@ -441,7 +440,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $arr: ...
         * @param       [type]          $depth_in: ...
         * @param       [type]          $searchString: ...
@@ -484,7 +483,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $pid: ...
         * @return      [type]          ...
         */
@@ -499,7 +498,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $arr: ...
         * @param       [type]          $depthData: ...
         * @param       [type]          $keyArray: ...
@@ -560,7 +559,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $depthDataArr: ...
         * @param       [type]          $pointer: ...
         * @return      [type]          ...
@@ -572,8 +571,8 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
                        $row = $this->hierarchyInfo[$pointer];
 
                        $depthDataArr[$row['templateID']]=$row;
-                       $depthDataArr[$row['templateID']]["bgcolor_setup"] = isset($this->clearList_setup_temp[$row['templateID']])?' bgColor="'.$GLOBALS["SOBE"]->doc->bgColor5.'"':'';
-                       $depthDataArr[$row['templateID']]["bgcolor_const"] = isset($this->clearList_const_temp[$row['templateID']])?' bgColor="'.$GLOBALS["SOBE"]->doc->bgColor5.'"':'';
+                       $depthDataArr[$row['templateID']]["bgcolor_setup"] = isset($this->clearList_setup_temp[$row['templateID']])?' class="bgColor5"':'';
+                       $depthDataArr[$row['templateID']]["bgcolor_const"] = isset($this->clearList_const_temp[$row['templateID']])?' class="bgColor5"':'';
                        unset($this->clearList_setup_temp[$row['templateID']]);
                        unset($this->clearList_const_temp[$row['templateID']]);
                        $this->templateTitles[$row['templateID']]=$row["title"];
@@ -587,7 +586,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $config: ...
         * @param       [type]          $lineNumbers: ...
         * @param       [type]          $comments: ...
@@ -618,7 +617,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
         * Returns a new string of max. $chars lenght
         * If the string is longer, it will be truncated and prepended with "..."
         * $chars must be an integer of at least 4
-        * 
+        *
         * @param       [type]          $string: ...
         * @param       [type]          $chars: ...
         * @return      [type]          ...
@@ -634,7 +633,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $ln: ...
         * @param       [type]          $str: ...
         * @return      [type]          ...
@@ -645,7 +644,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $input: ...
         * @param       [type]          $ln: ...
         * @param       [type]          $comments: ...
@@ -672,30 +671,21 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                $cArr[$k] = '<font color="green"><b>'.$cArr[$k].'</b></font>';
                        } elseif ($firstChar=="/" || $firstChar=="#")   {
                                if ($comments)  {
-                                       $cArr[$k] = '<font color="#666666">'.$cArr[$k].'</font>';
+                                       $cArr[$k] = '<span class="typo3-dimmed">'.$cArr[$k].'</span>';
                                } else {
                                        unset($cArr[$k]);
                                }
                        }
 
-/*                     if (ereg('\{\$[^\}]*\}',$v,$reg))       {
-                               while(list(,$f)=each($reg))     {
-                               debug($reg);
-                                       if ($f) {
-                                               $cArr[$k] = str_replace(htmlspecialchars($f),'<font color="green"><b>'.htmlspecialchars($f).'</b></font>',$cArr[$k]);
-//                                             debug($f);
-                                       }
-                               }
-                       }*/
+
                }
                $output = implode($cArr, "<BR>")."<BR>";
-//             $output = '<font face=verdana size=1 color=maroon>'.$output.'</font>';
                return $output;
        }
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $id: ...
         * @param       [type]          $template_uid: ...
         * @return      [type]          ...
@@ -706,30 +696,28 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                        if ($template_uid)      {
                                $addC = " AND uid=".$template_uid;
                        }
-                       $query = "SELECT * FROM sys_template WHERE pid = ".intval($id).$addC." ".$this->whereClause." ORDER BY sorting LIMIT 1";
-                       $res = mysql(TYPO3_db, $query);
-                       echo mysql_error();
-                       $row = mysql_fetch_assoc($res);
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause, '', 'sorting', '1');
+                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
+                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                        return $row;    // Returns the template row if found.
                }
        }
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $id: ...
         * @return      [type]          ...
         */
        function ext_getAllTemplates($id)               {
                        // Query is taken from the runThroughTemplates($theRootLine) function in the parent class.
                if (intval($id))        {
-                       $query = "SELECT * FROM sys_template WHERE pid = ".intval($id)." ".$this->whereClause." ORDER BY sorting";
-                       $res = mysql(TYPO3_db, $query);
-                       echo mysql_error();
                        $outRes=array();
-                       while($row = mysql_fetch_assoc($res))   {
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause, '', 'sorting');
+                       while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
                                $outRes[] = $row;
                        }
+                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
                        return $outRes; // Returns the template rows in an array.
                }
        }
@@ -737,7 +725,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
        /**
         * This function compares the flattened constants (default and all).
         * Returns an array with the constants from the whole template which may be edited by the module.
-        * 
+        *
         * @param       [type]          $default: ...
         * @return      [type]          ...
         */
@@ -803,7 +791,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $editConstArray: ...
         * @return      [type]          ...
         */
@@ -827,7 +815,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @return      [type]          ...
         */
        function ext_getCategoryLabelArray()    {
@@ -843,7 +831,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $type: ...
         * @return      [type]          ...
         */
@@ -884,7 +872,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $category: ...
         * @return      [type]          ...
         */
@@ -923,7 +911,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $key: ...
         * @return      [type]          ...
         */
@@ -933,7 +921,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $imgConf: ...
         * @return      [type]          ...
         */
@@ -945,12 +933,12 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                        $iFile = t3lib_div::getFileAbsFileName($imgConf);
                        if ($iFile)     {
                                $f = substr($iFile,strlen(PATH_site));  
-                               $tFile="../".$GLOBALS["BACK_PATH"].$f;
+                               $tFile=$GLOBALS["BACK_PATH"]."../".$f;
                        }
                } else {
                        $f = "uploads/tf/".$this->extractFromResources($this->setup["resources"],$imgConf);
                        $iFile=PATH_site.$f;
-                       $tFile="../".$GLOBALS["BACK_PATH"].$f;
+                       $tFile=$GLOBALS["BACK_PATH"]."../".$f;
                }
                $imageInfo=@getImagesize($iFile);
                return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
@@ -958,7 +946,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @return      [type]          ...
         */
        function ext_resourceDims()     {
@@ -987,7 +975,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $path: ...
         * @return      [type]          ...
         */
@@ -1001,7 +989,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate  {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $path: ...
         * @param       [type]          $type: ...
         * @return      [type]          ...
@@ -1027,7 +1015,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $params: ...
         * @return      [type]          ...
         */
@@ -1044,7 +1032,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $theConstants: ...
         * @param       [type]          $category: ...
         * @return      [type]          ...
@@ -1067,7 +1055,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                $subcat=$params["subcat_name"];
                                                $subcat_name = $params["subcat_name"] ? $this->subCategories[$params["subcat_name"]][0] : "Others";
                                                $output.='<tr>';
-                                               $output.='<td colspan=2 bgColor="'.$GLOBALS["SOBE"]->doc->bgColor4.'"><div align="center"><b>'.$subcat_name.'</b></div></td>';
+                                               $output.='<td colspan=2 class="bgColor4"><div align="center"><b>'.$subcat_name.'</b></div></td>';
                                                $output.='</tr>';
                                        }
 
@@ -1242,11 +1230,11 @@ class t3lib_tsparser_ext extends t3lib_TStemplate       {
                                                                                }
 #debug($copyFile);
                                                                                if ($copyFile && @is_file($copyFile))   {
-                                                                                       $p_field.='<img src=clear.gif width=20 height=1><img src="'.$GLOBALS["BACK_PATH"].'gfx/clip_copy.gif" width="12" height="12" border="0"><input type="Checkbox" name="_copyResource['.$params["name"].']" value="'.htmlspecialchars($copyFile).'" onClick="uFormUrl('.$aname.');if (this.checked) {alert(unescape(\''.rawurlencode(sprintf("This will make a copy of the current file, '%s'. Do you really want that?",$params["value"])).'\'));}">';
+                                                                                       $p_field.='<img src="clear.gif" width="20" height="1" alt="" /><img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/clip_copy.gif','width="12" height="12"').' border="0" alt="" /><input type="Checkbox" name="_copyResource['.$params["name"].']" value="'.htmlspecialchars($copyFile).'" onClick="uFormUrl('.$aname.');if (this.checked) {alert(unescape(\''.rawurlencode(sprintf("This will make a copy of the current file, '%s'. Do you really want that?",$params["value"])).'\'));}">';
                                                                                }
                                                                                        // Upload?
                                                                                $p_field.='<BR>';
-                                                                               $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')">';
+                                                                               $p_field.='<input type="file" name="upload_'.$fN.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().' onChange="uFormUrl('.$aname.')" size="50" />';
                                                                        }
                                                                break;
                                                                case 'small':
@@ -1260,11 +1248,11 @@ class t3lib_tsparser_ext extends t3lib_TStemplate       {
                                                if ($typeDat["type"]=="color" && substr($params["value"],0,2)!='{$')    {
                                                        $p_field='<table border=0 cellpadding=0 cellspacing=0><tr><td nowrap>'.$p_field.'</td><td>&nbsp;</td><td bgcolor="'.$params["value"].'"><img src="clear.gif" width=50 height=10></td></tr></table>';
                                                } else {
-                                                       $p_field='<nobr>'.$p_field.'</nobr><br>';
+                                                       $p_field='<span class="nobr">'.$p_field.'</span><br />';
                                                }
        
-                                               $p_name = '<font color="#666666">['.$params["name"].']</font><BR>';
-                                               $p_dlabel='<font color="#666666"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</font><BR>';                    
+                                               $p_name = '<span class="typo3-dimmed">['.$params["name"].']</span><BR>';
+                                               $p_dlabel='<span class="typo3-dimmed"><b>Default:</b> '.htmlspecialchars($params["default_value"]).'</span><BR>';                       
                                                $p_label = '<b>'.htmlspecialchars($head).'</b>';
                                                $p_descrip = $body ? htmlspecialchars($body)."<BR>" : "";
                                                
@@ -1317,7 +1305,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $pre: ...
         * @return      [type]          ...
         */
@@ -1361,7 +1349,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $key: ...
         * @param       [type]          $var: ...
         * @return      [type]          ...
@@ -1385,7 +1373,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $key: ...
         * @return      [type]          ...
         */
@@ -1400,7 +1388,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $arr: ...
         * @param       [type]          $settings: ...
         * @return      [type]          ...
@@ -1433,7 +1421,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $http_post_vars: ...
         * @param       [type]          $http_post_files: ...
         * @param       [type]          $theConstants: ...
@@ -1455,7 +1443,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                        while(list($key,$var)=each($data))      {
                                if (isset($theConstants[$key])) {
                                        if ($this->ext_dontCheckIssetValues || isset($check[$key]))     {               // If checkbox is set, update the value
-                                               list($var) = explode(chr(10),stripslashes($var));       // exploding with linebreak, just to make sure that no multiline input is given!
+                                               list($var) = explode(chr(10),$var);     // exploding with linebreak, just to make sure that no multiline input is given!
                                                $typeDat=$this->ext_getTypeData($theConstants[$key]["type"]);
                                                switch($typeDat["type"])        {
                                                        case "int":
@@ -1487,7 +1475,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                        break;
                                                        case "wrap":
                                                                if (isset($Wdata[$key]))        {
-                                                                       $var.="|".stripslashes($Wdata[$key]);
+                                                                       $var.="|".$Wdata[$key];
                                                                }
                                                        break;
                                                        case "offset":
@@ -1560,7 +1548,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $typeDat: ...
         * @param       [type]          $tplRow: ...
         * @param       [type]          $theRealFileName: ...
@@ -1568,6 +1556,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
         * @return      [type]          ...
         */
        function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) {
+
                        // extensions
                $extList = $typeDat["paramstr"];
                if ($extList=="IMAGE_EXT")      {
@@ -1575,12 +1564,14 @@ class t3lib_tsparser_ext extends t3lib_TStemplate       {
                }
                $fI=t3lib_div::split_fileref($theRealFileName);
                if ($theRealFileName && (!$extList || t3lib_div::inList($extList,$fI["fileext"])))      {
+                       $tmp_upload_name = t3lib_div::upload_to_tempfile($tmp_name);    // If there is an uploaded file, move it for the sake of safe_mode.
+               
                                // Saving resource
                        $alternativeFileName=array();
-                       $alternativeFileName[$tmp_name] = $theRealFileName;
+                       $alternativeFileName[$tmp_upload_name] = $theRealFileName;
                                // Making list of resources
                        $resList = $tplRow["resources"];
-                       $resList = $tmp_name.",".$resList;
+                       $resList = $tmp_upload_name.",".$resList;
                        $resList=implode(t3lib_div::trimExplode(",",$resList,1),",");
                                // Making data-array
                        $recData=array();
@@ -1592,6 +1583,8 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                        $tce->start($recData,Array());
                        $tce->process_datamap();
                        
+                       t3lib_div::unlink_tempfile($tmp_upload_name);
+                       
                        $tmpRow = t3lib_BEfunc::getRecord("sys_template",$tplRow["uid"],"resources");
                        $tplRow["resources"] = $tmpRow["resources"];
 
@@ -1603,7 +1596,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $id: ...
         * @param       [type]          $perms_clause: ...
         * @return      [type]          ...
@@ -1620,7 +1613,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $val: ...
         * @return      [type]          ...
         */
@@ -1632,7 +1625,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
        /**
         * [Describe function...]
-        * 
+        *
         * @param       [type]          $value: ...
         * @return      [type]          ...
         */