‪TYPO3CMS  10.4
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  $this->WMresult = '';
62  $this->WMmenuItems = count($this->result);
63  $typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);
64  $this->WMsubmenuObjSuffixes = $typoScriptService->explodeConfigurationForOptionSplit(['sOSuffix' => $this->mconf['submenuObjSuffixes'] ?? null], $this->WMmenuItems);
65  foreach ($this->result as $key => $val) {
66  ‪$GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
67  ‪$GLOBALS['TSFE']->register['count_MENUOBJ']++;
68  // Initialize the cObj with the page record of the menu item
69  $this->WMcObj->start($this->menuArr[$key], 'pages');
70  $this->I = [];
71  $this->I['key'] = $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'] ?? false) {
80  $this->I['accessKey'] = $this->‪accessKey((string)($this->I['title'] ?? ''));
81  } else {
82  $this->I['accessKey'] = [];
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 ($titleAttrValue !== '') {
96  $this->I['linkHREF']['title'] = $titleAttrValue;
97  }
98 
99  // stdWrap for doNotLinkIt
100  if (isset($this->I['val']['doNotLinkIt.'])) {
101  $this->I['val']['doNotLinkIt'] = $this->WMcObj->stdWrap($this->I['val']['doNotLinkIt'], $this->I['val']['doNotLinkIt.']);
102  }
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'] ?? null);
120  }
121  if (($this->I['val']['stdWrap2'] ?? false) || isset($this->I['val']['stdWrap2.'])) {
122  $stdWrap2 = isset($this->I['val']['stdWrap2.']) ? $this->WMcObj->stdWrap('|', $this->I['val']['stdWrap2.']) : '|';
123  $wrapPartsStdWrap = explode($this->I['val']['stdWrap2'] ?: '|', $stdWrap2);
124  } else {
125  $wrapPartsStdWrap = ['', ''];
126  }
127  // Make before, middle and after parts
128  $this->I['parts'] = [];
129  $this->I['parts']['before'] = $this->‪getBeforeAfter('before');
130  $this->I['parts']['stdWrap2_begin'] = $wrapPartsStdWrap[0];
131  // stdWrap for doNotShowLink
132  if (isset($this->I['val']['doNotShowLink.'])) {
133  $this->I['val']['doNotShowLink'] = $this->WMcObj->stdWrap($this->I['val']['doNotShowLink'], $this->I['val']['doNotShowLink.']);
134  }
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']) {
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 = isset($this->I['val']['allWrap.']) ? $this->WMcObj->stdWrap($this->I['val']['allWrap'], $this->I['val']['allWrap.']) : $this->I['val']['allWrap'];
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}', $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 = isset($this->I['val'][$pref . '.']) ? $this->WMcObj->stdWrap($this->I['val'][$pref], $this->I['val'][$pref . '.']) : $this->I['val'][$pref];
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  // Add part to the accumulated result + fetch submenus
198  if (!$this->I['spacer']) {
199  $this->I['theItem'] .= $this->‪subMenu($this->I['uid'], $this->WMsubmenuObjSuffixes[$key]['sOSuffix'] ?? '');
200  }
201  $part = isset($this->I['val']['wrapItemAndSub.']) ? $this->WMcObj->stdWrap($this->I['val']['wrapItemAndSub'], $this->I['val']['wrapItemAndSub.']) : $this->I['val']['wrapItemAndSub'];
202  $this->WMresult .= $part ? $this->WMcObj->wrap($this->I['theItem'], $part) : $this->I['theItem'];
203  }
204 
211  protected function ‪extProc_finish()
212  {
213  if (is_array($this->mconf['stdWrap.'] ?? null)) {
214  $this->WMresult = $this->WMcObj->stdWrap($this->WMresult, $this->mconf['stdWrap.']);
215  }
216  return $this->WMcObj->wrap($this->WMresult, $this->mconf['wrap'] ?? '');
217  }
218 }
‪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:1770
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject\getBeforeAfter
‪string getBeforeAfter($pref)
Definition: TextMenuContentObject.php:179
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
Definition: AbstractMenuContentObject.php:46
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\userProcess
‪mixed userProcess($mConfKey, $passVar)
Definition: AbstractMenuContentObject.php:1742
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject\extProc_afterLinking
‪extProc_afterLinking($key)
Definition: TextMenuContentObject.php:195
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject\extProc_finish
‪string extProc_finish()
Definition: TextMenuContentObject.php:211
‪TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject
Definition: TextMenuContentObject.php:25
‪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
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\processItemStates
‪array processItemStates($splitCount)
Definition: AbstractMenuContentObject.php:1241
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\setATagParts
‪setATagParts()
Definition: AbstractMenuContentObject.php:1755
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\accessKey
‪array accessKey($title)
Definition: AbstractMenuContentObject.php:1714
‪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:1283
‪TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject\subMenu
‪string subMenu($uid, $objSuffix)
Definition: AbstractMenuContentObject.php:1501