[FEATURE] RTE: Add property buttons.abbreviation.removeFieldsets 87/34287/7
authorStanislas Rolland <typo3@sjbr.ca>
Fri, 6 Feb 2015 20:26:42 +0000 (15:26 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 19 Mar 2015 16:40:43 +0000 (17:40 +0100)
The configuration property specifies a list of fieldsets to remove from
the abbreviation dialogue. Possible string values are: acronym,
definedAcronym, abbreviation, definedAbbreviation

Releases: master
Resolves: #63040
Resolves: #64165

Change-Id: I8c25279d8aa00b33f285ef8091d3f92ca25c1e1d
Reviewed-on: http://review.typo3.org/34287
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/core/Documentation/Changelog/master/Feature-63040-AddRteConfigurationPropertyButtonsAbbreviationRemoveFieldsets.rst [new file with mode: 0644]
typo3/sysext/rtehtmlarea/Classes/Extension/Abbreviation.php
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/Plugins/Abbreviation.js
typo3/sysext/rtehtmlarea/extensions/Abbreviation/locallang_csh.xlf

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-63040-AddRteConfigurationPropertyButtonsAbbreviationRemoveFieldsets.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-63040-AddRteConfigurationPropertyButtonsAbbreviationRemoveFieldsets.rst
new file mode 100644 (file)
index 0000000..d62a4d3
--- /dev/null
@@ -0,0 +1,21 @@
+=====================================================================================
+Feature: #63040 - Add RTE configuration property buttons.abbreviation.removeFieldsets
+=====================================================================================
+
+Description
+===========
+
+New property buttons.abbreviation.removeFieldsets may be used in Page TSconfig
+to configure the abbreviation dialogue.
+
+If set, the listed fieldsets of the Abbreviation dialogue are not shown.
+
+Possible values in the list are: acronym, definedAcronym, abbreviation, definedAbbreviation
+
+Impact
+======
+
+The acronym tag is deprecated in HTML5. Installations that want to use the Abbreviation
+feature of the RTE, but do not wish to use the acronym setting tab of the Abbreviation
+dialogue, may set this property in the Page TSconfig of the RTE, specifying
+buttons.abbreviation.removeFieldsets = acronym,definedAcronym
index 3dfc1b6..4e5b32e 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Rtehtmlarea\Extension;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Abbreviation extension for htmlArea RTE
@@ -103,15 +104,27 @@ class Abbreviation extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                        }
                        unset($this->thisConfig['buttons.']['acronym.']);
                }
-               // Convert any other reference to acronym two levels down in Page TSconfig, except in processing options
+               // Convert any other reference to acronym two levels down in Page TSconfig, except in processing options and removeFieldsets property
                foreach ($parentObject->thisConfig as $key => $config) {
                        if ($key !== 'proc.') {
                                if (is_array($config)) {
                                        foreach ($config as $subKey => $subConfig) {
-                                               $parentObject->thisConfig[$key][$subKey] = str_replace('acronym', 'abbreviation', $subConfig);
+                                               if (is_array($subConfig)) {
+                                                       foreach ($subConfig as $subSubKey => $subSubConfig) {
+                                                               if ($subSubKey !== 'removeFieldsets') {
+                                                                       $parentObject->thisConfig[$key][$subKey][$subSubKey] = str_replace('acronym', 'abbreviation', $subSubConfig);
+                                                               }
+                                                       }
+                                               } else {
+                                                       if ($subKey !== 'removeFieldsets') {
+                                                               $parentObject->thisConfig[$key][$subKey] = str_replace('acronym', 'abbreviation', $subConfig);
+                                                       }
+                                               }
                                        }
                                } else {
-                                       $parentObject->thisConfig[$key] = str_replace('acronym', 'abbreviation', $config);
+                                       if ($key !== 'removeFieldsets') {
+                                               $parentObject->thisConfig[$key] = str_replace('acronym', 'abbreviation', $config);
+                                       }
                                }
                        }
                }
@@ -125,7 +138,9 @@ class Abbreviation extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                if (is_object($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->userTS['options.']['RTEkeyList'])) {
                        $GLOBALS['BE_USER']->userTS['options.']['RTEkeyList'] = str_replace('acronym', 'abbreviation', $GLOBALS['BE_USER']->userTS['options.']['RTEkeyList']);
                }
-               return parent::main($parentObject) && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables');
+               // Remove button if all fieldsets are removed
+               $removedFieldsets = GeneralUtility::trimExplode(',', $this->thisConfig['buttons.']['abbreviation.']['removeFieldsets'], TRUE);
+               return parent::main($parentObject) && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables') && count($removedFieldsets) < 4;
        }
 
        /**
@@ -144,6 +159,10 @@ class Abbreviation extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                        }
                        $registerRTEinJavascriptString .= '
                        RTEarea[' . $RTEcounter . '].buttons.' . $button . '.abbreviationUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', ('abbreviation_' . $this->htmlAreaRTE->contentLanguageUid), 'js', $this->buildJSAbbreviationArray($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') . ';';
@@ -170,19 +189,16 @@ class Abbreviation extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                $lockBeUserToDBmounts = isset($this->thisConfig['buttons.'][$button . '.']['lockBeUserToDBmounts']) ? $this->thisConfig['buttons.'][$button . '.']['lockBeUserToDBmounts'] : $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'];
                if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'] && $lockBeUserToDBmounts) {
                        // Temporarily setting alternative web browsing mounts
-                       $existingWebMounts = '';
-                       $alternativeWebmountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
-                       $appendAlternativeWebmountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints.append'));
-                       if (!empty($alternativeWebmountPoints)) {
-                               $alternativeWebmountPoints = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $alternativeWebmountPoints);
-                               $existingWebMounts = $GLOBALS['BE_USER']->returnWebmounts();
-                               $GLOBALS['BE_USER']->setWebmounts($alternativeWebmountPoints, $appendAlternativeWebmountPoints);
+                       $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
+                       if ($altMountPoints) {
+                               $savedGroupDataWebmounts = $GLOBALS['BE_USER']->groupData['webmounts'];
+                               $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(GeneralUtility::intExplode(',', $altMountPoints)));
                        }
                        $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
                        $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
                        $recursive = isset($this->thisConfig['buttons.'][$button . '.']['recursive']) ? (int)$this->thisConfig['buttons.'][$button . '.']['recursive'] : 0;
                        if (trim($this->thisConfig['buttons.'][$button . '.']['pages'])) {
-                               $pids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->thisConfig['buttons.'][$button . '.']['pages'], TRUE);
+                               $pids = GeneralUtility::trimExplode(',', $this->thisConfig['buttons.'][$button . '.']['pages'], TRUE);
                                foreach ($pids as $key => $val) {
                                        if (!$GLOBALS['BE_USER']->isInWebMount($val, $perms_clause)) {
                                                unset($pids[$key]);
@@ -192,10 +208,10 @@ class Abbreviation extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                                $pids = $webMounts;
                        }
                        // Restoring webmounts
-                       if (!empty($alternativeWebmountPoints)) {
-                               $GLOBALS['BE_USER']->setWebmounts($existingWebMounts);
+                       if ($altMountPoints) {
+                               $GLOBALS['BE_USER']->groupData['webmounts'] = $savedGroupDataWebmounts;
                        }
-                       $queryGenerator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\QueryGenerator::class);
+                       $queryGenerator = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\QueryGenerator::class);
                        $pageTree = '';
                        $pageTreePrefix = '';
                        foreach ($pids as $key => $val) {
@@ -221,7 +237,7 @@ class Abbreviation extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi {
                        }
                        // Restrict to abbreviations in certain languages
                        if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['language.']) && isset($this->thisConfig['buttons.']['language.']['restrictToItems'])) {
-                               $languageList = implode('\',\'', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $tableB)));
+                               $languageList = implode('\',\'', GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $tableB)));
                                $whereClause .= ' AND ' . $tableB . '.lg_iso_2 IN (' . $languageList . ') ';
                        }
                        $whereClause .= BackendUtility::BEenableFields($tableA);
index 5028eef..7257c31 100644 (file)
@@ -30,7 +30,14 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                 */
                configurePlugin: function(editor) {
                        this.pageTSConfiguration = this.editorConfiguration.buttons.abbreviation;
-                       /*
+                       var removeFieldsets = (this.pageTSConfiguration && this.pageTSConfiguration.removeFieldsets) ? this.pageTSConfiguration.removeFieldsets : '';
+                       removeFieldsets = removeFieldsets.split(',');
+                       var fieldsets = ['abbreviation', 'definedAbbreviation', 'acronym' ,'definedAcronym'];
+                       this.enabledFieldsets = {};
+                       for (var i = fieldsets.length; --i >= 0;) {
+                               this.enabledFieldsets[fieldsets[i]] = removeFieldsets.indexOf(fieldsets[i]) === -1;
+                       }
+                       /**
                         * Registering plugin "About" information
                         */
                        var pluginInformation = {
@@ -43,7 +50,7 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                license         : 'GPL'
                        };
                        this.registerPluginInformation(pluginInformation);
-                       /*
+                       /**
                         * Registering the button
                         */
                        var buttonId = 'Abbreviation';
@@ -51,7 +58,6 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                id              : buttonId,
                                tooltip         : this.localize('Insert abbreviation'),
                                action          : 'onButtonPress',
-                               hide            : (this.pageTSConfiguration.noAcronym && this.pageTSConfiguration.noAbbr),
                                dialog          : true,
                                iconCls         : 'htmlarea-action-abbreviation-edit',
                                contextMenuTitle: this.localize(buttonId + '-contextMenuTitle')
@@ -59,7 +65,8 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                        this.registerButton(buttonConfiguration);
                        return true;
                 },
-               /*
+
+               /**
                 * Sets of default configuration values for dialogue form fields
                 */
                configDefaults: {
@@ -72,26 +79,19 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                mode: 'local'
                        }
                },
-               /*
+
+               /**
                 * This function gets called when the button was pressed
                 *
-                * @param       object          editor: the editor instance
-                * @param       string          id: the button id or the key
-                *
-                * @return      boolean         false if action is completed
+                * @param object editor: the editor instance
+                * @param string id: the button id or the key
+                * @return boolean false if action is completed
                 */
                onButtonPress: function(editor, id) {
                                // Could be a button or its hotkey
                        var buttonId = this.translateHotKey(id);
                        buttonId = buttonId ? buttonId : id;
-                       var abbr = editor.getSelection().getParentElement();
-                               // Working around Safari issue
-                       if (!abbr && this.editor.statusBar && this.editor.statusBar.getSelection()) {
-                               abbr = this.editor.statusBar.getSelection();
-                       }
-                       if (!abbr || !/^(acronym|abbr)$/i.test(abbr.nodeName)) {
-                               abbr = editor.getSelection().getFirstAncestorOfType(['acronym', 'abbr']);
-                       }
+                       var abbr = this.getCurrentAbbrElement();
                        var type = typeof abbr === 'object' && abbr !== null ? abbr.nodeName.toLowerCase() : '';
                        this.params = {
                                abbr: abbr,
@@ -105,20 +105,37 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                this.getWindowDimensions({ width: 580}, buttonId),
                                this.buildTabItemsConfig(abbr),
                                this.buildButtonsConfig(abbr, this.okHandler, this.deleteHandler),
-                               (type == 'acronym') ? 1 : 0
+                               type
                        );
                        return false;
                },
-               /*
-                * Open the dialogue window
+
+               /**
+                * Get the current abbr or aconym element, if any is selected
                 *
-                * @param       string          title: the window title
-                * @param       string          buttonId: the itemId of the button that was pressed
-                * @param       integer         dimensions: the opening width of the window
-                * @param       object          tabItems: the configuration of the tabbed panel
-                * @param       object          buttonsConfig: the configuration of the buttons
-                * @param       number          activeTab: index of the opening tab
+                * @return object the element or null
+                */
+               getCurrentAbbrElement: function() {
+                       var abbr = this.editor.getSelection().getParentElement();
+                       // Working around Safari issue
+                       if (!abbr && this.editor.statusBar && this.editor.statusBar.getSelection()) {
+                               abbr = this.editor.statusBar.getSelection();
+                       }
+                       if (!abbr || !/^(acronym|abbr)$/i.test(abbr.nodeName)) {
+                               abbr = this.editor.getSelection().getFirstAncestorOfType(['abbr', 'acronym']);
+                       }
+                       return abbr;
+               },
+
+               /**
+                * Open the dialogue window
                 *
+                * @param string title: the window title
+                * @param string buttonId: the itemId of the button that was pressed
+                * @param integer dimensions: the opening width of the window
+                * @param object tabItems: the configuration of the tabbed panel
+                * @param object buttonsConfig: the configuration of the buttons
+                * @param string activeTab: itemId of the opening tab
                 * @return      void
                 */
                openDialogue: function (title, buttonId, dimensions, tabItems, buttonsConfig, activeTab) {
@@ -160,23 +177,27 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                        });
                        this.show();
                },
-               /*
+
+               /**
                 * Build the dialogue tab items config
                 *
-                * @param       object          element: the element being edited, if any
-                *
-                * @return      object          the tab items configuration
+                * @param object element: the element being edited, if any
+                * @return object the tab items configuration
                 */
                buildTabItemsConfig: function (element) {
                        var type = typeof element === 'object' && element !== null ? element.nodeName.toLowerCase() : '';
                        var tabItems = [];
                        var abbrTabItems = [];
-                               // abbr tab not shown if the current selection is an acronym
+                       // abbreviation tab not shown if the current selection is an acronym
                        if (type !== 'acronym') {
-                               if (!this.pageTSConfiguration.noAbbr) {
-                                       this.addConfigElement(this.buildDefinedTermFieldsetConfig((type == 'abbr') ? element : null, 'abbr'), abbrTabItems);
+                               // definedAbbreviation fieldset not shown if no pre-defined abbreviation exists
+                               if (!this.pageTSConfiguration.noAbbr && this.enabledFieldsets['definedAbbreviation']) {
+                                       this.addConfigElement(this.buildDefinedTermFieldsetConfig((type === 'abbr') ? element : null, 'abbr'), abbrTabItems);
+                               }
+                               // abbreviation fieldset not shown if the selection is empty or not inside an abbr element
+                               if ((!this.editor.getSelection().isEmpty() || type === 'abbr') && this.enabledFieldsets['abbreviation']) {
+                                       this.addConfigElement(this.buildUseTermFieldsetConfig((type === 'abbr') ? element : null, 'abbr'), abbrTabItems);
                                }
-                               this.addConfigElement(this.buildUseTermFieldsetConfig((type == 'abbr') ? element : null, 'abbr'), abbrTabItems);
                        }
                        if (abbrTabItems.length > 0) {
                                tabItems.push({
@@ -186,12 +207,16 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                });
                        }
                        var acronymTabItems = [];
-                               // acronym tab not shown if the current selection is an abbr
+                       // acronym tab not shown if the current selection is an abbreviation
                        if (type !== 'abbr') {
-                               if (!this.pageTSConfiguration.noAcronym) {
-                                       this.addConfigElement(this.buildDefinedTermFieldsetConfig((type == 'acronym') ? element : null, 'acronym'), acronymTabItems);
+                               // definedAcronym fieldset not shown if no pre-defined acronym exists
+                               if (!this.pageTSConfiguration.noAcronym && this.enabledFieldsets['definedAcronym']) {
+                                       this.addConfigElement(this.buildDefinedTermFieldsetConfig((type === 'acronym') ? element : null, 'acronym'), acronymTabItems);
+                               }
+                               // acronym fieldset not shown if the selection is empty or not inside an acronym element
+                               if ((!this.editor.getSelection().isEmpty() || type === 'acronym') && this.enabledFieldsets['acronym']) {
+                                       this.addConfigElement(this.buildUseTermFieldsetConfig((type === 'acronym') ? element : null, 'acronym'), acronymTabItems);
                                }
-                               this.addConfigElement(this.buildUseTermFieldsetConfig((type == 'abbr') ? element : null, 'abbr'), acronymTabItems);
                        }
                        if (acronymTabItems.length > 0) {
                                tabItems.push({
@@ -202,7 +227,8 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                        }
                        return tabItems;
                },
-               /*
+
+               /**
                 * Build the dialogue buttons config
                 *
                 * @param       object          element: the element being edited, if any
@@ -239,16 +265,16 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                tpl: '<tpl for="."><div ext:qtip="{abbr}" style="text-align:left;font-size:11px;" class="x-combo-list-item">{term}</div></tpl>',
                                store: new Ext.data.JsonStore({
                                        autoDestroy:  true,
-                                       autoLoad: true,
+                                       autoLoad: false,
                                        root: type,
                                        fields: [ { name: 'term'}, { name: 'abbr'},  { name: 'language'}],
                                        url: this.pageTSConfiguration.abbreviationUrl
                                }),
                                width: 350,
                                listeners: {
-                                       beforerender: {
+                                       afterrender: {
                                                fn: function (combo) {
-                                                               // Ensure the store is loaded
+                                                       // Ensure the store is loaded
                                                        combo.getStore().load({
                                                                callback: function () { this.onSelectorRender(combo); },
                                                                scope: this
@@ -271,16 +297,16 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                itemId: 'abbrSelector',
                                store: new Ext.data.JsonStore({
                                        autoDestroy:  true,
-                                       autoLoad: true,
+                                       autoLoad: false,
                                        root: type,
                                        fields: [ { name: 'term'}, { name: 'abbr'},  { name: 'language'}],
                                        url: this.pageTSConfiguration.abbreviationUrl
                                }),
                                width: 100,
                                listeners: {
-                                       beforerender: {
+                                       afterrender: {
                                                fn: function (combo) {
-                                                               // Ensure the store is loaded
+                                                       // Ensure the store is loaded
                                                        combo.getStore().load({
                                                                callback: function () { this.onSelectorRender(combo); },
                                                                scope: this
@@ -349,7 +375,8 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                }
                        };
                },
-               /*
+
+               /**
                 * Handler on rendering the defined abbreviation fieldset
                 * If an abbr is selected but no term is selected, select any corresponding term with the correct language value, if any
                 */
@@ -374,11 +401,15 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                if (index !== -1) {
                                        term = abbrStore.getAt(index).get('term');
                                        termSelector.setValue(term);
-                                       fieldset.ownerCt.find('itemId', 'useTerm')[0].setValue(term);
+                                       var useTermField = fieldset.ownerCt.find('itemId', 'useTerm');
+                                       if (useTermField.length) {
+                                               useTermField[0].setValue(term);
+                                       }
                                }
                        }
                },
-               /*
+
+               /**
                 * Filter the term and abbr selector lists
                 * Set initial values
                 * If there is already an abbr and the filtered list has only one or no element, hide the fieldset
@@ -388,10 +419,10 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                        store.filterBy(function (record) {
                                return !this.params.text || !this.params.title || this.params.text == record.get('term') || this.params.title == record.get('term') || this.params.title == record.get('abbr');
                        }, this);
-                               // Make sure the combo list is filtered
+                       // Make sure the combo list is filtered
                        store.snapshot = store.data;
                        var store = combo.getStore();
-                               // Initialize the term and abbr combos
+                       // Initialize the term and abbr combos
                        if (combo.getItemId() == 'termSelector') {
                                if (this.params.title) {
                                        var index = store.findExact('term', this.params.title);
@@ -417,7 +448,8 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                }
                        }
                },
-               /*
+
+               /**
                 * Handler when a term is selected
                 */
                onTermSelect: function (combo, record, index) {
@@ -426,10 +458,10 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                        var term = record.get('term');
                        var abbr = record.get('abbr');
                        var language = record.get('language');
-                               // Update the abbreviation selector
+                       // Update the abbreviation selector
                        var abbrSelector = tab.find('itemId', 'abbrSelector')[0];
                        abbrSelector.setValue(abbr);
-                               // Update the language selector
+                       // Update the language selector
                        var languageSelector = tab.find('itemId', 'language');
                        if (languageSelector.length > 0) {
                                if (language) {
@@ -438,10 +470,14 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                        languageSelector[0].setValue('none');
                                }
                        }
-                               // Update the term to use
-                       tab.find('itemId', 'useTerm')[0].setValue(term);
+                       // Update the term to use
+                       var useTermField = tab.find('itemId', 'useTerm');
+                       if (useTermField.length) {
+                               useTermField[0].setValue(term);
+                       }
                },
-               /*
+
+               /**
                 * Handler when an abbreviation or acronym is selected
                 */
                onAbbrSelect: function (combo, record, index) {
@@ -449,10 +485,10 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                        var tab = fieldset.findParentByType('container');
                        var term = record.get('term');
                        var language = record.get('language');
-                               // Update the term selector
+                       // Update the term selector
                        var termSelector = tab.find('itemId', 'termSelector')[0];
                        termSelector.setValue(term);
-                               // Update the language selector
+                       // Update the language selector
                        var languageSelector = tab.find('itemId', 'language');
                        if (languageSelector.length > 0) {
                                if (language) {
@@ -461,10 +497,14 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                        languageSelector[0].setValue('none');
                                }
                        }
-                               // Update the term to use
-                       tab.find('itemId', 'useTerm')[0].setValue(term);
+                       // Update the term to use
+                       var useTermField = tab.find('itemId', 'useTerm');
+                       if (useTermField.length) {
+                               useTermField[0].setValue(term);
+                       }
                },
-               /*
+
+               /**
                 * This function builds the configuration object for the Abbreviation or Acronym to use fieldset
                 *
                 * @param       object          element: the element being edited, if any
@@ -487,7 +527,8 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                items: itemsConfig
                        };
                },
-               /*
+
+               /**
                 * Handler when the ok button is pressed
                 */
                okHandler: function (button, event) {
@@ -499,10 +540,15 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                        var termSelector = tab.find('itemId', 'termSelector');
                        var term = termSelector && termSelector.length > 0 ? termSelector[0].getValue() : '';
                        var abbrSelector = tab.find('itemId', 'abbrSelector');
+                       var useTermField = tab.find('itemId', 'useTerm');
                        if (!this.params.abbr) {
                                var abbr = this.editor.document.createElement(type);
-                               abbr.title = tab.find('itemId', 'useTerm')[0].getValue();
-                               if (term == abbr.title && abbrSelector && abbrSelector.length > 0) {
+                               if (useTermField.length) {
+                                       abbr.title = useTermField[0].getValue();
+                               } else {
+                                       abbr.title = term;
+                               }
+                               if (term === abbr.title && abbrSelector && abbrSelector.length > 0) {
                                        abbr.innerHTML = abbrSelector[0].getValue();
                                } else {
                                        abbr.innerHTML = this.params.text;
@@ -520,18 +566,23 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                                }
                        } else {
                                var abbr = this.params.abbr;
-                               abbr.title = tab.find('itemId', 'useTerm')[0].getValue();
+                               if (useTermField.length) {
+                                       abbr.title = useTermField[0].getValue();
+                               } else {
+                                       abbr.title = term;
+                               }
                                if (language) {
                                        this.getPluginInstance('Language').setLanguageAttributes(abbr, language);
                                }
-                               if (term == abbr.title && abbrSelector && abbrSelector.length > 0) {
+                               if (term === abbr.title && abbrSelector && abbrSelector.length > 0) {
                                        abbr.innerHTML = abbrSelector[0].getValue();
                                }
                        }
                        this.close();
                        event.stopEvent();
                },
-               /*
+
+               /**
                 * Handler when the delete button is pressed
                 */
                deleteHandler: function (button, event) {
@@ -549,11 +600,18 @@ define('TYPO3/CMS/Rtehtmlarea/Plugins/Abbreviation',
                 */
                onUpdateToolbar: function (button, mode, selectionEmpty, ancestors) {
                        if ((mode === 'wysiwyg') && this.editor.isEditable()) {
-                               var el = this.editor.getSelection().getParentElement();
-                               if (el) {
-                                       button.setDisabled(((el.nodeName.toLowerCase() == 'acronym' && this.pageTSConfiguration.noAcronym) || (el.nodeName.toLowerCase() == 'abbr' && this.pageTSConfiguration.noAbbr)));
-                                       button.setInactive(!(el.nodeName.toLowerCase() == 'acronym' && !this.pageTSConfiguration.noAcronym) && !(el.nodeName.toLowerCase() == 'abbr' && !this.pageTSConfiguration.noAbbr));
-                               }
+                               var el = this.getCurrentAbbrElement();
+                               var nodeName = typeof el === 'object' && el !== null ? el.nodeName.toLowerCase() : '';
+                               // Disable the button if the selection and not inside a abbr or acronym element
+                               button.setDisabled(
+                                       (this.editor.getSelection().isEmpty() && nodeName !== 'abbr' && nodeName !== 'acronym')
+                                       && (this.pageTSConfiguration.noAbbr || !this.enabledFieldsets['definedAbbreviation'])
+                                       && (this.pageTSConfiguration.noAcronym || !this.enabledFieldsets['definedAcronym'])
+                               );
+                               button.setInactive(
+                                       !(nodeName === 'abbr' && (this.enabledFieldsets['definedAbbreviation'] || this.enabledFieldsets['abbreviation']))
+                                       && !(nodeName === 'acronym' && (this.enabledFieldsets['definedAcronym'] || this.enabledFieldsets['acronym']))
+                               );
                                button.setTooltip(this.localize((button.disabled || button.inactive) ? 'Insert abbreviation' : 'Edit abbreviation'));
                                button.contextMenuTitle = '';
                                if (this.dialog) {
index 3a96bf6..92d92cc 100644 (file)
@@ -12,7 +12,7 @@
                        <trans-unit id=".details" xml:space="preserve">
                                <source>Clicking the "Insert abbreviation" icon in the RTE tool bar opens a dialogue that allows to insert an abbreviation or to edit one that already exists in the content.
 Any existing abbreviation is underlined with a broken line and the cursor changes to a question mark when the mouse goes over it.
-The dialogue allows to associate an abbreviation to a term. The abbreviation may be selected among abbreviations that have been pre-defined in the database or may be entered directly in the dialogue.</source>
+The dialogue allows to associate an abbreviation to a term. The abbreviation may be selected among abbreviations that have been pre-defined in the database or the term being abbreviated may be entered directly in the dialogue.</source>
                        </trans-unit>
                        <trans-unit id=".image" xml:space="preserve">
                                <source>EXT:rtehtmlarea/Resources/Public/Images/Plugins/Abbreviation/abbreviation.gif</source>
@@ -78,13 +78,13 @@ If a pre-defined abbreviation (or acronym) is selected, the language for which i
                                <source>Term to abbreviate</source>
                        </trans-unit>
                        <trans-unit id="termToAbridge.description" xml:space="preserve">
-                               <source>This section lets you enter a term for which the current selection will be the short form.</source>
+                               <source>This section lets you enter the unabbreviated term for which the currently selected text will be the short form.</source>
                        </trans-unit>
                        <trans-unit id="useThisTerm.alttitle" xml:space="preserve">
                                <source>Use this term</source>
                        </trans-unit>
                        <trans-unit id="useThisTerm.description" xml:space="preserve">
-                               <source>Enter the term that you want to associate as the unabbreviated form of the current selection.</source>
+                               <source>Enter the term that you want to associate as the unabbreviated form of the currently selected text.</source>
                        </trans-unit>
                        <trans-unit id="useThisTerm.details" xml:space="preserve">
                                <source>The entered term will be set as the title attribute of the abbreviation (or acronym) element.</source>