[TASK] Remove function index
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / media / scripts / gmenu_foldout.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@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 * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
31 * XHTML compliant
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 /**
57 * Class extension tslib_gmenu for the creation of DHTML foldout menus
58 *
59 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
60 * @package TYPO3
61 * @subpackage tslib
62 */
63 class tslib_gmenu_foldout extends tslib_gmenu {
64 var $GMENU_fixKey='foldout';
65
66 var $WMarrowNO;
67 var $WMarrowACT;
68 var $WMimagesFlag;
69 var $WMimageHTML;
70 var $WMsubmenu;
71 var $WMtableWrap;
72 var $WM_activeOnLoad='';
73
74 /**
75 * Initializing, setting internal variables (prefixed WM)
76 *
77 * @return void
78 */
79 function extProc_init() {
80 $this->WMarrowNO='';
81 $this->WMarrowACT='';
82 $this->WMimagesFlag=0;
83 $this->WMimageHTML ='';
84 if (($this->mconf['arrowNO']||$this->mconf['arrowNO.']) && ($this->mconf['arrowACT']||$this->mconf['arrowACT.'])) {
85 $this->WMarrowNO = $GLOBALS['TSFE']->cObj->getImgResource($this->mconf['arrowNO'],$this->mconf['arrowNO.']);
86 $this->WMarrowACT = $GLOBALS['TSFE']->cObj->getImgResource($this->mconf['arrowACT'],$this->mconf['arrowACT.']);
87 if (is_array($this->WMarrowACT) && is_array($this->WMarrowNO)) {
88 $this->WMimagesFlag=1;
89 }
90 }
91 }
92
93 /**
94 * Processing before the links are created.
95 * Basically this is setting an onclick handler for clicking the menu item.
96 *
97 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
98 * @return void
99 */
100 function extProc_beforeLinking($key) {
101 $this->I['addATagParams']='';
102 $this->WMsubmenu = $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']);
103 if (trim($this->WMsubmenu)) {
104 $this->I['addATagParams']=' onclick="GF_menu('.$key.');'.($this->mconf['dontLinkIfSubmenu'] ? ' return false;' : '').'"';
105 if ($this->isActive($this->I['uid'], $this->getMPvar($key)) && $this->mconf['displayActiveOnLoad']) { // orig: && $this->WMisSub, changed 210901
106 $this->WM_activeOnLoad='GF_menu('.$key.');';
107 }
108 }
109 }
110
111 /**
112 * Processing after linking, basically setting the <div>-layers for the menu items and possibly wrapping in table, adding bullet images.
113 *
114 * @param integer Pointer to $this->menuArr[$key] where the current menu element record is found
115 * @return void
116 */
117 function extProc_afterLinking($key) {
118 $this->WMtableWrap = $this->mconf['dontWrapInTable'] ? '' : '<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr><td>|</td></tr></table>';
119
120 if ($this->WMimagesFlag) {
121 $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']:'').' alt="" />';
122 } else {$this->WMimageHTML="";}
123
124 if (strstr($this->I['theItem'], '###ARROW_IMAGE###')) {
125 $this->I['theItem'] = str_replace('###ARROW_IMAGE###', $this->WMimageHTML, $this->I['theItem']);
126 } else {
127 $this->I['theItem'] = $this->WMimageHTML.$this->I['theItem'];
128 }
129
130 $this->WMresult.= '
131 <div class="clTop" id="divTop'.($key+1).'">'.$this->tmpl->wrap($this->I['theItem'], $this->WMtableWrap).'
132 <div class="clSub" id="divSub'.($key+1).'">
133 '.$this->WMsubmenu.'
134 </div>
135 </div>'; // Originally a <br /> between the div-tags, but it seemed to break stuff.
136 }
137
138 /**
139 * Putting things together, in particular the JavaScript code needed for the DHTML menu.
140 *
141 * @return string Empty string! (Since $GLOBALS['TSFE']->divSection is set with the <div>-sections used in the menu)
142 */
143 function extProc_finish() {
144 $bHeight = t3lib_div::intInRange(($this->mconf['bottomHeight']?$this->mconf['bottomHeight']:100) ,0,3000);
145 $bottomContent = $this->mconf['bottomContent'] ? $GLOBALS['TSFE']->cObj->cObjGetSingle($this->mconf['bottomContent'],$this->mconf['bottomContent.'], '/GMENU_FOLDOUT/.bottomContent') : '';
146 $adjustTopHeights = intval($this->mconf['adjustItemsH']);
147 $adjustSubHeights = intval($this->mconf['adjustSubItemsH']);
148 $mWidth = t3lib_div::intInRange(($this->mconf['menuWidth']?$this->mconf['menuWidth']:170) ,0,3000);
149 $mHeight = t3lib_div::intInRange(($this->mconf['menuHeight']?$this->mconf['menuHeight']:400) ,0,3000);
150 $insertmColor= $this->mconf['menuBackColor'] ? 'BACKGROUND-COLOR: '.$this->mconf['menuBackColor'].'; layer-background-color: '.$this->mconf['menuBackColor'] : '';
151 $insertBottomColor= $this->mconf['bottomBackColor'] ? 'BACKGROUND-COLOR: '.$this->mconf['bottomBackColor'].'; layer-background-color: '.$this->mconf['bottomBackColor'] : '';
152 $menuOffset = t3lib_div::intExplode(',',$this->mconf['menuOffset'].',');
153 $subOffset = t3lib_div::intExplode(',',$this->mconf['subMenuOffset'].',');
154
155
156 $GLOBALS['TSFE']->additionalHeaderData['gmenu_layer_shared']='<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath('cms').'tslib/media/scripts/jsfunc.layermenu.js"></script>';
157 $GLOBALS['TSFE']->additionalHeaderData['gmenu_foldout']='<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath('cms').'tslib/media/scripts/jsfunc.foldout.js"></script>';
158
159 $GLOBALS["TSFE"]->additionalHeaderData[].= '
160 <style type="text/css">
161 /*<![CDATA[*/
162 #divCont {
163 Z-INDEX: 1; LEFT: '.$menuOffset[0].'px; VISIBILITY: hidden; WIDTH: '.$mWidth.'px; POSITION: absolute; TOP: '.$menuOffset[1].'px; HEIGHT: '.$mHeight.'px
164 }
165 .clTop {
166 Z-INDEX: 1; WIDTH: '.$mWidth.'px; POSITION: absolute; '.$insertmColor.'
167 }
168 .clSub {
169 Z-INDEX: 1; LEFT: '.$subOffset[0].'px; WIDTH: '.$mWidth.'px; POSITION: absolute; TOP: '.$subOffset[1].'px
170 }
171 .bottomLayer {
172 Z-INDEX: 1; WIDTH: '.$mWidth.'px; CLIP: rect(0px '.$mWidth.'px '.$bHeight.'px 0px); POSITION: absolute; HEIGHT: '.$bHeight.'px; '.$insertBottomColor.'
173 }
174 /*]]>*/
175 </style>
176 <script type="text/javascript">
177 /*<![CDATA[*/
178 <!--
179 GFV_foldNumber='.$this->WMmenuItems.'; //How many toplinks do you have?
180 GFV_foldTimer='.t3lib_div::intInRange(($this->mconf['foldTimer']?$this->mconf['foldTimer']:40) ,1,3000).'; //The timeout in the animation, these are milliseconds.
181 GFV_foldSpeed='.t3lib_div::intInRange($this->mconf['foldSpeed'],1,100).'; //How many steps in an animation?
182 GFV_stayFolded='.($this->mconf['stayFolded'] ? 'true' : 'false').'; //Stay open when you click a new toplink?
183 GFV_foldImg='.$this->WMimagesFlag.'; //Do you want images (if not set to 0 and remove the images from the body)?
184 GFV_currentFold=null;
185 GFV_foldStep1=null;
186 GFV_foldStep2=null;
187 GFV_step=0;
188 GFV_active=false; //Don\'t change this one.
189 GFV_adjustTopHeights = '.$adjustTopHeights.';
190 GFV_adjustSubHeights = '.$adjustSubHeights.';
191 if (bw.opera) {
192 GFV_scrX= innerWidth;
193 GFV_scrY= innerHeight;
194 }
195
196 //This is the default image.
197 //Remember to change the actual images in the page as well, but remember to keep the name of the image.
198 var GFV_unImg=new Image();
199 GFV_unImg.src="'.$GLOBALS['TSFE']->absRefPrefix.$this->WMarrowNO[3].'";
200
201 var GFV_exImg=new Image(); //Making an image variable...
202 GFV_exImg.src="'.$GLOBALS['TSFE']->absRefPrefix.$this->WMarrowACT[3].'"; //...this is the source of the image that it changes to when the menu expands.
203
204 //-->
205 /*]]>*/
206 </script>
207 ';
208
209 $GLOBALS['TSFE']->JSeventFuncCalls['onmousemove']['GF_resizeForOpera()']= 'GF_resizeForOpera();';
210 $GLOBALS['TSFE']->JSeventFuncCalls['onload']['GMENU_FOLDOUT']= 'if(bw.bw) {GF_initFoldout();'.$this->WM_activeOnLoad.'}';
211
212 $GLOBALS['TSFE']->divSection.= '
213 <div id="divCont"><!-- These are the contents of the foldoutmenu. -->
214 '.$this->tmpl->wrap($this->WMresult,$this->mconf['wrap']).'
215 <div class="bottomLayer" id="divTop'.($this->WMmenuItems+1).'">
216 <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. -->
217 </div>'.$this->tmpl->wrap($bottomContent, $this->WMtableWrap).'
218 </div>
219 </div><!-- Here ends the foldoutmenu. -->
220 ';
221 return '';
222 }
223 }
224
225 $GLOBALS['TSFE']->tmpl->menuclasses.=',gmenu_foldout';
226
227
228 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['media/scripts/gmenu_foldout.php'])) {
229 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['media/scripts/gmenu_foldout.php']);
230 }
231
232 ?>