Fixed Bug #10121: followUp - replaced extJScode with extJsCode in template.php
[Packages/TYPO3.CMS.git] / typo3 / template.php
index d3ae399..2e4b98b 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 since TYPO3 4.0
+ * @deprecated since TYPO3 3.6
  */
 function fw($str)      {
        return $str;
@@ -173,6 +173,7 @@ class template {
        var $form='';                                   // This can be set to the HTML-code for a formtag. Useful when you need a form to span the whole page; Inserted exactly after the body-tag.
        var $JScodeLibArray = array();          // Similar to $JScode (see below) but used as an associative array to prevent double inclusion of JS code. This is used to include certain external Javascript libraries before the inline JS code. <script>-Tags are not wrapped around automatically
        var $JScode='';                                 // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
+       var $extJsCode = '';                            // Additional header code for ExtJS. It will be included in document header and inserted in a Ext.onReady(function()
        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 xhtml_trans. You can also set it to 'html_3', 'xhtml_strict' or 'xhtml_frames'.
@@ -228,7 +229,11 @@ class template {
                global $TBE_STYLES;
 
                        // Setting default scriptID:
-               $this->scriptID = ereg_replace('^.*\/(sysext|ext)\/','ext/',substr(PATH_thisScript,strlen(PATH_site)));
+               if (($temp_M = (string) t3lib_div::_GET('M')) && $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M]) {
+                       $this->scriptID = ereg_replace('^.*\/(sysext|ext)\/', 'ext/', $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M] . 'index.php');
+               } else {
+                       $this->scriptID = ereg_replace('^.*\/(sysext|ext)\/', 'ext/', substr(PATH_thisScript, strlen(PATH_site)));
+               }
                if (TYPO3_mainDir!='typo3/' && substr($this->scriptID,0,strlen(TYPO3_mainDir)) == TYPO3_mainDir)        {
                        $this->scriptID = 'typo3/'.substr($this->scriptID,strlen(TYPO3_mainDir));       // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
                }
@@ -679,13 +684,15 @@ class template {
        '.$this->docStyle().'
        '.implode("\n", $this->JScodeLibArray).'
        '.$this->JScode.'
-       '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).'
+       '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).
+       ($this->extJsCode ? $this->wrapScriptTags('Ext.onReady(function() {' . chr(10) . $this->extJsCode . chr(10) . '});') : '') .
+       '
        <!--###POSTJSMARKER###-->
 </head>
 ';
-               $this->JScodeLibArray=array();
-               $this->JScode='';
-               $this->JScodeArray=array();
+               $this->JScodeLibArray = array();
+               $this->JScode = $this->extJsCode = '';
+               $this->JScodeArray = array();
 
                if ($this->docType=='xhtml_frames')     {
                        return $str;
@@ -875,7 +882,7 @@ $str.=$this->docBodyTagBegin().
         *
         * @return      void
         * @internal
-        * @deprecated since TYPO3 4.0
+        * @deprecated since TYPO3 3.6
         */
        function middle()       {
        }
@@ -1481,37 +1488,37 @@ $str.=$this->docBodyTagBegin().
                                        $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
                                }
 
-                               $isNotEmpty = strcmp(trim($def['content']),'');
+                               $isEmpty = !(strcmp(trim($def['content']),'') || strcmp(trim($def['icon']),''));
 
                                // "Removes" empty tabs
-                               if (!$isNotEmpty && $dividers2tabs == 1) {
+                               if ($isEmpty && $dividers2tabs == 1) {
                                        continue;
                                }
 
                                $mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
-                               $requiredIcon = '<img name="'.$id.'-'.$index.'-REQ" src="clear.gif" width="10" height="10" hspace="4" alt="" />';
+                               $requiredIcon = '<img name="' . $id . '-' . $index . '-REQ" src="' . $GLOBALS['BACK_PATH'] . 'gfx/clear.gif" width="10" height="10" hspace="4" alt="" />';
 
                                if (!$foldout)  {
                                                // Create TAB cell:
                                        $options[$tabRows][] = '
-                                                       <td class="'.($isNotEmpty ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
-                                                       ($isNotEmpty ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
+                                                       <td class="'.($isEmpty ? 'disabled' : 'tab').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
+                                                       ($isEmpty ? '' : '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>').
                                                        $def['icon'].
                                                        ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
                                                        $requiredIcon.
                                                        $this->icons($def['stateIcon'],'margin-left: 10px;').
-                                                       ($isNotEmpty ? '</a>' :'').
+                                                       ($isEmpty ? '' : '</a>').
                                                        '</td>';
                                        $titleLenCount+= strlen($def['label']);
                                } else {
                                                // Create DIV layer for content:
                                        $divs[] = '
-                                               <div class="'.($isNotEmpty ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
-                                                       ($isNotEmpty ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
+                                               <div class="'.($isEmpty ? 'disabled' : 'tab').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
+                                                       ($isEmpty ? '' : '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>').
                                                        $def['icon'].
                                                        ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
                                                        $requiredIcon.
-                                                       ($isNotEmpty ? '</a>' : '').
+                                                       ($isEmpty ? '' : '</a>').
                                                        '</div>';
                                }
 
@@ -1526,7 +1533,7 @@ $str.=$this->docBodyTagBegin().
                                                DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
                                ';
                                        // If not empty and we have the toggle option on, check if the tab needs to be expanded
-                               if ($toggle == 1 && $isNotEmpty) {
+                               if ($toggle == 1 && !$isEmpty) {
                                        $JSinit[] = '
                                                if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
                                        ';
@@ -2049,4 +2056,4 @@ if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/templ
 // ******************************
 $GLOBALS['TBE_TEMPLATE'] = t3lib_div::makeInstance('template');
 
-?>
\ No newline at end of file
+?>