fea6c55c91904f80f57b389d71c9b5e9411c944a
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / Menu / GraphicalMenuContentObject.php
1 <?php
2 namespace TYPO3\CMS\Frontend\ContentObject\Menu;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18
19 /**
20 * Extension class creating graphic based menus (PNG or GIF files)
21 *
22 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
23 */
24 class GraphicalMenuContentObject extends AbstractMenuContentObject {
25
26 /**
27 * Calls procesItemStates() so that the common configuration for the menu items are resolved into individual configuration per item.
28 * Calls makeGifs() for all "normal" items and if configured for, also the "rollover" items.
29 *
30 * @return void
31 * @see AbstractMenuContentObject::procesItemStates(), makeGifs()
32 */
33 public function generate() {
34 $splitCount = count($this->menuArr);
35 if ($splitCount) {
36 list($NOconf, $ROconf) = $this->procesItemStates($splitCount);
37 //store initial count value
38 $temp_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
39 $temp_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
40 // Now we generate the giffiles:
41 $this->makeGifs($NOconf, 'NO');
42 // store count from NO obj
43 $tempcnt_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
44 $tempcnt_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
45 if ($this->mconf['debugItemConf']) {
46 echo '<h3>$NOconf:</h3>';
47 debug($NOconf);
48 }
49 // RollOver
50 if ($ROconf) {
51 // Start recount for rollover with initial values
52 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $temp_HMENU_MENUOBJ;
53 $GLOBALS['TSFE']->register['count_MENUOBJ'] = $temp_MENUOBJ;
54 $this->makeGifs($ROconf, 'RO');
55 if ($this->mconf['debugItemConf']) {
56 echo '<h3>$ROconf:</h3>';
57 debug($ROconf);
58 }
59 }
60 // Use count from NO obj
61 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ;
62 $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempcnt_MENUOBJ;
63 }
64 }
65
66 /**
67 * Will traverse input array with configuration per-item and create corresponding GIF files for the menu.
68 * The data of the files are stored in $this->result
69 *
70 * @param array $conf Array with configuration for each item.
71 * @param string $resKey Type of images: normal ("NO") or rollover ("RO"). Valid values are "NO" and "RO
72 * @return void
73 * @access private
74 * @see generate()
75 */
76 public function makeGifs($conf, $resKey) {
77 $isGD = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'];
78 if (!is_array($conf)) {
79 $conf = array();
80 }
81 $totalWH = array();
82 $items = count($conf);
83 if ($isGD) {
84 // Generate the gif-files. the $menuArr is filled with some values like output_w, output_h, output_file
85 $Hcounter = 0;
86 $Wcounter = 0;
87 $Hobjs = $this->mconf['applyTotalH'];
88 if ($Hobjs) {
89 $Hobjs = GeneralUtility::intExplode(',', $Hobjs);
90 }
91 $Wobjs = $this->mconf['applyTotalW'];
92 if ($Wobjs) {
93 $Wobjs = GeneralUtility::intExplode(',', $Wobjs);
94 }
95 $minDim = $this->mconf['min'];
96 if ($minDim) {
97 $minDim = $this->parent_cObj->calcIntExplode(',', $minDim . ',');
98 }
99 $maxDim = $this->mconf['max'];
100 if ($maxDim) {
101 $maxDim = $this->parent_cObj->calcIntExplode(',', $maxDim . ',');
102 }
103 if ($minDim) {
104 $conf[$items] = $conf[$items - 1];
105 $this->menuArr[$items] = array();
106 $items = count($conf);
107 }
108 // TOTAL width
109 if ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY'] || $this->mconf['distributeX'] || $this->mconf['distributeY']) {
110 $totalWH = $this->findLargestDims($conf, $items, $Hobjs, $Wobjs, $minDim, $maxDim);
111 }
112 }
113 $c = 0;
114 $maxFlag = 0;
115 $distributeAccu = array('H' => 0, 'W' => 0);
116 foreach ($conf as $key => $val) {
117 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
118 $GLOBALS['TSFE']->register['count_MENUOBJ']++;
119 if ($items == $c + 1 && $minDim) {
120 $Lobjs = $this->mconf['removeObjectsOfDummy'];
121 if ($Lobjs) {
122 $Lobjs = GeneralUtility::intExplode(',', $Lobjs);
123 foreach ($Lobjs as $remItem) {
124 unset($val[$remItem]);
125 unset($val[$remItem . '.']);
126 }
127 }
128 $flag = 0;
129 $tempXY = explode(',', $val['XY']);
130 if ($Wcounter < $minDim[0]) {
131 $tempXY[0] = $minDim[0] - $Wcounter;
132 $flag = 1;
133 }
134 if ($Hcounter < $minDim[1]) {
135 $tempXY[1] = $minDim[1] - $Hcounter;
136 $flag = 1;
137 }
138 $val['XY'] = implode(',', $tempXY);
139 if (!$flag) {
140 break;
141 }
142 }
143 $c++;
144 if ($isGD) {
145 // Pre-working the item
146 $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
147 $gifCreator->init();
148 $gifCreator->start($val, $this->menuArr[$key]);
149 // If useLargestItemH/W is specified
150 if (count($totalWH) && ($this->mconf['useLargestItemX'] || $this->mconf['useLargestItemY'])) {
151 $tempXY = explode(',', $gifCreator->setup['XY']);
152 if ($this->mconf['useLargestItemX']) {
153 $tempXY[0] = max($totalWH['W']);
154 }
155 if ($this->mconf['useLargestItemY']) {
156 $tempXY[1] = max($totalWH['H']);
157 }
158 // Regenerate the new values...
159 $val['XY'] = implode(',', $tempXY);
160 $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
161 $gifCreator->init();
162 $gifCreator->start($val, $this->menuArr[$key]);
163 }
164 // If distributeH/W is specified
165 if (count($totalWH) && ($this->mconf['distributeX'] || $this->mconf['distributeY'])) {
166 $tempXY = explode(',', $gifCreator->setup['XY']);
167 if ($this->mconf['distributeX']) {
168 $diff = $this->mconf['distributeX'] - $totalWH['W_total'] - $distributeAccu['W'];
169 $compensate = round($diff / ($items - $c + 1));
170 $distributeAccu['W'] += $compensate;
171 $tempXY[0] = $totalWH['W'][$key] + $compensate;
172 }
173 if ($this->mconf['distributeY']) {
174 $diff = $this->mconf['distributeY'] - $totalWH['H_total'] - $distributeAccu['H'];
175 $compensate = round($diff / ($items - $c + 1));
176 $distributeAccu['H'] += $compensate;
177 $tempXY[1] = $totalWH['H'][$key] + $compensate;
178 }
179 // Regenerate the new values...
180 $val['XY'] = implode(',', $tempXY);
181 $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
182 $gifCreator->init();
183 $gifCreator->start($val, $this->menuArr[$key]);
184 }
185 // If max dimensions are specified
186 if ($maxDim) {
187 $tempXY = explode(',', $val['XY']);
188 if ($maxDim[0] && $Wcounter + $gifCreator->XY[0] >= $maxDim[0]) {
189 $tempXY[0] == $maxDim[0] - $Wcounter;
190 $maxFlag = 1;
191 }
192 if ($maxDim[1] && $Hcounter + $gifCreator->XY[1] >= $maxDim[1]) {
193 $tempXY[1] = $maxDim[1] - $Hcounter;
194 $maxFlag = 1;
195 }
196 if ($maxFlag) {
197 $val['XY'] = implode(',', $tempXY);
198 $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
199 $gifCreator->init();
200 $gifCreator->start($val, $this->menuArr[$key]);
201 }
202 }
203 // displace
204 if ($Hobjs) {
205 foreach ($Hobjs as $index) {
206 if ($gifCreator->setup[$index] && $gifCreator->setup[$index . '.']) {
207 $oldOffset = explode(',', $gifCreator->setup[$index . '.']['offset']);
208 $gifCreator->setup[$index . '.']['offset'] = implode(',', $gifCreator->applyOffset($oldOffset, array(0, -$Hcounter)));
209 }
210 }
211 }
212 if ($Wobjs) {
213 foreach ($Wobjs as $index) {
214 if ($gifCreator->setup[$index] && $gifCreator->setup[$index . '.']) {
215 $oldOffset = explode(',', $gifCreator->setup[$index . '.']['offset']);
216 $gifCreator->setup[$index . '.']['offset'] = implode(',', $gifCreator->applyOffset($oldOffset, array(-$Wcounter, 0)));
217 }
218 }
219 }
220 }
221 // Finding alternative GIF names if any (by altImgResource)
222 $gifFileName = '';
223 if ($conf[$key]['altImgResource'] || is_array($conf[$key]['altImgResource.'])) {
224 if (!is_object($cObj)) {
225 $cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
226 }
227 $cObj->start($this->menuArr[$key], 'pages');
228 $altImgInfo = $cObj->getImgResource($conf[$key]['altImgResource'], $conf[$key]['altImgResource.']);
229 $gifFileName = $altImgInfo[3];
230 }
231 // If an alternative name was NOT given, find the GIFBUILDER name.
232 if (!$gifFileName && $isGD) {
233 $gifCreator->createTempSubDir('menu/');
234 $gifFileName = $gifCreator->fileName('menu/');
235 }
236 $this->result[$resKey][$key] = $conf[$key];
237 // Generation of image file:
238 // File exists
239 if (file_exists($gifFileName)) {
240 $info = @getimagesize($gifFileName);
241 $this->result[$resKey][$key]['output_w'] = (int)$info[0];
242 $this->result[$resKey][$key]['output_h'] = (int)$info[1];
243 $this->result[$resKey][$key]['output_file'] = $gifFileName;
244 } elseif ($isGD) {
245 // file is generated
246 $gifCreator->make();
247 $this->result[$resKey][$key]['output_w'] = $gifCreator->w;
248 $this->result[$resKey][$key]['output_h'] = $gifCreator->h;
249 $this->result[$resKey][$key]['output_file'] = $gifFileName;
250 $gifCreator->output($this->result[$resKey][$key]['output_file']);
251 $gifCreator->destroy();
252 }
253 $this->result[$resKey][$key]['output_file'] = GeneralUtility::png_to_gif_by_imagemagick($this->result[$resKey][$key]['output_file']);
254 // counter is increased
255 $Hcounter += $this->result[$resKey][$key]['output_h'];
256 // counter is increased
257 $Wcounter += $this->result[$resKey][$key]['output_w'];
258 if ($maxFlag) {
259 break;
260 }
261 }
262 }
263
264 /**
265 * Function searching for the largest width and height of the menu items to be generated.
266 * Uses some of the same code as makeGifs and even instantiates some gifbuilder objects BUT does not render the images - only reading out which width they would have.
267 * Remember to upgrade the code in here if the makeGifs function is updated.
268 *
269 * @param array $conf Same configuration array as passed to makeGifs()
270 * @param int $items The number of menu items
271 * @param array $Hobjs Array with "applyTotalH" numbers
272 * @param array $Wobjs Array with "applyTotalW" numbers
273 * @param array $minDim Array with "min" x/y
274 * @param array $maxDim Array with "max" x/y
275 * @return array Array with keys "H" and "W" which are in themselves arrays with the heights and widths of menu items inside. This can be used to find the max/min size of the menu items.
276 * @access private
277 * @see makeGifs()
278 */
279 public function findLargestDims($conf, $items, $Hobjs, $Wobjs, $minDim, $maxDim) {
280 $totalWH = array(
281 'W' => array(),
282 'H' => array(),
283 'W_total' => 0,
284 'H_total' => 0
285 );
286 $Hcounter = 0;
287 $Wcounter = 0;
288 $c = 0;
289 $maxFlag = 0;
290 foreach ($conf as $key => $val) {
291 // SAME CODE AS makeGifs()! BEGIN
292 if ($items == $c + 1 && $minDim) {
293 $Lobjs = $this->mconf['removeObjectsOfDummy'];
294 if ($Lobjs) {
295 $Lobjs = GeneralUtility::intExplode(',', $Lobjs);
296 foreach ($Lobjs as $remItem) {
297 unset($val[$remItem]);
298 unset($val[$remItem . '.']);
299 }
300 }
301 $flag = 0;
302 $tempXY = explode(',', $val['XY']);
303 if ($Wcounter < $minDim[0]) {
304 $tempXY[0] = $minDim[0] - $Wcounter;
305 $flag = 1;
306 }
307 if ($Hcounter < $minDim[1]) {
308 $tempXY[1] = $minDim[1] - $Hcounter;
309 $flag = 1;
310 }
311 $val['XY'] = implode(',', $tempXY);
312 if (!$flag) {
313 break;
314 }
315 }
316 $c++;
317 $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
318 $gifCreator->init();
319 $gifCreator->start($val, $this->menuArr[$key]);
320 if ($maxDim) {
321 $tempXY = explode(',', $val['XY']);
322 if ($maxDim[0] && $Wcounter + $gifCreator->XY[0] >= $maxDim[0]) {
323 $tempXY[0] == $maxDim[0] - $Wcounter;
324 $maxFlag = 1;
325 }
326 if ($maxDim[1] && $Hcounter + $gifCreator->XY[1] >= $maxDim[1]) {
327 $tempXY[1] = $maxDim[1] - $Hcounter;
328 $maxFlag = 1;
329 }
330 if ($maxFlag) {
331 $val['XY'] = implode(',', $tempXY);
332 $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
333 $gifCreator->init();
334 $gifCreator->start($val, $this->menuArr[$key]);
335 }
336 }
337 // SAME CODE AS makeGifs()! END
338 // Setting the width/height
339 $totalWH['W'][$key] = $gifCreator->XY[0];
340 $totalWH['H'][$key] = $gifCreator->XY[1];
341 $totalWH['W_total'] += $gifCreator->XY[0];
342 $totalWH['H_total'] += $gifCreator->XY[1];
343 // counter is increased
344 $Hcounter += $gifCreator->XY[1];
345 // counter is increased
346 $Wcounter += $gifCreator->XY[0];
347 if ($maxFlag) {
348 break;
349 }
350 }
351 return $totalWH;
352 }
353
354 /**
355 * Traverses the ->result['NO'] array of menu items configuration (made by ->generate()) and renders the HTML of each item (the images themselves was made with makeGifs() before this. See ->generate())
356 * During the execution of this function many internal methods prefixed "extProc_" from this class is called and many of these are for now dummy functions. But they can be used for processing as they are used by the GMENU_LAYERS
357 *
358 * @return string The HTML for the menu (returns result through $this->extProc_finish(); )
359 */
360 public function writeMenu() {
361 if (is_array($this->menuArr) && is_array($this->result) && count($this->result) && is_array($this->result['NO'])) {
362 // Create new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer for our use
363 $this->WMcObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
364 $this->WMresult = '';
365 $this->INPfixMD5 = substr(md5(microtime() . $this->GMENU_fixKey), 0, 4);
366 $this->WMmenuItems = count($this->result['NO']);
367 $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix' => $this->mconf['submenuObjSuffixes']), $this->WMmenuItems);
368 $this->extProc_init();
369 if (!isset($GLOBALS['TSFE']->additionalJavaScript['JSImgCode'])) {
370 $GLOBALS['TSFE']->additionalJavaScript['JSImgCode'] = '';
371 }
372 for ($key = 0; $key < $this->WMmenuItems; $key++) {
373 if ($this->result['NO'][$key]['output_file']) {
374 // Initialize the cObj with the page record of the menu item
375 $this->WMcObj->start($this->menuArr[$key], 'pages');
376 $this->I = array();
377 $this->I['key'] = $key;
378 $this->I['INPfix'] = ($this->imgNameNotRandom ? '' : '_' . $this->INPfixMD5) . '_' . $key;
379 $this->I['val'] = $this->result['NO'][$key];
380 $this->I['title'] = $this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']);
381 $this->I['uid'] = $this->menuArr[$key]['uid'];
382 $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
383 $this->I['pid'] = $this->menuArr[$key]['pid'];
384 $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
385 if (!$this->I['uid'] && !$this->menuArr[$key]['_OVERRIDE_HREF']) {
386 $this->I['spacer'] = 1;
387 }
388 $this->I['noLink'] = $this->I['spacer'] || $this->I['val']['noLink'] || !count($this->menuArr[$key]);
389 // !count($this->menuArr[$key]) means that this item is a dummyItem
390 $this->I['name'] = '';
391 // Set access key
392 if ($this->mconf['accessKey']) {
393 $this->I['accessKey'] = $this->accessKey($this->I['title']);
394 } else {
395 $this->I['accessKey'] = array();
396 }
397 // Make link tag
398 $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
399 if (isset($this->I['val']['additionalParams.'])) {
400 $this->I['val']['additionalParams'] = $this->WMcObj->stdWrap($this->I['val']['additionalParams'], $this->I['val']['additionalParams.']);
401 }
402 $this->I['linkHREF'] = $this->link($key, $this->I['val']['altTarget'], $this->mconf['forceTypeValue']);
403 // Title attribute of links:
404 $titleAttrValue = isset($this->I['val']['ATagTitle.']) ? $this->WMcObj->stdWrap($this->I['val']['ATagTitle'], $this->I['val']['ATagTitle.']) . $this->I['accessKey']['alt'] : $this->I['val']['ATagTitle'] . $this->I['accessKey']['alt'];
405 if (strlen($titleAttrValue)) {
406 $this->I['linkHREF']['title'] = $titleAttrValue;
407 }
408 // Set rollover
409 if ($this->result['RO'][$key] && !$this->I['noLink']) {
410 $this->I['theName'] = $this->imgNamePrefix . $this->I['uid'] . $this->I['INPfix'];
411 $this->I['name'] = ' ' . $this->nameAttribute . '="' . $this->I['theName'] . '"';
412 $this->I['linkHREF']['onMouseover'] = $this->WMfreezePrefix . 'over(\'' . $this->I['theName'] . '\');';
413 $this->I['linkHREF']['onMouseout'] = $this->WMfreezePrefix . 'out(\'' . $this->I['theName'] . '\');';
414 $GLOBALS['TSFE']->additionalJavaScript['JSImgCode'] .= LF . $this->I['theName'] . '_n=new Image(); ' . $this->I['theName'] . '_n.src = "' . $GLOBALS['TSFE']->absRefPrefix . $this->I['val']['output_file'] . '"; ';
415 $GLOBALS['TSFE']->additionalJavaScript['JSImgCode'] .= LF . $this->I['theName'] . '_h=new Image(); ' . $this->I['theName'] . '_h.src = "' . $GLOBALS['TSFE']->absRefPrefix . $this->result['RO'][$key]['output_file'] . '"; ';
416 $GLOBALS['TSFE']->imagesOnPage[] = $this->result['RO'][$key]['output_file'];
417 $GLOBALS['TSFE']->setJS('mouseOver');
418 $this->extProc_RO($key);
419 }
420 // Set altText
421 $this->I['altText'] = $this->I['title'] . $this->I['accessKey']['alt'];
422 // Calling extra processing function
423 $this->extProc_beforeLinking($key);
424 // Set linking
425 if (!$this->I['noLink']) {
426 $this->setATagParts();
427 } else {
428 $this->I['A1'] = '';
429 $this->I['A2'] = '';
430 }
431 $this->I['IMG'] = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . $this->I['val']['output_file'] . '" width="' . $this->I['val']['output_w'] . '" height="' . $this->I['val']['output_h'] . '" ' . $this->parent_cObj->getBorderAttr('border="0"') . ($this->mconf['disableAltText'] ? '' : ' alt="' . htmlspecialchars($this->I['altText']) . '"') . $this->I['name'] . ($this->I['val']['imgParams'] ? ' ' . $this->I['val']['imgParams'] : '') . ' />';
432 // Make before, middle and after parts
433 $this->I['parts'] = array();
434 $this->I['parts']['ATag_begin'] = $this->I['A1'];
435 $this->I['parts']['image'] = $this->I['IMG'];
436 $this->I['parts']['ATag_end'] = $this->I['A2'];
437 // Passing I to a user function
438 if ($this->mconf['IProcFunc']) {
439 $this->I = $this->userProcess('IProcFunc', $this->I);
440 }
441 // Putting the item together.
442 // Merge parts + beforeAllWrap
443 $this->I['theItem'] = implode('', $this->I['parts']);
444 $this->I['theItem'] = $this->extProc_beforeAllWrap($this->I['theItem'], $key);
445 // wrap:
446 $this->I['theItem'] = $this->WMcObj->wrap($this->I['theItem'], $this->I['val']['wrap']);
447 // allWrap:
448 $allWrap = isset($this->I['val']['allWrap.']) ? $this->WMcObj->stdWrap($this->I['val']['allWrap'], $this->I['val']['allWrap.']) : $this->I['val']['allWrap'];
449 $this->I['theItem'] = $this->WMcObj->wrap($this->I['theItem'], $allWrap);
450 if ($this->I['val']['subst_elementUid']) {
451 $this->I['theItem'] = str_replace('{elementUid}', $this->I['uid'], $this->I['theItem']);
452 }
453 // allStdWrap:
454 if (is_array($this->I['val']['allStdWrap.'])) {
455 $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'], $this->I['val']['allStdWrap.']);
456 }
457 $GLOBALS['TSFE']->imagesOnPage[] = $this->I['val']['output_file'];
458 $this->extProc_afterLinking($key);
459 }
460 }
461 return $this->extProc_finish();
462 }
463 }
464
465 /**
466 * Called right before the traversing of $this->result begins.
467 * Can be used for various initialization
468 *
469 * @return void
470 * @access private
471 * @see writeMenu()
472 */
473 public function extProc_init() {
474
475 }
476
477 /**
478 * Called after all processing for RollOver of an element has been done.
479 *
480 * @param int Pointer to $this->menuArr[$key] where the current menu element record is found OR $this->result['RO'][$key] where the configuration for that elements RO version is found!
481 * @return void
482 * @access private
483 * @see writeMenu()
484 */
485 public function extProc_RO($key) {
486
487 }
488
489 /**
490 * Called right before the creation of the link for the menu item
491 *
492 * @param int Pointer to $this->menuArr[$key] where the current menu element record is found
493 * @return void
494 * @access private
495 * @see writeMenu()
496 */
497 public function extProc_beforeLinking($key) {
498
499 }
500
501 /**
502 * Called right after the creation of links for the menu item. This is also the last function call before the for-loop traversing menu items goes to the next item.
503 * This function MUST set $this->WMresult.=[HTML for menu item] to add the generated menu item to the internal accumulation of items.
504 * Further this calls the subMenu function in the parent class to create any submenu there might be.
505 *
506 * @param int Pointer to $this->menuArr[$key] where the current menu element record is found
507 * @return void
508 * @access private
509 * @see writeMenu(), AbstractMenuContentObject::subMenu()
510 */
511 public function extProc_afterLinking($key) {
512 // Add part to the accumulated result + fetch submenus
513 if (!$this->I['spacer']) {
514 $this->I['theItem'] .= $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']);
515 }
516 $part = isset($this->I['val']['wrapItemAndSub.']) ? $this->WMcObj->stdWrap($this->I['val']['wrapItemAndSub'], $this->I['val']['wrapItemAndSub.']) : $this->I['val']['wrapItemAndSub'];
517 $this->WMresult .= $part ? $this->WMcObj->wrap($this->I['theItem'], $part) : $this->I['theItem'];
518 }
519
520 /**
521 * Called before the "wrap" happens on the menu item.
522 *
523 * @param string The current content of the menu item, $this->I['theItem'], passed along.
524 * @param int Pointer to $this->menuArr[$key] where the current menu element record is found
525 * @return string The modified version of $item, going back into $this->I['theItem']
526 * @access private
527 * @see writeMenu()
528 */
529 public function extProc_beforeAllWrap($item, $key) {
530 return $item;
531 }
532
533 /**
534 * Called before the writeMenu() function returns (only if a menu was generated)
535 *
536 * @return string The total menu content should be returned by this function
537 * @access private
538 * @see writeMenu()
539 */
540 public function extProc_finish() {
541 // stdWrap:
542 if (is_array($this->mconf['stdWrap.'])) {
543 $this->WMresult = $this->WMcObj->stdWrap($this->WMresult, $this->mconf['stdWrap.']);
544 }
545 return $this->WMcObj->wrap($this->WMresult, $this->mconf['wrap']) . $this->WMextraScript;
546 }
547
548 }