Small things
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_content.php
index f248dd2..713ec7d 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -31,7 +31,7 @@
  * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
  * XHTML compliant
  *
- * class tslib_cObj                            :               All main TypoScript features, rendering of content objects (cObjects). This class is the backbone of TypoScript Template rendering.
+ * class tslib_cObj                    :               All main TypoScript features, rendering of content objects (cObjects). This class is the backbone of TypoScript Template rendering.
  * class tslib_controlTable            :               Makes a table CTABLE (TS cObject)
  * class tslib_tableOffset             :               Makes a table-offset (TS)
  * class tslib_frameset                        :               Generates framesets (TS)
  *
  *
  *  250: class tslib_cObj
- *  348:     function start($data,$table='')
- *  363:     function setParent($data,$currentRecord)
+ *  344:     function start($data,$table='')
+ *  359:     function setParent($data,$currentRecord)
  *
  *              SECTION: CONTENT_OBJ:
- *  388:     function getCurrentVal()
- *  399:     function setCurrentVal($value)
- *  412:     function cObjGet($setup,$addKey='')
- *  436:     function cObjGetSingle($name,$conf,$TSkey='__')
+ *  384:     function getCurrentVal()
+ *  395:     function setCurrentVal($value)
+ *  408:     function cObjGet($setup,$addKey='')
+ *  432:     function cObjGetSingle($name,$conf,$TSkey='__')
  *
  *              SECTION: Functions rendering content objects (cObjects)
- *  582:     function HTML($conf)
- *  593:     function TEXT($conf)
- *  604:     function CLEARGIF($conf)
- *  623:     function COBJ_ARRAY($conf,$ext='')
- *  659:     function USER($conf,$ext='')
- *  686:     function FILE($conf)
- *  702:     function IMAGE($conf)
- *  721:     function IMG_RESOURCE($conf)
- *  733:     function IMGTEXT($conf)
- * 1129:     function CONTENT($conf)
- * 1192:     function RECORDS($conf)
- * 1270:     function HMENU($conf)
- * 1302:     function CTABLE ($conf)
- * 1340:     function OTABLE ($conf)
- * 1355:     function COLUMNS ($conf)
- * 1434:     function HRULER ($conf)
- * 1459:     function CASEFUNC ($conf)
- * 1484:     function LOAD_REGISTER($conf,$name)
- * 1524:     function FORM($conf,$formData='')
- * 1963:     function SEARCHRESULT($conf)
- * 2128:     function PHP_SCRIPT($conf,$ext='')
- * 2171:     function TEMPLATE($conf)
- * 2322:     function MULTIMEDIA($conf)
+ *  578:     function HTML($conf)
+ *  589:     function TEXT($conf)
+ *  600:     function CLEARGIF($conf)
+ *  619:     function COBJ_ARRAY($conf,$ext='')
+ *  655:     function USER($conf,$ext='')
+ *  682:     function FILE($conf)
+ *  698:     function IMAGE($conf)
+ *  717:     function IMG_RESOURCE($conf)
+ *  729:     function IMGTEXT($conf)
+ * 1125:     function CONTENT($conf)
+ * 1188:     function RECORDS($conf)
+ * 1266:     function HMENU($conf)
+ * 1298:     function CTABLE ($conf)
+ * 1336:     function OTABLE ($conf)
+ * 1351:     function COLUMNS ($conf)
+ * 1430:     function HRULER ($conf)
+ * 1455:     function CASEFUNC ($conf)
+ * 1480:     function LOAD_REGISTER($conf,$name)
+ * 1520:     function FORM($conf,$formData='')
+ * 1970:     function SEARCHRESULT($conf)
+ * 2135:     function PHP_SCRIPT($conf,$ext='')
+ * 2178:     function TEMPLATE($conf)
+ * 2329:     function MULTIMEDIA($conf)
  *
  *              SECTION: Various helper functions for content objects:
- * 2411:     function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf)
- * 2452:     function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
- * 2470:     function cImage($file,$conf)
- * 2503:     function imageLinkWrap($string,$imageFile,$conf)
- * 2568:     function fileResource($fName, $addParams='alt="" title=""')
- * 2591:     function lastChanged($tstamp)
- * 2608:     function linkWrap($content,$wrap)
- * 2626:     function getAltParam($conf)
+ * 2418:     function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf)
+ * 2459:     function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
+ * 2477:     function cImage($file,$conf)
+ * 2510:     function imageLinkWrap($string,$imageFile,$conf)
+ * 2575:     function fileResource($fName, $addParams='alt="" title=""')
+ * 2598:     function lastChanged($tstamp)
+ * 2615:     function linkWrap($content,$wrap)
+ * 2633:     function getAltParam($conf)
  *
  *              SECTION: HTML template processing functions
- * 2683:     function getSubpart($content, $marker)
- * 2712:     function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
- * 2754:     function substituteMarker($content,$marker,$markContent)
- * 2774:     function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
- * 2872:     function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
- * 2893:     function substituteMarkerInObject(&$tree, $markContentArray)
- * 2916:     function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)
+ * 2690:     function getSubpart($content, $marker)
+ * 2719:     function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
+ * 2761:     function substituteMarker($content,$marker,$markContent)
+ * 2781:     function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
+ * 2879:     function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
+ * 2900:     function substituteMarkerInObject(&$tree, $markContentArray)
+ * 2923:     function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)
  *
  *              SECTION: "stdWrap" + sub functions
- * 2979:     function stdWrap($content,$conf)
- * 3144:     function numRows($conf)
- * 3165:     function listNum($content,$listNum,$char)
- * 3185:     function checkIf($conf)
- * 3248:     function filelist($data)
- * 3327:     function clean_directory($theDir)
- * 3345:     function HTMLparser_TSbridge($theValue, $conf)
- * 3359:     function dataWrap($content,$wrap)
- * 3372:     function insertData($str)
- * 3402:     function prefixComment($str,$conf,$content)
- * 3426:     function substring($content,$options)
- * 3444:     function crop($content,$options)
- * 3476:     function removeBadHTML($text, $conf)
- * 3520:     function textStyle($theValue, $conf)
- * 3587:     function tableStyle($theValue, $conf)
- * 3628:     function addParams($content,$conf)
- * 3671:     function filelink($theValue, $conf)
- * 3738:     function locDataJU($jumpUrl,$conf)
- * 3769:     function calc($val)
- * 3798:     function calcIntExplode($delim, $string)
- * 3818:     function splitObj($value, $conf)
- * 3874:     function parseFunc($theValue, $conf, $ref='')
- * 3984:     function _parseFunc ($theValue, $conf)
- * 4186:     function encaps_lineSplit($theValue, $conf)
- * 4269:     function http_makelinks($data,$conf)
- * 4336:     function mailto_makelinks($data,$conf)
- * 4388:     function getImgResource($file,$fileArray)
+ * 2986:     function stdWrap($content,$conf)
+ * 3151:     function numRows($conf)
+ * 3172:     function listNum($content,$listNum,$char)
+ * 3192:     function checkIf($conf)
+ * 3255:     function filelist($data)
+ * 3334:     function clean_directory($theDir)
+ * 3352:     function HTMLparser_TSbridge($theValue, $conf)
+ * 3366:     function dataWrap($content,$wrap)
+ * 3379:     function insertData($str)
+ * 3409:     function prefixComment($str,$conf,$content)
+ * 3433:     function substring($content,$options)
+ * 3451:     function crop($content,$options)
+ * 3483:     function removeBadHTML($text, $conf)
+ * 3527:     function textStyle($theValue, $conf)
+ * 3594:     function tableStyle($theValue, $conf)
+ * 3635:     function addParams($content,$conf)
+ * 3678:     function filelink($theValue, $conf)
+ * 3745:     function locDataJU($jumpUrl,$conf)
+ * 3776:     function calc($val)
+ * 3805:     function calcIntExplode($delim, $string)
+ * 3825:     function splitObj($value, $conf)
+ * 3881:     function parseFunc($theValue, $conf, $ref='')
+ * 3991:     function _parseFunc ($theValue, $conf)
+ * 4193:     function encaps_lineSplit($theValue, $conf)
+ * 4276:     function http_makelinks($data,$conf)
+ * 4343:     function mailto_makelinks($data,$conf)
+ * 4406:     function getImgResource($file,$fileArray)
  *
  *              SECTION: Data retrieval etc.
- * 4560:     function getFieldVal($field)
- * 4580:     function getData($string,$fieldArray)
- * 4707:     function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
- * 4729:     function getGlobal($var, $source=NULL)
- * 4754:     function getKey($key,$arr)
+ * 4583:     function getFieldVal($field)
+ * 4603:     function getData($string,$fieldArray)
+ * 4730:     function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
+ * 4752:     function getGlobal($var, $source=NULL)
+ * 4777:     function getKey($key,$arr)
  *
  *              SECTION: Link functions (typolink)
- * 4806:     function typoLink($linktxt, $conf)
- * 5073:     function typoLink_URL($conf)
- * 5091:     function getTypoLink($label,$params,$urlParameters=array(),$target='')
- * 5121:     function getTypoLink_URL($params,$urlParameters=array(),$target='')
- * 5133:     function typolinkWrap($conf)
- * 5146:     function currentPageUrl($urlParameters=array(),$id=0)
- * 5159:     function getClosestMPvalueForPage($pageId, $raw=FALSE)
+ * 4829:     function typoLink($linktxt, $conf)
+ * 5111:     function typoLink_URL($conf)
+ * 5129:     function getTypoLink($label,$params,$urlParameters=array(),$target='')
+ * 5159:     function getTypoLink_URL($params,$urlParameters=array(),$target='')
+ * 5171:     function typolinkWrap($conf)
+ * 5184:     function currentPageUrl($urlParameters=array(),$id=0)
+ * 5197:     function getClosestMPvalueForPage($pageId, $raw=FALSE)
  *
  *              SECTION: Miscellaneous functions, stand alone
- * 5235:     function wrap($content,$wrap,$char='|')
- * 5251:     function noTrimWrap($content,$wrap)
- * 5265:     function wrapSpace($content, $wrap)
- * 5291:     function callUserFunction($funcName,$conf,$content)
- * 5332:     function processParams($params)
- * 5350:     function keywords($content)
- * 5367:     function caseshift($theValue, $case)
- * 5392:     function HTMLcaseshift($theValue, $case)
- * 5421:     function bytes($sizeInBytes,$labels)
- * 5432:     function calcAge($seconds,$labels)
- * 5463:     function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
- * 5490:     function URLqMark($url,$params)
- * 5506:     function checkEmail($email)
- * 5518:     function clearTSProperties($TSArr,$propList)
- * 5537:     function mergeTSRef($confArr,$prop)
- * 5560:     function joinTSarrays($conf,$old_conf)
- * 5583:     function gifBuilderTextBox($gifbuilderConf, $conf, $text)
- * 5639:     function linebreaks($string,$chars,$maxLines=0)
- * 5670:     function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
+ * 5273:     function wrap($content,$wrap,$char='|')
+ * 5289:     function noTrimWrap($content,$wrap)
+ * 5303:     function wrapSpace($content, $wrap)
+ * 5329:     function callUserFunction($funcName,$conf,$content)
+ * 5370:     function processParams($params)
+ * 5388:     function keywords($content)
+ * 5405:     function caseshift($theValue, $case)
+ * 5430:     function HTMLcaseshift($theValue, $case)
+ * 5459:     function bytes($sizeInBytes,$labels)
+ * 5470:     function calcAge($seconds,$labels)
+ * 5501:     function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
+ * 5528:     function URLqMark($url,$params)
+ * 5544:     function checkEmail($email)
+ * 5556:     function clearTSProperties($TSArr,$propList)
+ * 5575:     function mergeTSRef($confArr,$prop)
+ * 5598:     function joinTSarrays($conf,$old_conf)
+ * 5621:     function gifBuilderTextBox($gifbuilderConf, $conf, $text)
+ * 5677:     function linebreaks($string,$chars,$maxLines=0)
+ * 5708:     function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
  *
  *              SECTION: Database functions, making of queries
- * 5739:     function DBgetDelete($table, $uid, $doExec=FALSE)
- * 5771:     function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE)
- * 5813:     function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE)
- * 5850:     function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
- * 5890:     function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
- * 5930:     function enableFields($table,$show_hidden=0)
- * 5954:     function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)
- * 6054:     function whereSelectFromList($field,$value)
- * 6072:     function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
- * 6099:     function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')
- * 6120:     function searchWhere($sw,$searchFieldList,$searchTable='')
- * 6153:     function exec_getQuery($table, $conf)
- * 6171:     function getQuery($table, $conf, $returnQueryArray=FALSE)
- * 6250:     function getWhere($table,$conf, $returnQueryArray=FALSE)
- * 6344:     function checkPidArray($listArr)
- * 6367:     function checkPid($uid)
+ * 5777:     function DBgetDelete($table, $uid, $doExec=FALSE)
+ * 5809:     function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE)
+ * 5851:     function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE)
+ * 5888:     function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
+ * 5928:     function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
+ * 5968:     function enableFields($table,$show_hidden=0)
+ * 5992:     function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)
+ * 6092:     function whereSelectFromList($field,$value)
+ * 6110:     function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
+ * 6137:     function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')
+ * 6158:     function searchWhere($sw,$searchFieldList,$searchTable='')
+ * 6191:     function exec_getQuery($table, $conf)
+ * 6209:     function getQuery($table, $conf, $returnQueryArray=FALSE)
+ * 6288:     function getWhere($table,$conf, $returnQueryArray=FALSE)
+ * 6382:     function checkPidArray($listArr)
+ * 6405:     function checkPid($uid)
  *
  *              SECTION: Frontend editing functions
- * 6423:     function editPanel($content, $conf, $currentRecord='', $dataArr=array())
- * 6588:     function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
- * 6653:     function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='')
- * 6693:     function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
- * 6720:     function editPanelPreviewBorder($table,$row,$content,$thick)
- * 6737:     function isDisabled($table,$row)
+ * 6461:     function editPanel($content, $conf, $currentRecord='', $dataArr=array())
+ * 6626:     function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
+ * 6691:     function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='')
+ * 6731:     function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
+ * 6758:     function editPanelPreviewBorder($table,$row,$content,$thick)
+ * 6775:     function isDisabled($table,$row)
  *
  *
- * 6768: class tslib_frameset
- * 6778:     function make($setup)
- * 6815:     function frameParams($setup, $typeNum)
- * 6858:     function framesetParams($setup)
+ * 6806: class tslib_frameset
+ * 6816:     function make($setup)
+ * 6853:     function frameParams($setup, $typeNum)
+ * 6896:     function framesetParams($setup)
  *
  *
- * 6891: class tslib_tableOffset
- * 6903:     function start($content,$offset)
+ * 6929: class tslib_tableOffset
+ * 6941:     function start($content,$offset)
  *
  *
- * 6981: class tslib_controlTable
- * 7016:     function start($offset,$cMargins)
+ * 7019: class tslib_controlTable
+ * 7054:     function start($offset,$cMargins)
  *
  * TOTAL FUNCTIONS: 129
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -249,11 +249,7 @@ if(t3lib_extMgm::isLoaded('obts')) {
  */
 class tslib_cObj {
        var $align = Array ('center', 'right', 'left');
-/*     var $caseConvStrings = array(
-                       '�������',
-                       '��������
-               );
-*/
+
        /**
         * Holds ImageMagick parameters and extensions used for compression
         *
@@ -607,7 +603,7 @@ class tslib_cObj {
                $w = $w ? $w : 1;
                $h = $h ? $h : 1;
                $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
-               $theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'" border="0" alt="" title="" />', $wrap);
+               $theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" />', $wrap);
 
                return $this->stdWrap($theValue,$conf['stdWrap.']);
        }
@@ -916,7 +912,7 @@ class tslib_cObj {
                                }
 
                                        // Image Object supplied:
-                               if (is_array($imgConf) || $imgConf['file']) {
+                               if (is_array($imgConf)) {
                                        if ($this->image_effects[$image_effects])       {
                                                $imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects];
                                        }
@@ -1027,15 +1023,15 @@ class tslib_cObj {
                                // draw table
                        for ($c=0;$c<$rowCount;$c++) {  // Looping through rows. If 'noRows' is set, this is '1 time', but $rowCount_temp will hold the actual number of rows!
                                if ($c && $rowspacing)  {               // If this is NOT the first time in the loop AND if space is required, a row-spacer is added. In case of "noRows" rowspacing is done further down.
-                                       $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" border="0" alt="" title="" /></td></tr>';
+                                       $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td></tr>';
                                }
                                $tablecode.='<tr>';     // starting row
                                for ($b=0; $b<$colCount_temp; $b++)     {       // Looping through the columns
                                        if ($b && $colspacing)  {               // If this is NOT the first iteration AND if column space is required. In case of "noCols", the space is done without a separate cell.
                                                if (!$noCols)   {
-                                                       $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1" border="0" alt="" title="" /></td>';
+                                                       $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td>';
                                                } else {
-                                                       $colSpacer='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($border?$colspacing-6:$colspacing).'" height="'.($imageRowsMaxHeights[$c]+($border?$borderThickness*2:0)).'" border="0" align="'.($border?'left':'top').'" alt="" title="" />';
+                                                       $colSpacer='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($border?$colspacing-6:$colspacing).'" height="'.($imageRowsMaxHeights[$c]+($border?$borderThickness*2:0)).'"'.$this->getBorderAttr(' border="0"').' align="'.($border?'left':'top').'" alt="" title="" />';
                                                        $colSpacer='<td valign="top">'.$colSpacer.'</td>';      // added 160301, needed for the new "noCols"-table...
                                                        $tablecode.=$colSpacer;
                                                }
@@ -1088,10 +1084,10 @@ class tslib_cObj {
                        $spaceBelowAbove = intval($this->stdWrap($conf['spaceBelowAbove'],$conf['spaceBelowAbove.']));
                        switch ($contentPosition)       {
                                case '0':       // above
-                                       $output= '<div align="'.$align.'">'.$tablecode.'</div>'.$this->wrapSpace($content, $spaceBelowAbove.'|0');
+                                       $output= '<div style="text-align:'.$align.';">'.$tablecode.'</div>'.$this->wrapSpace($content, $spaceBelowAbove.'|0');
                                break;
                                case '8':       // below
-                                       $output= $this->wrapSpace($content, '0|'.$spaceBelowAbove).'<div align="'.$align.'">'.$tablecode.'</div>';
+                                       $output= $this->wrapSpace($content, '0|'.$spaceBelowAbove).'<div style="text-align:'.$align.';">'.$tablecode.'</div>';
                                break;
                                case '16':      // in text
                                        $output= $tablecode.$content;
@@ -1140,39 +1136,65 @@ class tslib_cObj {
                        $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
                        $renderObjConf = $conf['renderObj.'];
 
-                       $res = $this->exec_getQuery($conf['table'],$conf['select.']);
-                       if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
-                               $GLOBALS['TT']->setTSlogMessage($error,3);
-                       } else {
-                               $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
-                               $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
-                               $cObj =t3lib_div::makeInstance('tslib_cObj');
-                               $cObj->setParent($this->data,$this->currentRecord);
-                               $this->currentRecordNumber=0;
-                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
+                       $slide = intval($conf['slide'])?intval($conf['slide']):0;
+                       $slideCollect = intval($conf['slide.']['collect'])?intval($conf['slide.']['collect']):0;
+                       $slideCollectReverse = intval($conf['slide.']['collectReverse'])?true:false;
+                       $slideCollectFuzzy = $slideCollect?(intval($conf['slide.']['collectFuzzy'])?true:false):true;
+                       $again = false;
+
+                       do {
+                               $res = $this->exec_getQuery($conf['table'],$conf['select.']);
+                               if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
+                                       $GLOBALS['TT']->setTSlogMessage($error,3);
+                               } else {
+                                       $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
+                                       $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
+                                       $cObj =t3lib_div::makeInstance('tslib_cObj');
+                                       $cObj->setParent($this->data,$this->currentRecord);
+                                       $this->currentRecordNumber=0;
+                                       $cobjValue = '';
+                                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
 
                                                // Versioning preview:
-                                       $GLOBALS['TSFE']->sys_page->versionOL($conf['table'],$row);
+                                               $GLOBALS['TSFE']->sys_page->versionOL($conf['table'],$row);
 
                                                // Language Overlay:
-                                       if ($GLOBALS['TSFE']->sys_language_contentOL)   {
+                                               if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
                                                $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL);
+                                               }
+
+                                               if (is_array($row)) { // Might be unset in the sys_language_contentOL
+                                                       if (!$GLOBALS['TSFE']->recordRegister[$conf['table'].':'.$row['uid']]) {
+                                                               $this->currentRecordNumber++;
+                                                               $cObj->parentRecordNumber = $this->currentRecordNumber;
+                                                               $GLOBALS['TSFE']->currentRecord = $conf['table'].':'.$row['uid'];
+                                                               $this->lastChanged($row['tstamp']);
+                                                               $cObj->start($row,$conf['table']);
+                                                               if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) { $cobjValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->'; }
+                                                               $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
+                                                               $cobjValue .= $tmpValue;
+                                                       }# else debug($GLOBALS['TSFE']->recordRegister,'CONTENT');
+                                               }
                                        }
 
-                                       if (is_array($row))     {       // Might be unset in the sys_language_contentOL
-                                               if (!$GLOBALS['TSFE']->recordRegister[$conf['table'].':'.$row['uid']])  {
-                                                       $this->currentRecordNumber++;
-                                                       $cObj->parentRecordNumber = $this->currentRecordNumber;
-                                                       $GLOBALS['TSFE']->currentRecord = $conf['table'].':'.$row['uid'];
-                                                       $this->lastChanged($row['tstamp']);
-                                                       $cObj->start($row,$conf['table']);
-                                                       if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries'])      { $theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->'; }
-                                                       $theValue.= $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
-                                               }# else debug($GLOBALS['TSFE']->recordRegister,'CONTENT');
+                                       if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) { $cobjValue.='<!--DMAILER_SECTION_BOUNDARY_END-->'; }
+                               }
+                               if ($slideCollectReverse) {
+                                       $theValue = $cobjValue.$theValue;
+                               } else {
+                                       $theValue .= $cobjValue;
+                               }
+                               if ($slideCollect>0) {
+                                       $slideCollect--;
+                               }
+                               if ($slide) {
+                                       if ($slide>0) {
+                                               $slide--;
                                        }
+                                       $conf['select.']['pidInList'] = $this->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']);
+                                       $again = strlen($conf['select.']['pidInList'])?true:false;
                                }
-                               if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries'])      { $theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->'; }
-                       }
+                       } while ($again&&(($slide&&!strlen($tmpValue)&&$slideCollectFuzzy)||($slide&&$slideCollect)));
                }
 
                $theValue = $this->wrap($theValue,$conf['wrap']);
@@ -1232,7 +1254,7 @@ class tslib_cObj {
                                $GLOBALS['TSFE']->sys_page->versionOL($val['table'],$row);
 
                                        // Language Overlay:
-                               if ($GLOBALS['TSFE']->sys_language_contentOL)   {
+                               if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
                                        $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($val['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL);
                                }
 
@@ -1576,6 +1598,12 @@ class tslib_cObj {
                $fieldname_hashArray = Array();
                $cc = 0;
 
+                       // Formname;
+               $formname = $GLOBALS['TSFE']->uniqueHash();
+               if (ctype_digit($formname{0}))  {       // form name must start with a letter
+                       $formname = 'a'.$formname;
+               }
+
                foreach($dataArr as $val)       {
 
                        $cc++;
@@ -1635,7 +1663,7 @@ class tslib_cObj {
 
                                        // Accessibility: Set id = fieldname attribute:
                                if ($conf['accessibility'])     {
-                                       $elementIdAttribute = ' id="'.$confData['fieldname'].'"';
+                                       $elementIdAttribute = ' id="'.$formname.'_'.md5($confData['fieldname']).'"';
                                } else {
                                        $elementIdAttribute = '';
                                }
@@ -1649,7 +1677,12 @@ class tslib_cObj {
                                                $cols = t3lib_div::intInRange($cols*$compWidth, 1, 120);
 
                                                $rows=trim($fParts[2]) ? t3lib_div::intInRange($fParts[2],1,30) : 5;
-                                               $wrap=trim($fParts[3]) ? ' wrap="'.trim($fParts[3]).'"' : ' wrap="virtual"';
+                                               $wrap=trim($fParts[3]);
+                                               if ($conf['noWrapAttr'] || $wrap === 'disabled')        {
+                                                       $wrap='';
+                                               } else {
+                                                       $wrap = $wrap ? ' wrap="'.$wrap.'"' : ' wrap="virtual"';
+                                               }
                                                $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], str_replace('\n',chr(10),trim($parts[2])));
                                                $fieldCode=sprintf('<textarea name="%s"'.$elementIdAttribute.' cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
                                                        $confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default));
@@ -1752,6 +1785,9 @@ class tslib_cObj {
                                        break;
                                        case 'hidden':
                                                $value = trim($parts[2]);
+                                               if(strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
+                                                       break;
+                                               }
                                                if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname']))     {
                                                        $value = $GLOBALS['TSFE']->codeString($value);
                                                }
@@ -1773,11 +1809,16 @@ class tslib_cObj {
                                                } else $image='';
                                                if($image)      {
                                                        $fieldCode = str_replace('<img','<input type="image"'.$addParams.' name="'.$confData['fieldname'].'"' ,$image);
-                                               } else {
+                                               } else  {
                                                        $fieldCode=sprintf('<input type="submit" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />',
                                                                $confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
                                                }
                                        break;
+                                       case 'reset':
+                                               $value=trim($parts[2]);
+                                               $fieldCode=sprintf('<input type="reset" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />',
+                                                       $confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
+                                       break;
                                        case 'label':
                                                $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
                                        break;
@@ -1822,7 +1863,7 @@ class tslib_cObj {
                                                // Field:
                                        $fieldLabel = $confData['label'];
                                        if ($conf['accessibility'])     {
-                                               $fieldLabel = '<label for="'.htmlspecialchars($confData['fieldname']).'">'.$fieldLabel.'</label>';
+                                               $fieldLabel = '<label for="'.$formname.'_'.md5($confData['fieldname']).'">'.$fieldLabel.'</label>';
                                        }
 
                                                // Getting template code:
@@ -1894,7 +1935,7 @@ class tslib_cObj {
 
                        // Recipient:
                $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']);
-               if ($theEmail)  {
+               if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'])  {
                        $theEmail = $GLOBALS['TSFE']->codeString($theEmail);
                        $hiddenfields.='<input type="hidden" name="recipient" value="'.htmlspecialchars($theEmail).'" />';
                }
@@ -1916,6 +1957,9 @@ class tslib_cObj {
                                if (substr($hF_key,-1)!='.')    {
                                        $hF_value = $this->cObjGetSingle($hF_conf,$conf['hiddenFields.'][$hF_key.'.'],'hiddenfields');
                                        if (strlen($hF_value) && t3lib_div::inList('recipient_copy,recipient',$hF_key)) {
+                                               if($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
+                                                       continue;
+                                               }
                                                $hF_value = $GLOBALS['TSFE']->codeString($hF_value);
                                        }
                                        $hiddenfields.='<input type="hidden" name="'.$hF_key.'" value="'.htmlspecialchars($hF_value).'" />';
@@ -1923,8 +1967,9 @@ class tslib_cObj {
                        }
                }
 
-                       // Formname;
-               $formname = $GLOBALS['TSFE']->uniqueHash();
+                       // Wrap all hidden fields in a div tag (see http://bugs.typo3.org/view.php?id=678)
+               $hiddenfields = '<div style="display:none;">'.$hiddenfields.'</div>';
+
                if ($conf['REQ'])       {
                        $validateForm=' onsubmit="return validateForm(\''.$formname.'\',\''.implode(',',$fieldlist).'\',\''.rawurlencode($conf['goodMess']).'\',\''.rawurlencode($conf['badMess']).'\',\''.rawurlencode($conf['emailMess']).'\')"';
                        $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>';
@@ -2090,6 +2135,7 @@ class tslib_cObj {
                                $cObj->setParent($this->data,$this->currentRecord);
                                $renderCode='';
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($search->result))   {
+                                               // versionOL() here? This is search result displays, is that possible to preview anyway? Or are records selected here already future versions?
                                        $cObj->start($row);
                                        $renderCode.=$cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'],'renderObj');
                                }
@@ -2399,6 +2445,36 @@ class tslib_cObj {
         ************************************/
 
        /**
+        * Returns all parents of the given PID (Page UID) list
+        *
+        * @param       string          A list of page Content-Element PIDs (Page UIDs) / stdWrap
+        * @param       array           stdWrap array for the list
+        * @return      string          A list of PIDs
+        * @access private
+        */
+       function getSlidePids($pidList, $pidConf)       {
+               $pidList = trim($this->stdWrap($pidList,$pidConf));
+               if (!strcmp($pidList,''))       {
+                       $pidList = 'this';
+               }
+               if (trim($pidList))     {
+                       $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$pidList));
+                       $listArr = $this->checkPidArray($listArr);
+               }
+               $pidList = array();
+               if (is_array($listArr)&&count($listArr))        {
+                       foreach ($listArr as $uid)      {
+                               $page = $GLOBALS['TSFE']->sys_page->getPage($uid);
+                               if (!$page['is_siteroot'])      {
+                                       $pidList[] = $page['pid'];
+                               }
+                       }
+               }
+               return implode(',', $pidList);
+       }
+
+
+       /**
         * Creates a link to a netprint application on another website (where the "netprint" extension is running")
         * Related to the extension "netprint"
         *
@@ -2480,7 +2556,7 @@ class tslib_cObj {
                        }
                        $altParam = $this->getAltParam($conf);
 
-                       $theValue = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.t3lib_div::rawUrlEncodeFP($info[3])).'" width="'.$info[0].'" height="'.$info[1].'"  border="'.intval($conf['border']).'"'.($conf['params']?' '.$conf['params']:'').($altParam).' />';
+                       $theValue = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.t3lib_div::rawUrlEncodeFP($info[3])).'" width="'.$info[0].'" height="'.$info[1].'"'.$this->getBorderAttr(' border="'.intval($conf['border']).'"').($conf['params']?' '.$conf['params']:'').($altParam).' />';
                        if ($conf['linkWrap'])  {
                                $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
                        } elseif ($conf['imageLinkWrap']) {
@@ -2489,6 +2565,17 @@ class tslib_cObj {
                        return $this->wrap($theValue,$conf['wrap']);
                }
        }
+       /**
+        * Returns the 'border' attribute for an <img> tag only if the doctype is not xhtml_strict,xhtml_11 or xhtml_2 or if the config parameter 'disableImgBorderAttr' is not set.
+        *
+        * @param       string          the border attribute
+        * @return      string          the border attribute
+        */
+       function getBorderAttr($borderAttr) {
+               if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->config['config']['doctype']) || !$GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
+                       return $borderAttr;
+               }
+       }
 
        /**
         * Wraps the input string in link-tags that opens the image in a new window.
@@ -2572,7 +2659,7 @@ class tslib_cObj {
                        if (t3lib_div::inList('jpg,gif,jpeg,png',$fileinfo['fileext'])) {
                                $imgFile = $incFile;
                                $imgInfo = @getImageSize($imgFile);
-                               return '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgFile.'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'" border="0" '.$addParams.' />';
+                               return '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgFile.'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'"'.$this->getBorderAttr(' border="0"').' '.$addParams.' />';
                        } elseif (filesize($incFile)<1024*1024) {
                                return $GLOBALS['TSFE']->tmpl->fileContent($incFile);
                        }
@@ -3014,10 +3101,14 @@ class tslib_cObj {
                                $content=$this->listNum($content,$listNumber,$conf['listNum.']['splitChar']);
                        }
 
-                       if ($conf['trim']){$content=trim($content);}
+                       if ($conf['trim'])      { $content=trim($content); }
+
+                               // Call stdWrap recursively
+                       if ($conf['stdWrap'])   { $content=$this->stdWrap($content,$conf['stdWrap.']); }
+
                        if (   ($conf['required'] && (string)$content=='') || ($conf['if.'] && !$this->checkIf($conf['if.'])) || ($conf['fieldRequired'] && !trim($this->data[$conf['fieldRequired']]))    ){
                                $content = '';
-                       } else {
+                       } else  {
                                        // Perform data processing:
                                if ($conf['csConv'])    { $content=$GLOBALS['TSFE']->csConv($content,$conf['csConv']); }
                                if ($conf['parseFunc.'] || $conf['parseFunc']) {$content=$this->parseFunc($content,$conf['parseFunc.'],$conf['parseFunc']);}
@@ -3067,7 +3158,7 @@ class tslib_cObj {
 
                                if ($conf['wrapAlign'] || $conf['wrapAlign.']){
                                        $wrapAlign = trim($this->stdWrap($conf['wrapAlign'], $conf['wrapAlign.']));
-                                       if ($wrapAlign) {$content=$this->wrap($content, '<div align="'.$wrapAlign.'">|</div>');}
+                                       if ($wrapAlign) {$content=$this->wrap($content, '<div style="text-align:'.$wrapAlign.';">|</div>');}
                                }
                                if ($conf['typolink.']){$content=$this->typolink($content, $conf['typolink.']);}
 
@@ -3471,7 +3562,7 @@ class tslib_cObj {
         * @param       array           TypoScript configuration.
         * @return      string          Return string
         * @author      Thomas Bley (all from moregroupware cvs code / readmessage.inc.php, published under gpl by Thomas)
-        * @author      Kasper Sk�hj
+        * @author      Kasper Skaarhoj
         */
        function removeBadHTML($text, $conf)    {
 
@@ -3569,7 +3660,7 @@ class tslib_cObj {
                        $theValue=$this->wrap($theValue, $fontWrap);
                }
                        // align
-               if ($align)     {$theValue=$this->wrap($theValue, '<div align="'.$align.'">|</div>');}
+               if ($align)     {$theValue=$this->wrap($theValue, '<div style="text-align:'.$align.';">|</div>');}
                        // return
                return $theValue;
        }
@@ -3693,14 +3784,16 @@ class tslib_cObj {
                                                $icon = $this->cObjGetSingle($conf['iconCObject'],$conf['iconCObject.'],'iconCObject');
                                        } else {
                                                if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])   {
-                                                       $icon = 't3lib/thumbs.php?&dummy='.$GLOBALS['EXEC_TIME'].'&file='.rawurlencode('../'.$theFile);
+                                                       $thumbSize = '';
+                                                       if ($conf['icon_thumbSize'] || $conf['icon_thumbSize.'])        { $thumbSize = '&size='.$this->stdWrap($conf['icon_thumbSize'], $conf['icon_thumbSize.']); }
+                                                       $icon = 't3lib/thumbs.php?&dummy='.$GLOBALS['EXEC_TIME'].'&file='.rawurlencode('../'.$theFile).$thumbSize;
                                                } else {
                                                        $icon = 't3lib/gfx/notfound_thumb.gif';
                                                }
-                                               $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'" border="0"'.$this->getAltParam($conf).' />';
+                                               $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'"'.$this->getBorderAttr(' border="0"').''.$this->getAltParam($conf).' />';
                                        }
                                } else {
-                                       $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'" width="18" height="16" border="0"'.$this->getAltParam($conf).' />';
+                                       $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'" width="18" height="16"'.$this->getBorderAttr(' border="0"').''.$this->getAltParam($conf).' />';
                                }
                                if ($conf['icon_link']) {$icon = $this->wrap($icon, $theLinkWrap);}
                                $icon = $this->stdWrap($icon,$conf['icon.']);
@@ -4349,18 +4442,9 @@ class tslib_cObj {
                                $parts[0] = substr($textpieces[$i],0,$len);
                                $parts[1] = substr($textpieces[$i],$len);
                                $linktxt = ereg_replace('\?.*','',$parts[0]);
-                               if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable'])      {
-                                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses)        {
-                                               $mailToUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail('mailto:'.$parts[0])."');";
-                                               $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
-                                               $linktxt = str_replace('@',$atLabel ? $atLabel : '(at)', $linktxt);
-                                       } else {
-                                               $mailToUrl = 'mailto:'.$parts[0];
-                                       }
-                                       $res = '<a href="'.htmlspecialchars($mailToUrl).'"'.$aTagParams.'>';
-                               } else {
-                                       $res = '<a href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('mailto:'.$parts[0]).$GLOBALS['TSFE']->getMethodUrlIdToken).'"'.$aTagParams.'>';
-                               }
+                               list($mailToUrl,$linktxt) = $this->getMailTo($parts[0],$linktxt,$initP);
+                               $mailToUrl = $GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii'?$mailToUrl:htmlspecialchars($mailToUrl);
+                               $res = '<a href="'.$mailToUrl.'"'.$aTagParams.'>';
                                if ($conf['ATagBeforeWrap'])    {
                                        $res= $res.$this->wrap($linktxt, $conf['wrap']).'</a>';
                                } else {
@@ -4424,6 +4508,11 @@ class tslib_cObj {
                                                if (!isset($GLOBALS['TSFE']->tmpl->fileCache[$hash]))   {
                                                        $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
                                                        $gifCreator->init();
+
+                                                       if ($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix'])     {
+                                                               $gifCreator->filenamePrefix = $GLOBALS['TSFE']->fileNameASCIIPrefix(ereg_replace('\.[[:alnum:]]+$','',basename($theImage)),intval($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']),'_');
+                                                       }
+
                                                        if ($fileArray['sample'])       {
                                                                $gifCreator->scalecmd = '-sample';
                                                                $GLOBALS['TT']->setTSlogMessage('Sample option: Images are scaled with -sample.');
@@ -4667,6 +4756,9 @@ class tslib_cObj {
                                        case 'lll':
                                                $retVal = $GLOBALS['TSFE']->sL('LLL:'.$key);
                                        break;
+                                       case 'path':
+                                               $retVal = $GLOBALS['TSFE']->tmpl->getFileName($key);
+                                       break;
                                        case 'cobj':
                                                switch((string)$key)    {
                                                        case 'parentRecordNumber':
@@ -4721,7 +4813,7 @@ class tslib_cObj {
         * Example: $var = "HTTP_SERVER_VARS | something" will return the value $GLOBALS['HTTP_SERVER_VARS']['something'] value
         *
         * @param       string          Key, see description of functon
-        * @param       array           If you want another array that $GLOBALS used, then just put it in here!
+        * @param       array           If you want another array than $GLOBALS used, then just put it in here!
         * @return      mixed           Value from $GLOBALS
         * @access private
         * @see getData()
@@ -4849,17 +4941,7 @@ class tslib_cObj {
                                // Detecting kind of link:
                        if(strstr($link_param,'@') && !$pU['scheme'])   {               // If it's a mail address:
                                $link_param = eregi_replace('^mailto:','',$link_param);
-                               if ($linktxt=='') $linktxt = $link_param;
-                               if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable'])      {
-                                       $this->lastTypoLinkUrl = 'mailto:'.$link_param;
-                                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses)        {
-                                               $this->lastTypoLinkUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail($this->lastTypoLinkUrl)."');";
-                                               $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
-                                               $linktxt=str_replace('@',$atLabel?$atLabel:'(at)',$linktxt);
-                                       }
-                               } else {
-                                       $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('mailto:'.$link_param).$GLOBALS['TSFE']->getMethodUrlIdToken;
-                               }
+                               list($this->lastTypoLinkUrl,$linktxt) = $this->getMailTo($link_param,$linktxt,$initP);
                                $finalTagParts['url']=$this->lastTypoLinkUrl;
                                $finalTagParts['TYPE']='mailto';
                        } else {
@@ -4911,7 +4993,7 @@ class tslib_cObj {
                                                $GLOBALS['TT']->setTSlogMessage("typolink(): File '".$splitLinkParam[0]."' did not exist, so '".$linktxt."' was not linked.",1);
                                                return $linktxt;
                                        }
-                               } else {        // integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to tables.php!!)
+                               } else {        // integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to definition in $TCA!)
                                        if ($conf['no_cache.']) $conf['no_cache']=$this->stdWrap($conf['no_cache'], $conf['no_cache.']);
                                        $link_params_parts=explode('#',$link_param);
                                        $link_param = trim($link_params_parts[0]);              // Link-data del
@@ -4932,7 +5014,9 @@ class tslib_cObj {
                                        }
 
                                                // Looking up the page record to verify its existence:
-                                       $page = $GLOBALS['TSFE']->sys_page->getPage($link_param);
+                                       $disableGroupAccessCheck = $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] ? TRUE : FALSE;
+                                       $page = $GLOBALS['TSFE']->sys_page->getPage($link_param,$disableGroupAccessCheck);
+
                                        if (count($page))       {
                                                        // This checks if the linked id is in the rootline of this site and if not it will find the domain for that ID and prefix it:
                                                $tCR_domain='';
@@ -4947,7 +5031,7 @@ class tslib_cObj {
                                                        }
                                                        if (!$tCR_flag) {
                                                                foreach($tCR_rootline as $tCR_data)     {
-                                                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_domain', 'pid='.intval($tCR_data['uid']).' AND redirectTo=""'.$this->enableFields('sys_domain'), '', 'sorting');
+                                                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_domain', 'pid='.intval($tCR_data['uid']).' AND redirectTo=\'\''.$this->enableFields('sys_domain'), '', 'sorting');
                                                                        if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                                                                $tCR_domain = ereg_replace('\/$','',$row['domainName']);
                                                                                break;
@@ -4964,7 +5048,7 @@ class tslib_cObj {
                                                        // Look for overlay Mount Point:
                                                $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($page['uid'], $page);
                                                if (is_array($mount_info) && $mount_info['overlay'])    {
-                                                       $page = $GLOBALS['TSFE']->sys_page->getPage($mount_info['mount_pid']);
+                                                       $page = $GLOBALS['TSFE']->sys_page->getPage($mount_info['mount_pid'],$disableGroupAccessCheck);
                                                        if (!count($page))      {
                                                                $GLOBALS['TT']->setTSlogMessage("typolink(): Mount point '".$mount_info['mount_pid']."' was not available, so '".$linktxt."' was not linked.",1);
                                                                return $linktxt;
@@ -4976,11 +5060,12 @@ class tslib_cObj {
                                                if ($linktxt=='') $linktxt = $page['title'];
 
                                                        // Query Params:
-                                               $addQueryParams = trim($this->stdWrap($conf['additionalParams'],$conf['additionalParams.']));
+                                               $addQueryParams = $conf['addQueryString'] ? '&'.t3lib_div::getIndpEnv('QUERY_STRING') : '';
+                                               $addQueryParams .= trim($this->stdWrap($conf['additionalParams'],$conf['additionalParams.']));
                                                if (substr($addQueryParams,0,1)!='&')           {
                                                        $addQueryParams = '';
                                                } elseif ($conf['useCacheHash']) {      // cache hashing:
-                                                       $pA = $GLOBALS['TSFE']->cHashParams($addQueryParams.$GLOBALS['TSFE']->linkVars);        // Added '.$this->linkVars' dec 2003: The need for adding the linkVars is that they will be included in the link, but not the cHash. Thus the linkVars will always be the problem that prevents the cHash from working. I cannot see what negative implications in terms of incompatibilities this could bring, but for now I hope there are none. So here we go... (- kasper)
+                                                       $pA = t3lib_div::cHashParams($addQueryParams.$GLOBALS['TSFE']->linkVars);       // Added '.$this->linkVars' dec 2003: The need for adding the linkVars is that they will be included in the link, but not the cHash. Thus the linkVars will always be the problem that prevents the cHash from working. I cannot see what negative implications in terms of incompatibilities this could bring, but for now I hope there are none. So here we go... (- kasper)
                                                        $addQueryParams.= '&cHash='.t3lib_div::shortMD5(serialize($pA));
                                                }
                                                        // Add "&MP" var:
@@ -5016,6 +5101,20 @@ class tslib_cObj {
                                                                }
                                                        }
                                                }
+
+                                                       // If link is to a access restricted page which should be redirected, then find new URL:
+                                               if ($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] &&
+                                                               $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']!=='NONE' &&
+                                                               !$GLOBALS['TSFE']->checkPageGroupAccess($page)) {
+                                                                       $thePage = $GLOBALS['TSFE']->sys_page->getPage($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']);
+
+                                                                       $addParams = $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages_addParams'];
+                                                                       $addParams = str_replace('###RETURN_URL###',rawurlencode($this->lastTypoLinkUrl),$addParams);
+                                                                       $addParams = str_replace('###PAGE_ID###',$page['uid'],$addParams);
+                                                                       $LD = $GLOBALS['TSFE']->tmpl->linkData($thePage,$target,'','','',$addParams,$theTypeP);
+                                                                       $this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'');
+                                               }
+
                                                        // Rendering the tag.
                                                $finalTagParts['url']=$this->lastTypoLinkUrl;
                                                $finalTagParts['targetParams']=$targetPart;
@@ -5031,7 +5130,11 @@ class tslib_cObj {
                                $onClick="vHWin=window.open('".$GLOBALS['TSFE']->baseUrlWrap($finalTagParts['url'])."','FEopenLink','".$JSwindowParams."');vHWin.focus();return false;";
                                $res = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
                        } else {
-                               $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                               if ($GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii' && $finalTagParts['TYPE'] === 'mailto') {
+                                       $res = '<a href="'.$finalTagParts['url'].'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                               } else {
+                                       $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
+                               }
                        }
 
                                // Call user function:
@@ -5097,10 +5200,7 @@ class tslib_cObj {
                }
                if (is_array($urlParameters))   {
                        if (count($urlParameters))      {
-                               reset($urlParameters);
-                               while(list($k,$v)=each($urlParameters)) {
-                                       $conf['additionalParams'].='&'.$k.'='.rawurlencode($v);
-                               }
+                               $conf['additionalParams'].= t3lib_div::implodeArrayForUrl('',$urlParameters);
                        }
                } else {
                        $conf['additionalParams'].=$urlParameters;
@@ -5196,7 +5296,43 @@ class tslib_cObj {
                return !$raw  ? ($MP ? '&MP='.rawurlencode($MP) : '') : $MP;
        }
 
+       /**
+        * Creates a href attibute for given $mailAddress.
+        * The function uses spamProtectEmailAddresses and Jumpurl functionality for encoding the mailto statement.
+        * If spamProtectEmailAddresses is disabled, it'll just return a string like "mailto:user@example.tld".
+        *
+        * @param       string          Email address
+        * @param       string          $initP: Initial link parameters, only used if Jumpurl functionality is enabled. Example: ?id=5&type=0
+        * @return      string          Returns a numerical array with two elements: 1) $mailToUrl, string ready to be inserted into the href attribute of the <a> tag, b) $linktxt: The string between starting and ending <a> tag.
+        */
+       function getMailTo($mailAddress,$linktxt,$initP='?') {
+               if(!strcmp($linktxt,''))        { $linktxt = $mailAddress; }
 
+               $mailToUrl = 'mailto:'.$mailAddress;
+
+               if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable']) {
+                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses) {
+                               if ($GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii')    {
+                                       $mailToUrl = $GLOBALS['TSFE']->encryptEmail($mailToUrl);
+                               } else {
+                                       $mailToUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail($mailToUrl)."');";
+                               }
+                               if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']) {
+                                       $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
+                               }
+                               $linktxt = str_replace('@',$atLabel?$atLabel:'(at)',$linktxt);
+
+                               if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']) {
+                                       $lastDotLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']);
+                                       $lastDotLabel = $lastDotLabel ? $lastDotLabel : '(dot)';
+                                       $linktxt = preg_replace('/\.([^\.]+)$/', $lastDotLabel.'$1', $linktxt);
+                               }
+                       }
+               } else {
+                       $mailToUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($mailToUrl).$GLOBALS['TSFE']->getMethodUrlIdToken;
+               }
+               return array($mailToUrl,$linktxt);
+       }
 
 
 
@@ -5269,10 +5405,10 @@ class tslib_cObj {
                        $wrapBefore = intval($wrapArray[0]);
                        $wrapAfter = intval($wrapArray[1]);
                        if ($wrapBefore)        {
-                               $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapBefore.'" border="0" class="spacer-gif" alt="" title="" /><br />'.$result;
+                               $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapBefore.'"'.$this->getBorderAttr(' border="0"').' class="spacer-gif" alt="" title="" /><br />'.$result;
                        }
                        if ($wrapAfter) {
-                               $result.='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapAfter.'" border="0" class="spacer-gif" alt="" title="" /><br />';
+                               $result.='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapAfter.'"'.$this->getBorderAttr(' border="0"').' class="spacer-gif" alt="" title="" /><br />';
                        }
                }
                return $result;
@@ -5911,7 +6047,7 @@ class tslib_cObj {
                if (count($OR_arr))     {
                        $whereDef=' AND ('.implode(' OR ',$OR_arr).')';
                        if ($GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'])   {
-                               $whereDef.=' AND NOT '.$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'];
+                               $whereDef.=' AND '.$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'].'=0';
                        }
                }
                return $whereDef;
@@ -5924,7 +6060,7 @@ class tslib_cObj {
         *
         * @param       string          The table for which to get the where clause
         * @param       boolean         If set, then you want NOT to filter out hidden records. Otherwise hidden record are filtered based on the current preview settings.
-        * @return      string          The part of the where clause on the form " AND NOT [fieldname] AND ...". Eg. " AND NOT hidden AND starttime < 123345567"
+        * @return      string          The part of the where clause on the form " AND [fieldname]=0 AND ...". Eg. " AND hidden=0 AND starttime < 123345567"
         * @see t3lib_pageSelect::enableFields()
         */
        function enableFields($table,$show_hidden=0)    {
@@ -5954,7 +6090,7 @@ class tslib_cObj {
        function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)       {
 
                        // Init vars:
-               $allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol'.$addSelectFields;
+               $allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state'.$addSelectFields;
                $depth = intval($depth);
                $begin = intval($begin);
                $id = intval($id);
@@ -5991,37 +6127,43 @@ class tslib_cObj {
 
                                // Select sublevel:
                        if ($depth>0)   {
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND NOT deleted AND doktype!=255 AND doktype!=6'.$moreWhereClauses, '' ,'sorting');
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND deleted=0'.$moreWhereClauses, '' ,'sorting');
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
-#??                            $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
+                                       $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
 
-                                               // Find mount point if any:
-                                       $next_id = $row['uid'];
-                                       $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
-                                               // Overlay mode:
-                                       if (is_array($mount_info) && $mount_info['overlay'])    {
-                                               $next_id = $mount_info['mount_pid'];
-                                               $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND NOT deleted AND doktype!=255 AND doktype!=6'.$moreWhereClauses, '' ,'sorting');
-                                               $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
-#??                                            $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
-                                       }
-                                               // Add record:
-                                       if (is_array($row) && $dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row))       {
-                                                       // Add ID to list:
-                                               if ($begin<=0)  {
-                                                       if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row))        {
-                                                               $theList.= $next_id.',';
-                                                       }
+                                       if ($row['doktype']==255 || $row['doktype']==6 || $row['t3ver_state']==1)       { unset($row); }        // Doing this after the overlay to make sure changes in the overlay are respected.
+
+                                       if (is_array($row))     {
+                                                       // Find mount point if any:
+                                               $next_id = $row['uid'];
+                                               $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
+                                                       // Overlay mode:
+                                               if (is_array($mount_info) && $mount_info['overlay'])    {
+                                                       $next_id = $mount_info['mount_pid'];
+                                                       $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND deleted=0'.$moreWhereClauses, '' ,'sorting');
+                                                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
+                                                       $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
+
+                                                       if ($row['doktype']==255 || $row['doktype']==6 || $row['t3ver_state']==1)       { unset($row); }        // Doing this after the overlay to make sure changes in the overlay are respected.
                                                }
-                                                       // Next level:
-                                               if ($depth>1 && !$row['php_tree_stop']) {
-                                                               // Normal mode:
-                                                       if (is_array($mount_info) && !$mount_info['overlay'])   {
-                                                               $next_id = $mount_info['mount_pid'];
+                                                       // Add record:
+                                               if (is_array($row) && ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row)))     {
+                                                               // Add ID to list:
+                                                       if ($begin<=0)  {
+                                                               if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row))        {
+                                                                       $theList.= $next_id.',';
+                                                               }
                                                        }
-                                                               // Call recursively, if the id is not in prevID_array:
-                                                       if (!in_array($next_id,$prevId_array))  {
-                                                               $theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
+                                                               // Next level:
+                                                       if ($depth>1 && !$row['php_tree_stop']) {
+                                                                       // Normal mode:
+                                                               if (is_array($mount_info) && !$mount_info['overlay'])   {
+                                                                       $next_id = $mount_info['mount_pid'];
+                                                               }
+                                                                       // Call recursively, if the id is not in prevID_array:
+                                                               if (!in_array($next_id,$prevId_array))  {
+                                                                       $theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
+                                                               }
                                                        }
                                                }
                                        }
@@ -6056,7 +6198,7 @@ class tslib_cObj {
        }
 
        /**
-        * Executes a SELECT query for joining three tables according the the MM-relation standards used for tables configured in $TCA. That means MM-joins where the join table has the fields "uid_local" and "uid_foreign"
+        * Executes a SELECT query for joining three tables according to the MM-relation standards used for tables configured in $TCA. That means MM-joins where the join table has the fields "uid_local" and "uid_foreign"
         *
         * @param       string          List of fields to select
         * @param       string          The local table
@@ -6082,7 +6224,7 @@ class tslib_cObj {
        }
 
        /**
-        * Executes a SELECT query for joining two tables according the the MM-relation standards used for tables configured in $TCA. That means MM-joins where the join table has the fields "uid_local" and "uid_foreign"
+        * Executes a SELECT query for joining two tables according to the MM-relation standards used for tables configured in $TCA. That means MM-joins where the join table has the fields "uid_local" and "uid_foreign"
         * The two tables joined is the join table ($mm_table) and the foreign table ($foreign_table) - so the "local table" is not included but instead you can supply a list of UID integers from the local table to match in the join-table.
         *
         * @param       string          List of fields to select
@@ -6130,7 +6272,7 @@ class tslib_cObj {
                                if (strlen($val)>=2)    {
                                        reset($searchFields);
                                        while(list(,$field)=each($searchFields))        {
-                                               $where_p[]=$prefixTableName.$field.' LIKE "%'.$GLOBALS['TYPO3_DB']->quoteStr($val, $searchTable).'%"';
+                                               $where_p[] = $prefixTableName.$field.' LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($val, $searchTable).'%\'';
                                        }
                                }
                                if (count($where_p))    {
@@ -6276,7 +6418,7 @@ class tslib_cObj {
                                // removes all pages which are not visible for the user!
                        $listArr = $this->checkPidArray($listArr);
                        if (count($listArr))    {
-                           $query.=' AND '.$table.'.pid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')';
+                               $query.=' AND '.$table.'.pid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')';
                                $pid_uid_flag++;
                        } else {
                                $pid_uid_flag=0;                // If not uid and not pid then uid is set to 0 - which results in nothing!!
@@ -6306,7 +6448,8 @@ class tslib_cObj {
 
                        // enablefields
                if ($table=='pages')    {
-                       $query.=' '.$GLOBALS['TSFE']->sys_page->where_hid_del;
+                       $query.=' '.$GLOBALS['TSFE']->sys_page->where_hid_del.
+                                               $GLOBALS['TSFE']->sys_page->where_groupAccess;
                } else {
                        $query.=$this->enableFields($table);
                }
@@ -6560,13 +6703,19 @@ class tslib_cObj {
                                                                                </tr>
                                                                        </table>
                                                                </form>';
+                                               // wrap the panel
+                                       if ($conf['innerWrap']) $panel = $this->wrap($panel,$conf['innerWrap']);
+                                       if ($conf['innerWrap.']) $panel = $this->stdWrap($panel,$conf['innerWrap.']);
                                                // add black line:
                                        $panel.=$blackLine;
+                                               // wrap the complete panel
+                                       if ($conf['outerWrap']) $panel = $this->wrap($panel,$conf['outerWrap']);
+                                       if ($conf['outerWrap.']) $panel = $this->stdWrap($panel,$conf['outerWrap.']);
                                        $finalOut = $content.$panel;
                                break;
                        }
 
-                       if ($conf['previewBorder']) $finalOut = $this->editPanelPreviewBorder($table,$dataArr,$finalOut,$conf['previewBorder']);
+                       if ($conf['previewBorder']) $finalOut = $this->editPanelPreviewBorder($table,$dataArr,$finalOut,$conf['previewBorder'],$conf['previewBorder.']);
                        return $finalOut;
                } else {
                        return $content;
@@ -6713,14 +6862,20 @@ class tslib_cObj {
         * @param       array           The data record from $table
         * @param       string          The content string to wrap
         * @param       integer         The thickness of the border
+        * @param       array           The array with TypoScript properties for the content object
         * @return      string          The input string wrapped in a table with a border color of #cccccc and thickness = $thick
         * @access private
         * @see editPanel()
         */
-       function editPanelPreviewBorder($table,$row,$content,$thick)    {
-               $thick = t3lib_div::intInRange($thick,1,100);
+       function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array())      {
                if ($this->isDisabled($table,$row))     {
-                       $content='<table border="'.$thick.'" cellpadding="0" cellspacing="0" bordercolor="#cccccc" width="100%"><tr><td>'.$content.'</td></tr></table>';
+                       $thick = t3lib_div::intInRange($thick,1,100);
+                       $color = $conf['color'] ? $conf['color'] : '#cccccc';
+                       if ($conf['innerWrap']) $content = $this->wrap($content,$conf['innerWrap']);
+                       if ($conf['innerWrap.'])        $content = $this->stdWrap($content,$conf['innerWrap.']);
+                       $content='<table class="typo3-editPanel-previewBorder" border="'.$thick.'" cellpadding="0" cellspacing="0" bordercolor="'.$color.'" width="100%"><tr><td>'.$content.'</td></tr></table>';
+                       if ($conf['outerWrap']) $content = $this->wrap($content,$conf['outerWrap']);
+                       if ($conf['outerWrap.'])        $content = $this->stdWrap($panel,$conf['outerWrap.']);
                }
                return $content;
        }
@@ -6999,7 +7154,7 @@ class tslib_controlTable  {
        var $cMt = 0;           // content margin, top
        var $cMb = 1;           // content margin, bottom
 
-       var $contentW = 0;      // s�ter en lille gif-spacer nedest i content-framen
+       var $contentW = 0;      // Places a little gif-spacer in the bottom of the content frame
 
        var $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
 
@@ -7032,7 +7187,7 @@ class tslib_controlTable  {
                if ($this->bm) $rows++;
                if ($this->content) $rows++;
                if ($this->contentW) $rows++;
-               if (!$rows && $cols) $rows=1;           // hvis der slet ingen r�ker er sat i midten men der trods alt er nogle kolonner
+               if (!$rows && $cols) $rows=1;           // If there are no rows in the middle but still som columns...
 
                if ($rows&&$cols)       {
                        $res = chr(10).'<table '.$this->tableParams.'>';
@@ -7059,12 +7214,12 @@ class tslib_controlTable        {
                        if ($this->contentW)    {       $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$this->contentW.'" alt="" title="" /></td>';}
                        if (isset($middle[0]))  {$res.=$middle[0];}
 
-                               // venstre for content
+                               // Left of content
                        if ($cMargArr[2])       {       $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$cMargArr[2].'" alt="" title="" /></td>';             }
                        if ($this->rm)  {       $res.='<td'.$rowspan.' '.$this->rmTDparams.'>'.$this->rm.'</td>';               }
                        $res.= '</tr>';
 
-                               // flere end de 2 r�ker
+                               // More than the two rows
                        $mCount = count($middle);
                        for($a=1;$a<$mCount;$a++)       {
                                $res.='<tr>'.$middle[$a].'</tr>';