[FEATURE] Introduce shadowColumnsForMovePlaceholders property 73/28473/6
authorOliver Hader <oliver@typo3.org>
Mon, 17 Mar 2014 13:52:04 +0000 (14:52 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Fri, 21 Mar 2014 19:08:43 +0000 (20:08 +0100)
$TCA[<table>]['ctrl']['shadowColumnsForMovePlaceholders'] behaves
similar to shadowColumnsForNewPlaceholders but is only used for
move placeholders.

If shadowColumnsForMovePlaceholders is not defined in particular
for a table, but shadowColumnsForNewPlaceholders is defined,
then that value is used as a fallback - since that property
existed for a longer time already.

Resolves: #56994
Documentation: #56749
Releases: 6.2
Change-Id: Icdbd35234efae8162cfb2dc15a2838acd22370b1
Reviewed-on: https://review.typo3.org/28473
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/version/Classes/Hook/DataHandlerHook.php

index 3c7b019..011e3b6 100644 (file)
@@ -1210,6 +1210,26 @@ class DataHandlerHook {
                        // First, we create a placeholder record in the Live workspace that
                        // represents the position to where the record is eventually moved to.
                        $newVersion_placeholderFieldArray = array();
+
+                       // Use property for move placeholders if set (since TYPO3 CMS 6.2)
+                       if (isset($GLOBALS['TCA'][$table]['ctrl']['shadowColumnsForMovePlaceholders'])) {
+                               $shadowColumnsForMovePlaceholder = $GLOBALS['TCA'][$table]['ctrl']['shadowColumnsForMovePlaceholders'];
+                       // Fallback to property for new placeholder (existed long time before TYPO3 CMS 6.2)
+                       } elseif (isset($GLOBALS['TCA'][$table]['ctrl']['shadowColumnsForNewPlaceholders'])) {
+                               $shadowColumnsForMovePlaceholder = $GLOBALS['TCA'][$table]['ctrl']['shadowColumnsForNewPlaceholders'];
+                       }
+
+                       // Set values from the versioned record to the move placeholder
+                       if (!empty($shadowColumnsForMovePlaceholder)) {
+                               $versionedRecord = BackendUtility::getRecord($table, $wsUid);
+                               $shadowColumns = GeneralUtility::trimExplode(',', $shadowColumnsForMovePlaceholder, TRUE);
+                               foreach ($shadowColumns as $shadowColumn) {
+                                       if (isset($versionedRecord[$shadowColumn])) {
+                                               $newVersion_placeholderFieldArray[$shadowColumn] = $versionedRecord[$shadowColumn];
+                                       }
+                               }
+                       }
+
                        if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
                                $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
                        }