8561 Checkboxes and labels are aligned badly if in one line
[Packages/TYPO3.CMS.git] / typo3 / template.php
index 304d012..63e5871 100755 (executable)
@@ -140,7 +140,7 @@ require_once(PATH_t3lib.'class.t3lib_ajax.php');
  *
  * @param      string          Input string
  * @return     string          Output string (in the old days this was wrapped in <font> tags)
- * @deprecated
+ * @deprecated since TYPO3 4.0
  */
 function fw($str)      {
        return $str;
@@ -175,7 +175,7 @@ class template {
        var $JScode='';                                 // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
        var $JScodeArray = array();             // Similar to $JScode but for use as array with associative keys to prevent double inclusion of JS code. a <script> tag is automatically wrapped around.
        var $postCode='';                               // Additional 'page-end' code could be accommulated in this var. It will be outputted at the end of page before </body> and some other internal page-end code.
-       var $docType = '';                              // Doc-type used in the header. Default is HTML 4. You can also set it to 'strict', 'xhtml_trans', or 'xhtml_frames'.
+       var $docType = '';                              // Doc-type used in the header. Default is xhtml_trans. You can also set it to 'html_3', 'xhtml_strict' or 'xhtml_frames'.
        var $moduleTemplate = '';               // HTML template with markers for module
 
                // Other vars you can change, but less frequently used:
@@ -187,6 +187,7 @@ class template {
        var $form_rowsToStylewidth = 9.58;      // Multiplication factor for formWidth() input size (default is 48* this value).
        var $form_largeComp = 1.33;             // Compensation for large documents (used in class.t3lib_tceforms.php)
        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.
+       protected $additionalStyleSheets=array();       // Links to additional style sheets
 
                // TYPO3 Colorscheme.
                // If you want to change this, please do so through a skin using the global var $TBE_STYLES
@@ -608,6 +609,19 @@ class template {
         * @see endPage()
         */
        function startPage($title)      {
+                       // hook pre start page
+               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) {
+                       $preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'];
+                       if (is_array($preStartPageHook)) {
+                               $hookParameters = array(
+                                       'title' => &$title,
+                               );
+                               foreach ($preStartPageHook as $hookFunction)    {
+                                       t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
+                               }
+                       }
+               }
+
                        // Get META tag containing the currently selected charset for backend output. The function sets $this->charSet.
                $charSet = $this->initCharset();
                $generator = $this->generator();
@@ -619,38 +633,39 @@ class template {
                header ('Content-Type:text/html;charset='.$this->charset);
 
                switch($this->docType)  {
+                       case 'html_3':
+                               $headerStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
+                               break;
                        case 'xhtml_strict':
-                               $headerStart= '<!DOCTYPE html
+                               $headerStart = '<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <?xml version="1.0" encoding="'.$this->charset.'"?>
 <?xml-stylesheet href="#internalStyle" type="text/css"?>
 ';
-                       break;
-                       case 'xhtml_trans':
-                               $headerStart= '<!DOCTYPE html
-     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<?xml version="1.0" encoding="'.$this->charset.'"?>
-<?xml-stylesheet href="#internalStyle" type="text/css"?>
-';
-                       break;
+                               break;
                        case 'xhtml_frames':
-                               $headerStart= '<!DOCTYPE html
+                               $headerStart = '<!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
 <?xml version="1.0" encoding="'.$this->charset.'"?>
 ';
-                       break;
+                               break;
+                       // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE.
+                       case 'xhtml_trans':
                        default:
-                               $headerStart='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
-                       break;
+                               $headerStart = '<!DOCTYPE html
+     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="'.$this->charset.'"?>
+<?xml-stylesheet href="#internalStyle" type="text/css"?>
+';
                }
 
-               $tabJScode = '';
-               if (!$GLOBALS['BE_USER']->uc['disableTabInTextarea'])   {
-                               // This loads the tabulator-in-textarea feature. It automatically modifies every textarea which is found.
-                       $tabJScode = '<script src="'.$this->backPath.'tab.js" type="text/javascript"></script>';
+               // This loads the tabulator-in-textarea feature. It automatically modifies
+               // every textarea which is found.
+               if (!$GLOBALS['BE_USER']->uc['disableTabInTextarea']) {
+                       $this->loadJavascriptLib('tab.js');
                }
 
                        // Construct page header.
@@ -664,7 +679,6 @@ class template {
        '.$this->docStyle().'
        '.implode("\n", $this->JScodeLibArray).'
        '.$this->JScode.'
-       '.$tabJScode.'
        '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).'
        <!--###POSTJSMARKER###-->
 </head>
@@ -713,7 +727,7 @@ $str.=$this->docBodyTagBegin().
                $str .= '</html>';
 
                        // Logging: Can't find better place to put it:
-               if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session','',0,array('_FLUSH'=>TRUE));
+               if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session', 'template', 0, array('_FLUSH' => true));
 
                return $str;
        }
@@ -861,7 +875,7 @@ $str.=$this->docBodyTagBegin().
         *
         * @return      void
         * @internal
-        * @deprecated
+        * @deprecated since TYPO3 4.0
         */
        function middle()       {
        }
@@ -924,7 +938,8 @@ $str.=$this->docBodyTagBegin().
                                        /*###POSTCSSMARKER###*/
                                /*]]>*/
                        </style>
-                       '.($this->styleSheetFile_post?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile_post.'" />':'')
+                       '.($this->styleSheetFile_post?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile_post.'" />':'').'
+                       '.implode("\n", $this->additionalStyleSheets)
                )
                ;
                $this->inDocStyles='';
@@ -935,6 +950,21 @@ $str.=$this->docBodyTagBegin().
        }
 
        /**
+        * Insert additional style sheet link
+        *
+        * @param       string          $key: some key identifying the style sheet
+        * @param       string          $href: uri to the style sheet file
+        * @param       string          $title: value for the title attribute of the link element
+        * @return      string          $relation: value for the rel attribute of the link element
+        * @return      void
+        */
+       function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
+               if (!isset($this->additionalStyleSheets[$key])) {
+                       $this->additionalStyleSheets[$key] = '<link rel="' . $relation . '" type="text/css" href="' . $href . '"' . ($title ? (' title="' . $title . '"') : '') . ' />';
+               }
+        }
+
+       /**
         * Insert post rendering document style into already rendered content
         * This is needed for extobjbase
         *
@@ -1495,7 +1525,8 @@ $str.=$this->docBodyTagBegin().
                                $JSinit[] = '
                                                DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
                                ';
-                               if ($toggle==1) {
+                                       // If not empty and we have the toggle option on, check if the tab needs to be expanded
+                               if ($toggle == 1 && $isNotEmpty) {
                                        $JSinit[] = '
                                                if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
                                        ';
@@ -1885,7 +1916,7 @@ $str.=$this->docBodyTagBegin().
         * @param       array           HTML for all buttons
         * @return      array           Containing HTML for both buttonlists
         */
-       private function getDocHeaderButtons($buttons) {
+       protected function getDocHeaderButtons($buttons) {
                $markers = array();
                        // Fill buttons for left and right float
                $floats = array('left', 'right');
@@ -1919,7 +1950,7 @@ $str.=$this->docBodyTagBegin().
         * @param       array   Current page
         * @return      string  Page path
         */
-       private function getPagePath($pageRecord) {
+       protected function getPagePath($pageRecord) {
                global $LANG;
                        // Is this a real page
                if ($pageRecord['uid']) {
@@ -1938,7 +1969,7 @@ $str.=$this->docBodyTagBegin().
         * @param       array   Current page
         * @return      string  Page info
         */
-       private function getPageInfo($pageRecord) {
+       protected function getPageInfo($pageRecord) {
                global $BE_USER;
                                // Add icon with clickmenu, etc:
                if ($pageRecord['uid']) {       // If there IS a real page
@@ -2007,25 +2038,15 @@ class mediumDoc extends template {
 }
 
 
-
-// Include extension to the template class?
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php'])     {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']);
 }
 
 
 
-// ******************************************************
-// The backend language engine is started (ext: "lang")
-// ******************************************************
-require_once(PATH_typo3.'sysext/lang/lang.php');
-$GLOBALS['LANG'] = t3lib_div::makeInstance('language');
-$GLOBALS['LANG']->init($BE_USER->uc['lang']);
-
-
-
 // ******************************
 // The template is loaded
 // ******************************
 $GLOBALS['TBE_TEMPLATE'] = t3lib_div::makeInstance('template');
-?>
+
+?>
\ No newline at end of file