Commit 972d0ef4 authored by Benni Mack's avatar Benni Mack Committed by Christian Kuhn
Browse files

[BUGFIX] HMENU: Use ATagParams directly from typolink

When setting "HMENU.1.NO.ATagParams" then "ATagParams"
called in cObj->ATagParams is now processed once by
setting the option in typolink().

This way, any hooks in ATagParams are added within
the context of the typolink function, also receiving
all information in the LinkResult object. This is
now possible with TYPO3 v11.

Some workarounds are needed and document on how
to clean this functionality up in TYPO3 v12+.

Resolves: #96486
Releases: main
Change-Id: I5804931ec623035247baf34a226fe70e44736a72
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72909

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 82e79aed
...@@ -1244,6 +1244,9 @@ abstract class AbstractMenuContentObject ...@@ -1244,6 +1244,9 @@ abstract class AbstractMenuContentObject
// and blank URLs might appear when the realurl encoding is used and a link to the frontpage is generated. // and blank URLs might appear when the realurl encoding is used and a link to the frontpage is generated.
$attrs['HREF'] = (string)$LD['totalURL'] !== '' ? $LD['totalURL'] : $tsfe->baseUrl; $attrs['HREF'] = (string)$LD['totalURL'] !== '' ? $LD['totalURL'] : $tsfe->baseUrl;
$attrs['TARGET'] = $LD['target'] ?? ''; $attrs['TARGET'] = $LD['target'] ?? '';
$attrs = array_merge($attrs, $LD['ATagParams']);
// @todo: prefer to use lower-case href / target to be consistent
unset($attrs['href'], $attrs['target']);
$runtimeCache->set($cacheId, $attrs); $runtimeCache->set($cacheId, $attrs);
// End showAccessRestrictedPages // End showAccessRestrictedPages
...@@ -1552,7 +1555,7 @@ abstract class AbstractMenuContentObject ...@@ -1552,7 +1555,7 @@ abstract class AbstractMenuContentObject
*/ */
protected function setATagParts() protected function setATagParts()
{ {
$params = trim($this->I['val']['ATagParams']) . ($this->I['accessKey']['code'] ?? ''); $params = trim($this->I['accessKey']['code'] ?? '');
$params = $params !== '' ? ' ' . $params : ''; $params = $params !== '' ? ' ' . $params : '';
$this->I['A1'] = '<a ' . GeneralUtility::implodeAttributes($this->I['linkHREF'], true) . $params . '>'; $this->I['A1'] = '<a ' . GeneralUtility::implodeAttributes($this->I['linkHREF'], true) . $params . '>';
$this->I['A2'] = '</a>'; $this->I['A2'] = '</a>';
...@@ -1652,12 +1655,19 @@ abstract class AbstractMenuContentObject ...@@ -1652,12 +1655,19 @@ abstract class AbstractMenuContentObject
if ($oTarget) { if ($oTarget) {
$conf['target'] = $oTarget; $conf['target'] = $oTarget;
} }
// $this->I['val'] contains the configuration of the ItemState (e.g. NO / SPC) etc, which should be handed in
// to this method instead of accessed directly in the future.
if (isset($this->I['val']['ATagParams']) || isset($this->I['val']['ATagParams.'])) {
$conf['ATagParams'] = $this->I['val']['ATagParams'] ?? '';
$conf['ATagParams.'] = $this->I['val']['ATagParams.'] ?? [];
}
if ($page['sectionIndex_uid'] ?? false) { if ($page['sectionIndex_uid'] ?? false) {
$conf['section'] = $page['sectionIndex_uid']; $conf['section'] = $page['sectionIndex_uid'];
} }
$this->parent_cObj->typoLink('|', $conf); $this->parent_cObj->typoLink('|', $conf);
$LD = $this->parent_cObj->lastTypoLinkLD; $LD = $this->parent_cObj->lastTypoLinkLD;
$LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl; $LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl;
$LD['ATagParams'] = $this->parent_cObj->lastTypoLinkResult ? $this->parent_cObj->lastTypoLinkResult->getAttributes() : [];
return $LD; return $LD;
} }
......
...@@ -84,7 +84,6 @@ class TextMenuContentObject extends AbstractMenuContentObject ...@@ -84,7 +84,6 @@ class TextMenuContentObject extends AbstractMenuContentObject
$this->I['accessKey'] = []; $this->I['accessKey'] = [];
} }
// Make link tag // Make link tag
$this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
$this->I['val']['additionalParams'] = $this->WMcObj->stdWrapValue('additionalParams', $this->I['val']); $this->I['val']['additionalParams'] = $this->WMcObj->stdWrapValue('additionalParams', $this->I['val']);
$this->I['linkHREF'] = $this->link((int)$key, (string)($this->I['val']['altTarget'] ?? ''), ($this->mconf['forceTypeValue'] ?? '')); $this->I['linkHREF'] = $this->link((int)$key, (string)($this->I['val']['altTarget'] ?? ''), ($this->mconf['forceTypeValue'] ?? ''));
if (empty($this->I['linkHREF'])) { if (empty($this->I['linkHREF'])) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment