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