[FEATURE] Introduce allowLanguageSynchronization 91/51291/31
authorOliver Hader <oliver@typo3.org>
Thu, 12 Jan 2017 14:21:52 +0000 (15:21 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 7 Feb 2017 16:09:10 +0000 (17:09 +0100)
commit2fd70c83530adf89ba49d2015aff028cc7bbacb5
treeeeb82fe6c4d9baa4c33524c4484aa77af4c12f40
parent1dd78c74c531cb0c2090246fc424e65fc82d2c97
[FEATURE] Introduce allowLanguageSynchronization

This feature introduces a new functionality called
"allowLanguageSynchronization" which can be set on a field
configuration of a TCA column. This is the successor of
"l10n_mode=mergeIfNotBlank" as the old option had several
conceptual downsides:

1) "mergeIfNotBlank" took the value of the default record
   during runtime, but only if the translation field was empty.
   This means it was not possible to see what the record
   actually contained without having all fields of the parent
   at hand.

2) It was not possible to have a value "santa" in the original
   record but remove the option in a translation (because an
   empty string "" implicitly triggered the runtime call in the
   frontend)

3) "mergeIfNotBlank" did not work on relations except for files
   fetched via the FileRepository API calls, but for no other
   inline elements.

4) "mergeIfNotBlank" did the overlay functionality in the frontend,
   but only FormEngine and DataHandler took care of the option.
   Custom backend modules had to implement the same functionality.

5) In FormEngine, there was an icon in the translation record that
   if the record kept empty the value of the original language was
   taken, but this is not optimal in terms of usability.

6) "mergeIfNotBlank" did not take the new l10n_source option into
   account, where localizations could be made from other records
   than the default language "0".

The new feature can be set on any TCA column setting:

$GLOBALS['TCA'][<table-name>]['columns']
[<field-name>]['config']['behaviour']
['allowLanguageSynchronization'] = true;

This brings an option to records with translations (both from
l10n_parent and l10n_source) to have the value for all translations
synchronized or explictly have a checkbox to use a custom value.

The information whether a field is custom filled, or kept in sync
from l10n_parent/l10n_source is stored in a separate field called
"l10n_state" inside the database.

The introduced upgrade wizard and TCA migration to remove
"l10n_mode=mergeIfNotBlank" has been modified to migrate to this
option and add a l10n_state database field if a TCA table used
"mergeIfNotBlank" but did not add the l10n_state field manually
via ext_tables.sql yet.

New extensions can easily use the new option right away,
extensions that need to stay compatible with v7 and v8 can add
both options right away to have the same output.

The main goals to achieve with this change is now:

* Have consistent database values for all records regardless
  of l10n_mode=mergeIfNotBlank paving the way to fetch translated
  records without having to overlay (once l10n_mode=exclude is
  also copying values and relations)
* Be more explicit for editors about records that have a different
  or the same state as their l10n_parent/l10n_source as a benefit
  for bigger instances with a lot of languages
* Avoid hidden magic when retrieving localized records in the
  TYPO3 Frontend.

Resolves: #79658
Related: #79243
Releases: master
Change-Id: I6c2dbfeb09b47f958a536c9ab050c24ba4bbcbbd
Reviewed-on: https://review.typo3.org/51291
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
53 files changed:
typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php
typo3/sysext/backend/Classes/Form/Element/CheckboxElement.php
typo3/sysext/backend/Classes/Form/Element/GroupElement.php
typo3/sysext/backend/Classes/Form/Element/ImageManipulationElement.php
typo3/sysext/backend/Classes/Form/Element/InputColorPickerElement.php
typo3/sysext/backend/Classes/Form/Element/InputDateTimeElement.php
typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php
typo3/sysext/backend/Classes/Form/Element/InputTextElement.php
typo3/sysext/backend/Classes/Form/Element/RadioElement.php
typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php
typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleBoxElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php
typo3/sysext/backend/Classes/Form/Element/TextElement.php
typo3/sysext/backend/Classes/Form/Element/TextTableElement.php
typo3/sysext/backend/Classes/Form/FieldWizard/LocalizationStateSelector.php [new file with mode: 0644]
typo3/sysext/backend/Classes/Form/FormDataCompiler.php
typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseLanguageRows.php
typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseRecordTypeValue.php
typo3/sysext/backend/Classes/Form/NodeFactory.php
typo3/sysext/backend/Resources/Public/JavaScript/FormEngine.js
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseLanguageRowsTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseRecordTypeValueTest.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/DataHandling/DatabaseSchemaService.php [new file with mode: 0644]
typo3/sysext/core/Classes/DataHandling/Localization/DataMapItem.php [new file with mode: 0644]
typo3/sysext/core/Classes/DataHandling/Localization/DataMapProcessor.php [new file with mode: 0644]
typo3/sysext/core/Classes/DataHandling/Localization/State.php [new file with mode: 0644]
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Configuration/TCA/sys_category.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-51291-PageRepositoryShouldFieldBeOverlaid.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Feature-51291-SynchronizedFieldValuesInLocalizedRecords.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Functional/DataHandling/Group/AbstractActionTestCase.php
typo3/sysext/core/Tests/Functional/DataHandling/Group/Modify/ActionTest.php
typo3/sysext/core/Tests/Functional/DataHandling/Group/Modify/DataSet/localizeContentOfRelationWSynchronization.csv [new file with mode: 0644]
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/AbstractActionTestCase.php
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/Modify/ActionTest.php
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/Modify/DataSet/localizeParentContentWAllChildrenSelectNLanguageSynchronization.csv [new file with mode: 0644]
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/AbstractActionTestCase.php
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/Modify/ActionTest.php
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/Modify/DataSet/localizeParentContentWAllChildrenSelectNLanguageSynchronization.csv [new file with mode: 0644]
typo3/sysext/core/Tests/Functional/DataHandling/Regular/AbstractActionTestCase.php
typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/ActionTest.php
typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/DataSet/localizeContentWSynchronization.csv [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php
typo3/sysext/core/ext_localconf.php
typo3/sysext/filemetadata/Configuration/TCA/Overrides/sys_file_metadata.php
typo3/sysext/frontend/Classes/Page/PageRepository.php
typo3/sysext/frontend/Configuration/TCA/tt_content.php
typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php
typo3/sysext/install/Classes/Updates/DatabaseRowsUpdateWizard.php
typo3/sysext/install/Classes/Updates/RowUpdater/L10nModeUpdater.php
typo3/sysext/lang/Resources/Private/Language/locallang_wizards.xlf