TYPO3 CMS  TYPO3_7-6
TextMenuContentObject.php
Go to the documentation of this file.
1 <?php
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 
21 {
29  public function generate()
30  {
31  $NOconf = [];
32  $splitCount = count($this->menuArr);
33  if ($splitCount) {
34  list($NOconf) = $this->procesItemStates($splitCount);
35  }
36  if (!empty($this->mconf['debugItemConf'])) {
37  echo '<h3>$NOconf:</h3>';
38  debug($NOconf);
39  }
40  $this->result = $NOconf;
41  }
42 
52  public function writeMenu()
53  {
54  if (empty($this->result)) {
55  return '';
56  }
57 
58  $this->WMresult = '';
59  $this->INPfixMD5 = substr(md5(microtime() . 'tmenu'), 0, 4);
60  $this->WMmenuItems = count($this->result);
61  $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(['sOSuffix' => $this->mconf['submenuObjSuffixes']], $this->WMmenuItems);
62  $this->extProc_init();
63  foreach ($this->result as $key => $val) {
64  $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
65  $GLOBALS['TSFE']->register['count_MENUOBJ']++;
66  // Initialize the cObj with the page record of the menu item
67  $this->WMcObj->start($this->menuArr[$key], 'pages');
68  $this->I = [];
69  $this->I['key'] = $key;
70  $this->I['INPfix'] = ($this->imgNameNotRandom ? '' : '_' . $this->INPfixMD5) . '_' . $key;
71  $this->I['val'] = $val;
72  $this->I['title'] = isset($this->I['val']['stdWrap.']) ? $this->WMcObj->stdWrap($this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']), $this->I['val']['stdWrap.']) : $this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']);
73  $this->I['uid'] = $this->menuArr[$key]['uid'];
74  $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
75  $this->I['pid'] = $this->menuArr[$key]['pid'];
76  $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
77  // Set access key
78  if ($this->mconf['accessKey']) {
79  $this->I['accessKey'] = $this->accessKey($this->I['title']);
80  } else {
81  $this->I['accessKey'] = [];
82  }
83  // Make link tag
84  $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
85  if (isset($this->I['val']['additionalParams.'])) {
86  $this->I['val']['additionalParams'] = $this->WMcObj->stdWrap($this->I['val']['additionalParams'], $this->I['val']['additionalParams.']);
87  }
88  $this->I['linkHREF'] = $this->link($key, $this->I['val']['altTarget'], $this->mconf['forceTypeValue']);
89  if (empty($this->I['linkHREF'])) {
90  $this->I['val']['doNotLinkIt'] = 1;
91  }
92  // Title attribute of links:
93  $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'];
94  if ($titleAttrValue !== '') {
95  $this->I['linkHREF']['title'] = $titleAttrValue;
96  }
97 
98  // Calling extra processing function
99  $this->extProc_beforeLinking($key);
100  // stdWrap for doNotLinkIt
101  if (isset($this->I['val']['doNotLinkIt.'])) {
102  $this->I['val']['doNotLinkIt'] = $this->WMcObj->stdWrap($this->I['val']['doNotLinkIt'], $this->I['val']['doNotLinkIt.']);
103  }
104  // Compile link tag
105  if (!$this->I['val']['doNotLinkIt']) {
106  $this->I['val']['doNotLinkIt'] = 0;
107  }
108  if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt'] != 1) {
109  $this->setATagParts();
110  } else {
111  $this->I['A1'] = '';
112  $this->I['A2'] = '';
113  }
114  // ATagBeforeWrap processing:
115  if ($this->I['val']['ATagBeforeWrap']) {
116  $wrapPartsBefore = explode('|', $this->I['val']['linkWrap']);
117  $wrapPartsAfter = ['', ''];
118  } else {
119  $wrapPartsBefore = ['', ''];
120  $wrapPartsAfter = explode('|', $this->I['val']['linkWrap']);
121  }
122  if ($this->I['val']['stdWrap2'] || isset($this->I['val']['stdWrap2.'])) {
123  $stdWrap2 = isset($this->I['val']['stdWrap2.']) ? $this->WMcObj->stdWrap('|', $this->I['val']['stdWrap2.']) : '|';
124  $wrapPartsStdWrap = explode($this->I['val']['stdWrap2'] ? $this->I['val']['stdWrap2'] : '|', $stdWrap2);
125  } else {
126  $wrapPartsStdWrap = ['', ''];
127  }
128  // Make before, middle and after parts
129  $this->I['parts'] = [];
130  $this->I['parts']['before'] = $this->getBeforeAfter('before');
131  $this->I['parts']['stdWrap2_begin'] = $wrapPartsStdWrap[0];
132  // stdWrap for doNotShowLink
133  if (isset($this->I['val']['doNotShowLink.'])) {
134  $this->I['val']['doNotShowLink'] = $this->WMcObj->stdWrap($this->I['val']['doNotShowLink'], $this->I['val']['doNotShowLink.']);
135  }
136  if (!$this->I['val']['doNotShowLink']) {
137  $this->I['parts']['notATagBeforeWrap_begin'] = $wrapPartsAfter[0];
138  $this->I['parts']['ATag_begin'] = $this->I['A1'];
139  $this->I['parts']['ATagBeforeWrap_begin'] = $wrapPartsBefore[0];
140  $this->I['parts']['title'] = $this->I['title'];
141  $this->I['parts']['ATagBeforeWrap_end'] = $wrapPartsBefore[1];
142  $this->I['parts']['ATag_end'] = $this->I['A2'];
143  $this->I['parts']['notATagBeforeWrap_end'] = $wrapPartsAfter[1];
144  }
145  $this->I['parts']['stdWrap2_end'] = $wrapPartsStdWrap[1];
146  $this->I['parts']['after'] = $this->getBeforeAfter('after');
147  // Passing I to a user function
148  if ($this->mconf['IProcFunc']) {
149  $this->I = $this->userProcess('IProcFunc', $this->I);
150  }
151  // Merge parts + beforeAllWrap
152  $this->I['theItem'] = implode('', $this->I['parts']);
153  $this->I['theItem'] = $this->extProc_beforeAllWrap($this->I['theItem'], $key);
154  // allWrap:
155  $allWrap = isset($this->I['val']['allWrap.']) ? $this->WMcObj->stdWrap($this->I['val']['allWrap'], $this->I['val']['allWrap.']) : $this->I['val']['allWrap'];
156  $this->I['theItem'] = $this->WMcObj->wrap($this->I['theItem'], $allWrap);
157  if ($this->I['val']['subst_elementUid']) {
158  $this->I['theItem'] = str_replace('{elementUid}', $this->I['uid'], $this->I['theItem']);
159  }
160  // allStdWrap:
161  if (is_array($this->I['val']['allStdWrap.'])) {
162  $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'], $this->I['val']['allStdWrap.']);
163  }
164  // Calling extra processing function
165  $this->extProc_afterLinking($key);
166  }
167  return $this->extProc_finish();
168  }
169 
176  public function getBeforeAfter($pref)
177  {
178  $res = '';
179  if ($imgInfo = $this->WMcObj->getImgResource($this->I['val'][$pref . 'Img'], $this->I['val'][$pref . 'Img.'])) {
180  $theName = $this->imgNamePrefix . $this->I['uid'] . $this->I['INPfix'] . $pref;
181  $name = ' ' . $this->nameAttribute . '="' . $theName . '"';
182  $GLOBALS['TSFE']->imagesOnPage[] = $imgInfo[3];
183  $res = '<img' . ' src="' . $GLOBALS['TSFE']->absRefPrefix . $imgInfo[3] . '"' . ' width="' . $imgInfo[0] . '"' . ' height="' . $imgInfo[1] . '"' . $name . ($this->I['val'][$pref . 'ImgTagParams'] ? ' ' . $this->I['val'][$pref . 'ImgTagParams'] : '') . $this->parent_cObj->getBorderAttr(' border="0"');
184  if (!strstr($res, 'alt="')) {
185  // Adding alt attribute if not set.
186  $res .= ' alt=""';
187  }
188  $res .= ' />';
189  if ($this->I['val'][$pref . 'ImgLink']) {
190  $res = $this->I['A1'] . $res . $this->I['A2'];
191  }
192  }
193  $processedPref = isset($this->I['val'][$pref . '.']) ? $this->WMcObj->stdWrap($this->I['val'][$pref], $this->I['val'][$pref . '.']) : $this->I['val'][$pref];
194  if (isset($this->I['val'][$pref . 'Wrap'])) {
195  return $this->WMcObj->wrap($res . $processedPref, $this->I['val'][$pref . 'Wrap']);
196  } else {
197  return $res . $processedPref;
198  }
199  }
200 
209  public function extProc_init()
210  {
211  }
212 
221  public function extProc_beforeLinking($key)
222  {
223  }
224 
234  public function extProc_afterLinking($key)
235  {
236  // Add part to the accumulated result + fetch submenus
237  if (!$this->I['spacer']) {
238  $this->I['theItem'] .= $this->subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix']);
239  }
240  $part = isset($this->I['val']['wrapItemAndSub.']) ? $this->WMcObj->stdWrap($this->I['val']['wrapItemAndSub'], $this->I['val']['wrapItemAndSub.']) : $this->I['val']['wrapItemAndSub'];
241  $this->WMresult .= $part ? $this->WMcObj->wrap($this->I['theItem'], $part) : $this->I['theItem'];
242  }
243 
253  public function extProc_beforeAllWrap($item, $key)
254  {
255  return $item;
256  }
257 
265  public function extProc_finish()
266  {
267  // stdWrap:
268  if (is_array($this->mconf['stdWrap.'])) {
269  $this->WMresult = $this->WMcObj->stdWrap($this->WMresult, $this->mconf['stdWrap.']);
270  }
271  return $this->WMcObj->wrap($this->WMresult, $this->mconf['wrap']) . $this->WMextraScript;
272  }
273 }
debug($variable='', $name=' *variable *', $line=' *line *', $file=' *file *', $recursiveDepth=3, $debugLevel='E_DEBUG')
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']