Bug #74586
closedRTE default link style doesn't work correctly
100%
Description
I have the following default configurations in my TypoScript-config for the RTE:
buttons.link.properties.class.allowedClasses = external-link, external-link-new-window, internal-link, internal-link-new-window, download, mail buttons.link.page.properties.class.default = internal-link buttons.link.url.properties.class.default = external-link buttons.link.file.properties.class.default = download buttons.link.mail.properties.class.default = mail
On click of "insert link" in the RTE, the default style "Internal link" is set for the "Page" tab correctly (style-internal.png).
After changing the tab from "Page" to "External URL" the default style is empty and my default style class isn't preselected (style-external-empty.png).
After clicking the active tab "External URL" again, the default style class "External link" is preselected correctly (style-external.png).
I think the problem is the IF statement, which checks if a style is selected, but doesn't check the active link handler (e.g. page, url, ...), i.e. the actice tab.
/typo3/sysext/rtehtmlarea/Classes/Controller/BrowseLinksController.php on line 299:
$selected = ''; if ($this->linkAttributeValues['class'] === $class || !$this->linkAttributeValues['class'] && $this->classesAnchorDefault[$this->displayedLinkHandlerId] == $class) { $selected = 'selected="selected"'; }
After switching from "Internal" to "External URL", $this->linkAttributeValues['class'] is filled with the previous default class "internal-link". The condition that checks, if $this->linkAttributeValues['class'] is empty, returns false, so the default style class is not set.
So I've simply checked if the choosen class belongs to the displayed link handler and unset it if not. I'm not sure if this is the best way or if there are other side effects, but it seems to work.
// Check if if (isset($this->linkAttributeValues['class']) && isset($classesAnchor[$this->displayedLinkHandlerId])) { if (!in_array($this->linkAttributeValues['class'], $classesAnchor[$this->displayedLinkHandlerId])) { unset($this->linkAttributeValues); } } // Constructing the class selector options foreach ($classesAnchorArray as $class) { if (!in_array($class, $classesAnchor['all']) || in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$this->displayedLinkHandlerId]) && in_array($class, $classesAnchor[$this->displayedLinkHandlerId])) { $selected = ''; if ($this->linkAttributeValues['class'] === $class || !$this->linkAttributeValues['class'] && $this->classesAnchorDefault[$this->displayedLinkHandlerId] == $class) { $selected = 'selected="selected"'; } ...
Files