[FEATURE] Purge language packs in language module 60/50860/4
authorMichael Oehlhof <typo3@oehlhof.de>
Fri, 2 Dec 2016 19:23:30 +0000 (20:23 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Sat, 3 Dec 2016 13:54:33 +0000 (14:54 +0100)
A "remove" button is added to the list of the installed languages.

Resolves: #58637
Releases: master
Change-Id: Ibd8911d2c58e449a026f52f4bd8b0b2d04bc2bbf
Reviewed-on: https://review.typo3.org/50860
Reviewed-by: Markus Sommer <markussom@posteo.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Build/Resources/Public/Less/TYPO3/_module_lang.less
typo3/sysext/backend/Resources/Public/Css/backend.css
typo3/sysext/core/Documentation/Changelog/master/Feature-58637-PurgeLanguagePacksInLanguageModule.rst [new file with mode: 0644]
typo3/sysext/lang/Classes/Controller/LanguageController.php
typo3/sysext/lang/Classes/View/Language/RemoveLanguageJson.php [new file with mode: 0644]
typo3/sysext/lang/Resources/Private/Language/locallang.xlf
typo3/sysext/lang/Resources/Private/Layouts/Default.html
typo3/sysext/lang/Resources/Private/Templates/Language/ListLanguages.html
typo3/sysext/lang/Resources/Public/JavaScript/LanguageModule.js
typo3/sysext/lang/ext_tables.php

index c1a1518..2749710 100644 (file)
@@ -27,6 +27,7 @@ div.typo3-module-lang {
 
                                a {
                                        &.deactivateLanguageLink,
+                                       &.removeLanguageLink,
                                        &.updateLanguageLink,
                                        &.updateTranslationLink {
                                                display: none;
@@ -70,6 +71,7 @@ div.typo3-module-lang {
                tr.complete,
                td.complete {
                        a {
+                               &.removeLanguageLink,
                                &.updateLanguageLink,
                                &.updateTranslationLink {
                                        display: none;
index 2489c50..5fcbd52 100644 (file)
@@ -13701,6 +13701,7 @@ div.typo3-module-lang table.t3-datatable tr.disabled {
   color: #aaaaaa;
 }
 div.typo3-module-lang table.t3-datatable tr.disabled a.deactivateLanguageLink,
+div.typo3-module-lang table.t3-datatable tr.disabled a.removeLanguageLink,
 div.typo3-module-lang table.t3-datatable tr.disabled a.updateLanguageLink,
 div.typo3-module-lang table.t3-datatable tr.disabled a.updateTranslationLink {
   display: none;
@@ -13726,6 +13727,10 @@ div.typo3-module-lang table.t3-datatable tr.complete div.progressBar {
   display: inline;
   cursor: default;
 }
+div.typo3-module-lang table.t3-datatable tr.processing a.removeLanguageLink,
+div.typo3-module-lang table.t3-datatable td.processing a.removeLanguageLink,
+div.typo3-module-lang table.t3-datatable tr.complete a.removeLanguageLink,
+div.typo3-module-lang table.t3-datatable td.complete a.removeLanguageLink,
 div.typo3-module-lang table.t3-datatable tr.processing a.updateLanguageLink,
 div.typo3-module-lang table.t3-datatable td.processing a.updateLanguageLink,
 div.typo3-module-lang table.t3-datatable tr.complete a.updateLanguageLink,
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-58637-PurgeLanguagePacksInLanguageModule.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-58637-PurgeLanguagePacksInLanguageModule.rst
new file mode 100644 (file)
index 0000000..4f4a354
--- /dev/null
@@ -0,0 +1,22 @@
+.. include:: ../../Includes.txt
+
+=========================================================
+Feature: #58637 - Purge language packs in language module
+=========================================================
+
+See :issue:`58637`
+
+Description
+===========
+
+The language module in the backend offers the possibility to activate and deactivate language packs.
+If deactivating a language pack that previously has been loaded, the data stays in typo3conf/l10n/<locale>/ .
+A remove button is added to the actions. With the remove action the language is disabled and the data is removed from the typo3conf/l10n/<locale>/ directory.
+
+
+Impact
+======
+
+The language data can now be removed from the installation.
+
+.. index:: Backend
\ No newline at end of file
index c75cc16..c183bd3 100644 (file)
@@ -239,6 +239,23 @@ class LanguageController extends ActionController
     }
 
     /**
+     * Remove a language
+     *
+     * @param array $data The request data
+     * @return void
+     */
+    public function removeLanguageAction(array $data)
+    {
+        $response = ['success' => false];
+        if (!empty($data['locale'])) {
+            $response = $this->languageRepository->deactivateByLocale($data['locale']);
+            $absoluteLanguagePath = GeneralUtility::getFileAbsFileName(PATH_typo3conf . 'l10n/' . $data['locale']);
+            GeneralUtility::rmdir($absoluteLanguagePath, true);
+        }
+        $this->view->assign('response', $response);
+    }
+
+    /**
      * DocHeaderMenu
      */
     protected function prepareDocHeaderMenu()
@@ -258,6 +275,7 @@ class LanguageController extends ActionController
             'flashmessage.canceled',
             'flashmessage.languageActivated',
             'flashmessage.languageDeactivated',
+            'flashmessage.languageRemoved',
             'flashmessage.noLanguageActivated',
             'flashmessage.errorOccurred',
             'table.processing',
diff --git a/typo3/sysext/lang/Classes/View/Language/RemoveLanguageJson.php b/typo3/sysext/lang/Classes/View/Language/RemoveLanguageJson.php
new file mode 100644 (file)
index 0000000..29e2d54
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace TYPO3\CMS\Lang\View\Language;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * JSON view for "removeLanguage" action in "Language" controller
+ */
+class RemoveLanguageJson extends \TYPO3\CMS\Lang\View\AbstractJsonView
+{
+    /**
+     * Returns the response data
+     *
+     * @return array The response data
+     */
+    protected function getReponseData()
+    {
+        return $this->variables['response'];
+    }
+}
index be05d3f..c74c635 100644 (file)
@@ -59,6 +59,9 @@
                        <trans-unit id="flashmessage.languageDeactivated">
                                <source>Language was successfully deactivated.</source>
                        </trans-unit>
+                       <trans-unit id="flashmessage.languageRemoved">
+                               <source>Language was successfully deactivated and removed.</source>
+                       </trans-unit>
                        <trans-unit id="flashmessage.errorOccurred">
                                <source>The request has failed.</source>
                        </trans-unit>
index 24bb192..29271a2 100644 (file)
@@ -5,6 +5,7 @@
        data-update-translation-uri="{f:uri.action(action:'updateTranslation',format:'json')}"
        data-activate-language-uri="{f:uri.action(action:'activateLanguage',format:'json')}"
        data-deactivate-language-uri="{f:uri.action(action:'deactivateLanguage',format:'json')}"
+       data-remove-language-uri="{f:uri.action(action:'removeLanguage',format:'json')}"
        data-prefix="tx_lang_tools_langlanguage"
 >
 
index d72bca7..219f12b 100644 (file)
                                </td>
                                <td class="actions">
                                        <a class="btn btn-default updateLanguageLink" data-action="updateLanguage"
-                                          data-locale="{language.locale}" data-language="{language.label}" data-selected="true"><span
-                                               title="Download" class="t3-icon fa fa-download"> </span></a>
-
+                                                data-locale="{language.locale}" data-language="{language.label}" data-selected="true">
+                                               <span title="Download" class="t3-icon fa fa-download"> </span>
+                                       </a>
+                                       <a class="btn btn-default removeLanguageLink" data-action="removeLanguage"
+                                                data-locale="{language.locale}" data-language="{language.label}" data-selected="true">
+                                               <span title="Remove" class="t3-icon fa fa-trash"> </span>
+                                       </a>
                                        <div class="progressBar">
                                                <div class="progress">
                                                        <div class="progress-text"></div>
index 4e1de2c..e8f9555 100644 (file)
@@ -49,6 +49,7 @@ define(['jquery',
                        activateIcon: 'span.activateIcon',
                        deactivateIcon: 'span.deactivateIcon',
                        downloadIcon: 'span.downloadIcon',
+                       removeIcon: 'span.removeIcon',
                        loadingIcon: 'span.loadingIcon',
                        completeIcon: 'span.completeIcon',
                        progressBar: 'div.progressBar',
@@ -153,6 +154,31 @@ define(['jquery',
        };
 
        /**
+        * Remove a language
+        *
+        * @param {HTMLElement} triggerElement
+        * @param {Object} parameters
+        */
+       LanguageModule.removeLanguageAction = function(triggerElement, parameters) {
+               var $row = $(triggerElement).closest('tr'),
+                       locale = $row.data('locale'),
+                       $lastUpdate = $(LanguageModule.identifiers.lastUpdate, $row);
+
+               if ($row.hasClass(LanguageModule.classes.processing)) {
+                       LanguageModule.abortAjaxRequest();
+               }
+               LanguageModule.executeAjaxRequest(LanguageModule.settings.removeLanguageUri, {locale: locale}, function(response, status) {
+                       if (status === 'success' && response.success) {
+                               $row.removeClass(LanguageModule.classes.enabled).removeClass(LanguageModule.classes.complete).addClass(LanguageModule.classes.disabled);
+                               $lastUpdate.html('');
+                               LanguageModule.displaySuccess(LanguageModule.labels.languageRemoved);
+                       } else {
+                               LanguageModule.displayError(LanguageModule.labels.errorOccurred);
+                       }
+               });
+       };
+
+       /**
         * Update a language
         *
         * @param {HTMLElement} triggerElement
@@ -261,6 +287,7 @@ define(['jquery',
                        activate: $(LanguageModule.identifiers.activateIcon, LanguageModule.context).html(),
                        deactivate: $(LanguageModule.identifiers.deactivateIcon, LanguageModule.context).html(),
                        download: $(LanguageModule.identifiers.downloadIcon, LanguageModule.context).html(),
+                       remove: $(LanguageModule.identifiers.removeIcon, LanguageModule.context).html(),
                        loading: $(LanguageModule.identifiers.loadingIcon, LanguageModule.context).html(),
                        complete: $(LanguageModule.identifiers.completeIcon, LanguageModule.context).html(),
                        progressBar: $(LanguageModule.identifiers.progressBar, LanguageModule.context).html()
@@ -270,7 +297,7 @@ define(['jquery',
        /**
         * Build labels
         *
-        * @returns {{processing: *, search: *, loadingRecords: *, zeroRecords: *, emptyTable: *, dateFormat: *, errorHeader: *, infoHeader: *, successHeader: *, languageActivated: *, errorOccurred: *, languageDeactivated: *, updateComplete: *}}
+        * @returns {{processing: *, search: *, loadingRecords: *, zeroRecords: *, emptyTable: *, dateFormat: *, errorHeader: *, infoHeader: *, successHeader: *, languageActivated: *, errorOccurred: *, languageDeactivated: *, languageRemoved: *, updateComplete: *}}
         */
        LanguageModule.buildLabels = function() {
                return {
@@ -286,6 +313,7 @@ define(['jquery',
                        languageActivated: TYPO3.lang['flashmessage.languageActivated'],
                        errorOccurred: TYPO3.lang['flashmessage.errorOccurred'],
                        languageDeactivated: TYPO3.lang['flashmessage.languageDeactivated'],
+                       languageRemoved: TYPO3.lang['flashmessage.languageRemoved'],
                        noLanguageActivated: TYPO3.lang['flashmessage.noLanguageActivated'],
                        updateComplete: TYPO3.lang['flashmessage.updateComplete'],
                        canceled: TYPO3.lang['flashmessage.canceled']
@@ -341,6 +369,7 @@ define(['jquery',
                                render: function(data, type, row) {
                                        var links = [
                                                LanguageModule.buildActionLink('updateTranslation', data, LanguageModule.icons.download),
+                                               LanguageModule.buildActionLink('removeTranslation', data, LanguageModule.icons.remove),
                                                LanguageModule.buildLoadingIndicator(),
                                                LanguageModule.buildCompleteIndicator()
                                        ];
index f9514ba..c8dafb1 100644 (file)
@@ -10,7 +10,7 @@ if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) {
         'language',
         'after:extensionmanager',
         [
-            'Language' => 'listLanguages, listTranslations, getTranslations, updateLanguage, updateTranslation, activateLanguage, deactivateLanguage',
+            'Language' => 'listLanguages, listTranslations, getTranslations, updateLanguage, updateTranslation, activateLanguage, deactivateLanguage, removeLanguage',
         ],
         [
             'access' => 'admin',