[BUGFIX] Regression: filelistFolderTree constructor is recursive
[Packages/TYPO3.CMS.git] / typo3 / template.php
index 8080cf5..c3e0f25 100644 (file)
  *
  * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *  145: function fw($str)
- *
- *
- *  169: class template
- *  224:     function template()
- *
- *              SECTION: EVALUATION FUNCTIONS
- *  298:     function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE)
- *  315:     function viewPageIcon($id,$backPath,$addParams='hspace="3"')
- *  341:     function issueCommand($params,$rUrl='')
- *  356:     function isCMlayers()
- *  366:     function thisBlur()
- *  376:     function helpStyle()
- *  393:     function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))
- *  419:     function getFileheader($title,$path,$iconfile)
- *  434:     function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")
- *  467:     function makeShortcutUrl($gvList,$setList)
- *  488:     function formWidth($size=48,$textarea=0,$styleOverride='')
- *  513:     function formWidthText($size=48,$styleOverride='',$wrap='')
- *  530:     function redirectUrls($thisLocation='')
- *  554:     function formatTime($tstamp,$type)
- *  571:     function parseTime()
- *
- *              SECTION: PAGE BUILDING FUNCTIONS.
- *  604:     function startPage($title)
- *  686:     function endPage()
- *  720:     function header($text)
- *  741:     function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE)
- *  765:     function divider($dist)
- *  781:     function spacer($dist)
- *  800:     function sectionHeader($label,$sH=FALSE,$addAttrib='')
- *  817:     function sectionBegin()
- *  838:     function sectionEnd()
- *  858:     function middle()
- *  867:     function endPageJS()
- *  884:     function docBodyTagBegin()
- *  894:     function docStyle()
- *  936:     function insertStylesAndJS($content)
- *  956:     function initCharset()
- *  968:     function generator()
- *
- *              SECTION: OTHER ELEMENTS
- * 1001:     function icons($type, $styleAttribValue='')
- * 1030:     function t3Button($onClick,$label)
- * 1041:     function dfw($string)
- * 1051:     function rfw($string)
- * 1061:     function wrapInCData($string)
- * 1078:     function wrapScriptTags($string, $linebreak=TRUE)
- * 1117:     function table($arr, $layout='')
- * 1159:     function menuTable($arr1,$arr2=array(), $arr3=array())
- * 1192:     function funcMenu($content,$menu)
- * 1210:     function clearCacheMenu($id,$addSaveOptions=0)
- * 1246:     function getContextMenuCode()
- * 1251:     function showClickmenu(table, uid, listFr, enDisItems, backPath, addParams)
- * 1280:     function showClickmenu_noajax(url)
- * 1287:     function showClickmenu_ajax(t3ajax)
- * 1472:     function getDragDropCode($table)
- * 1483:     function cancelDragEvent(event)
- * 1496:     function mouseMoveEvent (event)
- * 1509:     function dragElement(id,elementID)
- * 1528:     function dropElement(id)
- * 1577:     function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')
- * 1607:     function getTabMenuRaw($menuItems)
- * 1676:     function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1)
- * 1801:     function getDynTabMenuJScode()
- * 1892:     function getVersionSelector($id,$noAction=FALSE)
- *
- *
- * 2060: class bigDoc extends template
- *
- *
- * 2069: class noDoc extends template
- *
- *
- * 2078: class smallDoc extends template
- *
- *
- * 2087: class mediumDoc extends template
- *
- * TOTAL FUNCTIONS: 57
- * (This index is automatically created/updated by the extension "extdeveval")
- *
- */
 
 
 
@@ -168,7 +82,7 @@ class template {
        var $endJS=1;                                   // If set, then a JavaScript section will be outputted in the bottom of page which will try and update the top.busy session expiry object.
 
                // TYPO3 Colorscheme.
-               // If you want to change this, please do so through a skin using the global var $TBE_STYLES
+               // If you want to change this, please do so through a skin using the global var $GLOBALS['TBE_STYLES']
        var $bgColor = '#F7F3EF';               // Light background color
        var $bgColor2 = '#9BA1A8';              // Steel-blue
        var $bgColor3 = '#F6F2E6';              // dok.color
@@ -241,13 +155,11 @@ class template {
 
        /**
         * Constructor
-        * Imports relevant parts from global $TBE_STYLES (colorscheme)
+        * Imports relevant parts from global $GLOBALS['TBE_STYLES'] (colorscheme)
         *
         * @return      void
         */
-       function template()     {
-               global $TBE_STYLES;
-
+       function __construct()  {
                        // Initializes the page rendering object:
                $this->getPageRenderer();
 
@@ -264,27 +176,27 @@ class template {
                $this->bodyTagId = preg_replace('/[^A-Za-z0-9-]/','-',$this->scriptID);
 
                        // Individual configuration per script? If so, make a recursive merge of the arrays:
-               if (is_array($TBE_STYLES['scriptIDindex'][$this->scriptID]))    {
-                       $ovr = $TBE_STYLES['scriptIDindex'][$this->scriptID];           // Make copy
-                       $TBE_STYLES = t3lib_div::array_merge_recursive_overrule($TBE_STYLES,$ovr);              // merge styles.
-                       unset($TBE_STYLES['scriptIDindex'][$this->scriptID]);   // Have to unset - otherwise the second instantiation will do it again!
+               if (is_array($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID])) {
+                       $ovr = $GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID];                // Make copy
+                       $GLOBALS['TBE_STYLES'] = t3lib_div::array_merge_recursive_overrule($GLOBALS['TBE_STYLES'],$ovr);                // merge styles.
+                       unset($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID]);        // Have to unset - otherwise the second instantiation will do it again!
                }
 
                        // Color scheme:
-               if ($TBE_STYLES['mainColors']['bgColor'])       $this->bgColor=$TBE_STYLES['mainColors']['bgColor'];
-               if ($TBE_STYLES['mainColors']['bgColor1'])      $this->bgColor1=$TBE_STYLES['mainColors']['bgColor1'];
-               if ($TBE_STYLES['mainColors']['bgColor2'])      $this->bgColor2=$TBE_STYLES['mainColors']['bgColor2'];
-               if ($TBE_STYLES['mainColors']['bgColor3'])      $this->bgColor3=$TBE_STYLES['mainColors']['bgColor3'];
-               if ($TBE_STYLES['mainColors']['bgColor4'])      $this->bgColor4=$TBE_STYLES['mainColors']['bgColor4'];
-               if ($TBE_STYLES['mainColors']['bgColor5'])      $this->bgColor5=$TBE_STYLES['mainColors']['bgColor5'];
-               if ($TBE_STYLES['mainColors']['bgColor6'])      $this->bgColor6=$TBE_STYLES['mainColors']['bgColor6'];
-               if ($TBE_STYLES['mainColors']['hoverColor'])    $this->hoverColor=$TBE_STYLES['mainColors']['hoverColor'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor'])    $this->bgColor=$GLOBALS['TBE_STYLES']['mainColors']['bgColor'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor1'])   $this->bgColor1=$GLOBALS['TBE_STYLES']['mainColors']['bgColor1'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor2'])   $this->bgColor2=$GLOBALS['TBE_STYLES']['mainColors']['bgColor2'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor3'])   $this->bgColor3=$GLOBALS['TBE_STYLES']['mainColors']['bgColor3'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor4'])   $this->bgColor4=$GLOBALS['TBE_STYLES']['mainColors']['bgColor4'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor5'])   $this->bgColor5=$GLOBALS['TBE_STYLES']['mainColors']['bgColor5'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor6'])   $this->bgColor6=$GLOBALS['TBE_STYLES']['mainColors']['bgColor6'];
+               if ($GLOBALS['TBE_STYLES']['mainColors']['hoverColor']) $this->hoverColor=$GLOBALS['TBE_STYLES']['mainColors']['hoverColor'];
 
                        // Main Stylesheets:
-               if ($TBE_STYLES['stylesheet'])  $this->styleSheetFile = $TBE_STYLES['stylesheet'];
-               if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2 = $TBE_STYLES['stylesheet2'];
-               if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post = $TBE_STYLES['styleSheetFile_post'];
-               if ($TBE_STYLES['inDocStyles_TBEstyle'])        $this->inDocStyles_TBEstyle = $TBE_STYLES['inDocStyles_TBEstyle'];
+               if ($GLOBALS['TBE_STYLES']['stylesheet'])       $this->styleSheetFile = $GLOBALS['TBE_STYLES']['stylesheet'];
+               if ($GLOBALS['TBE_STYLES']['stylesheet2'])      $this->styleSheetFile2 = $GLOBALS['TBE_STYLES']['stylesheet2'];
+               if ($GLOBALS['TBE_STYLES']['styleSheetFile_post'])      $this->styleSheetFile_post = $GLOBALS['TBE_STYLES']['styleSheetFile_post'];
+               if ($GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle'])     $this->inDocStyles_TBEstyle = $GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle'];
 
                        // include all stylesheets
                foreach ($this->getSkinStylesheetDirectories() as $stylesheetDirectory) {
@@ -292,9 +204,21 @@ class template {
                }
 
                        // Background image
-               if ($TBE_STYLES['background'])  $this->backGroundImage = $TBE_STYLES['background'];
+               if ($GLOBALS['TBE_STYLES']['background'])       $this->backGroundImage = $GLOBALS['TBE_STYLES']['background'];
        }
 
+       /**
+        * Compatibility constructor.
+        *
+        * @deprecated since TYPO3 4.6 and will be removed in TYPO3 4.8. Use __construct() instead.
+        */
+       public function template() {
+               t3lib_div::logDeprecatedFunction();
+                       // Note: we cannot call $this->__construct() here because it would call the derived class constructor and cause recursion
+                       // This code uses official PHP behavior (http://www.php.net/manual/en/language.oop5.basic.php) when $this in the
+                       // statically called non-static method inherits $this from the caller's scope.
+               template::__construct();
+       }
 
        /**
         * Gets instance of PageRenderer
@@ -469,7 +393,7 @@ class template {
        function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))     {
                if (is_array($row) && $row['uid'])      {
                        $iconImgTag=t3lib_iconWorks::getSpriteIconForRecord($table, $row , array('title' => htmlspecialchars($path)));
-                       $title = strip_tags($row[$GLOBALS['TCA'][$table]['ctrl']['label']]);
+                       $title = strip_tags(t3lib_BEfunc::getRecordTitle($table, $row));
                        $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'');
                        if ($table=='pages')    $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
                } else {
@@ -746,9 +670,10 @@ class template {
                                $headerStart = '<!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
-                               // The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
+                               break;
                        case 'html5':
                        default:
+                                       // The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
                                $headerStart = '<!DOCTYPE html>' . LF;
                                $htmlTag = '<html>';
                                // disable rendering of XHTML tags
@@ -779,7 +704,7 @@ class template {
                $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
 
                        // Add the XML prologue for XHTML doctypes
-               if (strpos($this->doctype, 'xhtml') !== FALSE) {
+               if (strpos($this->docType, 'xhtml') !== FALSE) {
                                // Put the XML prologue before or after the doctype declaration according to browser
                        if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
                                $headerStart = $headerStart . LF . $xmlPrologue;
@@ -1210,7 +1135,7 @@ $str.=$this->docBodyTagBegin().
                                $skinStylesheetDirs = $this->stylesheetsSkins;
 
                                        // skins can add custom stylesheetDirectories using
-                                       // $TBE_STYLES['skins'][$_EXTKEY]['stylesheetDirectories']
+                                       // $GLOBALS['TBE_STYLES']['skins'][$_EXTKEY]['stylesheetDirectories']
                                if (is_array($skin['stylesheetDirectories'])) {
                                        $skinStylesheetDirs = array_merge($skinStylesheetDirs, $skin['stylesheetDirectories']);
                                }
@@ -1914,7 +1839,7 @@ $str.=$this->docBodyTagBegin().
                }
                $htmlTemplate = '';
                if ($filename !== '') {
-                       $htmlTemplate = t3lib_div::getURL($filename);
+                       $htmlTemplate = t3lib_div::getUrl($filename);
                }
                return $htmlTemplate;
        }