* Fixed bug #8716: htmlArea RTE: target configured on link class not honoured
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 15 Jun 2008 04:07:49 +0000 (04:07 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sun, 15 Jun 2008 04:07:49 +0000 (04:07 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3823 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php

index 4a1bf04..69c551d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-15  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #8716: htmlArea RTE: target configured on link class not honoured
+
 2008-06-13  Oliver Hader  <oliver@typo3.org>
 
        * Fixed bug #8239: Wrong parameter order for strpos in t3lib_div::getHostname
index b019f41..06037d8 100644 (file)
@@ -1,3 +1,7 @@
+2008-06-15  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #8716: htmlArea RTE: target configured on link class not honoured
+
 2008-05-15  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #8348: htmlArea RTE: ctrl+c and ctrl+x do not work in IE with TYPO3 4.2
index a91e845..98c4724 100644 (file)
@@ -3,7 +3,7 @@
 *  Copyright notice
 *
 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
-*  (c) 2005-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2005-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -35,7 +35,7 @@
  * $Id$
  *
  * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- * @author     Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author     Stanislas Rolland <typo3(arobas)sjbr.ca>
  */
 
 require_once (PATH_typo3.'class.browse_links.php');
@@ -291,6 +291,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
 
                        // Rich Text Editor specific configuration:
                $addPassOnParams='';
+               $classSelected = array();
                if ((string)$this->mode=='rte') {
                        $RTEtsConfigParts = explode(':',$this->RTEtsConfigParams);
                        $addPassOnParams .= '&RTEtsConfigParams='.rawurlencode($this->RTEtsConfigParams);
@@ -337,9 +338,9 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                        while(list(,$class)=each($classesAnchorArray)) {
                                                if (!in_array($class, $classesAnchor['all']) || (in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType]))) {
                                                        $selected = '';
-                                                       if ($this->setClass == $class) $selected = 'selected="selected"';
-                                                       if (!$this->setClass && $this->classesAnchorDefault[$anchorType] == $class) {
+                                                       if ($this->setClass == $class || (!$this->setClass && $this->classesAnchorDefault[$anchorType] == $class)) {
                                                                $selected = 'selected="selected"';
+                                                               $classSelected[$anchorType] = true;
                                                        }
                                                        $classLabel = (is_array($RTEsetup['properties']['classes.']) && is_array($RTEsetup['properties']['classes.'][$class.'.']) && $RTEsetup['properties']['classes.'][$class.'.']['name']) ? $this->getPageConfigLabel($RTEsetup['properties']['classes.'][$class.'.']['name'], 0) : $class;
                                                        $classStyle = (is_array($RTEsetup['properties']['classes.']) && is_array($RTEsetup['properties']['classes.'][$class.'.']) && $RTEsetup['properties']['classes.'][$class.'.']['value']) ? $RTEsetup['properties']['classes.'][$class.'.']['value'] : '';
@@ -356,7 +357,14 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                }
 
                        // Initializing the target value (RTE)
-               $this->setTarget = $this->curUrlArray['target'];
+                       // Unset the target if it is set to a value different than default and if no class is selected and the target field is not displayed
+                       // In other words, do not forward the target if we changed tab and the target field is not displayed
+               $this->setTarget = (isset($this->curUrlArray['target'])
+                               && !(
+                                       ($this->curUrlArray['target'] != $this->thisConfig['defaultLinkTarget'])
+                                       && !$classSelected[$this->act]
+                                       && is_array($this->buttonConfig['targetSelector.']) && $this->buttonConfig['targetSelector.']['disabled'] && is_array($this->buttonConfig['popupSelector.']) && $this->buttonConfig['popupSelector.']['disabled'])
+                               ) ? $this->curUrlArray['target'] : '';
                if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target']))     {
                        $this->setTarget=$this->thisConfig['defaultLinkTarget'];
                }
@@ -465,6 +473,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                        var theLink = \''.$this->siteURL.'?id=\'+id+(anchor?anchor:"");
                                        if (document.ltargetform.anchor_title) setTitle(document.ltargetform.anchor_title.value);
                                        if (document.ltargetform.anchor_class) setClass(document.ltargetform.anchor_class.value);
+                                       if (document.ltargetform.ltarget) setTarget(document.ltargetform.ltarget.value);
                                        plugin.createLink(theLink,cur_target,cur_class,cur_title);
                                        return false;
                                }
@@ -472,18 +481,21 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                        var theLink = \''.$this->siteURL.'\'+folder;
                                        if (document.ltargetform.anchor_title) setTitle(document.ltargetform.anchor_title.value);
                                        if (document.ltargetform.anchor_class) setClass(document.ltargetform.anchor_class.value);
+                                       if (document.ltargetform.ltarget) setTarget(document.ltargetform.ltarget.value);
                                        plugin.createLink(theLink,cur_target,cur_class,cur_title);
                                        return false;
                                }
                                function link_spec(theLink)     {       //
                                        if (document.ltargetform.anchor_title) setTitle(document.ltargetform.anchor_title.value);
                                        if (document.ltargetform.anchor_class) setClass(document.ltargetform.anchor_class.value);
+                                       if (document.ltargetform.ltarget) setTarget(document.ltargetform.ltarget.value);
                                        plugin.createLink(theLink,cur_target,cur_class,cur_title);
                                        return false;
                                }
                                function link_current() {       //
                                        if (document.ltargetform.anchor_title) setTitle(document.ltargetform.anchor_title.value);
                                        if (document.ltargetform.anchor_class) setClass(document.ltargetform.anchor_class.value);
+                                       if (document.ltargetform.ltarget) setTarget(document.ltargetform.ltarget.value);
                                        if (cur_href!="http://" && cur_href!="mailto:") {
                                                plugin.createLink(cur_href,cur_target,cur_class,cur_title);
                                        }
@@ -910,27 +922,23 @@ class tx_rtehtmlarea_browse_links extends browse_links {
 
                $ltarget = '';
                if ($this->act != 'mail')       {
-                       if (!($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled'])) {
-                               $ltarget .= '
-                                               <tr>
-                                                       <td>'.$LANG->getLL('target',1).':</td>
-                                                       <td><input type="text" name="ltarget" onchange="setTarget(this.value);" value="'.htmlspecialchars($this->setTarget?$this->setTarget:(($this->setClass || !$this->classesAnchorDefault[$this->act])?'':$this->classesAnchorDefaultTarget[$this->act])).'"'.$this->doc->formWidth(10).' /></td>';
-                               $ltarget .= '
-                                                       <td colspan="2">';
-                               if (!$targetSelectorConfig['disabled']) {
-                                       $ltarget .= '
-                                                               <select name="ltarget_type" onchange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
-                                                                       <option></option>
-                                                                       <option value="_top">'.$LANG->getLL('top',1).'</option>
-                                                                       <option value="_blank">'.$LANG->getLL('newWindow',1).'</option>
-                                                               </select>';
-                               }
+                       $ltarget .= '
+                                       <tr id="ltargetrow"'. (($targetSelectorConfig['disabled'] && $popupSelectorConfig['disabled']) ? ' style="display: none;"' : '') . '>
+                                               <td>'.$LANG->getLL('target',1).':</td>
+                                               <td><input type="text" name="ltarget" onchange="setTarget(this.value);" value="'.htmlspecialchars($this->setTarget?$this->setTarget:(($this->setClass || !$this->classesAnchorDefault[$this->act])?'':$this->classesAnchorDefaultTarget[$this->act])).'"'.$this->doc->formWidth(10).' /></td>';
+                       $ltarget .= '
+                                               <td colspan="2">';
+                       if (!$targetSelectorConfig['disabled']) {
                                $ltarget .= '
-                                                       </td>';
+                                                       <select name="ltarget_type" onchange="setTarget(this.options[this.selectedIndex].value);document.ltargetform.ltarget.value=this.options[this.selectedIndex].value;this.selectedIndex=0;">
+                                                               <option></option>
+                                                               <option value="_top">'.$LANG->getLL('top',1).'</option>
+                                                               <option value="_blank">'.$LANG->getLL('newWindow',1).'</option>
+                                                       </select>';
                        }
-
                        $ltarget .= '
-                                               </tr>';
+                                               </td>
+                                       </tr>';
                        if (!$popupSelectorConfig['disabled']) {
 
                                $selectJS = 'if (document.ltargetform.popup_width.options[document.ltargetform.popup_width.selectedIndex].value>0 && document.ltargetform.popup_height.options[document.ltargetform.popup_height.selectedIndex].value>0)        {
@@ -981,12 +989,19 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                                        for (var i = HTMLArea.classesAnchorSetup.length; --i >= 0;) {
                                                                var anchorClass = HTMLArea.classesAnchorSetup[i];
                                                                if (anchorClass[\'name\'] == document.ltargetform.anchor_class.value) {
-                                                                       if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
+                                                                       if (anchorClass[\'titleText\'] && document.ltargetform.anchor_title) {
+                                                                               document.ltargetform.anchor_title.value = anchorClass[\'titleText\'];
+                                                                               setTitle(anchorClass[\'titleText\']);
+                                                                       }
                                                                        if (anchorClass[\'target\']) {
                                                                                if (document.ltargetform.ltarget) {
                                                                                        document.ltargetform.ltarget.value = anchorClass[\'target\'];
                                                                                }
                                                                                setTarget(anchorClass[\'target\']);
+                                                                       } else if (document.ltargetform.ltarget && document.getElementById(\'ltargetrow\').style.display == \'none\') {
+                                                                                       // Reset target to default if field is not displayed and class has no configured target
+                                                                               document.ltargetform.ltarget.value = \''. ($this->thisConfig['defaultLinkTarget']?$this->thisConfig['defaultLinkTarget']:'') .'\';
+                                                                               setTarget(document.ltargetform.ltarget.value);
                                                                        }
                                                                        break;
                                                                }