33 trigger_error(
'GMENU and GraphicalMenuContentObject will be removed in TYPO3 v10.0, you should build accessible websites with TMENU/Text, and optional images on top, which can be achieved with TypoScript.', E_USER_DEPRECATED);
44 $splitCount = count($this->menuArr);
49 $temp_HMENU_MENUOBJ = $tsfe->register[
'count_HMENU_MENUOBJ'];
50 $temp_MENUOBJ = $tsfe->register[
'count_MENUOBJ'];
54 $tempcnt_HMENU_MENUOBJ = $tsfe->register[
'count_HMENU_MENUOBJ'];
55 $tempcnt_MENUOBJ = $tsfe->register[
'count_MENUOBJ'];
56 if ($this->mconf[
'debugItemConf']) {
57 echo
'<h3>$NOconf:</h3>';
63 $tsfe->register[
'count_HMENU_MENUOBJ'] = $temp_HMENU_MENUOBJ;
64 $tsfe->register[
'count_MENUOBJ'] = $temp_MENUOBJ;
66 if ($this->mconf[
'debugItemConf']) {
67 echo
'<h3>$ROconf:</h3>';
72 $tsfe->register[
'count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ;
73 $tsfe->register[
'count_MENUOBJ'] = $tempcnt_MENUOBJ;
88 $isGD =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'gdlib'];
102 $Hobjs = $this->mconf[
'applyTotalH'];
104 $Hobjs = GeneralUtility::intExplode(
',', $Hobjs);
106 $Wobjs = $this->mconf[
'applyTotalW'];
108 $Wobjs = GeneralUtility::intExplode(
',', $Wobjs);
110 $minDim = $this->mconf[
'min'];
114 $maxDim = $this->mconf[
'max'];
120 $this->menuArr[$items] = [];
124 if ($this->mconf[
'useLargestItemX'] || $this->mconf[
'useLargestItemY'] || $this->mconf[
'distributeX'] || $this->mconf[
'distributeY']) {
130 $distributeAccu = [
'H' => 0,
'W' => 0];
131 foreach (
$conf as $key => $val) {
134 if ($items === $c + 1 && $minDim) {
135 $Lobjs = $this->mconf[
'removeObjectsOfDummy'];
137 $Lobjs = GeneralUtility::intExplode(
',', $Lobjs);
138 foreach ($Lobjs as $remItem) {
139 unset($val[$remItem]);
140 unset($val[$remItem .
'.']);
144 $tempXY = explode(
',', $val[
'XY']);
145 if ($Wcounter < $minDim[0]) {
146 $tempXY[0] = $minDim[0] - $Wcounter;
149 if ($Hcounter < $minDim[1]) {
150 $tempXY[1] = $minDim[1] - $Hcounter;
153 $val[
'XY'] = implode(
',', $tempXY);
162 $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
163 $gifCreator->start($val, $this->menuArr[$key]);
165 if (!empty($totalWH) && ($this->mconf[
'useLargestItemX'] || $this->mconf[
'useLargestItemY'])) {
166 $tempXY = explode(
',', $gifCreator->setup[
'XY']);
167 if ($this->mconf[
'useLargestItemX']) {
168 $tempXY[0] = max($totalWH[
'W']);
170 if ($this->mconf[
'useLargestItemY']) {
171 $tempXY[1] = max($totalWH[
'H']);
174 $val[
'XY'] = implode(
',', $tempXY);
175 $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
176 $gifCreator->start($val, $this->menuArr[$key]);
179 if (!empty($totalWH) && ($this->mconf[
'distributeX'] || $this->mconf[
'distributeY'])) {
180 $tempXY = explode(
',', $gifCreator->setup[
'XY']);
181 if ($this->mconf[
'distributeX']) {
182 $diff = $this->mconf[
'distributeX'] - $totalWH[
'W_total'] - $distributeAccu[
'W'];
183 $compensate = round($diff / ($items - $c + 1));
184 $distributeAccu[
'W'] += $compensate;
185 $tempXY[0] = $totalWH[
'W'][$key] + $compensate;
187 if ($this->mconf[
'distributeY']) {
188 $diff = $this->mconf[
'distributeY'] - $totalWH[
'H_total'] - $distributeAccu[
'H'];
189 $compensate = round($diff / ($items - $c + 1));
190 $distributeAccu[
'H'] += $compensate;
191 $tempXY[1] = $totalWH[
'H'][$key] + $compensate;
194 $val[
'XY'] = implode(
',', $tempXY);
195 $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
196 $gifCreator->start($val, $this->menuArr[$key]);
200 $tempXY = explode(
',', $val[
'XY']);
201 if ($maxDim[0] && $Wcounter + $gifCreator->XY[0] >= $maxDim[0]) {
202 $tempXY[0] = $maxDim[0] - $Wcounter;
205 if ($maxDim[1] && $Hcounter + $gifCreator->XY[1] >= $maxDim[1]) {
206 $tempXY[1] = $maxDim[1] - $Hcounter;
210 $val[
'XY'] = implode(
',', $tempXY);
211 $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
212 $gifCreator->start($val, $this->menuArr[$key]);
217 foreach ($Hobjs as $index) {
218 if ($gifCreator->setup[$index] && $gifCreator->setup[$index .
'.']) {
219 $oldOffset = explode(
',', $gifCreator->setup[$index .
'.'][
'offset']);
220 $gifCreator->setup[$index .
'.'][
'offset'] = implode(
',', $gifCreator->applyOffset($oldOffset, [0, -$Hcounter]));
225 foreach ($Wobjs as $index) {
226 if ($gifCreator->setup[$index] && $gifCreator->setup[$index .
'.']) {
227 $oldOffset = explode(
',', $gifCreator->setup[$index .
'.'][
'offset']);
228 $gifCreator->setup[$index .
'.'][
'offset'] = implode(
',', $gifCreator->applyOffset($oldOffset, [-$Wcounter, 0]));
235 if (
$conf[$key][
'altImgResource'] || is_array(
$conf[$key][
'altImgResource.'])) {
236 $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
237 $cObj->start($this->menuArr[$key],
'pages');
238 $altImgInfo = $cObj->getImgResource(
$conf[$key][
'altImgResource'],
$conf[$key][
'altImgResource.']);
239 $gifFileName = $altImgInfo[3];
242 if (!$gifFileName && $isGD) {
244 $gifFileName = $gifCreator->fileName(
'assets/menu/');
246 $this->result[$resKey][$key] =
$conf[$key];
249 if (file_exists($gifFileName)) {
250 $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $gifFileName);
251 $this->result[$resKey][$key][
'output_w'] = (int)$imageInfo->getWidth();
252 $this->result[$resKey][$key][
'output_h'] = (int)$imageInfo->getHeight();
253 $this->result[$resKey][$key][
'output_file'] = $gifFileName;
257 $this->result[$resKey][$key][
'output_w'] = $gifCreator->w;
258 $this->result[$resKey][$key][
'output_h'] = $gifCreator->h;
259 $this->result[$resKey][$key][
'output_file'] = $gifFileName;
260 $gifCreator->output($this->result[$resKey][$key][
'output_file']);
261 $gifCreator->destroy();
264 $Hcounter += $this->result[$resKey][$key][
'output_h'];
266 $Wcounter += $this->result[$resKey][$key][
'output_w'];
290 $items = (int)$items;
301 foreach (
$conf as $key => $val) {
303 if ($items === $c + 1 && $minDim) {
304 $Lobjs = $this->mconf[
'removeObjectsOfDummy'];
306 $Lobjs = GeneralUtility::intExplode(
',', $Lobjs);
307 foreach ($Lobjs as $remItem) {
308 unset($val[$remItem]);
309 unset($val[$remItem .
'.']);
313 $tempXY = explode(
',', $val[
'XY']);
314 if ($Wcounter < $minDim[0]) {
315 $tempXY[0] = $minDim[0] - $Wcounter;
318 if ($Hcounter < $minDim[1]) {
319 $tempXY[1] = $minDim[1] - $Hcounter;
322 $val[
'XY'] = implode(
',', $tempXY);
328 $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
329 $gifCreator->start($val, $this->menuArr[$key]);
331 $tempXY = explode(
',', $val[
'XY']);
332 if ($maxDim[0] && $Wcounter + $gifCreator->XY[0] >= $maxDim[0]) {
333 $tempXY[0] = $maxDim[0] - $Wcounter;
336 if ($maxDim[1] && $Hcounter + $gifCreator->XY[1] >= $maxDim[1]) {
337 $tempXY[1] = $maxDim[1] - $Hcounter;
341 $val[
'XY'] = implode(
',', $tempXY);
342 $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
343 $gifCreator->start($val, $this->menuArr[$key]);
348 $totalWH[
'W'][$key] = $gifCreator->XY[0];
349 $totalWH[
'H'][$key] = $gifCreator->XY[1];
350 $totalWH[
'W_total'] += $gifCreator->XY[0];
351 $totalWH[
'H_total'] += $gifCreator->XY[1];
353 $Hcounter += $gifCreator->XY[1];
355 $Wcounter += $gifCreator->XY[0];
371 if (!is_array($this->menuArr) || empty($this->result) || !is_array($this->result[
'NO'])) {
374 $this->WMresult =
'';
375 $this->INPfixMD5 = substr(md5(microtime() . $this->GMENU_fixKey), 0, 4);
376 $this->WMmenuItems = count($this->result[
'NO']);
377 $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
378 $this->WMsubmenuObjSuffixes = $typoScriptService->explodeConfigurationForOptionSplit([
'sOSuffix' => $this->mconf[
'submenuObjSuffixes']], $this->WMmenuItems);
381 if (!isset($tsfe->additionalJavaScript[
'JSImgCode'])) {
382 $tsfe->additionalJavaScript[
'JSImgCode'] =
'';
385 if ($this->result[
'NO'][$key][
'output_file']) {
387 $this->WMcObj->start($this->menuArr[$key],
'pages');
389 $this->I[
'key'] = $key;
390 $this->I[
'INPfix'] = ($this->imgNameNotRandom ?
'' :
'_' .
$this->INPfixMD5) .
'_' . $key;
391 $this->I[
'val'] = $this->result[
'NO'][$key];
392 $this->I[
'title'] = $this->
getPageTitle($this->menuArr[$key][
'title'], $this->menuArr[$key][
'nav_title']);
393 $this->I[
'uid'] = $this->menuArr[$key][
'uid'];
394 $this->I[
'mount_pid'] = $this->menuArr[$key][
'mount_pid'];
395 $this->I[
'pid'] = $this->menuArr[$key][
'pid'];
396 $this->I[
'spacer'] = $this->menuArr[$key][
'isSpacer'];
397 if (!$this->I[
'uid'] && !$this->menuArr[$key][
'_OVERRIDE_HREF']) {
398 $this->I[
'spacer'] = 1;
400 $this->I[
'noLink'] = $this->I[
'spacer'] || $this->I[
'val'][
'noLink'] || empty($this->menuArr[$key]);
402 $this->I[
'name'] =
'';
404 if ($this->mconf[
'accessKey']) {
405 $this->I[
'accessKey'] = $this->
accessKey($this->I[
'title']);
407 $this->I[
'accessKey'] = [];
410 $this->I[
'val'][
'ATagParams'] = $this->WMcObj->getATagParams($this->I[
'val']);
411 if (isset($this->I[
'val'][
'additionalParams.'])) {
412 $this->I[
'val'][
'additionalParams'] = $this->WMcObj->stdWrap($this->I[
'val'][
'additionalParams'], $this->I[
'val'][
'additionalParams.']);
414 $this->I[
'linkHREF'] = $this->
link($key, $this->I[
'val'][
'altTarget'], $this->mconf[
'forceTypeValue']);
416 $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'];
417 if ($titleAttrValue !==
'') {
418 $this->I[
'linkHREF'][
'title'] = $titleAttrValue;
421 if ($this->result[
'RO'][$key] && !$this->I[
'noLink']) {
422 $this->I[
'theName'] = $this->imgNamePrefix . $this->I[
'uid'] . $this->I[
'INPfix'];
423 $this->I[
'name'] =
' ' . $this->nameAttribute .
'="' . $this->I[
'theName'] .
'"';
424 $this->I[
'linkHREF'][
'onMouseover'] = $this->WMfreezePrefix .
'over(' . GeneralUtility::quoteJSvalue($this->I[
'theName']) .
');';
425 $this->I[
'linkHREF'][
'onMouseout'] = $this->WMfreezePrefix .
'out(' . GeneralUtility::quoteJSvalue($this->I[
'theName']) .
');';
426 $tsfe->additionalJavaScript[
'JSImgCode'] .= LF . $this->I[
'theName'] .
'_n=new Image(); ' . $this->I[
'theName'] .
'_n.src = ' . GeneralUtility::quoteJSvalue($tsfe->absRefPrefix . $this->I[
'val'][
'output_file']) .
'; ';
427 $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']) .
'; ';
428 $tsfe->imagesOnPage[] = $this->result[
'RO'][$key][
'output_file'];
429 $tsfe->setJS(
'mouseOver');
433 $this->I[
'altText'] = $this->I[
'title'] . $this->I[
'accessKey'][
'alt'];
437 if (!$this->I[
'noLink']) {
443 $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'] :
'') .
' />';
445 $this->I[
'parts'] = [];
446 $this->I[
'parts'][
'ATag_begin'] = $this->I[
'A1'];
447 $this->I[
'parts'][
'image'] = $this->I[
'IMG'];
448 $this->I[
'parts'][
'ATag_end'] = $this->I[
'A2'];
450 if ($this->mconf[
'IProcFunc']) {
455 $this->I[
'theItem'] = implode(
'', $this->I[
'parts']);
458 $this->I[
'theItem'] = $this->WMcObj->wrap($this->I[
'theItem'], $this->I[
'val'][
'wrap']);
460 $allWrap = isset($this->I[
'val'][
'allWrap.']) ? $this->WMcObj->stdWrap($this->I[
'val'][
'allWrap'], $this->I[
'val'][
'allWrap.']) : $this->I[
'val'][
'allWrap'];
461 $this->I[
'theItem'] = $this->WMcObj->wrap($this->I[
'theItem'], $allWrap);
462 if ($this->I[
'val'][
'subst_elementUid']) {
463 $this->I[
'theItem'] = str_replace(
'{elementUid}', $this->I[
'uid'], $this->I[
'theItem']);
466 if (is_array($this->I[
'val'][
'allStdWrap.'])) {
467 $this->I[
'theItem'] = $this->WMcObj->stdWrap($this->I[
'theItem'], $this->I[
'val'][
'allStdWrap.']);
469 $tsfe->imagesOnPage[] = $this->I[
'val'][
'output_file'];
518 if (!$this->I[
'spacer']) {
519 $this->I[
'theItem'] .= $this->
subMenu($this->I[
'uid'], $this->WMsubmenuObjSuffixes[$key][
'sOSuffix']);
521 $part = isset($this->I[
'val'][
'wrapItemAndSub.']) ? $this->WMcObj->stdWrap($this->I[
'val'][
'wrapItemAndSub'], $this->I[
'val'][
'wrapItemAndSub.']) : $this->I[
'val'][
'wrapItemAndSub'];
522 $this->WMresult .= $part ? $this->WMcObj->wrap($this->I[
'theItem'], $part) : $this->I[
'theItem'];
547 if (is_array($this->mconf[
'stdWrap.'])) {
548 $this->WMresult = $this->WMcObj->stdWrap($this->WMresult, $this->mconf[
'stdWrap.']);
563 $temp = explode(
',', $string);
564 foreach ($temp as $key => $val) {
565 $temp[$key] = (int)$this->parent_cObj->calc($val);