[TASK] Move config.sys_language_softExclude to compat7 36/52036/3
authorBenni Mack <benni@typo3.org>
Mon, 13 Mar 2017 20:30:47 +0000 (21:30 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Wed, 15 Mar 2017 06:07:32 +0000 (07:07 +0100)
The TypoScript option `config.sys_language_softExclude`
allows to set certain fields on tables to l10n_mode=exclude
during Frontend runtime. This TCA option has been migrated
to "allowLanguageSynchronization", but with the clean way that
the database values are consistent across all translations already.

Any special runtime logic and changes can still be done via hooks
for specific use-cases.

Resolves: #80266
Releases: master
Change-Id: I15c55a556b6f1c100e300299410e26d45409e09c
Reviewed-on: https://review.typo3.org/52036
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/compatibility7/Classes/Hooks/TcaSoftExcludeHook.php [new file with mode: 0644]
typo3/sysext/compatibility7/ext_localconf.php
typo3/sysext/core/Documentation/Changelog/master/Important-80266-MovedConfigsysLanguageSoftExcludeToCompatibility7.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/t3editor/Resources/Private/tsref.xml

diff --git a/typo3/sysext/compatibility7/Classes/Hooks/TcaSoftExcludeHook.php b/typo3/sysext/compatibility7/Classes/Hooks/TcaSoftExcludeHook.php
new file mode 100644 (file)
index 0000000..811a7aa
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+namespace TYPO3\CMS\Compatibility7\Hooks;
+
+/*
+ * 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!
+ */
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+
+/**
+ * Hook to validate the TypoScript option
+ * config.sys_language_softExclude
+ * that allows to set certain table/field combinations to use l10n_mode=exclude which have not set to l10n_mode
+ * by default.
+ *
+ * This option is mostly obsolete with TYPO3 v8 as the database sets for translation modes are handled via
+ * "allowLanguageSynchronization" where all fields are properly filled in all translations
+ */
+class TcaSoftExcludeHook
+{
+    /**
+     * Hooks in TSFE after the language initialization to set TCA l10n_mode=exclude on certain fields
+     * on runtime, called "softExclude"
+     *
+     * @param array $parameters left empty, not in use
+     * @param TypoScriptFrontendController $parentObject
+     */
+    public function setCustomExcludeFields(array $parameters, TypoScriptFrontendController $parentObject)
+    {
+        if (isset($parentObject->config['config']['sys_language_softExclude'])
+            && !empty($parentObject->config['config']['sys_language_softExclude'])) {
+            $tableFieldCombinations = GeneralUtility::trimExplode(',', $parentObject->config['config']['sys_language_softExclude'], true);
+            foreach ($tableFieldCombinations as $tableFieldCombination) {
+                list($tableName, $fieldName) = explode(':', $tableFieldCombination);
+                $GLOBALS['TCA'][$tableName]['columns'][$fieldName]['l10n_mode'] = 'exclude';
+            }
+        }
+    }
+}
index 399e9cd..3ac8cb1 100644 (file)
@@ -97,3 +97,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Backend\Controller\PageLayo
 
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Backend\Controller\PageLayoutController::class]['renderActionHook']['compatibility7_quickedit']
     = \TYPO3\CMS\Compatibility7\Hooks\PageLayoutActionHook::class . '->renderAction';
+
+// Enable TypoScript functionality config.sys_language_softExclude
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess']['compatibility7_softExclude']
+    = \TYPO3\CMS\Compatibility7\Hooks\TcaSoftExcludeHook::class . '->setCustomExcludeFields';
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-80266-MovedConfigsysLanguageSoftExcludeToCompatibility7.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-80266-MovedConfigsysLanguageSoftExcludeToCompatibility7.rst
new file mode 100644 (file)
index 0000000..e28e243
--- /dev/null
@@ -0,0 +1,23 @@
+.. include:: ../../Includes.txt
+
+===========================================================================
+Important: #80266 - Moved config.sys_language_softExclude to compatibility7
+===========================================================================
+
+See :issue:`80266`
+
+Description
+===========
+
+The TypoScript option `config.sys_language_softExclude` to set
+certain TCA table fields to `l10n_mode=exclude` during frontend request
+runtime has been moved to compatibility7.
+
+If any installation depends on this option in the TYPO3 frontend, the
+extension should be installed.
+
+However, as the TCA option `l10n_mode=exclude` has been superseded
+by the TCA option `allowLanguageSynchronization` the actual use-case
+for this TypoScript setting should be re-evaluated.
+
+.. index:: TypoScript
\ No newline at end of file
index cc5ccf5..f71b2df 100644 (file)
@@ -2717,12 +2717,6 @@ class TypoScriptFrontendController
             }
         }
 
-        // Setting softExclude:
-        $table_fields = GeneralUtility::trimExplode(',', $this->config['config']['sys_language_softExclude'], true);
-        foreach ($table_fields as $TF) {
-            list($tN, $fN) = explode(':', $TF);
-            $GLOBALS['TCA'][$tN]['columns'][$fN]['l10n_mode'] = 'exclude';
-        }
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess'])) {
             $_params = [];
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['settingLanguage_postProcess'] as $_funcRef) {
index c906bc5..0d5fe82 100644 (file)
@@ -851,18 +851,6 @@ hideNonTranslated : If this keyword is used a record that has no translation wil
                        <default><![CDATA[
 ]]></default>
                </property>
-               <property name="sys_language_softExclude" type="string">
-                       <description><![CDATA[Setting additional "exclude" flags for l10n_mode in TCA for frontend rendering.
-
-Syntax:
- [table]:[field],  [table]:[field],  [table]:[field], ...
-
-Example:
-config.sys_language_softExclude = tt_content:image , tt_content:header
-]]></description>
-                       <default><![CDATA[
-]]></default>
-               </property>
                <property name="sys_language_uid" type="int">
                        <description><![CDATA[This value points to the uid of a record from the "sys_language" table and if set, this means that various parts of the frontend display code will select records which are assigned to this language. See ->SELECT