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