Fixed bug #9331: htmlArea RTE Acronym feature: List of unabridged terms shows wrong...
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 18 Sep 2008 19:18:00 +0000 (19:18 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 18 Sep 2008 19:18:00 +0000 (19:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4146 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/extensions/Acronym/class.tx_rtehtmlarea_acronym.php
typo3/sysext/rtehtmlarea/mod2/class.tx_rtehtmlarea_acronym_mod.php

index ce39807..001e634 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-09-18  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #9331: htmlArea RTE Acronym feature: List of unabridged terms shows wrong values
+
 2008-09-18  Dmitry Dulepov  <dmitry@typo3.org>
 
        * Fixed bug #9346: Preinitialise GLOBALS[LANG] in init.php (thanks to Steffen Kamper)
index 0274cf5..4cf26d5 100644 (file)
@@ -1,3 +1,7 @@
+2008-09-18  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #9331: htmlArea RTE Acronym feature: List of unabridged terms shows wrong values
+
 2008-09-17  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Added feature #9370: htmlArea RTE: enhanced toggleborders feature
index 9eea8af..5d94dbe 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the Typo3 project. The Typo3 project is
@@ -24,7 +24,7 @@
 /**
  * Acronym extension for htmlArea RTE
  *
- * @author Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author Stanislas Rolland <typo3(arobas)sjbr.ca>
  *
  * TYPO3 SVN ID: $Id$
  *
@@ -131,8 +131,8 @@ class tx_rtehtmlarea_acronym extends tx_rtehtmlareaapi {
                $whereClause .= t3lib_BEfunc::deleteClause($table);
                $res = $TYPO3_DB->exec_SELECTquery('type,term,acronym', $table, $whereClause);
                while($acronymRow = $TYPO3_DB->sql_fetch_assoc($res))    {
-                       if( $acronymRow['type'] == 1) $JSAcronymArray .= (($this->acronymIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
-                       if ($acronymRow['type'] == 2) $JSAbbreviationArray .= (($this->AbbreviationIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
+                       if( $acronymRow['type'] == 1) $JSAcronymArray .= (($this->acronymIndex++)?',':'') . '"' . $acronymRow['term'] . '":"' . $acronymRow['acronym'] . '"' . $linebreak;
+                       if ($acronymRow['type'] == 2) $JSAbbreviationArray .= (($this->AbbreviationIndex++)?',':'') . '"' . $acronymRow['term'] . '":"' . $acronymRow['acronym'] . '"' . $linebreak;
                }
                $JSAcronymArray .= '};' . $linebreak;
                $JSAbbreviationArray .= '};' . $linebreak;
index 4fff64f..829baf2 100644 (file)
@@ -89,7 +89,7 @@ class tx_rtehtmlarea_acronym_mod {
                                        document.getElementById("abbrType").innerHTML = "' . $LANG->getLL('Abbreviation') . '";
                                }
                                document.getElementById("title").value = param["title"];
-                               fillSelect(param["text"]);
+                               fillSelect(param);
                                dialog.resize();
                        }
                        
@@ -115,22 +115,46 @@ class tx_rtehtmlarea_acronym_mod {
                                document.getElementById("title").focus();
                        };
                        
-                       function fillSelect(text) {
+                       function fillSelect(param) {
                                var termSelector = document.getElementById("termSelector");
                                var acronymSelector = document.getElementById("acronymSelector");
-                               while(termSelector.options.length>1) termSelector.options[termSelector.length-1] = null;
-                               while(acronymSelector.options.length>1) acronymSelector.options[acronymSelector.length-1] = null;
-                               if(abbrType == "acronym") var abbrObj = acronyms;
-                                       else var abbrObj = abbreviations;
-                               if(abbrObj != "") {
-                                       for(var i in abbrObj) {
-                                               same = (i==text);
-                                               termSelector.options[termSelector.options.length] = new Option(abbrObj[i], abbrObj[i], false, same);
-                                               acronymSelector.options[acronymSelector.options.length] = new Option(i, i, false, same);
-                                               if(same) document.content.title.value = abbrObj[i];
+                               while (termSelector.options.length > 1) {
+                                       termSelector.options[termSelector.length-1] = null;
+                               }
+                               while (acronymSelector.options.length > 1) {
+                                       acronymSelector.options[acronymSelector.length-1] = null;
+                                       }
+                               if (abbrType == "acronym") {
+                                       var abbrObj = acronyms;
+                               } else {
+                                       var abbrObj = abbreviations;
+                               }
+                               if (abbrObj != "") {
+                                       var sameTerm = false;
+                                       var sameAbbreviation = false;
+                                       var selectedOption = false;
+                                       for (var i in abbrObj) {
+                                               if (abbrObj.hasOwnProperty(i)) {
+                                                       if (param["title"]) {
+                                                               sameTerm = (param["title"] == i);
+                                                       } else {
+                                                               sameTerm = (param["text"] == i);
+                                                       }
+                                                       sameAbbreviation = (param["text"] == abbrObj[i]);
+                                                       if (!selectedOption && (sameTerm || sameAbbreviation)) {
+                                                               selectedOption = i;
+                                                       }
+                                                       if (!param["text"] || sameTerm || sameAbbreviation) {
+                                                               termSelector.options[termSelector.options.length] = new Option(i, i, false, (selectedOption == i));
+                                                               acronymSelector.options[acronymSelector.options.length] = new Option(abbrObj[i], abbrObj[i], false, (selectedOption == i));
+                                                       }
+                                                       if (selectedOption == i) {
+                                                               document.content.title.value = i;
+                                                       }
+                                               }
                                        }
                                }
-                               if(acronymSelector.options.length == 1) {
+                               if (acronymSelector.options.length == 1) {
                                        document.getElementById("selector").style.display = "none";
                                } else {
                                        document.getElementById("selector").style.display = "block";