Added $Id$ keywords, cleaned up comment tags
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / media / scripts / gmenu_foldout.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains the GMENU_FOLDOUT extension class, tslib_gmenu_foldout
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasper@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 80: class tslib_gmenu_foldout extends tslib_gmenu
42 * 96: function extProc_init()
43 * 117: function extProc_beforeLinking($key)
44 * 134: function extProc_afterLinking($key)
45 * 160: function extProc_finish()
46 *
47 * TOTAL FUNCTIONS: 4
48 * (This index is automatically created/updated by the extension "extdeveval")
49 *
50 */
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 /**
73 * Class extension tslib_gmenu for the creation of DHTML foldout menus
74 *
75 * @author Kasper Skaarhoj <kasper@typo3.com>
76 * @package TYPO3
77 * @subpackage tslib
78 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=386&cHash=f69ab462e2
79 */
80 class tslib_gmenu_foldout extends tslib_gmenu {
81 var $GMENU_fixKey='foldout';
82
83 var $WMarrowNO;
84 var $WMarrowACT;
85 var $WMimagesFlag;
86 var $WMimageHTML;
87 var $WMsubmenu;
88 var $WMtableWrap;
89 var $WM_activeOnLoad='';
90
91 /**
92 * Initializing, setting internal variables (prefixed WM)
93 *
94 * @return void
95 */
96 function extProc_init() {
97 $this->WMarrowNO='';
98 $this->WMarrowACT='';
99 $this->WMimagesFlag=0;
100 $this->WMimageHTML ='';
101 if (($this->mconf['arrowNO']||$this->mconf['arrowNO.']) && ($this->mconf['arrowACT']||$this->mconf['arrowACT.'])) {
102 $this->WMarrowNO = $GLOBALS['TSFE']->cObj->getImgResource($this->mconf['arrowNO'],$this->mconf['arrowNO.']);
103 $this->WMarrowACT = $GLOBALS['TSFE']->cObj->getImgResource($this->mconf['arrowACT'],$this->mconf['arrowACT.']);
104 if (is_array($this->WMarrowACT) && is_array($this->WMarrowNO)) {
105 $this->WMimagesFlag=1;
106 }
107 }
108 }
109
110 /**
111 * Processing before the links are created.
112 * Basically this is setting an onclick handler for clicking the menu item.
113 *
114 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
115 * @return void
116 */
117 function extProc_beforeLinking($key) {
118 $this->I['addATagParams']='';
119 $this->WMsubmenu = $this->subMenu($this->I['uid'],$this->I['mount_pid']);
120 if (trim($this->WMsubmenu)) {
121 $this->I['addATagParams']=' onclick="GF_menu('.$key.');'.($this->mconf['dontLinkIfSubmenu'] ? ' return false;' : '').'"';
122 if ($this->isActive($this->I['uid']) && $this->mconf['displayActiveOnLoad']) { // orig: && $this->WMisSub, changed 210901
123 $this->WM_activeOnLoad='GF_menu('.$key.');';
124 }
125 }
126 }
127
128 /**
129 * Processing after linking, basically setting the <div>-layers for the menu items and possibly wrapping in table, adding bullet images.
130 *
131 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
132 * @return void
133 */
134 function extProc_afterLinking($key) {
135 $this->WMtableWrap = $this->mconf['dontWrapInTable'] ? '' : '<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr><td>|</td></tr></table>';
136
137 if ($this->WMimagesFlag) {
138 $this->WMimageHTML='<img src="'.$GLOBALS['TSFE']->absRefPrefix.$this->WMarrowNO[3].'" width="'.$this->WMarrowNO[0].'" height="'.$this->WMarrowNO[1].'" border="0" name="imgA'.$key.'"'.($this->mconf['arrowImgParams']?' '.$this->mconf['arrowImgParams']:'').' />';
139 } else {$this->WMimageHTML="";}
140
141 if (strstr($this->I['theItem'], '###ARROW_IMAGE###')) {
142 $this->I['theItem'] = str_replace('###ARROW_IMAGE###', $this->WMimageHTML, $this->I['theItem']);
143 } else {
144 $this->I['theItem'] = $this->WMimageHTML.$this->I['theItem'];
145 }
146
147 $this->WMresult.= '
148 <div class="clTop" id="divTop'.($key+1).'">'.$this->tmpl->wrap($this->I['theItem'], $this->WMtableWrap).'
149 <div class="clSub" id="divSub'.($key+1).'">
150 '.$this->WMsubmenu.'
151 </div>
152 </div>'; // Originally a <BR> between the div-tags, but it seemed to break stuff.
153 }
154
155 /**
156 * Putting things together, in particular the JavaScript code needed for the DHTML menu.
157 *
158 * @return string Empty string! (Since $GLOBALS['TSFE']->divSection is set with the <div>-sections used in the menu)
159 */
160 function extProc_finish() {
161 $bHeight = t3lib_div::intInRange(($this->mconf['bottomHeight']?$this->mconf['bottomHeight']:100) ,0,3000);
162 $bottomContent = $this->mconf['bottomContent'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($this->mconf['bottomContent'],$this->mconf['bottomContent.'], '/GMENU_FOLDOUT/.bottomContent') : '';
163 $adjustTopHeights = intval($this->mconf['adjustItemsH']);
164 $adjustSubHeights = intval($this->mconf['adjustSubItemsH']);
165 $mWidth = t3lib_div::intInRange(($this->mconf['menuWidth']?$this->mconf['menuWidth']:170) ,0,3000);
166 $mHeight = t3lib_div::intInRange(($this->mconf['menuHeight']?$this->mconf['menuHeight']:400) ,0,3000);
167 $insertmColor= $this->mconf['menuBackColor'] ? 'BACKGROUND-COLOR: '.$this->mconf['menuBackColor'].'; layer-background-color: '.$this->mconf['menuBackColor'] : '';
168 $insertBottomColor= $this->mconf['bottomBackColor'] ? 'BACKGROUND-COLOR: '.$this->mconf['bottomBackColor'].'; layer-background-color: '.$this->mconf['bottomBackColor'] : '';
169 $menuOffset = t3lib_div::intExplode(',',$this->mconf['menuOffset'].',');
170 $subOffset = t3lib_div::intExplode(',',$this->mconf['subMenuOffset'].',');
171
172
173 $GLOBALS['TSFE']->additionalHeaderData['gmenu_layer_shared']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'media/scripts/jsfunc.layermenu.js"></script>';
174 $GLOBALS['TSFE']->additionalHeaderData['gmenu_foldout']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'media/scripts/jsfunc.foldout.js"></script>';
175
176 $GLOBALS["TSFE"]->additionalHeaderData[].= '
177 <style type="text/css">
178 /*<![CDATA[*/
179 #divCont {
180 Z-INDEX: 1; LEFT: '.$menuOffset[0].'px; VISIBILITY: hidden; WIDTH: '.$mWidth.'px; POSITION: absolute; TOP: '.$menuOffset[1].'px; HEIGHT: '.$mHeight.'px
181 }
182 .clTop {
183 Z-INDEX: 1; WIDTH: '.$mWidth.'px; POSITION: absolute; '.$insertmColor.'
184 }
185 .clSub {
186 Z-INDEX: 1; LEFT: '.$subOffset[0].'px; WIDTH: '.$mWidth.'px; POSITION: absolute; TOP: '.$subOffset[1].'px
187 }
188 .bottomLayer {
189 Z-INDEX: 1; WIDTH: '.$mWidth.'px; CLIP: rect(0px '.$mWidth.'px '.$bHeight.'px 0px); POSITION: absolute; HEIGHT: '.$bHeight.'px; '.$insertBottomColor.'
190 }
191 /*]]>*/
192 </style>
193 <script type="text/javascript">
194 /*<![CDATA[*/
195 <!--
196 GFV_foldNumber='.$this->WMmenuItems.'; //How many toplinks do you have?
197 GFV_foldTimer='.t3lib_div::intInRange(($this->mconf['foldTimer']?$this->mconf['foldTimer']:40) ,1,3000).'; //The timeout in the animation, these are milliseconds.
198 GFV_foldSpeed='.t3lib_div::intInRange($this->mconf['foldSpeed'],1,100).'; //How many steps in an animation?
199 GFV_stayFolded='.($this->mconf['stayFolded'] ? 'true' : 'false').'; //Stay open when you click a new toplink?
200 GFV_foldImg='.$this->WMimagesFlag.'; //Do you want images (if not set to 0 and remove the images from the body)?
201 GFV_currentFold=null;
202 GFV_foldStep1=null;
203 GFV_foldStep2=null;
204 GFV_step=0;
205 GFV_active=false; //Don\'t change this one.
206 GFV_adjustTopHeights = '.$adjustTopHeights.';
207 GFV_adjustSubHeights = '.$adjustSubHeights.';
208 if (bw.opera) {
209 GFV_scrX= innerWidth;
210 GFV_scrY= innerHeight;
211 }
212
213 //This is the default image.
214 //Remember to change the actual images in the page as well, but remember to keep the name of the image.
215 var GFV_unImg=new Image();
216 GFV_unImg.src="'.$GLOBALS['TSFE']->absRefPrefix.$this->WMarrowNO[3].'";
217
218 var GFV_exImg=new Image(); //Making an image variable...
219 GFV_exImg.src="'.$GLOBALS['TSFE']->absRefPrefix.$this->WMarrowACT[3].'"; //...this is the source of the image that it changes to when the menu expands.
220
221 //-->
222 /*]]>*/
223 </script>
224 ';
225
226 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']['GF_resizeForOpera()']= 'GF_resizeForOpera();';
227 $GLOBALS['TSFE']->JSeventFuncCalls['onload']['GMENU_FOLDOUT']= 'if(bw.bw) {GF_initFoldout();'.$this->WM_activeOnLoad.'}';
228
229 $GLOBALS['TSFE']->divSection.= '
230 <div id="divCont"><!-- These are the contents of the foldoutmenu. -->
231 '.$this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).'
232 <div class="bottomLayer" id="divTop'.($this->WMmenuItems+1).'">
233 <div class="clSub" id="divSub'.($this->WMmenuItems+1).'"><!-- This is a cover layer, it should always be the last one, and does NOT count in your number of toplinks! --><!-- So if this one is divTop7, the GFV_foldNumber variable should be set to 6 --><!-- This layer covers up the last sub, so if the last sub gets too big, increase this layers size in the stylesheet. --><!-- There are tables with width="100%" around the toplinks, to force NS4 to use the real width specified for the toplinks in the stylesheet. -->
234 </div>'.$this->tmpl->wrap($bottomContent, $this->WMtableWrap).'
235 </div>
236 </div><!-- Here ends the foldoutmenu. -->
237 ';
238 return '';
239 }
240 }
241
242 $GLOBALS['TSFE']->tmpl->menuclasses.=',gmenu_foldout';
243
244
245 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/gmenu_foldout.php']) {
246 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/gmenu_foldout.php']);
247 }
248
249 ?>