lochmueller / calendarize

📆 Best TYPO3 Calendar ever 📆
http://typo3.org/extensions/repository/view/calendarize
75 stars 84 forks source link

Linkhandler links ignores title, classes etc. from link browser #748

Closed hannesbochmann closed 1 year ago

hannesbochmann commented 1 year ago

If I add a link in let's say a RTE editor the css classes, title attribute and so on are ignored when the link is rendered in the FE. I think this is because HDNET\Calendarize\Typolink\DatabaseRecordLinkBuilder doesn't take care of that in contrast to TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder.

Is there a reason why the building of the typolink is done in HDNET\Calendarize\Typolink\DatabaseRecordLinkBuilder instead of delegating it to TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder ? I think in HDNET\Calendarize\Typolink\DatabaseRecordLinkBuilder::build() everything after building the TypoScript configuration can be removed and replaced by simply providing the TypoScript configuration like TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder expects it and leaving the rest to TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder::build(). The code looks like this in the moment:

$localContentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$localContentObjectRenderer->parameters = $this->contentObjectRenderer->parameters;
$link = $localContentObjectRenderer->typoLink($linkText, $typoScriptConfiguration);

$this->contentObjectRenderer->lastTypoLinkLD = $localContentObjectRenderer->lastTypoLinkLD;
$this->contentObjectRenderer->lastTypoLinkUrl = $localContentObjectRenderer->lastTypoLinkUrl;
$this->contentObjectRenderer->lastTypoLinkTarget = $localContentObjectRenderer->lastTypoLinkTarget;

// nasty workaround so typolink stops putting a link together, there is a link already built
throw new UnableToLinkException('', 1491130170, null, $link);

It could be changed to this I think:

$configurationKey = $linkDetails['identifier'].'.';
$this->getTypoScriptFrontendController()
    ->tmpl
    ->setup['config.']['recordLinks.'][$configurationKey]['typolink.'] = $typoScriptConfiguration;
return parent::build($linkDetails, $linkText, $target, $conf);

It seems like the links are still built correct and on top the attributes from the link browser are taken into account now.

What do you think about that change? I can provide a PR if you like.

lochmueller commented 1 year ago

Hey @hannesbochmann sounds good. Feel free to send a pull request. Regards, Tim