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