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