Project

General

Profile

Actions

Bug #74586

closed

RTE default link style doesn't work correctly

Added by Tim Jungebluth over 8 years ago. Updated about 7 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

Also available in: Atom PDF