* Feature: Enhancements to the acronym feature of htmlArea RTE
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 31 Jan 2008 05:43:02 +0000 (05:43 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 31 Jan 2008 05:43:02 +0000 (05:43 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2980 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/doc/manual.sxw
typo3/sysext/rtehtmlarea/ext_tables.php
typo3/sysext/rtehtmlarea/extensions/Acronym/class.tx_rtehtmlarea_acronym.php
typo3/sysext/rtehtmlarea/htmlarea/plugins/Acronym/acronym.js
typo3/sysext/rtehtmlarea/mod2/class.tx_rtehtmlarea_acronym_mod.php

index 4b8bd74..85e0f79 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-01-31  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
+
+       * Feature: Enhancements to the acronym feature of htmlArea RTE
+
 2008-01-29  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * Feature/cleanup: Restructure plugins QuickTag, TableOperations, UserElements
index bfd7a6c..679a7f7 100644 (file)
@@ -1,3 +1,7 @@
+2008-01-31  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
+
+       * Feature: Enhancements to the acronym feature of htmlArea RTE
+
 2008-01-29  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * Feature/cleanup: Restructure plugins QuickTag, TableOperations, UserElements
index 2730075..a128af3 100644 (file)
Binary files a/typo3/sysext/rtehtmlarea/doc/manual.sxw and b/typo3/sysext/rtehtmlarea/doc/manual.sxw differ
index 028bd1d..515b445 100644 (file)
@@ -12,7 +12,6 @@ if ($TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]['enableClickEnlarge']) {
                'label' => 'term',
                'default_sortby' => 'ORDER BY term',
                'sortby' => 'sorting',
-               'rootLevel' => 1,
                'delete' => 'deleted',
                'enablecolumns' => Array (
                        'disabled' => 'hidden',
index 7ff79e1..51b33e4 100644 (file)
@@ -47,11 +47,8 @@ class tx_rtehtmlarea_acronym extends tx_rtehtmlareaapi {
        protected $convertToolbarForHtmlAreaArray = array (
                'acronym'       => 'Acronym',
                );
-       
-       public function main($parentObject) {
-               return parent::main($parentObject) && !($this->htmlAreaRTE->client['BROWSER'] == 'msie' && $this->htmlAreaRTE->client['VERSION'] < 7);
-               
-       }
+       private $acronymIndex = 0;
+       private $abbraviationIndex = 0;
        
        /**
         * Return tranformed content
@@ -87,13 +84,21 @@ class tx_rtehtmlarea_acronym extends tx_rtehtmlareaapi {
                $registerRTEinJavascriptString = '';
                $button = 'acronym';
                if (in_array($button, $this->toolbar)) {
-                       if (!is_array( $this->thisConfig['buttons.']) || !is_array( $this->thisConfig['buttons.'][$button.'.'])) {
+                       if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$button.'.'])) {
                                        $registerRTEinJavascriptString .= '
                        RTEarea['.$RTEcounter.']["buttons"]["'. $button .'"] = new Object();';
                        }
                        $registerRTEinJavascriptString .= '
                        RTEarea['.$RTEcounter.'].buttons.'. $button .'.pathAcronymModule = "../../mod2/acronym.php";
                        RTEarea['.$RTEcounter.'].buttons.'. $button .'.acronymUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', 'acronym_'.$this->htmlAreaRTE->contentLanguageUid, 'js', $this->buildJSAcronymArray($this->htmlAreaRTE->contentLanguageUid)) . '";';
+                       
+                               // <abbr> was not supported by IE before version 7
+                       if ($this->htmlAreaRTE->client['BROWSER'] == 'msie' && $this->htmlAreaRTE->client['VERSION'] < 7) {
+                               $this->AbbreviationIndex = 0;
+                       }
+                       $registerRTEinJavascriptString .= '
+                       RTEarea['.$RTEcounter.'].buttons.'. $button .'.noAcronym = ' . ($this->acronymIndex ? 'false' : 'true') . ';
+                       RTEarea['.$RTEcounter.'].buttons.'. $button .'.noAbbr =  ' . ($this->AbbreviationIndex ? 'false' : 'true') . ';';
                }
                
                return $registerRTEinJavascriptString;
@@ -107,23 +112,27 @@ class tx_rtehtmlarea_acronym extends tx_rtehtmlareaapi {
        function buildJSAcronymArray($languageUid) {
                global $TYPO3_CONF_VARS, $TYPO3_DB;
                
+               $button = 'acronym';
+               $PIDList = 0;
+               if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$button.'.']) && trim($this->thisConfig['buttons.'][$button.'.']['PIDList'])) {
+                       $PIDList = implode(',', t3lib_div::trimExplode(',', $this->thisConfig['buttons.'][$button.'.']['PIDList']));
+               }
                $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->htmlAreaRTE->ID]['enableCompressedScripts'] ? '' : chr(10);
-               $acronymIndex = 0;
-               $abbraviationIndex = 0;
                $JSAcronymArray .= 'acronyms = { ' . $linebreak;
                $JSAbbreviationArray .= 'abbreviations = { ' . $linebreak;
                $table = 'tx_rtehtmlarea_acronym';
                if ($languageUid > -1) {
-                       $whereClause = '(sys_language_uid=' . $languageUid . ' OR sys_language_uid=-1)';
+                       $whereClause = '(sys_language_uid=' . $languageUid . ' OR sys_language_uid=-1) ';
                } else {
-                       $whereClause = '1 = 1';
+                       $whereClause = '1 = 1 ';
                }
+               $whereClause .= ($PIDList ? ' AND '. $table . '.pid IN (' . $TYPO3_DB->fullQuoteStr($PIDList, $table) . ') ' : '');
                $whereClause .= t3lib_BEfunc::BEenableFields($table);
                $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 .= (($acronymIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
-                       if($acronymRow['type'] == 2) $JSAbbreviationArray .= (($AbbreviationIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
+                       if( $acronymRow['type'] == 1) $JSAcronymArray .= (($this->acronymIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
+                       if ($acronymRow['type'] == 2) $JSAbbreviationArray .= (($this->AbbreviationIndex++)?',':'') . '"' . $acronymRow['acronym'] . '":"' . $acronymRow['term'] . '"' . $linebreak;
                }
                $JSAcronymArray .= '};' . $linebreak;
                $JSAbbreviationArray .= '};' . $linebreak;
index 3af1fcd..f199c9d 100644 (file)
@@ -27,7 +27,7 @@
 /*
  * Acronym plugin for htmlArea RTE
  *
- * TYPO3 CVS ID: $Id$
+ * TYPO3 SVN ID: $Id$
  */
 Acronym = HTMLArea.Plugin.extend({
        
@@ -40,9 +40,9 @@ Acronym = HTMLArea.Plugin.extend({
         */
        configurePlugin : function(editor) {
                
-               this.pageTSconfiguration = this.editorConfiguration.buttons.acronym;
-               this.acronymUrl = this.pageTSconfiguration.acronymUrl;
-               this.acronymModulePath = this.pageTSconfiguration.pathAcronymModule;
+               this.pageTSConfiguration = this.editorConfiguration.buttons.acronym;
+               this.acronymUrl = this.pageTSConfiguration.acronymUrl;
+               this.acronymModulePath = this.pageTSConfiguration.pathAcronymModule;
                
                /*
                 * Registering plugin "About" information
@@ -66,6 +66,7 @@ Acronym = HTMLArea.Plugin.extend({
                        id              : buttonId,
                        tooltip         : this.localize("Insert/Modify Acronym"),
                        action          : "onButtonPress",
+                       hide            : (this.pageTSConfiguration.noAcronym && this.pageTSConfiguration.noAbbr),
                        dialog          : true
                };
                this.registerButton(buttonConfiguration);
@@ -97,6 +98,22 @@ Acronym = HTMLArea.Plugin.extend({
                }
                parent.removeChild(element);
                this.editor.selectRange(this.editor.moveToBookmark(bookmark));
+       },
+       
+       /*
+        * This function gets called when the toolbar is updated
+        */
+       onUpdateToolbar : function () {
+               if (this.editor.getMode() === "wysiwyg" && this.editor.isEditable()) {
+                       var buttonId = "Acronym";
+                       if (this.isButtonInToolbar(buttonId)) {
+                               var el = this.editor.getParentElement();
+                               if (el) {
+                                       this.editor._toolbarObjects[buttonId].state("enabled", !((el.nodeName.toLowerCase() == "acronym" && this.pageTSConfiguration.noAcronym) || (el.nodeName.toLowerCase() == "abbr" && this.pageTSConfiguration.noAbbr)));
+                                       this.editor._toolbarObjects[buttonId].state("active", ((el.nodeName.toLowerCase() == "acronym" && !this.pageTSConfiguration.noAcronym) || (el.nodeName.toLowerCase() == "abbr" && !this.pageTSConfiguration.noAbbr)));
+                               }
+                       }
+               }
        }
 });
 
index dbd34d8..8048dd9 100644 (file)
@@ -98,10 +98,19 @@ class tx_rtehtmlarea_acronym_mod {
                                dialog.initialize("noLocalize", "noResize");
                                var abbrData = dialog.plugin.getJavascriptFile(dialog.plugin.acronymUrl, "noEval");
                                if (abbrData) eval(abbrData);
-                               if (abbrType != null) document.getElementById("type").style.display = "none";
-                                       else abbrType = "abbr";
-                               if (abbrType == "acronym") document.acronymForm.acronym.checked = true;
-                                       else  document.acronymForm.abbreviation.checked = true;
+                               if (dialog.plugin.pageTSConfiguration.noAcronym || dialog.plugin.pageTSConfiguration.noAbbr) {
+                                       document.getElementById("type").style.display = "none";
+                               }
+                               if (abbrType != null) {
+                                       document.getElementById("type").style.display = "none";
+                               } else {
+                                       abbrType = !dialog.plugin.pageTSConfiguration.noAbbr ? "abbr" : "acronym";
+                               }
+                               if (abbrType == "acronym" && !dialog.plugin.pageTSConfiguration.noAcronym) {
+                                       document.acronymForm.acronym.checked = true;
+                               } else {
+                                       document.acronymForm.abbreviation.checked = true;
+                               }
                                setType();
                                HTMLArea._addEvents(document.acronymForm.title,["keypress", "keydown", "dragdrop", "drop", "paste", "change"],function(ev) { document.acronymForm.termSelector.selectedIndex=-1; document.acronymForm.acronymSelector.selectedIndex=-1; });
                                document.getElementById("title").focus();