33 trigger_error(
'IMGMENU and ImageMenuContentObject 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);
45 $splitCount = count($this->menuArr);
49 if (!empty($this->mconf[
'debugItemConf'])) {
50 echo
'<h3>$NOconf:</h3>';
69 if (is_array($this->mconf[
'main.'])) {
70 $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
72 $conf = $this->mconf[
'main.'];
75 $gifObjCount = (int)end($sKeyArray);
78 foreach ($itemsConf as $key => $val) {
81 $waArr[$key][
'free'] = $gifObjCount;
83 foreach ($sKeyArray as $theKey) {
84 $theValue = $val[$theKey];
85 if ((
int)$theKey && ($theValArr = $val[$theKey .
'.'])) {
86 $cObjData = $this->menuArr[$key] ?: [];
88 if ($theValue ===
'TEXT') {
89 $waArr[$key][
'textNum'] = $gifObjCount;
90 $gifCreator->data = $cObjData;
91 $theValArr = $gifCreator->checkTextObj($theValArr);
93 unset($theValArr[
'text.']);
95 $LD = $this->
menuTypoLink($this->menuArr[$key], $this->mconf[
'target'],
'',
'', [],
'', $this->mconf[
'forceTypeValue']);
99 if ($this->menuArr[$key][
'_OVERRIDE_HREF']) {
100 $LD[
'totalURL'] = $this->menuArr[$key][
'_OVERRIDE_HREF'];
101 if ($this->menuArr[$key][
'_OVERRIDE_TARGET']) {
102 $LD[
'target'] = $this->menuArr[$key][
'_OVERRIDE_TARGET'];
106 if ($theValArr[
'imgMap.'][
'url'] ===
'') {
107 $theValArr[
'imgMap.'][
'url'] = $LD[
'totalURL'];
109 if ($theValArr[
'imgMap.'][
'target'] ===
'') {
110 $theValArr[
'imgMap.'][
'target'] = $LD[
'target'];
112 if (is_array($theValArr[
'imgMap.'][
'altText.'])) {
113 $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
114 $cObj->start($cObjData,
'pages');
115 if (isset($theValArr[
'imgMap.'][
'altText.'])) {
116 $theValArr[
'imgMap.'][
'altText'] = $cObj->stdWrap($theValArr[
'imgMap.'][
'altText'], $theValArr[
'imgMap.'][
'altText.']);
118 unset($theValArr[
'imgMap.'][
'altText.']);
120 if (is_array($theValArr[
'imgMap.'][
'titleText.'])) {
121 $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
122 $cObj->start($cObjData,
'pages');
123 if (isset($theValArr[
'imgMap.'][
'titleText.'])) {
124 $theValArr[
'imgMap.'][
'titleText'] = $cObj->stdWrap($theValArr[
'imgMap.'][
'titleText'], $theValArr[
'imgMap.'][
'titleText.']);
126 unset($theValArr[
'imgMap.'][
'titleText.']);
130 if ($theValue ===
'IMAGE') {
131 if ($theValArr[
'file'] ===
'GIFBUILDER') {
133 foreach ($temp_sKeyArray as $temp_theKey) {
134 if ($theValArr[
'mask.'][$temp_theKey] ===
'TEXT') {
135 $gifCreator->data = $this->menuArr[$key] ?: [];
136 $theValArr[
'mask.'][$temp_theKey .
'.'] = $gifCreator->checkTextObj($theValArr[
'mask.'][$temp_theKey .
'.']);
138 unset($theValArr[
'mask.'][$temp_theKey .
'.'][
'text.']);
142 if ($theValArr[
'mask'] ===
'GIFBUILDER') {
144 foreach ($temp_sKeyArray as $temp_theKey) {
145 if ($theValArr[
'mask.'][$temp_theKey] ===
'TEXT') {
146 $gifCreator->data = $this->menuArr[$key] ?: [];
147 $theValArr[
'mask.'][$temp_theKey .
'.'] = $gifCreator->checkTextObj($theValArr[
'mask.'][$temp_theKey .
'.']);
149 unset($theValArr[
'mask.'][$temp_theKey .
'.'][
'text.']);
156 if ($theValArr[
'if.']) {
158 $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
159 $cObj->start($cObjData,
'pages');
160 if (!empty($theValArr[
'if.']) && !$cObj->checkIf($theValArr[
'if.'])) {
163 unset($theValArr[
'if.']);
167 $conf[$gifObjCount] = $theValue;
168 $conf[$gifObjCount .
'.'] = $theValArr;
177 foreach ($waArr as $key => $val) {
178 if ($dConf[$key] = $itemsConf[$key][
'distrib']) {
179 $textBB = $gifCreator->objBB[$val[
'textNum']];
180 $dConf[$key] = str_replace(
182 [$textBB[0], $textBB[1]],
185 $dConf[$key] = GeneralUtility::intExplode(
',', $gifCreator->calcOffset($dConf[$key]));
188 $workArea = GeneralUtility::intExplode(
',', $gifCreator->calcOffset($this->mconf[
'dWorkArea']));
189 foreach ($waArr as $key => $val) {
190 $index = $val[
'free'];
191 $gifCreator->setup[$index] =
'WORKAREA';
192 $workArea[2] = $dConf[$key][2] ?: $dConf[$key][0];
193 $workArea[3] = $dConf[$key][3] ?: $dConf[$key][1];
194 $gifCreator->setup[$index .
'.'][
'set'] = implode(
',', $workArea);
195 $workArea[0] += $dConf[$key][0];
196 $workArea[1] += $dConf[$key][1];
198 if ($this->mconf[
'debugRenumberedObject']) {
199 echo
'<h3>Renumbered GIFBUILDER object:</h3>';
200 debug($gifCreator->setup);
203 $gifFileName = $gifCreator->fileName(
'assets/menu/');
206 $imgHash = md5($gifFileName);
207 $imgMap = $cache->get($imgHash);
209 if ($imgMap && file_exists($gifFileName)) {
210 $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $gifFileName);
211 $w = $imageInfo->getWidth();
212 $h = $imageInfo->getHeight();
218 $gifCreator->output($gifFileName);
219 $gifCreator->destroy();
220 $imgMap = $gifCreator->map;
221 $cache->set($imgHash, $imgMap, [
'ident_MENUIMAGEMAP'], 0);
223 $imgMap .= $this->mconf[
'imgMapExtras'];
224 $this->result = [
'output_file' => $gifFileName,
'output_w' => $w,
'output_h' => $h,
'imgMap' => $imgMap];
240 $menuName =
'menu_' . GeneralUtility::shortMD5($res[
'imgMap']);
241 $result =
'<img src="' . $this->
getTypoScriptFrontendController()->absRefPrefix . $res[
'output_file'] .
'" width="' . $res[
'output_w'] .
'" height="' . $res[
'output_h'] .
'" usemap="#' . $menuName .
'" border="0" ' . $this->mconf[
'params'];
244 $result .=
' alt="Menu Image Map"';
246 $result .=
' /><map name="' . $menuName .
'" id="' . $menuName .
'">' . $res[
'imgMap'] .
'</map>';
248 return $this->WMcObj->wrap(
$result, $this->mconf[
'wrap']);