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
Updated by Markus Klein over 8 years ago
- Status changed from New to Accepted
- Assignee set to Markus Klein
- Priority changed from Should have to Must have
- Target version set to 7.6.5
- Is Regression changed from No to Yes
- Sprint Focus set to Stabilization Sprint
Hi Tim!
Thanks for the detailed report.
Can you push a patch to our review system?
Tell me, if you need help.
Updated by Gerrit Code Review over 8 years ago
- Status changed from Accepted to Under Review
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47168
Updated by Gerrit Code Review over 8 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47168
Updated by Gerrit Code Review over 8 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47168
Updated by Gerrit Code Review over 8 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47168
Updated by Gerrit Code Review over 8 years ago
Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47178
Updated by Tim Jungebluth over 8 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset c7b2838491519f05792ad15fcaf1d4c7f807817f.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed