‪TYPO3CMS  11.5
TextMenuContentObject.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
25 {
32  public function ‪generate()
33  {
34  $itemConfiguration = [];
35  $splitCount = count($this->menuArr);
36  if ($splitCount) {
37  $itemConfiguration = $this->‪processItemStates($splitCount);
38  }
39  if (!empty($this->mconf['debugItemConf'])) {
40  echo '<h3>$itemConfiguration:</h3>';
41  ‪debug($itemConfiguration);
42  }
43  $this->result = $itemConfiguration;
44  }
45 
55  public function ‪writeMenu()
56  {
57  if (empty($this->result)) {
58  return '';
59  }
60 
61  $frontendController = $this->‪getTypoScriptFrontendController();
62  $this->WMresult = '';
63  $this->WMmenuItems = count($this->result);
64  $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
65  $this->WMsubmenuObjSuffixes = $typoScriptService->explodeConfigurationForOptionSplit(['sOSuffix' => $this->mconf['submenuObjSuffixes'] ?? null], $this->WMmenuItems);
66  foreach ($this->result as $key => $val) {
67  $frontendController->register['count_HMENU_MENUOBJ']++;
68  $frontendController->register['count_MENUOBJ']++;
69  // Initialize the cObj with the page record of the menu item
70  $this->WMcObj->start($this->menuArr[$key], 'pages', $this->request);
71  $this->I = [];
72  $this->I['key'] = $key;
73  $this->I['val'] = $val;
74  $this->I['title'] = $this->‪getPageTitle(($this->menuArr[$key]['title'] ?? ''), ($this->menuArr[$key]['nav_title'] ?? ''));
75  $this->I['title.'] = $this->I['val']['stdWrap.'] ?? [];
76  $this->I['title'] = $this->WMcObj->stdWrapValue('title', $this->I ?? []);
77  $this->I['uid'] = $this->menuArr[$key]['uid'] ?? 0;
78  $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'] ?? 0;
79  $this->I['pid'] = $this->menuArr[$key]['pid'] ?? 0;
80  $this->I['spacer'] = $this->menuArr[$key]['isSpacer'] ?? false;
81  // Set access key
82  if ($this->mconf['accessKey'] ?? false) {
83  $this->I['accessKey'] = $this->‪accessKey((string)($this->I['title'] ?? ''));
84  } else {
85  $this->I['accessKey'] = [];
86  }
87  // Make link tag
88  $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
89  $this->I['val']['additionalParams'] = $this->WMcObj->stdWrapValue('additionalParams', $this->I['val']);
90  $this->I['linkHREF'] = $this->‪link((int)$key, (string)($this->I['val']['altTarget'] ?? ''), ($this->mconf['forceTypeValue'] ?? ''));
91  if (empty($this->I['linkHREF'])) {
92  $this->I['val']['doNotLinkIt'] = 1;
93  }
94  // Title attribute of links:
95  $titleAttrValue = $this->WMcObj->stdWrapValue('ATagTitle', $this->I['val']);
96  $titleAttrValue .= $this->I['accessKey']['alt'] ?? '';
97  if ($titleAttrValue !== '') {
98  $this->I['linkHREF']['title'] = $titleAttrValue;
99  }
100 
101  // stdWrap for doNotLinkIt
102  $this->I['val']['doNotLinkIt'] = $this->WMcObj->stdWrapValue('doNotLinkIt', $this->I['val']);
103  // Compile link tag
104  if (!$this->I['val']['doNotLinkIt']) {
105  $this->I['val']['doNotLinkIt'] = 0;
106  }
107  if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt'] != 1) {
108  $this->‪setATagParts();
109  } else {
110  $this->I['A1'] = '';
111  $this->I['A2'] = '';
112  }
113  // ATagBeforeWrap processing:
114  if ($this->I['val']['ATagBeforeWrap'] ?? false) {
115  $wrapPartsBefore = explode('|', $this->I['val']['linkWrap'] ?? '');
116  $wrapPartsAfter = ['', ''];
117  } else {
118  $wrapPartsBefore = ['', ''];
119  $wrapPartsAfter = explode('|', $this->I['val']['linkWrap'] ?? '');
120  }
121  if (($this->I['val']['stdWrap2'] ?? false) || isset($this->I['val']['stdWrap2.'])) {
122  $stdWrap2 = (string)(isset($this->I['val']['stdWrap2.']) ? $this->WMcObj->stdWrap('|', $this->I['val']['stdWrap2.']) : '|');
123  $stdWrap2Value = (string)($this->I['val']['stdWrap2'] ?? '|');
124  $stdWrap2Value = $stdWrap2Value !== '' ? $stdWrap2Value : '|';
125  $wrapPartsStdWrap = explode($stdWrap2Value, $stdWrap2);
126  } else {
127  $wrapPartsStdWrap = ['', ''];
128  }
129  // Make before, middle and after parts
130  $this->I['parts'] = [];
131  $this->I['parts']['before'] = $this->‪getBeforeAfter('before');
132  $this->I['parts']['stdWrap2_begin'] = $wrapPartsStdWrap[0] ?? '';
133  // stdWrap for doNotShowLink
134  $this->I['val']['doNotShowLink'] = $this->WMcObj->stdWrapValue('doNotShowLink', $this->I['val']);
135  if (!$this->I['val']['doNotShowLink']) {
136  $this->I['parts']['notATagBeforeWrap_begin'] = $wrapPartsAfter[0] ?? '';
137  $this->I['parts']['ATag_begin'] = $this->I['A1'];
138  $this->I['parts']['ATagBeforeWrap_begin'] = $wrapPartsBefore[0] ?? '';
139  $this->I['parts']['title'] = $this->I['title'];
140  $this->I['parts']['ATagBeforeWrap_end'] = $wrapPartsBefore[1] ?? '';
141  $this->I['parts']['ATag_end'] = $this->I['A2'];
142  $this->I['parts']['notATagBeforeWrap_end'] = $wrapPartsAfter[1] ?? '';
143  }
144  $this->I['parts']['stdWrap2_end'] = $wrapPartsStdWrap[1] ?? '';
145  $this->I['parts']['after'] = $this->‪getBeforeAfter('after');
146  // Passing I to a user function
147  if ($this->mconf['IProcFunc'] ?? false) {
148  $this->I = $this->‪userProcess('IProcFunc', $this->I);
149  }
150  // Merge parts + beforeAllWrap
151  $this->I['theItem'] = implode('', $this->I['parts']);
152  // allWrap:
153  $allWrap = $this->WMcObj->stdWrapValue('allWrap', $this->I['val']);
154  $this->I['theItem'] = $this->WMcObj->wrap($this->I['theItem'], $allWrap);
155  if ($this->I['val']['subst_elementUid'] ?? false) {
156  $this->I['theItem'] = str_replace('{elementUid}', (string)$this->I['uid'], $this->I['theItem']);
157  }
158  // allStdWrap:
159  if (is_array($this->I['val']['allStdWrap.'] ?? null)) {
160  $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'], $this->I['val']['allStdWrap.']);
161  }
162  // Calling extra processing function
163  $this->‪extProc_afterLinking((int)$key);
164  }
165  return $this->‪extProc_finish();
166  }
167 
179  protected function ‪getBeforeAfter($pref)
180  {
181  $processedPref = $this->WMcObj->stdWrapValue($pref, $this->I['val']);
182  if (isset($this->I['val'][$pref . 'Wrap'])) {
183  return $this->WMcObj->wrap($processedPref, $this->I['val'][$pref . 'Wrap']);
184  }
185  return $processedPref;
186  }
187 
195  protected function ‪extProc_afterLinking($key)
196  {
197  $explicitSpacerRenderingEnabled = ($this->mconf['SPC'] ?? false);
198  $isSpacerPage = $this->I['spacer'] ?? false;
199  // If rendering of SPACERs is enabled, also allow rendering submenus with Spacers
200  if (!$isSpacerPage || $explicitSpacerRenderingEnabled) {
201  // Add part to the accumulated result + fetch submenus
202  $this->I['theItem'] .= $this->‪subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix'] ?? '');
203  }
204  $part = $this->WMcObj->stdWrapValue('wrapItemAndSub', $this->I['val']);
205  $this->WMresult .= $part ? $this->WMcObj->wrap($this->I['theItem'], $part) : $this->I['theItem'];
206  }
207 
214  protected function ‪extProc_finish()
215  {
216  if (is_array($this->mconf['stdWrap.'] ?? null)) {
217  $this->WMresult = (string)$this->WMcObj->stdWrap($this->WMresult, $this->mconf['stdWrap.']);
218  }
219  return $this->WMcObj->wrap($this->WMresult, $this->mconf['wrap'] ?? '');
220  }
221 }
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject\generate
‪generate()
Definition: TextMenuContentObject.php:32
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\getPageTitle
‪string getPageTitle($title, $nav_title)
Definition: AbstractMenuContentObject.php:1634
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject\getBeforeAfter
‪string getBeforeAfter($pref)
Definition: TextMenuContentObject.php:179
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
Definition: AbstractMenuContentObject.php:48
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\userProcess
‪mixed userProcess($mConfKey, $passVar)
Definition: AbstractMenuContentObject.php:1606
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject\extProc_afterLinking
‪extProc_afterLinking($key)
Definition: TextMenuContentObject.php:195
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\subMenu
‪string subMenu(int $uid, string $objSuffix)
Definition: AbstractMenuContentObject.php:1331
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject\extProc_finish
‪string extProc_finish()
Definition: TextMenuContentObject.php:214
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject
Definition: TextMenuContentObject.php:25
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\getTypoScriptFrontendController
‪getTypoScriptFrontendController()
Definition: AbstractMenuContentObject.php:1835
‪TYPO3\CMS\Frontend\ContentObject\Menu
Definition: AbstractMenuContentObject.php:16
‪TYPO3\CMS\Core\TypoScript\TypoScriptService
Definition: TypoScriptService.php:25
‪debug
‪debug($variable='', $title=null, $group=null)
Definition: GlobalDebugFunctions.php:19
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\processItemStates
‪array processItemStates($splitCount)
Definition: AbstractMenuContentObject.php:1146
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\setATagParts
‪setATagParts()
Definition: AbstractMenuContentObject.php:1619
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\accessKey
‪array accessKey($title)
Definition: AbstractMenuContentObject.php:1578
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject\writeMenu
‪string writeMenu()
Definition: TextMenuContentObject.php:55
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\link
‪array link($key, $altTarget, $typeOverride)
Definition: AbstractMenuContentObject.php:1188