Project

General

Profile

Actions

Bug #74586

closed

RTE default link style doesn't work correctly

Added by Tim Jungebluth about 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
RTE (rtehtmlarea + ckeditor)
Target version:
Start date:
2016-03-09
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:
Stabilization Sprint

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

style-internal.png (29.2 KB) style-internal.png Tim Jungebluth, 2016-03-09 20:34
style-external-empty.png (21.9 KB) style-external-empty.png Tim Jungebluth, 2016-03-09 20:34
style-external.png (22.5 KB) style-external.png Tim Jungebluth, 2016-03-09 20:34

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #75789: RTE link inserter does no longer show stylesClosed2016-04-19

Actions
Actions #1

Updated by Markus Klein about 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.

Actions #2

Updated by Gerrit Code Review about 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

Actions #3

Updated by Gerrit Code Review about 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

Actions #4

Updated by Gerrit Code Review about 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

Actions #5

Updated by Gerrit Code Review about 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

Actions #6

Updated by Gerrit Code Review about 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

Actions #7

Updated by Tim Jungebluth about 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #8

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF