[BUGFIX] Fix message "Translate to"
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / DataHandling / DataHandler.php
index a3465cb..f1db6f3 100644 (file)
@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\Html\RteHtmlParser;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
@@ -31,6 +32,7 @@ use TYPO3\CMS\Core\Utility\File\BasicFileUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 
 /**
@@ -45,7692 +47,8462 @@ use TYPO3\CMS\Core\Versioning\VersionState;
  * - $GLOBALS['LANG'] must exist
  *
  * tce_db.php for further comments and SYNTAX! Also see document 'TYPO3 Core API' for details.
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-class DataHandler {
-
-       // *********************
-       // Public variables you can configure before using the class:
-       // *********************
-       /**
-        * If TRUE, the default log-messages will be stored. This should not be necessary if the locallang-file for the
-        * log-display is properly configured. So disabling this will just save some database-space as the default messages are not saved.
-        *
-        * @var bool
-        */
-       public $storeLogMessages = TRUE;
-
-       /**
-        * If TRUE, actions are logged to sys_log.
-        *
-        * @var bool
-        */
-       public $enableLogging = TRUE;
-
-       /**
-        * If TRUE, the datamap array is reversed in the order, which is a nice thing if you're creating a whole new
-        * bunch of records.
-        *
-        * @var bool
-        */
-       public $reverseOrder = FALSE;
-
-       /**
-        * If TRUE, only fields which are different from the database values are saved! In fact, if a whole input array
-        * is similar, it's not saved then.
-        *
-        * @var bool
-        */
-       public $checkSimilar = TRUE;
-
-       /**
-        * If TRUE, incoming values in the data-array have their slashes stripped. ALWAYS SET THIS TO ZERO and supply an
-        * unescaped data array instead. This switch may totally disappear in future versions of this class!
-        *
-        * @var bool
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public $stripslashes_values = TRUE;
-
-       /**
-        * This will read the record after having updated or inserted it. If anything is not properly submitted an error
-        * is written to the log. This feature consumes extra time by selecting records
-        *
-        * @var bool
-        */
-       public $checkStoredRecords = TRUE;
-
-       /**
-        * If set, values '' and 0 will equal each other when the stored records are checked.
-        *
-        * @var bool
-        */
-       public $checkStoredRecords_loose = TRUE;
-
-       /**
-        * If this is set, then a page is deleted by deleting the whole branch under it (user must have
-        * delete permissions to it all). If not set, then the page is deleted ONLY if it has no branch.
-        *
-        * @var bool
-        */
-       public $deleteTree = FALSE;
-
-       /**
-        * If set, then the 'hideAtCopy' flag for tables will be ignored.
-        *
-        * @var bool
-        */
-       public $neverHideAtCopy = FALSE;
-
-       /**
-        * If set, then the TCE class has been instantiated during an import action of a T3D
-        *
-        * @var bool
-        */
-       public $isImporting = FALSE;
-
-       /**
-        * If set, then transformations are NOT performed on the input.
-        *
-        * @var bool
-        */
-       public $dontProcessTransformations = FALSE;
-
-       /**
-        * If set, .vDEFbase values are unset in flexforms.
-        *
-        * @var bool
-        */
-       public $clear_flexFormData_vDEFbase = FALSE;
-
-       /**
-        * TRUE: (traditional) Updates when record is saved. For flexforms, updates if change is made to the localized value.
-        * FALSE: Will not update anything.
-        * "FORCE_FFUPD" (string): Like TRUE, but will force update to the FlexForm Field
-        *
-        * @var bool|string
-        */
-       public $updateModeL10NdiffData = TRUE;
-
-       /**
-        * If TRUE, the translation diff. fields will in fact be reset so that they indicate that all needs to change again!
-        * It's meant as the opposite of declaring the record translated.
-        *
-        * @var bool
-        */
-       public $updateModeL10NdiffDataClear = FALSE;
-
-       /**
-        * If TRUE, workspace restrictions are bypassed on edit an create actions (process_datamap()).
-        * YOU MUST KNOW what you do if you use this feature!
-        *
-        * @var bool
-        */
-       public $bypassWorkspaceRestrictions = FALSE;
-
-       /**
-        * If TRUE, file handling of attached files (addition, deletion etc) is bypassed - the value is saved straight away.
-        * YOU MUST KNOW what you are doing with this feature!
-        *
-        * @var bool
-        */
-       public $bypassFileHandling = FALSE;
-
-       /**
-        * If TRUE, access check, check for deleted etc. for records is bypassed.
-        * YOU MUST KNOW what you are doing if you use this feature!
-        *
-        * @var bool
-        */
-       public $bypassAccessCheckForRecords = FALSE;
-
-       /**
-        * Comma-separated list. This list of tables decides which tables will be copied. If empty then none will.
-        * If '*' then all will (that the user has permission to of course)
-        *
-        * @var string
-        */
-       public $copyWhichTables = '*';
-
-       /**
-        * If 0 then branch is NOT copied.
-        * If 1 then pages on the 1st level is copied.
-        * If 2 then pages on the second level is copied ... and so on
-        *
-        * @var int
-        */
-       public $copyTree = 0;
-
-       /**
-        * [table][fields]=value: New records are created with default values and you can set this array on the
-        * form $defaultValues[$table][$field] = $value to override the default values fetched from TCA.
-        * If ->setDefaultsFromUserTS is called UserTSconfig default values will overrule existing values in this array
-        * (thus UserTSconfig overrules externally set defaults which overrules TCA defaults)
-        *
-        * @var array
-        */
-       public $defaultValues = array();
-
-       /**
-        * [table][fields]=value: You can set this array on the form $overrideValues[$table][$field] = $value to
-        * override the incoming data. You must set this externally. You must make sure the fields in this array are also
-        * found in the table, because it's not checked. All columns can be set by this array!
-        *
-        * @var array
-        */
-       public $overrideValues = array();
-
-       /**
-        * [filename]=alternative_filename: Use this array to force another name onto a file.
-        * Eg. if you set ['/tmp/blablabal'] = 'my_file.txt' and '/tmp/blablabal' is set for a certain file-field,
-        * then 'my_file.txt' will be used as the name instead.
-        *
-        * @var array
-        */
-       public $alternativeFileName = array();
-
-       /**
-        * Array [filename]=alternative_filepath: Same as alternativeFileName but with relative path to the file
-        *
-        * @var array
-        */
-       public $alternativeFilePath = array();
-
-       /**
-        * If entries are set in this array corresponding to fields for update, they are ignored and thus NOT updated.
-        * You could set this array from a series of checkboxes with value=0 and hidden fields before the checkbox with 1.
-        * Then an empty checkbox will disable the field.
-        *
-        * @var array
-        */
-       public $data_disableFields = array();
-
-       /**
-        * Use this array to validate suggested uids for tables by setting [table]:[uid]. This is a dangerous option
-        * since it will force the inserted record to have a certain UID. The value just have to be TRUE, but if you set
-        * it to "DELETE" it will make sure any record with that UID will be deleted first (raw delete).
-        * The option is used for import of T3D files when synchronizing between two mirrored servers.
-        * As a security measure this feature is available only for Admin Users (for now)
-        *
-        * @var array
-        */
-       public $suggestedInsertUids = array();
-
-       /**
-        * Object. Call back object for FlexForm traversal. Useful when external classes wants to use the
-        * iteration functions inside DataHandler for traversing a FlexForm structure.
-        *
-        * @var object
-        */
-       public $callBackObj;
-
-       // *********************
-       // Internal variables (mapping arrays) which can be used (read-only) from outside
-       // *********************
-       /**
-        * Contains mapping of auto-versionized records.
-        *
-        * @var array
-        */
-       public $autoVersionIdMap = array();
-
-       /**
-        * When new elements are created, this array contains a map between their "NEW..." string IDs and the eventual UID they got when stored in database
-        *
-        * @var array
-        */
-       public $substNEWwithIDs = array();
-
-       /**
-        * Like $substNEWwithIDs, but where each old "NEW..." id is mapped to the table it was from.
-        *
-        * @var array
-        */
-       public $substNEWwithIDs_table = array();
-
-       /**
-        * Holds the tables and there the ids of newly created child records from IRRE
-        *
-        * @var array
-        */
-       public $newRelatedIDs = array();
-
-       /**
-        * This array is the sum of all copying operations in this class. May be READ from outside, thus partly public.
-        *
-        * @var array
-        */
-       public $copyMappingArray_merged = array();
-
-       /**
-        * A map between input file name and final destination for files being attached to records.
-        *
-        * @var array
-        */
-       public $copiedFileMap = array();
-
-       /**
-        * Contains [table][id][field] of fiels where RTEmagic images was copied. Holds old filename as key and new filename as value.
-        *
-        * @var array
-        */
-       public $RTEmagic_copyIndex = array();
-
-       /**
-        * Errors are collected in this variable.
-        *
-        * @var array
-        */
-       public $errorLog = array();
-
-       /**
-        * Fields from the pages-table for which changes will trigger a pagetree refresh
-        *
-        * @var array
-        */
-       public $pagetreeRefreshFieldsFromPages = array('pid', 'sorting', 'deleted', 'hidden', 'title', 'doktype', 'is_siteroot', 'fe_group', 'nav_hide', 'nav_title', 'module', 'starttime', 'endtime', 'content_from_pid');
-
-       /**
-        * Indicates whether the pagetree needs a refresh because of important changes
-        *
-        * @var bool
-        */
-       public $pagetreeNeedsRefresh = FALSE;
-
-
-       // *********************
-       // Internal Variables, do not touch.
-       // *********************
-
-       // Variables set in init() function:
-
-       /**
-        * The user-object the script uses. If not set from outside, this is set to the current global $BE_USER.
-        *
-        * @var BackendUserAuthentication
-        */
-       public $BE_USER;
-
-       /**
-        * Will be set to uid of be_user executing this script
-        *
-        * @var int
-        */
-       public $userid;
-
-       /**
-        * Will be set to username of be_user executing this script
-        *
-        * @var string
-        */
-       public $username;
-
-       /**
-        * Will be set if user is admin
-        *
-        * @var bool
-        */
-       public $admin;
-
-       /**
-        * Can be overridden from $GLOBALS['TYPO3_CONF_VARS']
-        *
-        * @var array
-        */
-       public $defaultPermissions = array(
-               'user' => 'show,edit,delete,new,editcontent',
-               'group' => 'show,edit,new,editcontent',
-               'everybody' => ''
-       );
-
-       /**
-        * The list of <table>-<fields> that cannot be edited by user. This is compiled from TCA/exclude-flag combined with non_exclude_fields for the user.
-        *
-        * @var array
-        */
-       protected $excludedTablesAndFields = array();
-
-       /**
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        * @var int
-        */
-       public $include_filefunctions;
-
-       /**
-        * Data submitted from the form view, used to control behaviours,
-        * e.g. this is used to activate/deactivate fields and thus store NULL values
-        *
-        * @var array
-        */
-       protected $control = array();
-
-       /**
-        * Set with incoming data array
-        *
-        * @var array
-        */
-       public $datamap = array();
-
-       /**
-        * Set with incoming cmd array
-        *
-        * @var array
-        */
-       public $cmdmap = array();
-
-       // Internal static:
-       /**
-        * Permission mapping
-        *
-        * @var array
-        */
-       public $pMap = array(
-               'show' => 1,
-               // 1st bit
-               'edit' => 2,
-               // 2nd bit
-               'delete' => 4,
-               // 3rd bit
-               'new' => 8,
-               // 4th bit
-               'editcontent' => 16
-       );
-
-       /**
-        * Integer: The interval between sorting numbers used with tables with a 'sorting' field defined. Min 1
-        *
-        * @var int
-        */
-       public $sortIntervals = 256;
-
-       // Internal caching arrays
-       /**
-        * Used by function checkRecordUpdateAccess() to store whether a record is updatable or not.
-        *
-        * @var array
-        */
-       public $recUpdateAccessCache = array();
-
-       /**
-        * User by function checkRecordInsertAccess() to store whether a record can be inserted on a page id
-        *
-        * @var array
-        */
-       public $recInsertAccessCache = array();
-
-       /**
-        * Caching array for check of whether records are in a webmount
-        *
-        * @var array
-        */
-       public $isRecordInWebMount_Cache = array();
-
-       /**
-        * Caching array for page ids in webmounts
-        *
-        * @var array
-        */
-       public $isInWebMount_Cache = array();
-
-       /**
-        * Caching for collecting TSconfig for page ids
-        *
-        * @var array
-        */
-       public $cachedTSconfig = array();
-
-       /**
-        * Used for caching page records in pageInfo()
-        *
-        * @var array
-        */
-       public $pageCache = array();
-
-       /**
-        * Array caching workspace access for BE_USER
-        *
-        * @var array
-        */
-       public $checkWorkspaceCache = array();
-
-       // Other arrays:
-       /**
-        * For accumulation of MM relations that must be written after new records are created.
-        *
-        * @var array
-        */
-       public $dbAnalysisStore = array();
-
-       /**
-        * For accumulation of files which must be deleted after processing of all input content
-        *
-        * @var array
-        */
-       public $removeFilesStore = array();
-
-       /**
-        * Uploaded files, set by process_uploads()
-        *
-        * @var array
-        */
-       public $uploadedFileArray = array();
-
-       /**
-        * Used for tracking references that might need correction after operations
-        *
-        * @var array
-        */
-       public $registerDBList = array();
-
-       /**
-        * Used for tracking references that might need correction in pid field after operations (e.g. IRRE)
-        *
-        * @var array
-        */
-       public $registerDBPids = array();
-
-       /**
-        * Used by the copy action to track the ids of new pages so subpages are correctly inserted!
-        * THIS is internally cleared for each executed copy operation! DO NOT USE THIS FROM OUTSIDE!
-        * Read from copyMappingArray_merged instead which is accumulating this information.
-        *
-        * NOTE: This is used by some outside scripts (e.g. hooks), as the results in $copyMappingArray_merged
-        * are only available after an action has been completed.
-        *
-        * @var array
-        */
-       public $copyMappingArray = array();
-
-       /**
-        * Array used for remapping uids and values at the end of process_datamap
-        *
-        * @var array
-        */
-       public $remapStack = array();
-
-       /**
-        * Array used for remapping uids and values at the end of process_datamap
-        * (e.g. $remapStackRecords[<table>][<uid>] = <index in $remapStack>)
-        *
-        * @var array
-        */
-       public $remapStackRecords = array();
-
-       /**
-        * Array used for checking whether new children need to be remapped
-        *
-        * @var array
-        */
-       protected $remapStackChildIds = array();
-
-       /**
-        * Array used for executing addition actions after remapping happened (set processRemapStack())
-        *
-        * @var array
-        */
-       protected $remapStackActions = array();
-
-       /**
-        * Array used for executing post-processing on the reference index
-        *
-        * @var array
-        */
-       protected $remapStackRefIndex = array();
-
-       /**
-        * Array used for additional calls to $this->updateRefIndex
-        *
-        * @var array
-        */
-       public $updateRefIndexStack = array();
-
-       /**
-        * Tells, that this DataHandler instance was called from \TYPO3\CMS\Impext\ImportExport.
-        * This variable is set by \TYPO3\CMS\Impext\ImportExport
-        *
-        * @var array
-        */
-       public $callFromImpExp = FALSE;
-
-       /**
-        * Array for new flexform index mapping
-        *
-        * @var array
-        */
-       public $newIndexMap = array();
-
-       // Various
-       /**
-        * basicFileFunctions object
-        * For "singleton" file-manipulation object
-        *
-        * @var BasicFileUtility
-        */
-       public $fileFunc;
-
-       /**
-        * Set to "currentRecord" during checking of values.
-        *
-        * @var array
-        */
-       public $checkValue_currentRecord = array();
-
-       /**
-        * A signal flag used to tell file processing that auto versioning has happened and hence certain action should be applied.
-        *
-        * @var bool
-        */
-       public $autoVersioningUpdate = FALSE;
-
-       /**
-        * Disable delete clause
-        *
-        * @var bool
-        */
-       protected $disableDeleteClause = FALSE;
-
-       /**
-        * @var array
-        */
-       protected $checkModifyAccessListHookObjects;
-
-       /**
-        * @var array
-        */
-       protected $version_remapMMForVersionSwap_reg;
-
-       /**
-        * The outer most instance of \TYPO3\CMS\Core\DataHandling\DataHandler:
-        * This object instantiates itself on versioning and localization ...
-        *
-        * @var \TYPO3\CMS\Core\DataHandling\DataHandler
-        */
-       protected $outerMostInstance = NULL;
-
-       /**
-        * Internal cache for collecting records that should trigger cache clearing
-        *
-        * @var array
-        */
-       static protected $recordsToClearCacheFor = array();
-
-       /**
-        * Database layer. Identical to $GLOBALS['TYPO3_DB']
-        *
-        * @var DatabaseConnection
-        */
-       protected $databaseConnection;
-
-       /**
-        * Runtime Cache to store and retrieve data computed for a single request
-        *
-        * @var \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend
-        */
-       protected $runtimeCache = NULL;
-
-       /**
-        * Prefix for the cache entries of nested element calls since the runtimeCache has a global scope.
-        *
-        * @var string
-        */
-       protected $cachePrefixNestedElementCalls = 'core-datahandler-nestedElementCalls-';
-
-       /**
-        *
-        */
-       public function __construct() {
-               $this->databaseConnection = $GLOBALS['TYPO3_DB'];
-               $this->runtimeCache = $this->getRuntimeCache();
-       }
-
-       /**
-        * @param array $control
-        */
-       public function setControl(array $control) {
-               $this->control = $control;
-       }
-
-       /**
-        * Initializing.
-        * For details, see 'TYPO3 Core API' document.
-        * This function does not start the processing of data, but merely initializes the object
-        *
-        * @param array $data Data to be modified or inserted in the database
-        * @param array $cmd Commands to copy, move, delete, localize, versionize records.
-        * @param BackendUserAuthentication|NULL $altUserObject An alternative userobject you can set instead of the default, which is $GLOBALS['BE_USER']
-        * @return void
-        */
-       public function start($data, $cmd, $altUserObject = NULL) {
-               // Initializing BE_USER
-               $this->BE_USER = is_object($altUserObject) ? $altUserObject : $GLOBALS['BE_USER'];
-               $this->userid = $this->BE_USER->user['uid'];
-               $this->username = $this->BE_USER->user['username'];
-               $this->admin = $this->BE_USER->user['admin'];
-               if ($this->BE_USER->uc['recursiveDelete']) {
-                       $this->deleteTree = 1;
-               }
-               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['explicitConfirmationOfTranslation'] && $this->updateModeL10NdiffData === TRUE) {
-                       $this->updateModeL10NdiffData = FALSE;
-               }
-               // Initializing default permissions for pages
-               $defaultPermissions = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPermissions'];
-               if (isset($defaultPermissions['user'])) {
-                       $this->defaultPermissions['user'] = $defaultPermissions['user'];
-               }
-               if (isset($defaultPermissions['group'])) {
-                       $this->defaultPermissions['group'] = $defaultPermissions['group'];
-               }
-               if (isset($defaultPermissions['everybody'])) {
-                       $this->defaultPermissions['everybody'] = $defaultPermissions['everybody'];
-               }
-               // generates the excludelist, based on TCA/exclude-flag and non_exclude_fields for the user:
-               if (!$this->admin) {
-                       $this->excludedTablesAndFields = array_flip($this->getExcludeListArray());
-               }
-               // Setting the data and cmd arrays
-               if (is_array($data)) {
-                       reset($data);
-                       $this->datamap = $data;
-               }
-               if (is_array($cmd)) {
-                       reset($cmd);
-                       $this->cmdmap = $cmd;
-               }
-       }
-
-       /**
-        * Function that can mirror input values in datamap-array to other uid numbers.
-        * Example: $mirror[table][11] = '22,33' will look for content in $this->datamap[table][11] and copy it to $this->datamap[table][22] and $this->datamap[table][33]
-        *
-        * @param array $mirror This array has the syntax $mirror[table_name][uid] = [list of uids to copy data-value TO!]
-        * @return void
-        */
-       public function setMirror($mirror) {
-               if (is_array($mirror)) {
-                       foreach ($mirror as $table => $uid_array) {
-                               if (isset($this->datamap[$table])) {
-                                       foreach ($uid_array as $id => $uidList) {
-                                               if (isset($this->datamap[$table][$id])) {
-                                                       $theIdsInArray = GeneralUtility::trimExplode(',', $uidList, TRUE);
-                                                       foreach ($theIdsInArray as $copyToUid) {
-                                                               $this->datamap[$table][$copyToUid] = $this->datamap[$table][$id];
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Initializes default values coming from User TSconfig
-        *
-        * @param array $userTS User TSconfig array
-        * @return void
-        */
-       public function setDefaultsFromUserTS($userTS) {
-               if (is_array($userTS)) {
-                       foreach ($userTS as $k => $v) {
-                               $k = substr($k, 0, -1);
-                               if ($k && is_array($v) && isset($GLOBALS['TCA'][$k])) {
-                                       if (is_array($this->defaultValues[$k])) {
-                                               $this->defaultValues[$k] = array_merge($this->defaultValues[$k], $v);
-                                       } else {
-                                               $this->defaultValues[$k] = $v;
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Processing of uploaded files.
-        * It turns out that some versions of PHP arranges submitted data for files different if sent in an array. This function will unify this so the internal array $this->uploadedFileArray will always contain files arranged in the same structure.
-        *
-        * @param array $postFiles $_FILES array
-        * @return void
-        */
-       public function process_uploads($postFiles) {
-               if (is_array($postFiles)) {
-                       // Editing frozen:
-                       if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec['freeze']) {
-                               if ($this->enableLogging) {
-                                       $this->newlog('All editing in this workspace has been frozen!', 1);
-                               }
-                               return FALSE;
-                       }
-                       $subA = reset($postFiles);
-                       if (is_array($subA)) {
-                               if (is_array($subA['name']) && is_array($subA['type']) && is_array($subA['tmp_name']) && is_array($subA['size'])) {
-                                       // Initialize the uploadedFilesArray:
-                                       $this->uploadedFileArray = array();
-                                       // For each entry:
-                                       foreach ($subA as $key => $values) {
-                                               $this->process_uploads_traverseArray($this->uploadedFileArray, $values, $key);
-                                       }
-                               } else {
-                                       $this->uploadedFileArray = $subA;
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Traverse the upload array if needed to rearrange values.
-        *
-        * @param array $outputArr $this->uploadedFileArray passed by reference
-        * @param array $inputArr Input array  ($_FILES parts)
-        * @param string $keyToSet The current $_FILES array key to set on the outermost level.
-        * @return void
-        * @access private
-        * @see process_uploads()
-        */
-       public function process_uploads_traverseArray(&$outputArr, $inputArr, $keyToSet) {
-               if (is_array($inputArr)) {
-                       foreach ($inputArr as $key => $value) {
-                               $this->process_uploads_traverseArray($outputArr[$key], $inputArr[$key], $keyToSet);
-                       }
-               } else {
-                       $outputArr[$keyToSet] = $inputArr;
-               }
-       }
-
-       /*********************************************
-        *
-        * HOOKS
-        *
-        *********************************************/
-       /**
-        * Hook: processDatamap_afterDatabaseOperations
-        * (calls $hookObj->processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $this);)
-        *
-        * Note: When using the hook after INSERT operations, you will only get the temporary NEW... id passed to your hook as $id,
-        * but you can easily translate it to the real uid of the inserted record using the $this->substNEWwithIDs array.
-        *
-        * @param array $hookObjectsArr (reference) Array with hook objects
-        * @param string $status (reference) Status of the current operation, 'new' or 'update
-        * @param string $table (reference) The table currently processing data for
-        * @param string $id (reference) The record uid currently processing data for, [integer] or [string] (like 'NEW...')
-        * @param array $fieldArray (reference) The field array of a record
-        * @return void
-        */
-       public function hook_processDatamap_afterDatabaseOperations(&$hookObjectsArr, &$status, &$table, &$id, &$fieldArray) {
-               // Process hook directly:
-               if (!isset($this->remapStackRecords[$table][$id])) {
-                       foreach ($hookObjectsArr as $hookObj) {
-                               if (method_exists($hookObj, 'processDatamap_afterDatabaseOperations')) {
-                                       $hookObj->processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $this);
-                               }
-                       }
-               } else {
-                       $this->remapStackRecords[$table][$id]['processDatamap_afterDatabaseOperations'] = array(
-                               'status' => $status,
-                               'fieldArray' => $fieldArray,
-                               'hookObjectsArr' => $hookObjectsArr
-                       );
-               }
-       }
-
-       /**
-        * Gets the 'checkModifyAccessList' hook objects.
-        * The first call initializes the accordant objects.
-        *
-        * @return array The 'checkModifyAccessList' hook objects (if any)
-        */
-       protected function getCheckModifyAccessListHookObjects() {
-               if (!isset($this->checkModifyAccessListHookObjects)) {
-                       $this->checkModifyAccessListHookObjects = array();
-                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'])) {
-                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'] as $classData) {
-                                       $hookObject = GeneralUtility::getUserObj($classData);
-                                       if (!$hookObject instanceof DataHandlerCheckModifyAccessListHookInterface) {
-                                               throw new \UnexpectedValueException('$hookObject must implement interface \\TYPO3\\CMS\\Core\\DataHandling\\DataHandlerCheckModifyAccessListHookInterface', 1251892472);
-                                       }
-                                       $this->checkModifyAccessListHookObjects[] = $hookObject;
-                               }
-                       }
-               }
-               return $this->checkModifyAccessListHookObjects;
-       }
-
-       /*********************************************
-        *
-        * PROCESSING DATA
-        *
-        *********************************************/
-       /**
-        * Processing the data-array
-        * Call this function to process the data-array set by start()
-        *
-        * @return void|FALSE
-        */
-       public function process_datamap() {
-               $this->controlActiveElements();
-
-               // Keep versionized(!) relations here locally:
-               $registerDBList = array();
-               $this->registerElementsToBeDeleted();
-               $this->datamap = $this->unsetElementsToBeDeleted($this->datamap);
-               // Editing frozen:
-               if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec['freeze']) {
-                       if ($this->enableLogging) {
-                               $this->newlog('All editing in this workspace has been frozen!', 1);
-                       }
-                       return FALSE;
-               }
-               // First prepare user defined objects (if any) for hooks which extend this function:
-               $hookObjectsArr = array();
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'])) {
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'] as $classRef) {
-                               $hookObject = GeneralUtility::getUserObj($classRef);
-                               if (method_exists($hookObject, 'processDatamap_beforeStart')) {
-                                       $hookObject->processDatamap_beforeStart($this);
-                               }
-                               $hookObjectsArr[] = $hookObject;
-                       }
-               }
-               // Organize tables so that the pages-table is always processed first. This is required if you want to make sure that content pointing to a new page will be created.
-               $orderOfTables = array();
-               // Set pages first.
-               if (isset($this->datamap['pages'])) {
-                       $orderOfTables[] = 'pages';
-               }
-               $orderOfTables = array_unique(array_merge($orderOfTables, array_keys($this->datamap)));
-               // Process the tables...
-               foreach ($orderOfTables as $table) {
-                       // Check if
-                       //         - table is set in $GLOBALS['TCA'],
-                       //         - table is NOT readOnly
-                       //         - the table is set with content in the data-array (if not, there's nothing to process...)
-                       //         - permissions for tableaccess OK
-                       $modifyAccessList = $this->checkModifyAccessList($table);
-                       if ($this->enableLogging && !$modifyAccessList) {
-                               $this->log($table, 0, 2, 0, 1, 'Attempt to modify table \'%s\' without permission', 1, array($table));
-                       }
-                       if (isset($GLOBALS['TCA'][$table]) && !$this->tableReadOnly($table) && is_array($this->datamap[$table]) && $modifyAccessList) {
-                               if ($this->reverseOrder) {
-                                       $this->datamap[$table] = array_reverse($this->datamap[$table], 1);
-                               }
-                               // For each record from the table, do:
-                               // $id is the record uid, may be a string if new records...
-                               // $incomingFieldArray is the array of fields
-                               foreach ($this->datamap[$table] as $id => $incomingFieldArray) {
-                                       if (is_array($incomingFieldArray)) {
-                                               // Handle native date/time fields
-                                               $dateTimeFormats = $this->databaseConnection->getDateTimeFormats($table);
-                                               foreach ($GLOBALS['TCA'][$table]['columns'] as $column => $config) {
-                                                       if (isset($incomingFieldArray[$column])) {
-                                                               if (isset($config['config']['dbType']) && ($config['config']['dbType'] === 'date' || $config['config']['dbType'] === 'datetime')) {
-                                                                       $emptyValue = $dateTimeFormats[$config['config']['dbType']]['empty'];
-                                                                       $format = $dateTimeFormats[$config['config']['dbType']]['format'];
-                                                                       $incomingFieldArray[$column] = $incomingFieldArray[$column] ? gmdate($format, $incomingFieldArray[$column]) : $emptyValue;
-                                                               }
-                                                       }
-                                               }
-                                               // Hook: processDatamap_preProcessFieldArray
-                                               foreach ($hookObjectsArr as $hookObj) {
-                                                       if (method_exists($hookObj, 'processDatamap_preProcessFieldArray')) {
-                                                               $hookObj->processDatamap_preProcessFieldArray($incomingFieldArray, $table, $id, $this);
-                                                       }
-                                               }
-                                               // ******************************
-                                               // Checking access to the record
-                                               // ******************************
-                                               $createNewVersion = FALSE;
-                                               $recordAccess = FALSE;
-                                               $old_pid_value = '';
-                                               $this->autoVersioningUpdate = FALSE;
-                                               // Is it a new record? (Then Id is a string)
-                                               if (!MathUtility::canBeInterpretedAsInteger($id)) {
-                                                       // Get a fieldArray with default values
-                                                       $fieldArray = $this->newFieldArray($table);
-                                                       // A pid must be set for new records.
-                                                       if (isset($incomingFieldArray['pid'])) {
-                                                               // $value = the pid
-                                                               $pid_value = $incomingFieldArray['pid'];
-                                                               // Checking and finding numerical pid, it may be a string-reference to another value
-                                                               $OK = 1;
-                                                               // If a NEW... id
-                                                               if (strstr($pid_value, 'NEW')) {
-                                                                       if ($pid_value[0] === '-') {
-                                                                               $negFlag = -1;
-                                                                               $pid_value = substr($pid_value, 1);
-                                                                       } else {
-                                                                               $negFlag = 1;
-                                                                       }
-                                                                       // Trying to find the correct numerical value as it should be mapped by earlier processing of another new record.
-                                                                       if (isset($this->substNEWwithIDs[$pid_value])) {
-                                                                               if ($negFlag === 1) {
-                                                                                       $old_pid_value = $this->substNEWwithIDs[$pid_value];
-                                                                               }
-                                                                               $pid_value = (int)($negFlag * $this->substNEWwithIDs[$pid_value]);
-                                                                       } else {
-                                                                               $OK = 0;
-                                                                       }
-                                                               }
-                                                               $pid_value = (int)$pid_value;
-                                                               // The $pid_value is now the numerical pid at this point
-                                                               if ($OK) {
-                                                                       $sortRow = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
-                                                                       // Points to a page on which to insert the element, possibly in the top of the page
-                                                                       if ($pid_value >= 0) {
-                                                                               // If this table is sorted we better find the top sorting number
-                                                                               if ($sortRow) {
-                                                                                       $fieldArray[$sortRow] = $this->getSortNumber($table, 0, $pid_value);
-                                                                               }
-                                                                               // The numerical pid is inserted in the data array
-                                                                               $fieldArray['pid'] = $pid_value;
-                                                                       } else {
-                                                                               // points to another record before ifself
-                                                                               // If this table is sorted we better find the top sorting number
-                                                                               if ($sortRow) {
-                                                                                       // Because $pid_value is < 0, getSortNumber returns an array
-                                                                                       $tempArray = $this->getSortNumber($table, 0, $pid_value);
-                                                                                       $fieldArray['pid'] = $tempArray['pid'];
-                                                                                       $fieldArray[$sortRow] = $tempArray['sortNumber'];
-                                                                               } else {
-                                                                                       // Here we fetch the PID of the record that we point to...
-                                                                                       $tempdata = $this->recordInfo($table, abs($pid_value), 'pid');
-                                                                                       $fieldArray['pid'] = $tempdata['pid'];
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                                       $theRealPid = $fieldArray['pid'];
-                                                       // Now, check if we may insert records on this pid.
-                                                       if ($theRealPid >= 0) {
-                                                               // Checks if records can be inserted on this $pid.
-                                                               $recordAccess = $this->checkRecordInsertAccess($table, $theRealPid);
-                                                               if ($recordAccess) {
-                                                                       $this->addDefaultPermittedLanguageIfNotSet($table, $incomingFieldArray);
-                                                                       $recordAccess = $this->BE_USER->recordEditAccessInternals($table, $incomingFieldArray, TRUE);
-                                                                       if (!$recordAccess) {
-                                                                               if ($this->enableLogging) {
-                                                                                       $this->newlog('recordEditAccessInternals() check failed. [' . $this->BE_USER->errorMsg . ']', 1);
-                                                                               }
-                                                                       } elseif (!$this->bypassWorkspaceRestrictions) {
-                                                                               // Workspace related processing:
-                                                                               // If LIVE records cannot be created in the current PID due to workspace restrictions, prepare creation of placeholder-record
-                                                                               if ($res = $this->BE_USER->workspaceAllowLiveRecordsInPID($theRealPid, $table)) {
-                                                                                       if ($res < 0) {
-                                                                                               $recordAccess = FALSE;
-                                                                                               if ($this->enableLogging) {
-                                                                                                       $this->newlog('Stage for versioning root point and users access level did not allow for editing', 1);
-                                                                                               }
-                                                                                       }
-                                                                               } else {
-                                                                                       // So, if no live records were allowed, we have to create a new version of this record:
-                                                                                       if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-                                                                                               $createNewVersion = TRUE;
-                                                                                       } else {
-                                                                                               $recordAccess = FALSE;
-                                                                                               if ($this->enableLogging) {
-                                                                                                       $this->newlog('Record could not be created in this workspace in this branch', 1);
-                                                                                               }
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               }
-                                                       } else {
-                                                               debug('Internal ERROR: pid should not be less than zero!');
-                                                       }
-                                                       // Yes new record, change $record_status to 'insert'
-                                                       $status = 'new';
-                                               } else {
-                                                       // Nope... $id is a number
-                                                       $fieldArray = array();
-                                                       $recordAccess = $this->checkRecordUpdateAccess($table, $id, $incomingFieldArray, $hookObjectsArr);
-                                                       if (!$recordAccess) {
-                                                               if ($this->enableLogging) {
-                                                                       $propArr = $this->getRecordProperties($table, $id);
-                                                                       $this->log($table, $id, 2, 0, 1, 'Attempt to modify record \'%s\' (%s) without permission. Or non-existing page.', 2, array($propArr['header'], $table . ':' . $id), $propArr['event_pid']);
-                                                               }
-                                                       } else {
-                                                               // Next check of the record permissions (internals)
-                                                               $recordAccess = $this->BE_USER->recordEditAccessInternals($table, $id);
-                                                               if (!$recordAccess) {
-                                                                       if ($this->enableLogging) {
-                                                                               $this->newlog('recordEditAccessInternals() check failed. [' . $this->BE_USER->errorMsg . ']', 1);
-                                                                       }
-                                                               } else {
-                                                                       // Here we fetch the PID of the record that we point to...
-                                                                       $tempdata = $this->recordInfo($table, $id, 'pid' . ($GLOBALS['TCA'][$table]['ctrl']['versioningWS'] ? ',t3ver_wsid,t3ver_stage' : ''));
-                                                                       $theRealPid = $tempdata['pid'];
-                                                                       // Use the new id of the versionized record we're trying to write to:
-                                                                       // (This record is a child record of a parent and has already been versionized.)
-                                                                       if ($this->autoVersionIdMap[$table][$id]) {
-                                                                               // For the reason that creating a new version of this record, automatically
-                                                                               // created related child records (e.g. "IRRE"), update the accordant field:
-                                                                               $this->getVersionizedIncomingFieldArray($table, $id, $incomingFieldArray, $registerDBList);
-                                                                               // Use the new id of the copied/versionized record:
-                                                                               $id = $this->autoVersionIdMap[$table][$id];
-                                                                               $recordAccess = TRUE;
-                                                                               $this->autoVersioningUpdate = TRUE;
-                                                                       } elseif (!$this->bypassWorkspaceRestrictions && ($errorCode = $this->BE_USER->workspaceCannotEditRecord($table, $tempdata))) {
-                                                                               $recordAccess = FALSE;
-                                                                               // Versioning is required and it must be offline version!
-                                                                               // Check if there already is a workspace version
-                                                                               $WSversion = BackendUtility::getWorkspaceVersionOfRecord($this->BE_USER->workspace, $table, $id, 'uid,t3ver_oid');
-                                                                               if ($WSversion) {
-                                                                                       $id = $WSversion['uid'];
-                                                                                       $recordAccess = TRUE;
-                                                                               } elseif ($this->BE_USER->workspaceAllowAutoCreation($table, $id, $theRealPid)) {
-                                                                                       // new version of a record created in a workspace - so always refresh pagetree to indicate there is a change in the workspace
-                                                                                       $this->pagetreeNeedsRefresh = TRUE;
-
-                                                                                       /** @var $tce DataHandler */
-                                                                                       $tce = GeneralUtility::makeInstance(self::class);
-                                                                                       $tce->stripslashes_values = 0;
-                                                                                       // Setting up command for creating a new version of the record:
-                                                                                       $cmd = array();
-                                                                                       $cmd[$table][$id]['version'] = array(
-                                                                                               'action' => 'new',
-                                                                                               'treeLevels' => -1,
-                                                                                               // Default is to create a version of the individual records... element versioning that is.
-                                                                                               'label' => 'Auto-created for WS #' . $this->BE_USER->workspace
-                                                                                       );
-                                                                                       $tce->start(array(), $cmd);
-                                                                                       $tce->process_cmdmap();
-                                                                                       $this->errorLog = array_merge($this->errorLog, $tce->errorLog);
-                                                                                       // If copying was successful, share the new uids (also of related children):
-                                                                                       if ($tce->copyMappingArray[$table][$id]) {
-                                                                                               foreach ($tce->copyMappingArray as $origTable => $origIdArray) {
-                                                                                                       foreach ($origIdArray as $origId => $newId) {
-                                                                                                               $this->uploadedFileArray[$origTable][$newId] = $this->uploadedFileArray[$origTable][$origId];
-                                                                                                               $this->autoVersionIdMap[$origTable][$origId] = $newId;
-                                                                                                       }
-                                                                                               }
-                                                                                               ArrayUtility::mergeRecursiveWithOverrule($this->RTEmagic_copyIndex, $tce->RTEmagic_copyIndex);
-                                                                                               // See where RTEmagic_copyIndex is used inside fillInFieldArray() for more information...
-                                                                                               // Update registerDBList, that holds the copied relations to child records:
-                                                                                               $registerDBList = array_merge($registerDBList, $tce->registerDBList);
-                                                                                               // For the reason that creating a new version of this record, automatically
-                                                                                               // created related child records (e.g. "IRRE"), update the accordant field:
-                                                                                               $this->getVersionizedIncomingFieldArray($table, $id, $incomingFieldArray, $registerDBList);
-                                                                                               // Use the new id of the copied/versionized record:
-                                                                                               $id = $this->autoVersionIdMap[$table][$id];
-                                                                                               $recordAccess = TRUE;
-                                                                                               $this->autoVersioningUpdate = TRUE;
-                                                                                       } elseif ($this->enableLogging) {
-                                                                                               $this->newlog('Could not be edited in offline workspace in the branch where found (failure state: \'' . $errorCode . '\'). Auto-creation of version failed!', 1);
-                                                                                       }
-                                                                               } elseif ($this->enableLogging) {
-                                                                                       $this->newlog('Could not be edited in offline workspace in the branch where found (failure state: \'' . $errorCode . '\'). Auto-creation of version not allowed in workspace!', 1);
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                                       // The default is 'update'
-                                                       $status = 'update';
-                                               }
-                                               // If access was granted above, proceed to create or update record:
-                                               if ($recordAccess) {
-                                                       // Here the "pid" is set IF NOT the old pid was a string pointing to a place in the subst-id array.
-                                                       list($tscPID) = BackendUtility::getTSCpid($table, $id, $old_pid_value ? $old_pid_value : $fieldArray['pid']);
-                                                       if ($status === 'new' && $table === 'pages') {
-                                                               $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
-                                                               if (isset($TSConfig['permissions.']) && is_array($TSConfig['permissions.'])) {
-                                                                       $fieldArray = $this->setTSconfigPermissions($fieldArray, $TSConfig['permissions.']);
-                                                               }
-                                                       }
-                                                       // Processing of all fields in incomingFieldArray and setting them in $fieldArray
-                                                       $fieldArray = $this->fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray, $theRealPid, $status, $tscPID);
-                                                       if ($createNewVersion) {
-                                                               // create a placeholder array with already processed field content
-                                                               $newVersion_placeholderFieldArray = $fieldArray;
-                                                       }
-                                                       // NOTICE! All manipulation beyond this point bypasses both "excludeFields" AND possible "MM" relations / file uploads to field!
-                                                       // Forcing some values unto field array:
-                                                       // NOTICE: This overriding is potentially dangerous; permissions per field is not checked!!!
-                                                       $fieldArray = $this->overrideFieldArray($table, $fieldArray);
-                                                       if ($createNewVersion) {
-                                                               $newVersion_placeholderFieldArray = $this->overrideFieldArray($table, $newVersion_placeholderFieldArray);
-                                                       }
-                                                       // Setting system fields
-                                                       if ($status == 'new') {
-                                                               if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
-                                                                       $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
-                                                                       if ($createNewVersion) {
-                                                                               $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
-                                                                       }
-                                                               }
-                                                               if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
-                                                                       $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']] = $this->userid;
-                                                                       if ($createNewVersion) {
-                                                                               $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']] = $this->userid;
-                                                                       }
-                                                               }
-                                                       } elseif ($this->checkSimilar) {
-                                                               // Removing fields which are equal to the current value:
-                                                               $fieldArray = $this->compareFieldArrayWithCurrentAndUnset($table, $id, $fieldArray);
-                                                       }
-                                                       if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'] && count($fieldArray)) {
-                                                               $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
-                                                               if ($createNewVersion) {
-                                                                       $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
-                                                               }
-                                                       }
-                                                       // Set stage to "Editing" to make sure we restart the workflow
-                                                       if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-                                                               $fieldArray['t3ver_stage'] = 0;
-                                                       }
-                                                       // Hook: processDatamap_postProcessFieldArray
-                                                       foreach ($hookObjectsArr as $hookObj) {
-                                                               if (method_exists($hookObj, 'processDatamap_postProcessFieldArray')) {
-                                                                       $hookObj->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $this);
-                                                               }
-                                                       }
-                                                       // Performing insert/update. If fieldArray has been unset by some userfunction (see hook above), don't do anything
-                                                       // Kasper: Unsetting the fieldArray is dangerous; MM relations might be saved already and files could have been uploaded that are now "lost"
-                                                       if (is_array($fieldArray)) {
-                                                               if ($status == 'new') {
-                                                                       if ($table === 'pages') {
-                                                                               // for new pages always a refresh is needed
-                                                                               $this->pagetreeNeedsRefresh = TRUE;
-                                                                       }
-
-                                                                       // This creates a new version of the record with online placeholder and offline version
-                                                                       if ($createNewVersion) {
-                                                                               // new record created in a workspace - so always refresh pagetree to indicate there is a change in the workspace
-                                                                               $this->pagetreeNeedsRefresh = TRUE;
-
-                                                                               $newVersion_placeholderFieldArray['t3ver_label'] = 'INITIAL PLACEHOLDER';
-                                                                               // Setting placeholder state value for temporary record
-                                                                               $newVersion_placeholderFieldArray['t3ver_state'] = (string)new VersionState(VersionState::NEW_PLACEHOLDER);
-                                                                               // Setting workspace - only so display of place holders can filter out those from other workspaces.
-                                                                               $newVersion_placeholderFieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
-                                                                               $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['label']] = $this->getPlaceholderTitleForTableLabel($table);
-                                                                               // Saving placeholder as 'original'
-                                                                               $this->insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE);
-                                                                               // For the actual new offline version, set versioning values to point to placeholder:
-                                                                               $fieldArray['pid'] = -1;
-                                                                               $fieldArray['t3ver_oid'] = $this->substNEWwithIDs[$id];
-                                                                               $fieldArray['t3ver_id'] = 1;
-                                                                               // Setting placeholder state value for version (so it can know it is currently a new version...)
-                                                                               $fieldArray['t3ver_state'] = (string)new VersionState(VersionState::NEW_PLACEHOLDER_VERSION);
-                                                                               $fieldArray['t3ver_label'] = 'First draft version';
-                                                                               $fieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
-                                                                               // When inserted, $this->substNEWwithIDs[$id] will be changed to the uid of THIS version and so the interface will pick it up just nice!
-                                                                               $phShadowId = $this->insertDB($table, $id, $fieldArray, TRUE, 0, TRUE);
-                                                                               if ($phShadowId) {
-                                                                                       // Processes fields of the placeholder record:
-                                                                                       $this->triggerRemapAction($table, $id, array($this, 'placeholderShadowing'), array($table, $phShadowId));
-                                                                                       // Hold auto-versionized ids of placeholders:
-                                                                                       $this->autoVersionIdMap[$table][$this->substNEWwithIDs[$id]] = $phShadowId;
-                                                                               }
-                                                                       } else {
-                                                                               $this->insertDB($table, $id, $fieldArray, FALSE, $incomingFieldArray['uid']);
-                                                                       }
-                                                               } else {
-                                                                       if ($table === 'pages') {
-                                                                               // only a certain number of fields needs to be checked for updates
-                                                                               // if $this->checkSimilar is TRUE, fields with unchanged values are already removed here
-                                                                               $fieldsToCheck = array_intersect($this->pagetreeRefreshFieldsFromPages, array_keys($fieldArray));
-                                                                               if (count($fieldsToCheck)) {
-                                                                                       $this->pagetreeNeedsRefresh = TRUE;
-                                                                               }
-                                                                       }
-                                                                       $this->updateDB($table, $id, $fieldArray);
-                                                                       $this->placeholderShadowing($table, $id);
-                                                               }
-                                                       }
-                                                       // Hook: processDatamap_afterDatabaseOperations
-                                                       // Note: When using the hook after INSERT operations, you will only get the temporary NEW... id passed to your hook as $id,
-                                                       // but you can easily translate it to the real uid of the inserted record using the $this->substNEWwithIDs array.
-                                                       $this->hook_processDatamap_afterDatabaseOperations($hookObjectsArr, $status, $table, $id, $fieldArray);
-                                               }
-                                       }
-                               }
-                       }
-               }
-               // Process the stack of relations to remap/correct
-               $this->processRemapStack();
-               $this->dbAnalysisStoreExec();
-               $this->removeRegisteredFiles();
-               // Hook: processDatamap_afterAllOperations
-               // Note: When this hook gets called, all operations on the submitted data have been finished.
-               foreach ($hookObjectsArr as $hookObj) {
-                       if (method_exists($hookObj, 'processDatamap_afterAllOperations')) {
-                               $hookObj->processDatamap_afterAllOperations($this);
-                       }
-               }
-               if ($this->isOuterMostInstance()) {
-                       $this->processClearCacheQueue();
-                       $this->resetElementsToBeDeleted();
-               }
-       }
-
-       /**
-        * Fix shadowing of data in case we are editing a offline version of a live "New" placeholder record:
-        *
-        * @param string $table Table name
-        * @param int $id Record uid
-        * @return void
-        */
-       public function placeholderShadowing($table, $id) {
-               if ($liveRec = BackendUtility::getLiveVersionOfRecord($table, $id, '*')) {
-                       if (VersionState::cast($liveRec['t3ver_state'])->indicatesPlaceholder()) {
-                               $justStoredRecord = BackendUtility::getRecord($table, $id);
-                               $newRecord = array();
-                               $shadowCols = $GLOBALS['TCA'][$table]['ctrl']['shadowColumnsForNewPlaceholders'];
-                               $shadowCols .= ',' . $GLOBALS['TCA'][$table]['ctrl']['languageField'];
-                               $shadowCols .= ',' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
-                               $shadowCols .= ',' . $GLOBALS['TCA'][$table]['ctrl']['type'];
-                               $shadowCols .= ',' . $GLOBALS['TCA'][$table]['ctrl']['label'];
-                               $shadowColumns = array_unique(GeneralUtility::trimExplode(',', $shadowCols, TRUE));
-                               foreach ($shadowColumns as $fieldName) {
-                                       if ((string)$justStoredRecord[$fieldName] !== (string)$liveRec[$fieldName] && isset($GLOBALS['TCA'][$table]['columns'][$fieldName]) && $fieldName !== 'uid' && $fieldName !== 'pid') {
-                                               $newRecord[$fieldName] = $justStoredRecord[$fieldName];
-                                       }
-                               }
-                               if (count($newRecord)) {
-                                       if ($this->enableLogging) {
-                                               $this->newlog2('Shadowing done on fields <i>' . implode(',', array_keys($newRecord)) . '</i> in placeholder record ' . $table . ':' . $liveRec['uid'] . ' (offline version UID=' . $id . ')', $table, $liveRec['uid'], $liveRec['pid']);
-                                       }
-                                       $this->updateDB($table, $liveRec['uid'], $newRecord);
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Create a placeholder title for the label field that does match the field requirements
-        *
-        * @param string $table The table name
-        * @return string placeholder value
-        */
-       protected function getPlaceholderTitleForTableLabel($table) {
-               $labelPlaceholder = '[PLACEHOLDER, WS#' . $this->BE_USER->workspace . ']';
-               $labelField = $GLOBALS['TCA'][$table]['ctrl']['label'];
-               if (!isset($GLOBALS['TCA'][$table]['columns'][$labelField]['config']['eval'])) {
-                       return $labelPlaceholder;
-               }
-               $evalCodesArray = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$labelField]['config']['eval'], TRUE);
-               $transformedLabel = $this->checkValue_input_Eval($labelPlaceholder, $evalCodesArray, '');
-               return isset($transformedLabel['value']) ? $transformedLabel['value'] : $labelPlaceholder;
-       }
-
-       /**
-        * Filling in the field array
-        * $this->excludedTablesAndFields is used to filter fields if needed.
-        *
-        * @param string $table Table name
-        * @param int $id Record ID
-        * @param array $fieldArray Default values, Preset $fieldArray with 'pid' maybe (pid and uid will be not be overridden anyway)
-        * @param array $incomingFieldArray Is which fields/values you want to set. There are processed and put into $fieldArray if OK
-        * @param int $realPid The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted.
-        * @param string $status Is 'new' or 'update'
-        * @param int $tscPID TSconfig PID
-        * @return array Field Array
-        */
-       public function fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray, $realPid, $status, $tscPID) {
-               // Initialize:
-               $originalLanguageRecord = NULL;
-               $originalLanguage_diffStorage = NULL;
-               $diffStorageFlag = FALSE;
-               // Setting 'currentRecord' and 'checkValueRecord':
-               if (strstr($id, 'NEW')) {
-                       // Must have the 'current' array - not the values after processing below...
-                       $currentRecord = ($checkValueRecord = $fieldArray);
-                       // IF $incomingFieldArray is an array, overlay it.
-                       // The point is that when new records are created as copies with flex type fields there might be a field containing information about which DataStructure to use and without that information the flexforms cannot be correctly processed.... This should be OK since the $checkValueRecord is used by the flexform evaluation only anyways...
-                       if (is_array($incomingFieldArray) && is_array($checkValueRecord)) {
-                               ArrayUtility::mergeRecursiveWithOverrule($checkValueRecord, $incomingFieldArray);
-                       }
-               } else {
-                       // We must use the current values as basis for this!
-                       $currentRecord = ($checkValueRecord = $this->recordInfo($table, $id, '*'));
-                       // This is done to make the pid positive for offline versions; Necessary to have diff-view for pages_language_overlay in workspaces.
-                       BackendUtility::fixVersioningPid($table, $currentRecord);
-                       // Get original language record if available:
-                       if (is_array($currentRecord) && $GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField'] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] && (int)$currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] > 0) {
-                               $lookUpTable = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'] ?: $table;
-                               $originalLanguageRecord = $this->recordInfo($lookUpTable, $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']], '*');
-                               BackendUtility::workspaceOL($lookUpTable, $originalLanguageRecord);
-                               $originalLanguage_diffStorage = unserialize($currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']]);
-                       }
-               }
-               $this->checkValue_currentRecord = $checkValueRecord;
-               // In the following all incoming value-fields are tested:
-               // - Are the user allowed to change the field?
-               // - Is the field uid/pid (which are already set)
-               // - perms-fields for pages-table, then do special things...
-               // - If the field is nothing of the above and the field is configured in TCA, the fieldvalues are evaluated by ->checkValue
-               // If everything is OK, the field is entered into $fieldArray[]
-               foreach ($incomingFieldArray as $field => $fieldValue) {
-                       if (!isset($this->excludedTablesAndFields[$table . '-' . $field]) && !$this->data_disableFields[$table][$id][$field]) {
-                               // The field must be editable.
-                               // Checking if a value for language can be changed:
-                               $languageDeny = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && (string)$GLOBALS['TCA'][$table]['ctrl']['languageField'] === (string)$field && !$this->BE_USER->checkLanguageAccess($fieldValue);
-                               if (!$languageDeny) {
-                                       // Stripping slashes - will probably be removed the day $this->stripslashes_values is removed as an option...
-                                       // @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-                                       if ($this->stripslashes_values) {
-                                               GeneralUtility::deprecationLog(
-                                                       'The option stripslash_values is typically set to FALSE as data should be properly prepared before sending to DataHandler. Do not rely on DataHandler removing extra slashes. The option will be removed in TYPO3 CMS 8.'
-                                               );
-                                               if (is_array($fieldValue)) {
-                                                       GeneralUtility::stripSlashesOnArray($fieldValue);
-                                               } else {
-                                                       $fieldValue = stripslashes($fieldValue);
-                                               }
-                                       }
-                                       switch ($field) {
-                                               case 'uid':
-                                               case 'pid':
-                                                       // Nothing happens, already set
-                                                       break;
-                                               case 'perms_userid':
-                                               case 'perms_groupid':
-                                               case 'perms_user':
-                                               case 'perms_group':
-                                               case 'perms_everybody':
-                                                       // Permissions can be edited by the owner or the administrator
-                                                       if ($table == 'pages' && ($this->admin || $status == 'new' || $this->pageInfo($id, 'perms_userid') == $this->userid)) {
-                                                               $value = (int)$fieldValue;
-                                                               switch ($field) {
-                                                                       case 'perms_userid':
-                                                                               $fieldArray[$field] = $value;
-                                                                               break;
-                                                                       case 'perms_groupid':
-                                                                               $fieldArray[$field] = $value;
-                                                                               break;
-                                                                       default:
-                                                                               if ($value >= 0 && $value < pow(2, 5)) {
-                                                                                       $fieldArray[$field] = $value;
-                                                                               }
-                                                               }
-                                                       }
-                                                       break;
-                                               case 't3ver_oid':
-                                               case 't3ver_id':
-                                               case 't3ver_wsid':
-                                               case 't3ver_state':
-                                               case 't3ver_count':
-                                               case 't3ver_stage':
-                                               case 't3ver_tstamp':
-                                                       // t3ver_label is not here because it CAN be edited as a regular field!
-                                                       break;
-                                               default:
-                                                       if (isset($GLOBALS['TCA'][$table]['columns'][$field])) {
-                                                               // Evaluating the value
-                                                               $res = $this->checkValue($table, $field, $fieldValue, $id, $status, $realPid, $tscPID);
-                                                               if (array_key_exists('value', $res)) {
-                                                                       $fieldArray[$field] = $res['value'];
-                                                               }
-                                                               // Add the value of the original record to the diff-storage content:
-                                                               if ($this->updateModeL10NdiffData && $GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']) {
-                                                                       $originalLanguage_diffStorage[$field] = $this->updateModeL10NdiffDataClear ? '' : $originalLanguageRecord[$field];
-                                                                       $diffStorageFlag = TRUE;
-                                                               }
-                                                               // If autoversioning is happening we need to perform a nasty hack. The case is parallel to a similar hack inside checkValue_group_select_file().
-                                                               // When a copy or version is made of a record, a search is made for any RTEmagic* images in fields having the "images" soft reference parser applied.
-                                                               // That should be TRUE for RTE fields. If any are found they are duplicated to new names and the file reference in the bodytext is updated accordingly.
-                                                               // However, with auto-versioning the submitted content of the field will just overwrite the corrected values. This leaves a) lost RTEmagic files and b) creates a double reference to the old files.
-                                                               // The only solution I can come up with is detecting when auto versioning happens, then see if any RTEmagic images was copied and if so make a stupid string-replace of the content !
-                                                               if ($this->autoVersioningUpdate === TRUE) {
-                                                                       if (is_array($this->RTEmagic_copyIndex[$table][$id][$field])) {
-                                                                               foreach ($this->RTEmagic_copyIndex[$table][$id][$field] as $oldRTEmagicName => $newRTEmagicName) {
-                                                                                       $fieldArray[$field] = str_replace(' src="' . $oldRTEmagicName . '"', ' src="' . $newRTEmagicName . '"', $fieldArray[$field]);
-                                                                               }
-                                                                       }
-                                                               }
-                                                       } elseif ($GLOBALS['TCA'][$table]['ctrl']['origUid'] === $field) {
-                                                               // Allow value for original UID to pass by...
-                                                               $fieldArray[$field] = $fieldValue;
-                                                       }
-                                       }
-                               }
-                       }
-               }
-               // Add diff-storage information:
-               if ($diffStorageFlag && !isset($fieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']])) {
-                       // If the field is set it would probably be because of an undo-operation - in which case we should not update the field of course...
-                       $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
-               }
-               // Checking for RTE-transformations of fields:
-               $types_fieldConfig = BackendUtility::getTCAtypes($table, $currentRecord);
-               $theTypeString = NULL;
-               if (is_array($types_fieldConfig)) {
-                       foreach ($types_fieldConfig as $vconf) {
-                               // RTE transformations:
-                               if (!$this->dontProcessTransformations) {
-                                       if (isset($fieldArray[$vconf['field']])) {
-                                               // Look for transformation flag:
-                                               switch ((string)$incomingFieldArray[('_TRANSFORM_' . $vconf['field'])]) {
-                                                       case 'RTE':
-                                                               if ($theTypeString === NULL) {
-                                                                       $theTypeString = BackendUtility::getTCAtypeValue($table, $currentRecord);
-                                                               }
-                                                               $RTEsetup = $this->BE_USER->getTSConfig('RTE', BackendUtility::getPagesTSconfig($tscPID));
-                                                               $thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $table, $vconf['field'], $theTypeString);
-                                                               // Get RTE object, draw form and set flag:
-                                                               $RTEobj = BackendUtility::RTEgetObj();
-                                                               if (is_object($RTEobj)) {
-                                                                       $fieldArray[$vconf['field']] = $RTEobj->transformContent('db', $fieldArray[$vconf['field']], $table, $vconf['field'], $currentRecord, $vconf['spec'], $thisConfig, '', $currentRecord['pid']);
-                                                               } else {
-                                                                       debug('NO RTE OBJECT FOUND!');
-                                                               }
-                                                               break;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               // Return fieldArray
-               return $fieldArray;
-       }
-
-       /*********************************************
-        *
-        * Evaluation of input values
-        *
-        ********************************************/
-       /**
-        * Evaluates a value according to $table/$field settings.
-        * This function is for real database fields - NOT FlexForm "pseudo" fields.
-        * NOTICE: Calling this function expects this: 1) That the data is saved! (files are copied and so on) 2) That files registered for deletion IS deleted at the end (with ->removeRegisteredFiles() )
-        *
-        * @param string $table Table name
-        * @param string $field Field name
-        * @param string $value Value to be evaluated. Notice, this is the INPUT value from the form. The original value (from any existing record) must be manually looked up inside the function if needed - or taken from $currentRecord array.
-        * @param string $id The record-uid, mainly - but not exclusively - used for logging
-        * @param string $status 'update' or 'new' flag
-        * @param int $realPid The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
-        * @param int $tscPID TSconfig PID
-        * @return array Returns the evaluated $value as key "value" in this array. Can be checked with isset($res['value']) ...
-        */
-       public function checkValue($table, $field, $value, $id, $status, $realPid, $tscPID) {
-               // Result array
-               $res = array();
-
-               // Processing special case of field pages.doktype
-               if (($table === 'pages' || $table === 'pages_language_overlay') && $field === 'doktype') {
-                       // If the user may not use this specific doktype, we issue a warning
-                       if (!($this->admin || GeneralUtility::inList($this->BE_USER->groupData['pagetypes_select'], $value))) {
-                               if ($this->enableLogging) {
-                                       $propArr = $this->getRecordProperties($table, $id);
-                                       $this->log($table, $id, 5, 0, 1, 'You cannot change the \'doktype\' of page \'%s\' to the desired value.', 1, array($propArr['header']), $propArr['event_pid']);
-                               }
-                               return $res;
-                       }
-                       if ($status == 'update') {
-                               // This checks 1) if we should check for disallowed tables and 2) if there are records from disallowed tables on the current page
-                               $onlyAllowedTables = isset($GLOBALS['PAGES_TYPES'][$value]['onlyAllowedTables']) ? $GLOBALS['PAGES_TYPES'][$value]['onlyAllowedTables'] : $GLOBALS['PAGES_TYPES']['default']['onlyAllowedTables'];
-                               if ($onlyAllowedTables) {
-                                       $theWrongTables = $this->doesPageHaveUnallowedTables($id, $value);
-                                       if ($theWrongTables) {
-                                               if ($this->enableLogging) {
-                                                       $propArr = $this->getRecordProperties($table, $id);
-                                                       $this->log($table, $id, 5, 0, 1, '\'doktype\' of page \'%s\' could not be changed because the page contains records from disallowed tables; %s', 2, array($propArr['header'], $theWrongTables), $propArr['event_pid']);
-                                               }
-                                               return $res;
-                                       }
-                               }
-                       }
-               }
-
-               $curValue = NULL;
-               if ((int)$id !== 0) {
-                       // Get current value:
-                       $curValueRec = $this->recordInfo($table, $id, $field);
-                       if (isset($curValueRec[$field])) {
-                               $curValue = $curValueRec[$field];
-                       }
-               }
-
-               // Getting config for the field
-               $tcaFieldConf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
-
-               // Create $recFID only for those types that need it
-               if (
-                       $tcaFieldConf['type'] === 'flex'
-                       || $tcaFieldConf['type'] === 'group' && ($tcaFieldConf['internal_type'] === 'file' || $tcaFieldConf['internal_type'] === 'file_reference')
-               ) {
-                       $recFID = $table . ':' . $id . ':' . $field;
-               } else {
-                       $recFID = NULL;
-               }
-
-               // Perform processing:
-               $res = $this->checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $this->uploadedFileArray[$table][$id][$field], $tscPID);
-               return $res;
-       }
-
-       /**
-        * Branches out evaluation of a field value based on its type as configured in $GLOBALS['TCA']
-        * Can be called for FlexForm pseudo fields as well, BUT must not have $field set if so.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the "value" key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from $GLOBALS['TCA']
-        * @param string $table Table name
-        * @param int $id UID of record
-        * @param mixed $curValue Current value of the field
-        * @param string $status 'update' or 'new' flag
-        * @param int $realPid The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
-        * @param string $recFID Field identifier [table:uid:field] for flexforms
-        * @param string $field Field name. Must NOT be set if the call is for a flexform field (since flexforms are not allowed within flexforms).
-        * @param array $uploadedFiles
-        * @param int $tscPID TSconfig PID
-        * @param array $additionalData Additional data to be forwarded to sub-processors
-        * @return array Returns the evaluated $value as key "value" in this array.
-        */
-       public function checkValue_SW($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $field, $uploadedFiles, $tscPID, array $additionalData = NULL) {
-               // Convert to NULL value if defined in TCA
-               if ($value === NULL && !empty($tcaFieldConf['eval']) && GeneralUtility::inList($tcaFieldConf['eval'], 'null')) {
-                       $res = array('value' => NULL);
-                       return $res;
-               }
-
-               switch ($tcaFieldConf['type']) {
-                       case 'text':
-                               $res = $this->checkValueForText($value, $tcaFieldConf);
-                               break;
-                       case 'passthrough':
-                       case 'imageManipulation':
-                       case 'user':
-                               $res['value'] = $value;
-                               break;
-                       case 'input':
-                               $res = $this->checkValueForInput($value, $tcaFieldConf, $table, $id, $realPid, $field);
-                               break;
-                       case 'check':
-                               $res = $this->checkValueForCheck($res, $value, $tcaFieldConf, $table, $id, $realPid, $field);
-                               break;
-                       case 'radio':
-                               $res = $this->checkValueForRadio($res, $value, $tcaFieldConf);
-                               break;
-                       case 'group':
-                       case 'select':
-                               $res = $this->checkValueForGroupSelect($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $recFID, $uploadedFiles, $field);
-                               break;
-                       case 'inline':
-                               $res = $this->checkValueForInline($res, $value, $tcaFieldConf, $table, $id, $status, $field, $additionalData);
-                               break;
-                       case 'flex':
-                               // FlexForms are only allowed for real fields.
-                               if ($field) {
-                                       $res = $this->checkValueForFlex($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $tscPID, $uploadedFiles, $field);
-                               }
-                               break;
-                       default:
-                               // Do nothing
-               }
-               return $res;
-       }
-
-       /**
-        * Evaluate "text" type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the "value" key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param array $PP Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @param string $field Field name
-        * @return array Modified $res array
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public function checkValue_text($res, $value, $tcaFieldConf, $PP, $field = '') {
-               GeneralUtility::logDeprecatedFunction();
-               return $this->checkValueForText($value, $tcaFieldConf);
-       }
-
-       /**
-        * Evaluate "text" type values.
-        *
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @return array $res The result array. The processed value (if any!) is set in the "value" key.
-        */
-       protected function checkValueForText($value, $tcaFieldConf) {
-               if (!isset($tcaFieldConf['eval']) || $tcaFieldConf['eval'] === '') {
-                       return array('value' => $value);
-               }
-               $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']);
-               if ($this->runtimeCache->has($cacheId)) {
-                       $evalCodesArray = $this->runtimeCache->get($cacheId);
-               } else {
-                       $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], TRUE);
-                       $this->runtimeCache->set($cacheId, $evalCodesArray);
-               }
-               return $this->checkValue_text_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']);
-       }
-
-       /**
-        * Evaluate "input" type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the "value" key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param array $PP Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @param string $field Field name
-        * @return array Modified $res array
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public function checkValue_input($res, $value, $tcaFieldConf, $PP, $field = '') {
-               GeneralUtility::logDeprecatedFunction();
-               list($table, $id, , , $realPid) = $PP;
-               return $this->checkValueForInput($value, $tcaFieldConf, $table, $id, $realPid, $field);
-       }
-
-       /**
-        * Evaluate "input" type values.
-        *
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param string $table Table name
-        * @param int $id UID of record
-        * @param int $realPid The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
-        * @param string $field Field name
-        * @return array $res The result array. The processed value (if any!) is set in the "value" key.
-        */
-       protected function checkValueForInput($value, $tcaFieldConf, $table, $id, $realPid, $field) {
-               // Handle native date/time fields
-               $isDateOrDateTimeField = FALSE;
-               $format = '';
-               $emptyValue = '';
-               if (isset($tcaFieldConf['dbType']) && ($tcaFieldConf['dbType'] === 'date' || $tcaFieldConf['dbType'] === 'datetime')) {
-                       $isDateOrDateTimeField = TRUE;
-                       $dateTimeFormats = $this->databaseConnection->getDateTimeFormats($table);
-                       // Convert the date/time into a timestamp for the sake of the checks
-                       $emptyValue = $dateTimeFormats[$tcaFieldConf['dbType']]['empty'];
-                       $format = $dateTimeFormats[$tcaFieldConf['dbType']]['format'];
-                       // At this point in the processing, the timestamps are still based on UTC
-                       $timeZone = new \DateTimeZone('UTC');
-                       $dateTime = \DateTime::createFromFormat('!' . $format, $value, $timeZone);
-                       $value = $value === $emptyValue ? 0 : $dateTime->getTimestamp();
-               }
-               // Secures the string-length to be less than max.
-               if ((int)$tcaFieldConf['max'] > 0) {
-                       $value = $GLOBALS['LANG']->csConvObj->substr($GLOBALS['LANG']->charSet, $value, 0, (int)$tcaFieldConf['max']);
-               }
-               // Checking range of value:
-               if ($tcaFieldConf['range'] && $value != $tcaFieldConf['checkbox'] && (int)$value !== (int)$tcaFieldConf['default']) {
-                       if (isset($tcaFieldConf['range']['upper']) && (int)$value > (int)$tcaFieldConf['range']['upper']) {
-                               $value = $tcaFieldConf['range']['upper'];
-                       }
-                       if (isset($tcaFieldConf['range']['lower']) && (int)$value < (int)$tcaFieldConf['range']['lower']) {
-                               $value = $tcaFieldConf['range']['lower'];
-                       }
-               }
-
-               if (empty($tcaFieldConf['eval'])) {
-                       $res = array('value' => $value);
-               } else {
-                       // Process evaluation settings:
-                       $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']);
-                       if ($this->runtimeCache->has($cacheId)) {
-                               $evalCodesArray = $this->runtimeCache->get($cacheId);
-                       } else {
-                               $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], TRUE);
-                               $this->runtimeCache->set($cacheId, $evalCodesArray);
-                       }
-
-                       $res = $this->checkValue_input_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']);
-
-                       // Process UNIQUE settings:
-                       // Field is NOT set for flexForms - which also means that uniqueInPid and unique is NOT available for flexForm fields! Also getUnique should not be done for versioning and if PID is -1 ($realPid<0) then versioning is happening...
-                       if ($field && $realPid >= 0 && !empty($res['value'])) {
-                               if (in_array('uniqueInPid', $evalCodesArray, TRUE)) {
-                                       $res['value'] = $this->getUnique($table, $field, $res['value'], $id, $realPid);
-                               }
-                               if ($res['value'] && in_array('unique', $evalCodesArray, TRUE)) {
-                                       $res['value'] = $this->getUnique($table, $field, $res['value'], $id);
-                               }
-                       }
-               }
-
-               // Handle native date/time fields
-               if ($isDateOrDateTimeField) {
-                       // Convert the timestamp back to a date/time
-                       $res['value'] = $res['value'] ? date($format, $res['value']) : $emptyValue;
-               }
-               return $res;
-       }
-
-       /**
-        * Evaluates 'check' type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param array $PP Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @param string $field Field name
-        * @return array Modified $res array
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public function checkValue_check($res, $value, $tcaFieldConf, $PP, $field = '') {
-               GeneralUtility::logDeprecatedFunction();
-               list($table, $id, , , $realPid) = $PP;
-               return $this->checkValueForCheck($res, $value, $tcaFieldConf, $table, $id, $realPid, $field);
-       }
-
-       /**
-        * Evaluates 'check' type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param string $table Table name
-        * @param int $id UID of record
-        * @param int $realPid The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
-        * @param string $field Field name
-        * @return array Modified $res array
-        */
-       protected function checkValueForCheck($res, $value, $tcaFieldConf, $table, $id, $realPid, $field) {
-               $itemC = count($tcaFieldConf['items']);
-               if (!$itemC) {
-                       $itemC = 1;
-               }
-               $maxV = pow(2, $itemC) - 1;
-               if ($value < 0) {
-                       $value = 0;
-               }
-               if ($value > $maxV) {
-                       $value = $maxV;
-               }
-               if ($field && $realPid >= 0 && $value > 0 && !empty($tcaFieldConf['eval'])) {
-                       $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], TRUE);
-                       $otherRecordsWithSameValue = array();
-                       $maxCheckedRecords = 0;
-                       if (in_array('maximumRecordsCheckedInPid', $evalCodesArray, TRUE)) {
-                               $otherRecordsWithSameValue = $this->getRecordsWithSameValue($table, $id, $field, $value, $realPid);
-                               $maxCheckedRecords = (int)$tcaFieldConf['validation']['maximumRecordsCheckedInPid'];
-                       }
-                       if (in_array('maximumRecordsChecked', $evalCodesArray, TRUE)) {
-                               $otherRecordsWithSameValue = $this->getRecordsWithSameValue($table, $id, $field, $value);
-                               $maxCheckedRecords = (int)$tcaFieldConf['validation']['maximumRecordsChecked'];
-                       }
-
-                       // there are more than enough records with value "1" in the DB
-                       // if so, set this value to "0" again
-                       if ($maxCheckedRecords && count($otherRecordsWithSameValue) >= $maxCheckedRecords) {
-                               $value = 0;
-                               if ($this->enableLogging) {
-                                       $this->log($table, $id, 5, 0, 1, 'Could not activate checkbox for field "%s". A total of %s record(s) can have this checkbox activated. Uncheck other records first in order to activate the checkbox of this record.', -1, array($GLOBALS['LANG']->sL(BackendUtility::getItemLabel($table, $field)), $maxCheckedRecords));
-                               }
-                       }
-               }
-               $res['value'] = $value;
-               return $res;
-       }
-
-       /**
-        * Evaluates 'radio' type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param array $PP Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @return array Modified $res array
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public function checkValue_radio($res, $value, $tcaFieldConf, $PP) {
-               GeneralUtility::logDeprecatedFunction();
-               return $this->checkValueForRadio($res, $value, $tcaFieldConf);
-       }
-
-       /**
-        * Evaluates 'radio' type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @return array Modified $res array
-        */
-       protected function checkValueForRadio($res, $value, $tcaFieldConf) {
-               if (is_array($tcaFieldConf['items'])) {
-                       foreach ($tcaFieldConf['items'] as $set) {
-                               if ((string)$set[1] === (string)$value) {
-                                       $res['value'] = $value;
-                                       break;
-                               }
-                       }
-               }
-               return $res;
-       }
-
-       /**
-        * Evaluates 'group' or 'select' type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param array $PP Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @param array $uploadedFiles
-        * @param string $field Field name
-        * @return array Modified $res array
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public function checkValue_group_select($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field) {
-               GeneralUtility::logDeprecatedFunction();
-               list($table, $id, $curValue, $status, , $recFID) = $PP;
-               return $this->checkValueForGroupSelect($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $recFID, $uploadedFiles, $field);
-       }
-
-       /**
-        * Evaluates 'group' or 'select' type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param string $table Table name
-        * @param int $id UID of record
-        * @param mixed $curValue Current value of the field
-        * @param string $status 'update' or 'new' flag
-        * @param string $recFID Field identifier [table:uid:field] for flexforms
-        * @param array $uploadedFiles
-        * @param string $field Field name
-        * @return array Modified $res array
-        */
-       protected function checkValueForGroupSelect($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $recFID, $uploadedFiles, $field) {
-               // Detecting if value sent is an array and if so, implode it around a comma:
-               if (is_array($value)) {
-                       $value = implode(',', $value);
-               }
-               // This converts all occurrences of '&#123;' to the byte 123 in the string - this is needed in very rare cases where file names with special characters (e.g. ???, umlaut) gets sent to the server as HTML entities instead of bytes. The error is done only by MSIE, not Mozilla and Opera.
-               // Anyway, this should NOT disturb anything else:
-               $value = $this->convNumEntityToByteValue($value);
-               // When values are sent as group or select they come as comma-separated values which are exploded by this function:
-               $valueArray = $this->checkValue_group_select_explodeSelectGroupValue($value);
-               // If multiple is not set, remove duplicates:
-               if (!$tcaFieldConf['multiple']) {
-                       $valueArray = array_unique($valueArray);
-               }
-               // If an exclusive key is found, discard all others:
-               if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['exclusiveKeys']) {
-                       $exclusiveKeys = GeneralUtility::trimExplode(',', $tcaFieldConf['exclusiveKeys']);
-                       foreach ($valueArray as $index => $key) {
-                               if (in_array($key, $exclusiveKeys, TRUE)) {
-                                       $valueArray = array($index => $key);
-                                       break;
-                               }
-                       }
-               }
-               // This could be a good spot for parsing the array through a validation-function which checks if the values are correct (except that database references are not in their final form - but that is the point, isn't it?)
-               // NOTE!!! Must check max-items of files before the later check because that check would just leave out file names if there are too many!!
-               $valueArray = $this->applyFiltersToValues($tcaFieldConf, $valueArray);
-               // Checking for select / authMode, removing elements from $valueArray if any of them is not allowed!
-               if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['authMode']) {
-                       $preCount = count($valueArray);
-                       foreach ($valueArray as $index => $key) {
-                               if (!$this->BE_USER->checkAuthMode($table, $field, $key, $tcaFieldConf['authMode'])) {
-                                       unset($valueArray[$index]);
-                               }
-                       }
-                       // During the check it turns out that the value / all values were removed - we respond by simply returning an empty array so nothing is written to DB for this field.
-                       if ($preCount && !count($valueArray)) {
-                               return array();
-                       }
-               }
-               // For group types:
-               if ($tcaFieldConf['type'] == 'group') {
-                       switch ($tcaFieldConf['internal_type']) {
-                               case 'file_reference':
-
-                               case 'file':
-                                       $valueArray = $this->checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFiles, $status, $table, $id, $recFID);
-                                       break;
-                               case 'db':
-                                       $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'group', $table, $field);
-                                       break;
-                       }
-               }
-               // For select types which has a foreign table attached:
-               $unsetResult = FALSE;
-               if ($tcaFieldConf['type'] == 'select' && $tcaFieldConf['foreign_table']) {
-                       // check, if there is a NEW... id in the value, that should be substituted later
-                       if (strpos($value, 'NEW') !== FALSE) {
-                               $this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
-                               $this->addNewValuesToRemapStackChildIds($valueArray);
-                               $this->remapStack[] = array(
-                                       'func' => 'checkValue_group_select_processDBdata',
-                                       'args' => array($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field),
-                                       'pos' => array('valueArray' => 0, 'tcaFieldConf' => 1, 'id' => 2, 'table' => 5),
-                                       'field' => $field
-                               );
-                               $unsetResult = TRUE;
-                       } else {
-                               $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field);
-                       }
-               }
-               if (!$unsetResult) {
-                       $newVal = $this->checkValue_checkMax($tcaFieldConf, $valueArray);
-                       $res['value'] = implode(',', $newVal);
-               } else {
-                       unset($res['value']);
-               }
-               return $res;
-       }
-
-       /**
-        * Applies the filter methods from a column's TCA configuration to a value array.
-        *
-        * @param array $tcaFieldConfiguration
-        * @param array $values
-        * @return array|mixed
-        * @throws \RuntimeException
-        */
-       protected function applyFiltersToValues(array $tcaFieldConfiguration, array $values) {
-               if (empty($tcaFieldConfiguration['filter']) || !is_array($tcaFieldConfiguration['filter'])) {
-                       return $values;
-               }
-               foreach ($tcaFieldConfiguration['filter'] as $filter) {
-                       if (empty($filter['userFunc'])) {
-                               continue;
-                       }
-                       $parameters = $filter['parameters'] ?: array();
-                       $parameters['values'] = $values;
-                       $parameters['tcaFieldConfig'] = $tcaFieldConfiguration;
-                       $values = GeneralUtility::callUserFunction($filter['userFunc'], $parameters, $this);
-                       if (!is_array($values)) {
-                               throw new \RuntimeException('Failed calling filter userFunc.', 1336051942);
-                       }
-               }
-               return $values;
-       }
-
-       /**
-        * Handling files for group/select function
-        *
-        * @param array $valueArray Array of incoming file references. Keys are numeric, values are files (basically, this is the exploded list of incoming files)
-        * @param array $tcaFieldConf Configuration array from TCA of the field
-        * @param string $curValue Current value of the field
-        * @param array $uploadedFileArray Array of uploaded files, if any
-        * @param string $status 'update' or 'new' flag
-        * @param string $table tablename of record
-        * @param int $id UID of record
-        * @param string $recFID Field identifier [table:uid:field] for flexforms
-        * @return array Modified value array
-        * @see checkValue_group_select()
-        */
-       public function checkValue_group_select_file($valueArray, $tcaFieldConf, $curValue, $uploadedFileArray, $status, $table, $id, $recFID) {
-               // If file handling should NOT be bypassed, do processing:
-               if (!$this->bypassFileHandling) {
-                       // If any files are uploaded, add them to value array
-                       // Numeric index means that there are multiple files
-                       if (isset($uploadedFileArray[0])) {
-                               $uploadedFiles = $uploadedFileArray;
-                       } else {
-                               // There is only one file
-                               $uploadedFiles = array($uploadedFileArray);
-                       }
-                       foreach ($uploadedFiles as $uploadedFileArray) {
-                               if (!empty($uploadedFileArray['name']) && $uploadedFileArray['tmp_name'] !== 'none') {
-                                       $valueArray[] = $uploadedFileArray['tmp_name'];
-                                       $this->alternativeFileName[$uploadedFileArray['tmp_name']] = $uploadedFileArray['name'];
-                               }
-                       }
-                       // Creating fileFunc object.
-                       if (!$this->fileFunc) {
-                               $this->fileFunc = GeneralUtility::makeInstance(BasicFileUtility::class);
-                               $this->include_filefunctions = 1;
-                       }
-                       // Setting permitted extensions.
-                       $all_files = array();
-                       $all_files['webspace']['allow'] = $tcaFieldConf['allowed'];
-                       $all_files['webspace']['deny'] = $tcaFieldConf['disallowed'] ?: '*';
-                       $all_files['ftpspace'] = $all_files['webspace'];
-                       $this->fileFunc->init('', $all_files);
-               }
-               // If there is an upload folder defined:
-               if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file') {
-                       // If filehandling should NOT be bypassed, do processing:
-                       if (!$this->bypassFileHandling) {
-                               // For logging..
-                               $propArr = $this->getRecordProperties($table, $id);
-                               // Get destrination path:
-                               $dest = $this->destPathFromUploadFolder($tcaFieldConf['uploadfolder']);
-                               // If we are updating:
-                               if ($status == 'update') {
-                                       // Traverse the input values and convert to absolute filenames in case the update happens to an autoVersionized record.
-                                       // Background: This is a horrible workaround! The problem is that when a record is auto-versionized the files of the record get copied and therefore get new names which is overridden with the names from the original record in the incoming data meaning both lost files and double-references!
-                                       // The only solution I could come up with (except removing support for managing files when autoversioning) was to convert all relative files to absolute names so they are copied again (and existing files deleted). This should keep references intact but means that some files are copied, then deleted after being copied _again_.
-                                       // Actually, the same problem applies to database references in case auto-versioning would include sub-records since in such a case references are remapped - and they would be overridden due to the same principle then.
-                                       // Illustration of the problem comes here:
-                                       // We have a record 123 with a file logo.gif. We open and edit the files header in a workspace. So a new version is automatically made.
-                                       // The versions uid is 456 and the file is copied to "logo_01.gif". But the form data that we sent was based on uid 123 and hence contains the filename "logo.gif" from the original.
-                                       // The file management code below will do two things: First it will blindly accept "logo.gif" as a file attached to the record (thus creating a double reference) and secondly it will find that "logo_01.gif" was not in the incoming filelist and therefore should be deleted.
-                                       // If we prefix the incoming file "logo.gif" with its absolute path it will be seen as a new file added. Thus it will be copied to "logo_02.gif". "logo_01.gif" will still be deleted but since the files are the same the difference is zero - only more processing and file copying for no reason. But it will work.
-                                       if ($this->autoVersioningUpdate === TRUE) {
-                                               foreach ($valueArray as $key => $theFile) {
-                                                       // If it is an already attached file...
-                                                       if ($theFile === basename($theFile)) {
-                                                               $valueArray[$key] = PATH_site . $tcaFieldConf['uploadfolder'] . '/' . $theFile;
-                                                       }
-                                               }
-                                       }
-                                       // Finding the CURRENT files listed, either from MM or from the current record.
-                                       $theFileValues = array();
-                                       // If MM relations for the files also!
-                                       if ($tcaFieldConf['MM']) {
-                                               $dbAnalysis = $this->createRelationHandlerInstance();
-                                               /** @var $dbAnalysis RelationHandler */
-                                               $dbAnalysis->start('', 'files', $tcaFieldConf['MM'], $id);
-                                               foreach ($dbAnalysis->itemArray as $item) {
-                                                       if ($item['id']) {
-                                                               $theFileValues[] = $item['id'];
-                                                       }
-                                               }
-                                       } else {
-                                               $theFileValues = GeneralUtility::trimExplode(',', $curValue, TRUE);
-                                       }
-                                       $currentFilesForHistory = implode(',', $theFileValues);
-                                       // DELETE files: If existing files were found, traverse those and register files for deletion which has been removed:
-                                       if (count($theFileValues)) {
-                                               // Traverse the input values and for all input values which match an EXISTING value, remove the existing from $theFileValues array (this will result in an array of all the existing files which should be deleted!)
-                                               foreach ($valueArray as $key => $theFile) {
-                                                       if ($theFile && !strstr(GeneralUtility::fixWindowsFilePath($theFile), '/')) {
-                                                               $theFileValues = ArrayUtility::removeArrayEntryByValue($theFileValues, $theFile);
-                                                       }
-                                               }
-                                               // This array contains the filenames in the uploadfolder that should be deleted:
-                                               foreach ($theFileValues as $key => $theFile) {
-                                                       $theFile = trim($theFile);
-                                                       if (@is_file(($dest . '/' . $theFile))) {
-                                                               $this->removeFilesStore[] = $dest . '/' . $theFile;
-                                                       } elseif ($this->enableLogging && $theFile) {
-                                                               $this->log($table, $id, 5, 0, 1, 'Could not delete file \'%s\' (does not exist). (%s)', 10, array($dest . '/' . $theFile, $recFID), $propArr['event_pid']);
-                                                       }
-                                               }
-                                       }
-                               }
-                               // Traverse the submitted values:
-                               foreach ($valueArray as $key => $theFile) {
-                                       // Init:
-                                       $maxSize = (int)$tcaFieldConf['max_size'];
-                                       // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
-                                       $theDestFile = '';
-                                       // a FAL file was added, now resolve the file object and get the absolute path
-                                       // @todo in future versions this needs to be modified to handle FAL objects natively
-                                       if (!empty($theFile) && MathUtility::canBeInterpretedAsInteger($theFile)) {
-                                               $fileObject = ResourceFactory::getInstance()->getFileObject($theFile);
-                                               $theFile = $fileObject->getForLocalProcessing(FALSE);
-                                       }
-                                       // NEW FILES? If the value contains '/' it indicates, that the file
-                                       // is new and should be added to the uploadsdir (whether its absolute or relative does not matter here)
-                                       if (strstr(GeneralUtility::fixWindowsFilePath($theFile), '/')) {
-                                               // Check various things before copying file:
-                                               // File and destination must exist
-                                               if (@is_dir($dest) && (@is_file($theFile) || @is_uploaded_file($theFile))) {
-                                                       // Finding size.
-                                                       if (is_uploaded_file($theFile) && $theFile == $uploadedFileArray['tmp_name']) {
-                                                               $fileSize = $uploadedFileArray['size'];
-                                                       } else {
-                                                               $fileSize = filesize($theFile);
-                                                       }
-                                                       // Check file size:
-                                                       if (!$maxSize || $fileSize <= $maxSize * 1024) {
-                                                               // Prepare filename:
-                                                               $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
-                                                               $fI = GeneralUtility::split_fileref($theEndFileName);
-                                                               // Check for allowed extension:
-                                                               if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
-                                                                       $theDestFile = $this->fileFunc->getUniqueName($this->fileFunc->cleanFileName($fI['file']), $dest);
-                                                                       // If we have a unique destination filename, then write the file:
-                                                                       if ($theDestFile) {
-                                                                               GeneralUtility::upload_copy_move($theFile, $theDestFile);
-                                                                               // Hook for post-processing the upload action
-                                                                               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'])) {
-                                                                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processUpload'] as $classRef) {
-                                                                                               $hookObject = GeneralUtility::getUserObj($classRef);
-                                                                                               if (!$hookObject instanceof DataHandlerProcessUploadHookInterface) {
-                                                                                                       throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Core\\DataHandling\\DataHandlerProcessUploadHookInterface', 1279962349);
-                                                                                               }
-                                                                                               $hookObject->processUpload_postProcessAction($theDestFile, $this);
-                                                                                       }
-                                                                               }
-                                                                               $this->copiedFileMap[$theFile] = $theDestFile;
-                                                                               clearstatcache();
-                                                                               if ($this->enableLogging && !@is_file($theDestFile)) {
-                                                                                       $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)', 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
-                                                                               }
-                                                                       } elseif ($this->enableLogging) {
-                                                                               $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: No destination file (%s) possible!. (%s)', 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
-                                                                       }
-                                                               } elseif ($this->enableLogging) {
-                                                                       $this->log($table, $id, 5, 0, 1, 'File extension \'%s\' not allowed. (%s)', 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
-                                                               }
-                                                       } elseif ($this->enableLogging) {
-                                                               $this->log($table, $id, 5, 0, 1, 'Filesize (%s) of file \'%s\' exceeds limit (%s). (%s)', 13, array(GeneralUtility::formatSize($fileSize), $theFile, GeneralUtility::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
-                                                       }
-                                               } elseif ($this->enableLogging) {
-                                                       $this->log($table, $id, 5, 0, 1, 'The destination (%s) or the source file (%s) does not exist. (%s)', 14, array($dest, $theFile, $recFID), $propArr['event_pid']);
-                                               }
-                                               // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
-                                               if (@is_file($theDestFile)) {
-                                                       $info = GeneralUtility::split_fileref($theDestFile);
-                                                       // The value is set to the new filename
-                                                       $valueArray[$key] = $info['file'];
-                                               } else {
-                                                       // The value is set to the new filename
-                                                       unset($valueArray[$key]);
-                                               }
-                                       }
-                               }
-                       }
-                       // If MM relations for the files, we will set the relations as MM records and change the valuearray to contain a single entry with a count of the number of files!
-                       if ($tcaFieldConf['MM']) {
-                               /** @var $dbAnalysis RelationHandler */
-                               $dbAnalysis = $this->createRelationHandlerInstance();
-                               // Dummy
-                               $dbAnalysis->tableArray['files'] = array();
-                               foreach ($valueArray as $key => $theFile) {
-                                       // Explode files
-                                       $dbAnalysis->itemArray[]['id'] = $theFile;
-                               }
-                               if ($status == 'update') {
-                                       $dbAnalysis->writeMM($tcaFieldConf['MM'], $id, 0);
-                                       $newFiles = implode(',', $dbAnalysis->getValueArray());
-                                       list(, , $recFieldName) = explode(':', $recFID);
-                                       if ($currentFilesForHistory != $newFiles) {
-                                               $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = $currentFilesForHistory;
-                                               $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = $newFiles;
-                                       } else {
-                                               $this->mmHistoryRecords[$table . ':' . $id]['oldRecord'][$recFieldName] = '';
-                                               $this->mmHistoryRecords[$table . ':' . $id]['newRecord'][$recFieldName] = '';
-                                       }
-                               } else {
-                                       $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, 0);
-                               }
-                               $valueArray = $dbAnalysis->countItems();
-                       }
-               } else {
-                       if (count($valueArray)) {
-                               // If filehandling should NOT be bypassed, do processing:
-                               if (!$this->bypassFileHandling) {
-                                       // For logging..
-                                       $propArr = $this->getRecordProperties($table, $id);
-                                       foreach ($valueArray as &$theFile) {
-                                               // FAL handling: it's a UID, thus it is resolved to the absolute path
-                                               if (!empty($theFile) && MathUtility::canBeInterpretedAsInteger($theFile)) {
-                                                       $fileObject = ResourceFactory::getInstance()->getFileObject($theFile);
-                                                       $theFile = $fileObject->getForLocalProcessing(FALSE);
-                                               }
-                                               if ($this->alternativeFilePath[$theFile]) {
-                                                       // If alternative File Path is set for the file, then it was an import
-                                                       // don't import the file if it already exists
-                                                       if (@is_file((PATH_site . $this->alternativeFilePath[$theFile]))) {
-                                                               $theFile = PATH_site . $this->alternativeFilePath[$theFile];
-                                                       } elseif (@is_file($theFile)) {
-                                                               $dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
-                                                               if (!@is_dir($dest)) {
-                                                                       GeneralUtility::mkdir_deep(PATH_site, dirname($this->alternativeFilePath[$theFile]) . '/');
-                                                               }
-                                                               // Init:
-                                                               $maxSize = (int)$tcaFieldConf['max_size'];
-                                                               // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
-                                                               $theDestFile = '';
-                                                               $fileSize = filesize($theFile);
-                                                               // Check file size:
-                                                               if (!$maxSize || $fileSize <= $maxSize * 1024) {
-                                                                       // Prepare filename:
-                                                                       $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
-                                                                       $fI = GeneralUtility::split_fileref($theEndFileName);
-                                                                       // Check for allowed extension:
-                                                                       if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
-                                                                               $theDestFile = PATH_site . $this->alternativeFilePath[$theFile];
-                                                                               // Write the file:
-                                                                               if ($theDestFile) {
-                                                                                       GeneralUtility::upload_copy_move($theFile, $theDestFile);
-                                                                                       $this->copiedFileMap[$theFile] = $theDestFile;
-                                                                                       clearstatcache();
-                                                                                       if ($this->enableLogging && !@is_file($theDestFile)) {
-                                                                                               $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)', 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
-                                                                                       }
-                                                                               } elseif ($this->enableLogging) {
-                                                                                       $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: No destination file (%s) possible!. (%s)', 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
-                                                                               }
-                                                                       } elseif ($this->enableLogging) {
-                                                                               $this->log($table, $id, 5, 0, 1, 'File extension \'%s\' not allowed. (%s)', 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
-                                                                       }
-                                                               } elseif ($this->enableLogging) {
-                                                                       $this->log($table, $id, 5, 0, 1, 'Filesize (%s) of file \'%s\' exceeds limit (%s). (%s)', 13, array(GeneralUtility::formatSize($fileSize), $theFile, GeneralUtility::formatSize($maxSize * 1024), $recFID), $propArr['event_pid']);
-                                                               }
-                                                               // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
-                                                               if (@is_file($theDestFile)) {
-                                                                       // The value is set to the new filename
-                                                                       $theFile = $theDestFile;
-                                                               } else {
-                                                                       // The value is set to the new filename
-                                                                       unset($theFile);
-                                                               }
-                                                       }
-                                               }
-                                               $theFile = GeneralUtility::fixWindowsFilePath($theFile);
-                                               if (GeneralUtility::isFirstPartOfStr($theFile, PATH_site)) {
-                                                       $theFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($theFile);
-                                               }
-                                       }
-                                       unset($theFile);
-                               }
-                       }
-               }
-               return $valueArray;
-       }
-
-       /**
-        * Evaluates 'flex' type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string|array $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param array $PP Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @param array $uploadedFiles Uploaded files for the field
-        * @param string $field Field name
-        * @return array Modified $res array
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
-        */
-       public function checkValue_flex($res, $value, $tcaFieldConf, $PP, $uploadedFiles, $field) {
-               GeneralUtility::logDeprecatedFunction();
-               list($table, $id, $curValue, $status, $realPid, $recFID, $tscPID) = $PP;
-               $this->checkValueForFlex($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $tscPID, $uploadedFiles, $field);
-       }
-
-       /**
-        * Evaluates 'flex' type values.
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string|array $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param string $table Table name
-        * @param int $id UID of record
-        * @param mixed $curValue Current value of the field
-        * @param string $status 'update' or 'new' flag
-        * @param int $realPid The real PID value of the record. For updates, this is just the pid of the record. For new records this is the PID of the page where it is inserted. If $realPid is -1 it means that a new version of the record is being inserted.
-        * @param string $recFID Field identifier [table:uid:field] for flexforms
-        * @param int $tscPID TSconfig PID
-        * @param array $uploadedFiles Uploaded files for the field
-        * @param string $field Field name
-        * @return array Modified $res array
-        */
-       protected function checkValueForFlex($res, $value, $tcaFieldConf, $table, $id, $curValue, $status, $realPid, $recFID, $tscPID, $uploadedFiles, $field) {
-
-               if (is_array($value)) {
-                       // This value is necessary for flex form processing to happen on flexform fields in page records when they are copied.
-                       // Problem: when copying a page, flexform XML comes along in the array for the new record - but since $this->checkValue_currentRecord does not have a uid or pid for that
-                       // sake, the BackendUtility::getFlexFormDS() function returns no good DS. For new records we do know the expected PID so therefore we send that with this special parameter.
-                       // Only active when larger than zero.
-                       $newRecordPidValue = $status == 'new' ? $realPid : 0;
-                       // Get current value array:
-                       $dataStructArray = BackendUtility::getFlexFormDS($tcaFieldConf, $this->checkValue_currentRecord, $table, $field, TRUE, $newRecordPidValue);
-                       $currentValueArray = (string)$curValue !== '' ? GeneralUtility::xml2array($curValue) : array();
-                       if (!is_array($currentValueArray)) {
-                               $currentValueArray = array();
-                       }
-                       if (is_array($currentValueArray['meta']['currentLangId'])) {
-                               unset($currentValueArray['meta']['currentLangId']);
-                       }
-                       // Remove all old meta for languages...
-                       // Evaluation of input values:
-                       $value['data'] = $this->checkValue_flex_procInData($value['data'], $currentValueArray['data'], $uploadedFiles['data'], $dataStructArray, array($table, $id, $curValue, $status, $realPid, $recFID, $tscPID));
-                       // Create XML from input value:
-                       $xmlValue = $this->checkValue_flexArray2Xml($value, TRUE);
-
-                       // Here we convert the currently submitted values BACK to an array, then merge the two and then BACK to XML again. This is needed to ensure the charsets are the same
-                       // (provided that the current value was already stored IN the charset that the new value is converted to).
-                       $arrValue = GeneralUtility::xml2array($xmlValue);
-
-                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkFlexFormValue'])) {
-                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkFlexFormValue'] as $classRef) {
-                                       $hookObject = GeneralUtility::getUserObj($classRef);
-                                       if (method_exists($hookObject, 'checkFlexFormValue_beforeMerge')) {
-                                               $hookObject->checkFlexFormValue_beforeMerge($this, $currentValueArray, $arrValue);
-                                       }
-                               }
-                       }
-
-                       ArrayUtility::mergeRecursiveWithOverrule($currentValueArray, $arrValue);
-                       $xmlValue = $this->checkValue_flexArray2Xml($currentValueArray, TRUE);
-
-                       // Action commands (sorting order and removals of elements) for flexform sections,
-                       // see FormEngine for the use of this GP parameter
-                       $actionCMDs = GeneralUtility::_GP('_ACTION_FLEX_FORMdata');
-                       if (is_array($actionCMDs[$table][$id][$field]['data'])) {
-                               $arrValue = GeneralUtility::xml2array($xmlValue);
-                               $this->_ACTION_FLEX_FORMdata($arrValue['data'], $actionCMDs[$table][$id][$field]['data']);
-                               $xmlValue = $this->checkValue_flexArray2Xml($arrValue, TRUE);
-                       }
-                       // Create the value XML:
-                       $res['value'] = '';
-                       $res['value'] .= $xmlValue;
-               } else {
-                       // Passthrough...:
-                       $res['value'] = $value;
-               }
-
-               return $res;
-       }
-
-       /**
-        * Converts an array to FlexForm XML
-        *
-        * @param array $array Array with FlexForm data
-        * @param bool $addPrologue If set, the XML prologue is returned as well.
-        * @return string Input array converted to XML
-        */
-       public function checkValue_flexArray2Xml($array, $addPrologue = FALSE) {
-               /** @var $flexObj FlexFormTools */
-               $flexObj = GeneralUtility::makeInstance(FlexFormTools::class);
-               return $flexObj->flexArray2Xml($array, $addPrologue);
-       }
-
-       /**
-        * Actions for flex form element (move, delete)
-        * allows to remove and move flexform sections
-        *
-        * @param array $valueArray by reference
-        * @param array $actionCMDs
-        */
-       protected function _ACTION_FLEX_FORMdata(&$valueArray, $actionCMDs) {
-               if (is_array($valueArray) && is_array($actionCMDs)) {
-                       foreach ($actionCMDs as $key => $value) {
-                               if ($key == '_ACTION') {
-                                       // First, check if there are "commands":
-                                       if (current($actionCMDs[$key]) !== '') {
-                                               asort($actionCMDs[$key]);
-                                               $newValueArray = array();
-                                               foreach ($actionCMDs[$key] as $idx => $order) {
-                                                       if (substr($idx, 0, 3) == 'ID-') {
-                                                               $idx = $this->newIndexMap[$idx];
-                                                       }
-                                                       // Just one reflection here: It is clear that when removing elements from a flexform, then we will get lost files unless we act on this delete operation by traversing and deleting files that were referred to.
-                                                       if ($order != 'DELETE') {
-                                                               $newValueArray[$idx] = $valueArray[$idx];
-                                                       }
-                                                       unset($valueArray[$idx]);
-                                               }
-                                               $valueArray = $valueArray + $newValueArray;
-                                       }
-                               } elseif (is_array($actionCMDs[$key]) && isset($valueArray[$key])) {
-                                       $this->_ACTION_FLEX_FORMdata($valueArray[$key], $actionCMDs[$key]);
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Evaluates 'inline' type values.
-        * (partly copied from the select_group function on this issue)
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param array $PP Additional parameters in a numeric array: $table,$id,$curValue,$status,$realPid,$recFID
-        * @param string $field Field name
-        * @param array $additionalData Additional data to be forwarded to sub-processors
-        * @return array Modified $res array
-        */
-       public function checkValue_inline($res, $value, $tcaFieldConf, $PP, $field, array $additionalData = NULL) {
-               list($table, $id, , $status) = $PP;
-               $this->checkValueForInline($res, $value, $tcaFieldConf, $table, $id, $status, $field, $additionalData);
-       }
-
-       /**
-        * Evaluates 'inline' type values.
-        * (partly copied from the select_group function on this issue)
-        *
-        * @param array $res The result array. The processed value (if any!) is set in the 'value' key.
-        * @param string $value The value to set.
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param string $table Table name
-        * @param int $id UID of record
-        * @param string $status 'update' or 'new' flag
-        * @param string $field Field name
-        * @param array $additionalData Additional data to be forwarded to sub-processors
-        * @return array Modified $res array
-        */
-       public function checkValueForInline($res, $value, $tcaFieldConf, $table, $id, $status, $field, array $additionalData = NULL) {
-               if (!$tcaFieldConf['foreign_table']) {
-                       // Fatal error, inline fields should always have a foreign_table defined
-                       return FALSE;
-               }
-               // When values are sent they come as comma-separated values which are exploded by this function:
-               $valueArray = GeneralUtility::trimExplode(',', $value);
-               // Remove duplicates: (should not be needed)
-               $valueArray = array_unique($valueArray);
-               // Example for received data:
-               // $value = 45,NEW4555fdf59d154,12,123
-               // We need to decide whether we use the stack or can save the relation directly.
-               if (strpos($value, 'NEW') !== FALSE || !MathUtility::canBeInterpretedAsInteger($id)) {
-                       $this->remapStackRecords[$table][$id] = array('remapStackIndex' => count($this->remapStack));
-                       $this->addNewValuesToRemapStackChildIds($valueArray);
-                       $this->remapStack[] = array(
-                               'func' => 'checkValue_inline_processDBdata',
-                               'args' => array($valueArray, $tcaFieldConf, $id, $status, $table, $field, $additionalData),
-                               'pos' => array('valueArray' => 0, 'tcaFieldConf' => 1, 'id' => 2, 'table' => 4),
-                               'additionalData' => $additionalData,
-                               'field' => $field,
-                       );
-                       unset($res['value']);
-               } elseif ($value || MathUtility::canBeInterpretedAsInteger($id)) {
-                       $res['value'] = $this->checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $id, $status, $table, $field, $additionalData);
-               }
-               return $res;
-       }
-
-       /**
-        * Checks if a fields has more items than defined via TCA in maxitems.
-        * If there are more items than allowd, the item list is truncated to the defined number.
-        *
-        * @param array $tcaFieldConf Field configuration from TCA
-        * @param array $valueArray Current value array of items
-        * @return array The truncated value array of items
-        */
-       public function checkValue_checkMax($tcaFieldConf, $valueArray) {
-               // BTW, checking for min and max items here does NOT make any sense when MM is used because the above function calls will just return an array with a single item (the count) if MM is used... Why didn't I perform the check before? Probably because we could not evaluate the validity of record uids etc... Hmm...
-               $valueArrayC = count($valueArray);
-               // NOTE to the comment: It's not really possible to check for too few items, because you must then determine first, if the field is actual used regarding the CType.
-               $maxI = isset($tcaFieldConf['maxitems']) ? (int)$tcaFieldConf['maxitems'] : 1;
-               if ($valueArrayC > $maxI) {
-                       $valueArrayC = $maxI;
-               }
-               // Checking for not too many elements
-               // Dumping array to list
-               $newVal = array();
-               foreach ($valueArray as $nextVal) {
-                       if ($valueArrayC == 0) {
-                               break;
-                       }
-                       $valueArrayC--;
-                       $newVal[] = $nextVal;
-               }
-               return $newVal;
-       }
-
-       /*********************************************
-        *
-        * Helper functions for evaluation functions.
-        *
-        ********************************************/
-       /**
-        * Gets a unique value for $table/$id/$field based on $value
-        *
-        * @param string $table Table name
-        * @param string $field Field name for which $value must be unique
-        * @param string $value Value string.
-        * @param int $id UID to filter out in the lookup (the record itself...)
-        * @param int $newPid If set, the value will be unique for this PID
-        * @return string Modified value (if not-unique). Will be the value appended with a number (until 100, then the function just breaks).
-        */
-       public function getUnique($table, $field, $value, $id, $newPid = 0) {
-               // Initialize:
-               $whereAdd = '';
-               $newValue = '';
-               if ((int)$newPid) {
-                       $whereAdd .= ' AND pid=' . (int)$newPid;
-               } else {
-                       $whereAdd .= ' AND pid>=0';
-               }
-               // "AND pid>=0" for versioning
-               $whereAdd .= $this->deleteClause($table);
-               // If the field is configured in TCA, proceed:
-               if (is_array($GLOBALS['TCA'][$table]) && is_array($GLOBALS['TCA'][$table]['columns'][$field])) {
-                       // Look for a record which might already have the value:
-                       $res = $this->databaseConnection->exec_SELECTquery('uid', $table, $field . '=' . $this->databaseConnection->fullQuoteStr($value, $table) . ' AND uid<>' . (int)$id . $whereAdd);
-                       $counter = 0;
-                       // For as long as records with the test-value existing, try again (with incremented numbers appended).
-                       while ($this->databaseConnection->sql_num_rows($res)) {
-                               $newValue = $value . $counter;
-                               $res = $this->databaseConnection->exec_SELECTquery('uid', $table, $field . '=' . $this->databaseConnection->fullQuoteStr($newValue, $table) . ' AND uid<>' . (int)$id . $whereAdd);
-                               $counter++;
-                               if ($counter > 100) {
-                                       break;
-                               }
-                       }
-                       $this->databaseConnection->sql_free_result($res);
-                       // If the new value is there:
-                       $value = $newValue !== '' ? $newValue : $value;
-               }
-               return $value;
-       }
-
-       /**
-        * gets all records that have the same value in a field
-        * excluding the given uid
-        *
-        * @param string $tableName Table name
-        * @param int $uid UID to filter out in the lookup (the record itself...)
-        * @param string $fieldName Field name for which $value must be unique
-        * @param string $value Value string.
-        * @param int $pageId If set, the value will be unique for this PID
-        * @return array
-        */
-       public function getRecordsWithSameValue($tableName, $uid, $fieldName, $value, $pageId = 0) {
-               $result = array();
-               if (!empty($GLOBALS['TCA'][$tableName]['columns'][$fieldName])) {
-
-                       $uid = (int)$uid;
-                       $pageId = (int)$pageId;
-                       $whereStatement = ' AND uid <> ' . $uid . ' AND ' . ($pageId ? 'pid = ' . $pageId : 'pid >= 0');
-                       $result = BackendUtility::getRecordsByField($tableName, $fieldName, $value, $whereStatement);
-               }
-               return $result;
-       }
-
-       /**
-        * @param string $value The field value to be evaluated
-        * @param array $evalArray Array of evaluations to traverse.
-        * @param string $is_in The "is_in" value of the field configuration from TCA
-        * @return array
-        */
-       public function checkValue_text_Eval($value, $evalArray, $is_in) {
-               $res = array();
-               $set = TRUE;
-               foreach ($evalArray as $func) {
-                       switch ($func) {
-                               case 'trim':
-                                       $value = trim($value);
-                                       break;
-                               case 'required':
-                                       if (!$value) {
-                                               $set = FALSE;
-                                       }
-                                       break;
-                               default:
-                                       if (empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func])) {
-                                               break;
-                                       }
-                                       $evalObj = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
-                                       if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue')) {
-                                               $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
-                                       }
-                       }
-               }
-               if ($set) {
-                       $res['value'] = $value;
-               }
-               return $res;
-       }
-
-       /**
-        * Evaluation of 'input'-type values based on 'eval' list
-        *
-        * @param string $value Value to evaluate
-        * @param array $evalArray Array of evaluations to traverse.
-        * @param string $is_in Is-in string for 'is_in' evaluation
-        * @return array Modified $value in key 'value' or empty array
-        */
-       public function checkValue_input_Eval($value, $evalArray, $is_in) {
-               $res = array();
-               $set = TRUE;
-               foreach ($evalArray as $func) {
-                       switch ($func) {
-                               case 'int':
-                               case 'year':
-                               case 'time':
-                               case 'timesec':
-                                       $value = (int)$value;
-                                       break;
-                               case 'date':
-                               case 'datetime':
-                                       $value = (int)$value;
-                                       if ($value > 0 && !$this->dontProcessTransformations) {
-                                               $value -= date('Z', $value);
-                                       }
-                                       break;
-                               case 'double2':
-                                       $value = preg_replace('/[^0-9,\\.-]/', '', $value);
-                                       $negative = $value[0] === '-';
-                                       $value = strtr($value, array(',' => '.', '-' => ''));
-                                       if (strpos($value, '.') === FALSE) {
-                                               $value .= '.0';
-                                       }
-                                       $valueArray = explode('.', $value);
-                                       $dec = array_pop($valueArray);
-                                       $value = join('', $valueArray) . '.' . $dec;
-                                       if ($negative) {
-                                               $value *= -1;
-                                       }
-                                       $value = number_format($value, 2, '.', '');
-                                       break;
-                               case 'md5':
-                                       if (strlen($value) != 32) {
-                                               $set = FALSE;
-                                       }
-                                       break;
-                               case 'trim':
-                                       $value = trim($value);
-                                       break;
-                               case 'upper':
-                                       $value = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $value, 'toUpper');
-                                       break;
-                               case 'lower':
-                                       $value = $GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $value, 'toLower');
-                                       break;
-                               case 'required':
-                                       if (!isset($value) || $value === '') {
-                                               $set = FALSE;
-                                       }
-                                       break;
-                               case 'is_in':
-                                       $c = strlen($value);
-                                       if ($c) {
-                                               $newVal = '';
-                                               for ($a = 0; $a < $c; $a++) {
-                                                       $char = substr($value, $a, 1);
-                                                       if (strpos($is_in, $char) !== FALSE) {
-                                                               $newVal .= $char;
-                                                       }
-                                               }
-                                               $value = $newVal;
-                                       }
-                                       break;
-                               case 'nospace':
-                                       $value = str_replace(' ', '', $value);
-                                       break;
-                               case 'alpha':
-                                       $value = preg_replace('/[^a-zA-Z]/', '', $value);
-                                       break;
-                               case 'num':
-                                       $value = preg_replace('/[^0-9]/', '', $value);
-                                       break;
-                               case 'alphanum':
-                                       $value = preg_replace('/[^a-zA-Z0-9]/', '', $value);
-                                       break;
-                               case 'alphanum_x':
-                                       $value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value);
-                                       break;
-                               case 'domainname':
-                                       if (!preg_match('/^[a-z0-9.\\-]*$/i', $value)) {
-                                               $value = GeneralUtility::idnaEncode($value);
-                                       }
-                                       break;
-                               case 'email':
-                                       $this->checkValue_input_ValidateEmail($value, $set);
-                                       break;
-                               default:
-                                       if (empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func])) {
-                                               break;
-                                       }
-                                       $evalObj = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
-                                       if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue')) {
-                                               $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
-                                       }
-                       }
-               }
-               if ($set) {
-                       $res['value'] = $value;
-               }
-               return $res;
-       }
-
-       /**
-        * If $value is not a valid e-mail address,
-        * $set will be set to false and a flash error
-        * message will be added
-        *
-        * @param string $value Value to evaluate
-        * @param bool $set TRUE if an update should be done
-        * @throws \InvalidArgumentException
-        * @throws \TYPO3\CMS\Core\Exception
-        * @return void
-        */
-       protected function checkValue_input_ValidateEmail($value, &$set) {
-               if (GeneralUtility::validEmail($value)) {
-                       return;
-               }
-
-               $set = FALSE;
-               /** @var FlashMessage $message */
-               $message = GeneralUtility::makeInstance(FlashMessage::class,
-                       sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:error.invalidEmail'), $value),
-                       '', // header is optional
-                       FlashMessage::ERROR,
-                       TRUE // whether message should be stored in session
-               );
-               /** @var $flashMessageService FlashMessageService */
-               $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
-               $flashMessageService->getMessageQueueByIdentifier()->enqueue($message);
-       }
-
-       /**
-        * Returns data for group/db and select fields
-        *
-        * @param array $valueArray Current value array
-        * @param array $tcaFieldConf TCA field config
-        * @param int $id Record id, used for look-up of MM relations (local_uid)
-        * @param string $status Status string ('update' or 'new')
-        * @param string $type The type, either 'select', 'group' or 'inline'
-        * @param string $currentTable Table name, needs to be passed to \TYPO3\CMS\Core\Database\RelationHandler
-        * @param string $currentField field name, needs to be set for writing to sys_history
-        * @return array Modified value array
-        */
-       public function checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, $type, $currentTable, $currentField) {
-               $tables = $type == 'group' ? $tcaFieldConf['allowed'] : $tcaFieldConf['foreign_table'] . ',' . $tcaFieldConf['neg_foreign_table'];
-               $prep = $type == 'group' ? $tcaFieldConf['prepend_tname'] : $tcaFieldConf['neg_foreign_table'];
-               $newRelations = implode(',', $valueArray);
-               /** @var $dbAnalysis RelationHandler */
-               $dbAnalysis = $this->createRelationHandlerInstance();
-               $dbAnalysis->registerNonTableValues = $tcaFieldConf['allowNonIdValues'] ? 1 : 0;
-               $dbAnalysis->start($newRelations, $tables, '', 0, $currentTable, $tcaFieldConf);
-               if ($tcaFieldConf['MM']) {
-                       if ($status == 'update') {
-                               /** @var $oldRelations_dbAnalysis RelationHandler */
-                               $oldRelations_dbAnalysis = $this->createRelationHandlerInstance();
-                               $oldRelations_dbAnalysis->registerNonTableValues = $tcaFieldConf['allowNonIdValues'] ? 1 : 0;
-                               // Db analysis with $id will initialize with the existing relations
-                               $oldRelations_dbAnalysis->start('', $tables, $tcaFieldConf['MM'], $id, $currentTable, $tcaFieldConf);
-                               $oldRelations = implode(',', $oldRelations_dbAnalysis->getValueArray());
-                               $dbAnalysis->writeMM($tcaFieldConf['MM'], $id, $prep);
-                               if ($oldRelations != $newRelations) {
-                                       $this->mmHistoryRecords[$currentTable . ':' . $id]['oldRecord'][$currentField] = $oldRelations;
-                                       $this->mmHistoryRecords[$currentTable . ':' . $id]['newRecord'][$currentField] = $newRelations;
-                               } else {
-                                       $this->mmHistoryRecords[$currentTable . ':' . $id]['oldRecord'][$currentField] = '';
-                                       $this->mmHistoryRecords[$currentTable . ':' . $id]['newRecord'][$currentField] = '';
-                               }
-                       } else {
-                               $this->dbAnalysisStore[] = array($dbAnalysis, $tcaFieldConf['MM'], $id, $prep, $currentTable);
-                       }
-                       $valueArray = $dbAnalysis->countItems();
-               } else {
-                       $valueArray = $dbAnalysis->getValueArray($prep);
-                       if ($type == 'select' && $prep) {
-                               $valueArray = $dbAnalysis->convertPosNeg($valueArray, $tcaFieldConf['foreign_table'], $tcaFieldConf['neg_foreign_table']);
-                       }
-               }
-               // Here we should see if 1) the records exist anymore, 2) which are new and check if the BE_USER has read-access to the new ones.
-               return $valueArray;
-       }
-
-       /**
-        * Explodes the $value, which is a list of files/uids (group select)
-        *
-        * @param string $value Input string, comma separated values. For each part it will also be detected if a '|' is found and the first part will then be used if that is the case. Further the value will be rawurldecoded.
-        * @return array The value array.
-        */
-       public function checkValue_group_select_explodeSelectGroupValue($value) {
-               $valueArray = GeneralUtility::trimExplode(',', $value, TRUE);
-               foreach ($valueArray as &$newVal) {
-                       $temp = explode('|', $newVal, 2);
-                       $newVal = str_replace(',', '', str_replace('|', '', rawurldecode($temp[0])));
-               }
-               unset($newVal);
-               return $valueArray;
-       }
-
-       /**
-        * Starts the processing the input data for flexforms. This will traverse all sheets / languages and for each it will traverse the sub-structure.
-        * See checkValue_flex_procInData_travDS() for more details.
-        * WARNING: Currently, it traverses based on the actual _data_ array and NOT the _structure_. This means that values for non-valid fields, lKey/vKey/sKeys will be accepted! For traversal of data with a call back function you should rather use \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools
-        *
-        * @param array $dataPart The 'data' part of the INPUT flexform data
-        * @param array $dataPart_current The 'data' part of the CURRENT flexform data
-        * @param array $uploadedFiles The uploaded files for the 'data' part of the INPUT flexform data
-        * @param array $dataStructArray Data structure for the form (might be sheets or not). Only values in the data array which has a configuration in the data structure will be processed.
-        * @param array $pParams A set of parameters to pass through for the calling of the evaluation functions
-        * @param string $callBackFunc Optional call back function, see checkValue_flex_procInData_travDS()  DEPRECATED, use \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools instead for traversal!
-        * @return array The modified 'data' part.
-        * @see checkValue_flex_procInData_travDS()
-        */
-       public function checkValue_flex_procInData($dataPart, $dataPart_current, $uploadedFiles, $dataStructArray, $pParams, $callBackFunc = '') {
-               if (is_array($dataPart)) {
-                       foreach ($dataPart as $sKey => $sheetDef) {
-                               list($dataStruct, $actualSheet) = GeneralUtility::resolveSheetDefInDS($dataStructArray, $sKey);
-                               if (is_array($dataStruct) && $actualSheet == $sKey && is_array($sheetDef)) {
-                                       foreach ($sheetDef as $lKey => $lData) {
-                                               $this->checkValue_flex_procInData_travDS($dataPart[$sKey][$lKey], $dataPart_current[$sKey][$lKey], $uploadedFiles[$sKey][$lKey], $dataStruct['ROOT']['el'], $pParams, $callBackFunc, $sKey . '/' . $lKey . '/');
-                                       }
-                               }
-                       }
-               }
-               return $dataPart;
-       }
-
-       /**
-        * Processing of the sheet/language data array
-        * When it finds a field with a value the processing is done by ->checkValue_SW() by default but if a call back function name is given that method in this class will be called for the processing instead.
-        *
-        * @param array $dataValues New values (those being processed): Multidimensional Data array for sheet/language, passed by reference!
-        * @param array $dataValues_current Current values: Multidimensional Data array. May be empty array() if not needed (for callBackFunctions)
-        * @param array $uploadedFiles Uploaded files array for sheet/language. May be empty array() if not needed (for callBackFunctions)
-        * @param array $DSelements Data structure which fits the data array
-        * @param array $pParams A set of parameters to pass through for the calling of the evaluation functions / call back function
-        * @param string $callBackFunc Call back function, default is checkValue_SW(). If $this->callBackObj is set to an object, the callback function in that object is called instead.
-        * @param string $structurePath
-        * @return void
-        * @see checkValue_flex_procInData()
-        */
-       public function checkValue_flex_procInData_travDS(&$dataValues, $dataValues_current, $uploadedFiles, $DSelements, $pParams, $callBackFunc, $structurePath) {
-               if (is_array($DSelements)) {
-                       // For each DS element:
-                       foreach ($DSelements as $key => $dsConf) {
-                               // Array/Section:
-                               if ($DSelements[$key]['type'] == 'array') {
-                                       if (is_array($dataValues[$key]['el'])) {
-                                               if ($DSelements[$key]['section']) {
-                                                       $newIndexCounter = 0;
-                                                       foreach ($dataValues[$key]['el'] as $ik => $el) {
-                                                               if (is_array($el)) {
-                                                                       if (!is_array($dataValues_current[$key]['el'])) {
-                                                                               $dataValues_current[$key]['el'] = array();
-                                                                       }
-                                                                       $theKey = key($el);
-                                                                       if (is_array($dataValues[$key]['el'][$ik][$theKey]['el'])) {
-                                                                               $this->checkValue_flex_procInData_travDS($dataValues[$key]['el'][$ik][$theKey]['el'], is_array($dataValues_current[$key]['el'][$ik]) ? $dataValues_current[$key]['el'][$ik][$theKey]['el'] : array(), $uploadedFiles[$key]['el'][$ik][$theKey]['el'], $DSelements[$key]['el'][$theKey]['el'], $pParams, $callBackFunc, $structurePath . $key . '/el/' . $ik . '/' . $theKey . '/el/');
-                                                                               // If element is added dynamically in the flexform of TCEforms, we map the ID-string to the next numerical index we can have in that particular section of elements:
-                                                                               // The fact that the order changes is not important since order is controlled by a separately submitted index.
-                                                                               if (substr($ik, 0, 3) == 'ID-') {
-                                                                                       $newIndexCounter++;
-                                                                                       // Set mapping index
-                                                                                       $this->newIndexMap[$ik] = (is_array($dataValues_current[$key]['el']) && count($dataValues_current[$key]['el']) ? max(array_keys($dataValues_current[$key]['el'])) : 0) + $newIndexCounter;
-                                                                                       // Transfer values
-                                                                                       $dataValues[$key]['el'][$this->newIndexMap[$ik]] = $dataValues[$key]['el'][$ik];
-                                                                                       // Unset original
-                                                                                       unset($dataValues[$key]['el'][$ik]);
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                               } else {
-                                                       if (!isset($dataValues[$key]['el'])) {
-                                                               $dataValues[$key]['el'] = array();
-                                                       }
-                                                       $this->checkValue_flex_procInData_travDS($dataValues[$key]['el'], $dataValues_current[$key]['el'], $uploadedFiles[$key]['el'], $DSelements[$key]['el'], $pParams, $callBackFunc, $structurePath . $key . '/el/');
-                                               }
-                                       }
-                               } else {
-                                       if (is_array($dsConf['TCEforms']['config']) && is_array($dataValues[$key])) {
-                                               foreach ($dataValues[$key] as $vKey => $data) {
-                                                       if ($callBackFunc) {
-                                                               if (is_object($this->callBackObj)) {
-                                                                       $res = $this->callBackObj->{$callBackFunc}($pParams, $dsConf['TCEforms']['config'], $dataValues[$key][$vKey], $dataValues_current[$key][$vKey], $uploadedFiles[$key][$vKey], $structurePath . $key . '/' . $vKey . '/');
-                                                               } else {
-                                                                       $res = $this->{$callBackFunc}($pParams, $dsConf['TCEforms']['config'], $dataValues[$key][$vKey], $dataValues_current[$key][$vKey], $uploadedFiles[$key][$vKey], $structurePath . $key . '/' . $vKey . '/');
-                                                               }
-                                                       } else {
-                                                               // Default
-                                                               list($CVtable, $CVid, $CVcurValue, $CVstatus, $CVrealPid, $CVrecFID, $CVtscPID) = $pParams;
-
-                                                               $additionalData = array(
-                                                                       'flexFormId' => $CVrecFID,
-                                                                       'flexFormPath' => trim(rtrim($structurePath, '/') . '/' . $key . '/' . $vKey, '/'),
-                                                               );
-
-                                                               $res = $this->checkValue_SW(array(), $dataValues[$key][$vKey], $dsConf['TCEforms']['config'], $CVtable, $CVid, $dataValues_current[$key][$vKey], $CVstatus, $CVrealPid, $CVrecFID, '', $uploadedFiles[$key][$vKey], $CVtscPID, $additionalData);
-                                                               // Look for RTE transformation of field:
-                                                               if ($dataValues[$key]['_TRANSFORM_' . $vKey] == 'RTE' && !$this->dontProcessTransformations) {
-                                                                       // Unsetting trigger field - we absolutely don't want that into the data storage!
-                                                                       unset($dataValues[$key]['_TRANSFORM_' . $vKey]);
-                                                                       if (isset($res['value'])) {
-                                                                               // Calculating/Retrieving some values here:
-                                                                               list(, , $recFieldName) = explode(':', $CVrecFID);
-                                                                               $theTypeString = BackendUtility::getTCAtypeValue($CVtable, $this->checkValue_currentRecord);
-                                                                               $specConf = BackendUtility::getSpecConfParts('', $dsConf['TCEforms']['defaultExtras']);
-                                                                               // Find, thisConfig:
-                                                                               $RTEsetup = $this->BE_USER->getTSConfig('RTE', BackendUtility::getPagesTSconfig($CVtscPID));
-                                                                               $thisConfig = BackendUtility::RTEsetup($RTEsetup['properties'], $CVtable, $recFieldName, $theTypeString);
-                                                                               // Get RTE object, draw form and set flag:
-                                                                               $RTEobj = BackendUtility::RTEgetObj();
-                                                                               if (is_object($RTEobj)) {
-                                                                                       $res['value'] = $RTEobj->transformContent('db', $res['value'], $CVtable, $recFieldName, $this->checkValue_currentRecord, $specConf, $thisConfig, '', $CVrealPid);
-                                                                               } else {
-                                                                                       debug('NO RTE OBJECT FOUND!');
-                                                                               }
-                                                                       }
-                                                               }
-                                                       }
-                                                       // Adding the value:
-                                                       if (isset($res['value'])) {
-                                                               $dataValues[$key][$vKey] = $res['value'];
-                                                       }
-                                                       // Finally, check if new and old values are different (or no .vDEFbase value is found) and if so, we record the vDEF value for diff'ing.
-                                                       // We do this after $dataValues has been updated since I expect that $dataValues_current holds evaluated values from database (so this must be the right value to compare with).
-                                                       if (substr($vKey, -9) != '.vDEFbase') {
-                                                               if ($this->clear_flexFormData_vDEFbase) {
-                                                                       $dataValues[$key][$vKey . '.vDEFbase'] = '';
-                                                               } elseif ($this->updateModeL10NdiffData && $GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'] && $vKey !== 'vDEF' && ((string)$dataValues[$key][$vKey] !== (string)$dataValues_current[$key][$vKey] || !isset($dataValues_current[$key][($vKey . '.vDEFbase')]) || $this->updateModeL10NdiffData === 'FORCE_FFUPD')) {
-                                                                       // Now, check if a vDEF value is submitted in the input data, if so we expect this has been processed prior to this operation (normally the case since those fields are higher in the form) and we can use that:
-                                                                       if (isset($dataValues[$key]['vDEF'])) {
-                                                                               $diffValue = $dataValues[$key]['vDEF'];
-                                                                       } else {
-                                                                               // If not found (for translators with no access to the default language) we use the one from the current-value data set:
-                                                                               $diffValue = $dataValues_current[$key]['vDEF'];
-                                                                       }
-                                                                       // Setting the reference value for vDEF for this translation. This will be used for translation tools to make a diff between the vDEF and vDEFbase to see if an update would be fitting.
-                                                                       $dataValues[$key][$vKey . '.vDEFbase'] = $this->updateModeL10NdiffDataClear ? '' : $diffValue;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Returns data for inline fields.
-        *
-        * @param array $valueArray Current value array
-        * @param array $tcaFieldConf TCA field config
-        * @param int $id Record id
-        * @param string $status Status string ('update' or 'new')
-        * @param string $table Table name, needs to be passed to \TYPO3\CMS\Core\Database\RelationHandler
-        * @param string $field The current field the values are modified for
-        * @param array $additionalData Additional data to be forwarded to sub-processors
-        * @return string Modified values
-        */
-       protected function checkValue_inline_processDBdata($valueArray, $tcaFieldConf, $id, $status, $table, $field, array $additionalData = NULL) {
-               $newValue = '';
-               $foreignTable = $tcaFieldConf['foreign_table'];
-               $valueArray = $this->applyFiltersToValues($tcaFieldConf, $valueArray);
-               // Fetch the related child records using \TYPO3\CMS\Core\Database\RelationHandler
-               /** @var $dbAnalysis RelationHandler */
-               $dbAnalysis = $this->createRelationHandlerInstance();
-               $dbAnalysis->start(implode(',', $valueArray), $foreignTable, '', 0, $table, $tcaFieldConf);
-               // If the localizationMode is set to 'keep', the children for the localized parent are kept as in the original untranslated record:
-               $localizationMode = BackendUtility::getInlineLocalizationMode($table, $tcaFieldConf);
-               if ($localizationMode == 'keep' && $status == 'update') {
-                       // Fetch the current record and determine the original record:
-                       $row = BackendUtility::getRecordWSOL($table, $id);
-                       if (is_array($row)) {
-                               $language = (int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
-                               $transOrigPointer = (int)$row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
-                               // If language is set (e.g. 1) and also transOrigPointer (e.g. 123), use transOrigPointer as uid:
-                               if ($language > 0 && $transOrigPointer) {
-                                       $id = $transOrigPointer;
-                                       // If we're in active localizationMode 'keep', prevent from writing data to the field of the parent record:
-                                       // (on removing the localized parent, the original (untranslated) children would then also be removed)
-                                       $keepTranslation = TRUE;
-                               }
-                       }
-               }
-               // IRRE with a pointer field (database normalization):
-               if ($tcaFieldConf['foreign_field']) {
-                       // if the record was imported, sorting was also imported, so skip this
-                       $skipSorting = $this->callFromImpExp ? TRUE : FALSE;
-                       // update record in intermediate table (sorting & pointer uid to parent record)
-                       $dbAnalysis->writeForeignField($tcaFieldConf, $id, 0, $skipSorting);
-                       $newValue = $keepTranslation ? 0 : $dbAnalysis->countItems(FALSE);
-               } else {
-                       if ($this->getInlineFieldType($tcaFieldConf) == 'mm') {
-                               // In order to fully support all the MM stuff, directly call checkValue_group_select_processDBdata instead of repeating the needed code here
-                               $valueArray = $this->checkValue_group_select_processDBdata($valueArray, $tcaFieldConf, $id, $status, 'select', $table, $field);
-                               $newValue = $keepTranslation ? 0 : $valueArray[0];
-                       } else {
-                               $valueArray = $dbAnalysis->getValueArray();
-                               // Checking that the number of items is correct:
-                               $valueArray = $this->checkValue_checkMax($tcaFieldConf, $valueArray);
-                               // If a valid translation of the 'keep' mode is active, update relations in the original(!) record:
-                               if ($keepTranslation) {
-                                       $this->updateDB($table, $transOrigPointer, array($field => implode(',', $valueArray)));
-                               } else {
-                                       $newValue = implode(',', $valueArray);
-                               }
-                       }
-               }
-               return $newValue;
-       }
-
-       /*********************************************
-        *
-        * PROCESSING COMMANDS
-        *
-        ********************************************/
-       /**
-        * Processing the cmd-array
-        * See "TYPO3 Core API" for a description of the options.
-        *
-        * @return void
-        */
-       public function process_cmdmap() {
-               // Editing frozen:
-               if ($this->BE_USER->workspace !== 0 && $this->BE_USER->workspaceRec['freeze']) {
-                       if ($this->enableLogging) {
-                               $this->newlog('All editing in this workspace has been frozen!', 1);
-                       }
-                       return FALSE;
-               }
-               // Hook initialization:
-               $hookObjectsArr = array();
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'])) {
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'] as $classRef) {
-                               $hookObj = GeneralUtility::getUserObj($classRef);
-                               if (method_exists($hookObj, 'processCmdmap_beforeStart')) {
-                                       $hookObj->processCmdmap_beforeStart($this);
-                               }
-                               $hookObjectsArr[] = $hookObj;
-                       }
-               }
-               $pasteDatamap = array();
-               // Traverse command map:
-               foreach ($this->cmdmap as $table => $_) {
-                       // Check if the table may be modified!
-                       $modifyAccessList = $this->checkModifyAccessList($table);
-                       if ($this->enableLogging && !$modifyAccessList) {
-                               $this->log($table, 0, 2, 0, 1, 'Attempt to modify table \'%s\' without permission', 1, array($table));
-                       }
-                       // Check basic permissions and circumstances:
-                       if (isset($GLOBALS['TCA'][$table]) && !$this->tableReadOnly($table) && is_array($this->cmdmap[$table]) && $modifyAccessList) {
-                               // Traverse the command map:
-                               foreach ($this->cmdmap[$table] as $id => $incomingCmdArray) {
-                                       $pasteUpdate = FALSE;
-                                       if (is_array($incomingCmdArray)) {
-                                               if ($table === 'pages') {
-                                                       // for commands on pages do a pagetree-refresh
-                                                       $this->pagetreeNeedsRefresh = TRUE;
-                                               }
-
-                                               // have found a command.
-                                               // Get command and value (notice, only one command is observed at a time!):
-                                               reset($incomingCmdArray);
-                                               $command = key($incomingCmdArray);
-                                               $value = current($incomingCmdArray);
-                                               if (is_array($value) && isset($value['action']) && $value['action'] === 'paste') {
-                                                       // Extended paste command: $command is set to "move" or "copy"
-                                                       // $value['update'] holds field/value pairs which should be updated after copy/move operation
-                                                       // $value['target'] holds original $value (target of move/copy)
-                                                       $pasteUpdate = $value['update'];
-                                                       $value = $value['target'];
-                                               }
-                                               foreach ($hookObjectsArr as $hookObj) {
-                                                       if (method_exists($hookObj, 'processCmdmap_preProcess')) {
-                                                               $hookObj->processCmdmap_preProcess($command, $table, $id, $value, $this, $pasteUpdate);
-                                                       }
-                                               }
-                                               // Init copyMapping array:
-                                               // Must clear this array before call from here to those functions:
-                                               // Contains mapping information between new and old id numbers.
-                                               $this->copyMappingArray = array();
-                                               // process the command
-                                               $commandIsProcessed = FALSE;
-                                               foreach ($hookObjectsArr as $hookObj) {
-                                                       if (method_exists($hookObj, 'processCmdmap')) {
-                                                               $hookObj->processCmdmap($command, $table, $id, $value, $commandIsProcessed, $this, $pasteUpdate);
-                                                       }
-                                               }
-                                               // Only execute default commands if a hook hasn't been processed the command already
-                                               if (!$commandIsProcessed) {
-                                                       $procId = $id;
-                                                       // Branch, based on command
-                                                       switch ($command) {
-                                                               case 'move':
-                                                                       $this->moveRecord($table, $id, $value);
-                                                                       break;
-                                                               case 'copy':
-                                                                       if ($table === 'pages') {
-                                                                               $this->copyPages($id, $value);
-                                                                       } else {
-                                                                               $this->copyRecord($table, $id, $value, 1);
-                                                                       }
-                                                                       $procId = $this->copyMappingArray[$table][$id];
-                                                                       break;
-                                                               case 'localize':
-                                                                       $this->localize($table, $id, $value);
-                                                                       break;
-                                                               case 'inlineLocalizeSynchronize':
-                                                                       $this->inlineLocalizeSynchronize($table, $id, $value);
-                                                                       break;
-                                                               case 'delete':
-                                                                       $this->deleteAction($table, $id);
-                                                                       break;
-                                                               case 'undelete':
-                                                                       $this->undeleteRecord($table, $id);
-                                                                       break;
-                                                       }
-                                                       if (is_array($pasteUpdate)) {
-                                                               $pasteDatamap[$table][$procId] = $pasteUpdate;
-                                                       }
-                                               }
-                                               foreach ($hookObjectsArr as $hookObj) {
-                                                       if (method_exists($hookObj, 'processCmdmap_postProcess')) {
-                                                               $hookObj->processCmdmap_postProcess($command, $table, $id, $value, $this, $pasteUpdate, $pasteDatamap);
-                                                       }
-                                               }
-                                               // Merging the copy-array info together for remapping purposes.
-                                               ArrayUtility::mergeRecursiveWithOverrule($this->copyMappingArray_merged, $this->copyMappingArray);
-                                       }
-                               }
-                       }
-               }
-               /** @var $copyTCE DataHandler */
-               $copyTCE = $this->getLocalTCE();
-               $copyTCE->start($pasteDatamap, '', $this->BE_USER);
-               $copyTCE->process_datamap();
-               $this->errorLog = array_merge($this->errorLog, $copyTCE->errorLog);
-               unset($copyTCE);
-
-               // Finally, before exit, check if there are ID references to remap.
-               // This might be the case if versioning or copying has taken place!
-               $this->remapListedDBRecords();
-               $this->processRemapStack();
-               foreach ($hookObjectsArr as $hookObj) {
-                       if (method_exists($hookObj, 'processCmdmap_afterFinish')) {
-                               $hookObj->processCmdmap_afterFinish($this);
-                       }
-               }
-               if ($this->isOuterMostInstance()) {
-                       $this->processClearCacheQueue();
-                       $this->resetNestedElementCalls();
-               }
-       }
-
-       /*********************************************
-        *
-        * Cmd: Copying
-        *
-        ********************************************/
-       /**
-        * Copying a single record
-        *
-        * @param string $table Element table
-        * @param int $uid Element UID
-        * @param int $destPid: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
-        * @param bool $first Is a flag set, if the record copied is NOT a 'slave' to another record copied. That is, if this record was asked to be copied in the cmd-array
-        * @param array $overrideValues Associative array with field/value pairs to override directly. Notice; Fields must exist in the table record and NOT be among excluded fields!
-        * @param string $excludeFields Commalist of fields to exclude from the copy process (might get default values)
-        * @param int $language Language ID (from sys_language table)
-        * @return int ID of new record, if any
-        */
-       public function copyRecord($table, $uid, $destPid, $first = FALSE, $overrideValues = array(), $excludeFields = '', $language = 0) {
-               $uid = ($origUid = (int)$uid);
-               // Only copy if the table is defined in $GLOBALS['TCA'], a uid is given and the record wasn't copied before:
-               if ($GLOBALS['TCA'][$table] && $uid && !$this->isRecordCopied($table, $uid)) {
-                       // This checks if the record can be selected which is all that a copy action requires.
-                       if ($this->doesRecordExist($table, $uid, 'show')) {
-                               $fullLanguageCheckNeeded = $table != 'pages';
-                               //Used to check language and general editing rights
-                               if ($language > 0 && $this->BE_USER->checkLanguageAccess($language) || $this->BE_USER->recordEditAccessInternals($table, $uid, FALSE, FALSE, $fullLanguageCheckNeeded)) {
-                                       $data = array();
-                                       $nonFields = array_unique(GeneralUtility::trimExplode(',', 'uid,perms_userid,perms_groupid,perms_user,perms_group,perms_everybody,t3ver_oid,t3ver_wsid,t3ver_id,t3ver_label,t3ver_state,t3ver_count,t3ver_stage,t3ver_tstamp,' . $excludeFields, TRUE));
-                                       // So it copies (and localized) content from workspace...
-                                       $row = BackendUtility::getRecordWSOL($table, $uid);
-                                       if (is_array($row)) {
-                                               // Initializing:
-                                               $theNewID = uniqid('NEW', TRUE);
-                                               $enableField = isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) ? $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] : '';
-                                               $headerField = $GLOBALS['TCA'][$table]['ctrl']['label'];
-                                               // Getting default data:
-                                               $defaultData = $this->newFieldArray($table);
-                                               // Getting "copy-after" fields if applicable:
-                                               $copyAfterFields = $destPid < 0 ? $this->fixCopyAfterDuplFields($table, $uid, abs($destPid), 0) : array();
-                                               // Page TSconfig related:
-                                               // NOT using \TYPO3\CMS\Backend\Utility\BackendUtility::getTSCpid() because we need the real pid - not the ID of a page, if the input is a page...
-                                               $tscPID = BackendUtility::getTSconfig_pidValue($table, $uid, $destPid);
-                                               $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
-                                               $tE = $this->getTableEntries($table, $TSConfig);
-                                               // Traverse ALL fields of the selected record:
-                                               $setDefaultOnCopyArray = array_flip(GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['setToDefaultOnCopy']));
-                                               foreach ($row as $field => $value) {
-                                                       if (!in_array($field, $nonFields, TRUE)) {
-                                                               // Get TCA configuration for the field:
-                                                               $conf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
-                                                               // Preparation/Processing of the value:
-                                                               // "pid" is hardcoded of course:
-                                                               if ($field == 'pid') {
-                                                                       $value = $destPid;
-                                                               } elseif (isset($overrideValues[$field])) {
-                                                                       // Override value...
-                                                                       $value = $overrideValues[$field];
-                                                               } elseif (isset($copyAfterFields[$field])) {
-                                                                       // Copy-after value if available:
-                                                                       $value = $copyAfterFields[$field];
-                                                               } elseif ($GLOBALS['TCA'][$table]['ctrl']['setToDefaultOnCopy'] && isset($setDefaultOnCopyArray[$field])) {
-                                                                       $value = $defaultData[$field];
-                                                               } else {
-                                                                       // Hide at copy may override:
-                                                                       if ($first && $field == $enableField && $GLOBALS['TCA'][$table]['ctrl']['hideAtCopy'] && !$this->neverHideAtCopy && !$tE['disableHideAtCopy']) {
-                                                                               $value = 1;
-                                                                       }
-                                                                       // Prepend label on copy:
-                                                                       if ($first && $field == $headerField && $GLOBALS['TCA'][$table]['ctrl']['prependAtCopy'] && !$tE['disablePrependAtCopy']) {
-                                                                               $value = $this->getCopyHeader($table, $this->resolvePid($table, $destPid), $field, $this->clearPrefixFromValue($table, $value), 0);
-                                                                       }
-                                                                       // Processing based on the TCA config field type (files, references, flexforms...)
-                                                                       $value = $this->copyRecord_procBasedOnFieldType($table, $uid, $field, $value, $row, $conf, $tscPID, $language);
-                                                               }
-                                                               // Add value to array.
-                                                               $data[$table][$theNewID][$field] = $value;
-                                                       }
-                                               }
-                                               // Overriding values:
-                                               if ($GLOBALS['TCA'][$table]['ctrl']['editlock']) {
-                                                       $data[$table][$theNewID][$GLOBALS['TCA'][$table]['ctrl']['editlock']] = 0;
-                                               }
-                                               // Setting original UID:
-                                               if ($GLOBALS['TCA'][$table]['ctrl']['origUid']) {
-                                                       $data[$table][$theNewID][$GLOBALS['TCA'][$table]['ctrl']['origUid']] = $uid;
-                                               }
-                                               // Do the copy by simply submitting the array through TCEmain:
-                                               /** @var $copyTCE DataHandler */
-                                               $copyTCE = $this->getLocalTCE();
-                                               $copyTCE->start($data, '', $this->BE_USER);
-                                               $copyTCE->process_datamap();
-                                               // Getting the new UID:
-                                               $theNewSQLID = $copyTCE->substNEWwithIDs[$theNewID];
-                                               if ($theNewSQLID) {
-                                                       $this->copyRecord_fixRTEmagicImages($table, BackendUtility::wsMapId($table, $theNewSQLID));
-                                                       $this->copyMappingArray[$table][$origUid] = $theNewSQLID;
-                                                       // Keep automatically versionized record information:
-                                                       if (isset($copyTCE->autoVersionIdMap[$table][$theNewSQLID])) {
-                                                               $this->autoVersionIdMap[$table][$theNewSQLID] = $copyTCE->autoVersionIdMap[$table][$theNewSQLID];
-                                                       }
-                                               }
-                                               // Copy back the cached TSconfig
-                                               $this->cachedTSconfig = $copyTCE->cachedTSconfig;
-                                               $this->errorLog = array_merge($this->errorLog, $copyTCE->errorLog);
-                                               unset($copyTCE);
-                                               if ($language == 0) {
-                                                       //repointing the new translation records to the parent record we just created
-                                                       $overrideValues[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] = $theNewSQLID;
-                                                       $this->copyL10nOverlayRecords($table, $uid, $destPid, $first, $overrideValues, $excludeFields);
-                                               }
-                                               return $theNewSQLID;
-                                       } elseif ($this->enableLogging) {
-                                               $this->log($table, $uid, 3, 0, 1, 'Attempt to copy record that did not exist!');
-                                       }
-                               } elseif ($this->enableLogging) {
-                                       $this->log($table, $uid, 3, 0, 1, 'Attempt to copy record without having permissions to do so. [' . $this->BE_USER->errorMsg . '].');
-                               }
-                       } elseif ($this->enableLogging) {
-                               $this->log($table, $uid, 3, 0, 1, 'Attempt to copy record without permission');
-                       }
-               }
-       }
-
-       /**
-        * Copying pages
-        * Main function for copying pages.
-        *
-        * @param int $uid Page UID to copy
-        * @param int $destPid Destination PID: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
-        * @return void
-        */
-       public function copyPages($uid, $destPid) {
-               // Initialize:
-               $uid = (int)$uid;
-               $destPid = (int)$destPid;
-               // Finding list of tables to copy.
-               // These are the tables, the user may modify
-               $copyTablesArray = $this->admin ? $this->compileAdminTables() : explode(',', $this->BE_USER->groupData['tables_modify']);
-               // If not all tables are allowed then make a list of allowed tables: That is the tables that figure in both allowed tables AND the copyTable-list
-               if (!strstr($this->copyWhichTables, '*')) {
-                       $copyWhichTablesArray = array_flip(GeneralUtility::trimExplode(',', $this->copyWhichTables . ',pages'));
-                       foreach ($copyTablesArray as $k => $table) {
-                               // Pages are always going...
-                               if (!$table || !isset($copyWhichTablesArray[$table])) {
-                                       unset($copyTablesArray[$k]);
-                               }
-                       }
-               }
-               $copyTablesArray = array_unique($copyTablesArray);
-               // Begin to copy pages if we're allowed to:
-               if ($this->admin || in_array('pages', $copyTablesArray, TRUE)) {
-                       // Copy this page we're on. And set first-flag (this will trigger that the record is hidden if that is configured)!
-                       $theNewRootID = $this->copySpecificPage($uid, $destPid, $copyTablesArray, 1);
-                       // If we're going to copy recursively...:
-                       if ($theNewRootID && $this->copyTree) {
-                               // Get ALL subpages to copy (read-permissions are respected!):
-                               $CPtable = $this->int_pageTreeInfo(array(), $uid, (int)$this->copyTree, $theNewRootID);
-                               // Now copying the subpages:
-                               foreach ($CPtable as $thePageUid => $thePagePid) {
-                                       $newPid = $this->copyMappingArray['pages'][$thePagePid];
-                                       if (isset($newPid)) {
-                                               $this->copySpecificPage($thePageUid, $newPid, $copyTablesArray);
-                                       } else {
-                                               if ($this->enableLogging) {
-                                                       $this->log('pages', $uid, 5, 0, 1, 'Something went wrong during copying branch');
-                                               }
-                                               break;
-                                       }
-                               }
-                       }
-               } elseif ($this->enableLogging) {
-                       $this->log('pages', $uid, 5, 0, 1, 'Attempt to copy page without permission to this table');
-               }
-       }
-
-       /**
-        * Copying a single page ($uid) to $destPid and all tables in the array copyTablesArray.
-        *
-        * @param int $uid Page uid
-        * @param int $destPid Destination PID: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
-        * @param array $copyTablesArray Table on pages to copy along with the page.
-        * @param bool $first Is a flag set, if the record copied is NOT a 'slave' to another record copied. That is, if this record was asked to be copied in the cmd-array
-        * @return int The id of the new page, if applicable.
-        */
-       public function copySpecificPage($uid, $destPid, $copyTablesArray, $first = FALSE) {
-               // Copy the page itself:
-               $theNewRootID = $this->copyRecord('pages', $uid, $destPid, $first);
-               // If a new page was created upon the copy operation we will proceed with all the tables ON that page:
-               if ($theNewRootID) {
-                       foreach ($copyTablesArray as $table) {
-                               // All records under the page is copied.
-                               if ($table && is_array($GLOBALS['TCA'][$table]) && $table != 'pages') {
-                                       $mres = $this->databaseConnection->exec_SELECTquery('uid', $table, 'pid=' . (int)$uid . $this->deleteClause($table), '', $GLOBALS['TCA'][$table]['ctrl']['sortby'] ? $GLOBALS['TCA'][$table]['ctrl']['sortby'] . ' DESC' : '');
-                                       while ($row = $this->databaseConnection->sql_fetch_assoc($mres)) {
-                                               // Copying each of the underlying records...
-                                               $this->copyRecord($table, $row['uid'], $theNewRootID);
-                                       }
-                                       $this->databaseConnection->sql_free_result($mres);
-                               }
-                       }
-                       $this->processRemapStack();
-                       return $theNewRootID;
-               }
-       }
-
-       /**
-        * Copying records, but makes a "raw" copy of a record.
-        * Basically the only thing observed is field processing like the copying of files and correction of ids. All other fields are 1-1 copied.
-        * Technically the copy is made with THIS instance of the tcemain class contrary to copyRecord() which creates a new instance and uses the processData() function.
-        * The copy is created by insertNewCopyVersion() which bypasses most of the regular input checking associated with processData() - maybe copyRecord() should even do this as well!?
-        * This function is used to create new versions of a record.
-        * NOTICE: DOES NOT CHECK PERMISSIONS to create! And since page permissions are just passed through and not changed to the user who executes the copy we cannot enforce permissions without getting an incomplete copy - unless we change permissions of course.
-        *
-        * @param string $table Element table
-        * @param int $uid Element UID
-        * @param int $pid Element PID (real PID, not checked)
-        * @param array $overrideArray Override array - must NOT contain any fields not in the table!
-        * @return array $workspaceOptions Options to be forwarded if actions happen on a workspace currently
-        * @return int Returns the new ID of the record (if applicable)
-        */
-       public function copyRecord_raw($table, $uid, $pid, $overrideArray = array(), array $workspaceOptions = array()) {
-               $uid = (int)$uid;
-               // Stop any actions if the record is marked to be deleted:
-               // (this can occur if IRRE elements are versionized and child elements are removed)
-               if ($this->isElementToBeDeleted($table, $uid)) {
-                       return NULL;
-               }
-               // Only copy if the table is defined in TCA, a uid is given and the record wasn't copied before:
-               if ($GLOBALS['TCA'][$table] && $uid && !$this->isRecordCopied($table, $uid)) {
-                       if ($this->doesRecordExist($table, $uid, 'show')) {
-                               // Set up fields which should not be processed. They are still written - just passed through no-questions-asked!
-                               $nonFields = array('uid', 'pid', 't3ver_id', 't3ver_oid', 't3ver_wsid', 't3ver_label', 't3ver_state', 't3ver_count', 't3ver_stage', 't3ver_tstamp', 'perms_userid', 'perms_groupid', 'perms_user', 'perms_group', 'perms_everybody');
-                               // Select main record:
-                               $row = $this->recordInfo($table, $uid, '*');
-                               if (is_array($row)) {
-                                       // Merge in override array.
-                                       $row = array_merge($row, $overrideArray);
-                                       // Traverse ALL fields of the selected record:
-                                       foreach ($row as $field => $value) {
-                                               if (!in_array($field, $nonFields, TRUE)) {
-                                                       // Get TCA configuration for the field:
-                                                       $conf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
-                                                       if (is_array($conf)) {
-                                                               // Processing based on the TCA config field type (files, references, flexforms...)
-                                                               $value = $this->copyRecord_procBasedOnFieldType($table, $uid, $field, $value, $row, $conf, $pid, 0, $workspaceOptions);
-                                                       }
-                                                       // Add value to array.
-                                                       $row[$field] = $value;
-                                               }
-                                       }
-                                       // Force versioning related fields:
-                                       $row['pid'] = $pid;
-                                       // Setting original UID:
-                                       if ($GLOBALS['TCA'][$table]['ctrl']['origUid']) {
-                                               $row[$GLOBALS['TCA'][$table]['ctrl']['origUid']] = $uid;
-                                       }
-                                       // Do the copy by internal function
-                                       $theNewSQLID = $this->insertNewCopyVersion($table, $row, $pid);
-                                       if ($theNewSQLID) {
-                                               $this->dbAnalysisStoreExec();
-                                               $this->dbAnalysisStore = array();
-                                               $this->copyRecord_fixRTEmagicImages($table, BackendUtility::wsMapId($table, $theNewSQLID));
-                                               return $this->copyMappingArray[$table][$uid] = $theNewSQLID;
-                                       }
-                               } elseif ($this->enableLogging) {
-                                       $this->log($table, $uid, 3, 0, 1, 'Attempt to rawcopy/versionize record that did not exist!');
-                               }
-                       } elseif ($this->enableLogging) {
-                               $this->log($table, $uid, 3, 0, 1, 'Attempt to rawcopy/versionize record without copy permission');
-                       }
-               }
-       }
-
-       /**
-        * Inserts a record in the database, passing TCA configuration values through checkValue() but otherwise does NOTHING and checks nothing regarding permissions.
-        * Passes the "version" parameter to insertDB() so the copy will look like a new version in the log - should probably be changed or modified a bit for more broad usage...
-        *
-        * @param string $table Table name
-        * @param array $fieldArray Field array to insert as a record
-        * @param int $realPid The value of PID field.  -1 is indication that we are creating a new version!
-        * @return int Returns the new ID of the record (if applicable)
-        */
-       public function insertNewCopyVersion($table, $fieldArray, $realPid) {
-               $id = uniqid('NEW', TRUE);
-               // $fieldArray is set as current record.
-               // The point is that when new records are created as copies with flex type fields there might be a field containing information about which DataStructure to use and without that information the flexforms cannot be correctly processed.... This should be OK since the $checkValueRecord is used by the flexform evaluation only anyways...
-               $this->checkValue_currentRecord = $fieldArray;
-               // Makes sure that transformations aren't processed on the copy.
-               $backupDontProcessTransformations = $this->dontProcessTransformations;
-               $this->dontProcessTransformations = TRUE;
-               // Traverse record and input-process each value:
-               foreach ($fieldArray as $field => $fieldValue) {
-                       if (isset($GLOBALS['TCA'][$table]['columns'][$field])) {
-                               // Evaluating the value.
-                               $res = $this->checkValue($table, $field, $fieldValue, $id, 'new', $realPid, 0);
-                               if (isset($res['value'])) {
-                                       $fieldArray[$field] = $res['value'];
-                               }
-                       }
-               }
-               // System fields being set:
-               if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
-                       $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
-               }
-               if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
-                       $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']] = $this->userid;
-               }
-               if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
-                       $fieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
-               }
-               // Finally, insert record:
-               $this->insertDB($table, $id, $fieldArray, TRUE);
-               // Resets dontProcessTransformations to the previous state.
-               $this->dontProcessTransformations = $backupDontProcessTransformations;
-               // Return new id:
-               return $this->substNEWwithIDs[$id];
-       }
-
-       /**
-        * Processing/Preparing content for copyRecord() function
-        *
-        * @param string $table Table name
-        * @param int $uid Record uid
-        * @param string $field Field name being processed
-        * @param string $value Input value to be processed.
-        * @param array $row Record array
-        * @param array $conf TCA field configuration
-        * @param int $realDestPid Real page id (pid) the record is copied to
-        * @param int $language Language ID (from sys_language table) used in the duplicated record
-        * @return array $workspaceOptions Options to be forwarded if actions happen on a workspace currently
-        * @access private
-        * @see copyRecord()
-        */
-       public function copyRecord_procBasedOnFieldType($table, $uid, $field, $value, $row, $conf, $realDestPid, $language = 0, array $workspaceOptions = array()) {
-               // Process references and files, currently that means only the files, prepending absolute paths (so the TCEmain engine will detect the file as new and one that should be made into a copy)
-               $value = $this->copyRecord_procFilesRefs($conf, $uid, $value);
-               $inlineSubType = $this->getInlineFieldType($conf);
-               // Get the localization mode for the current (parent) record (keep|select):
-               $localizationMode = BackendUtility::getInlineLocalizationMode($table, $field);
-               // Register if there are references to take care of or MM is used on an inline field (no change to value):
-               if ($this->isReferenceField($conf) || $inlineSubType == 'mm') {
-                       $allowedTables = $conf['type'] == 'group' ? $conf['allowed'] : $conf['foreign_table'] . ',' . $conf['neg_foreign_table'];
-                       $prependName = $conf['type'] == 'group' ? $conf['prepend_tname'] : $conf['neg_foreign_table'];
-                       $mmTable = isset($conf['MM']) && $conf['MM'] ? $conf['MM'] : '';
-                       $localizeForeignTable = isset($conf['foreign_table']) && BackendUtility::isTableLocalizable($conf['foreign_table']);
-                       $localizeReferences = $localizeForeignTable && isset($conf['localizeReferencesAtParentLocalization']) && $conf['localizeReferencesAtParentLocalization'];
-                       $localizeChildren = $localizeForeignTable && isset($conf['behaviour']['localizeChildrenAtParentLocalization']) && $conf['behaviour']['localizeChildrenAtParentLocalization'];
-                       /** @var $dbAnalysis RelationHandler */
-                       $dbAnalysis = $this->createRelationHandlerInstance();
-                       $dbAnalysis->start($value, $allowedTables, $mmTable, $uid, $table, $conf);
-                       // Localize referenced records of select fields:
-                       if ($language > 0 && ($localizeReferences && empty($mmTable) || $localizeChildren && $localizationMode === 'select' && $inlineSubType === 'mm')) {
-                               foreach ($dbAnalysis->itemArray as $index => $item) {
-                                       // Since select fields can reference many records, check whether there's already a localization:
-                                       $recordLocalization = BackendUtility::getRecordLocalization($item['table'], $item['id'], $language);
-                                       if ($recordLocalization) {
-                                               $dbAnalysis->itemArray[$index]['id'] = $recordLocalization[0]['uid'];
-                                       } elseif ($this->isNestedElementCallRegistered($item['table'], $item['id'], 'localize') === FALSE) {
-                                               $dbAnalysis->itemArray[$index]['id'] = $this->localize($item['table'], $item['id'], $language);
-                                       }
-                               }
-                               $dbAnalysis->purgeItemArray();
-                               $value = implode(',', $dbAnalysis->getValueArray($prependName));
-                       } elseif ($language > 0 && $localizeChildren === FALSE && $localizationMode === 'select' && $inlineSubType === 'mm') {
-                               foreach ($dbAnalysis->itemArray as $index => $item) {
-                                       // Since select fields can reference many records, check whether there's already a localization:
-                                       $recordLocalization = BackendUtility::getRecordLocalization($item['table'], $item['id'], $language);
-                                       if ($recordLocalization) {
-                                               $dbAnalysis->itemArray[$index]['id'] = $recordLocalization[0]['uid'];
-                                       } elseif ($this->isNestedElementCallRegistered($item['table'], $item['id'], 'localize') === FALSE) {
-                                               unset($dbAnalysis->itemArray[$index]);
-                                       }
-                               }
-                               $dbAnalysis->purgeItemArray();
-                               $value = implode(',', $dbAnalysis->getValueArray($prependName));
-                       } elseif ($mmTable) {
-                               $dbAnalysis->purgeItemArray();
-                               $value = implode(',', $dbAnalysis->getValueArray($prependName));
-                       }
-                       // Setting the value in this array will notify the remapListedDBRecords() function that this field MAY need references to be corrected
-                       if ($value) {
-                               $this->registerDBList[$table][$uid][$field] = $value;
-                       }
-               } elseif ($inlineSubType !== FALSE) {
-                       // Localization in mode 'keep', isn't a real localization, but keeps the children of the original parent record:
-                       if ($language > 0 && $localizationMode == 'keep') {
-                               $value = $inlineSubType == 'field' ? 0 : '';
-                       } else {
-                               // Fetch the related child records using \TYPO3\CMS\Core\Database\RelationHandler
-                               /** @var $dbAnalysis RelationHandler */
-                               $dbAnalysis = $this->createRelationHandlerInstance();
-                               $dbAnalysis->start($value, $conf['foreign_table'], '', $uid, $table, $conf);
-                               // Walk through the items, copy them and remember the new id:
-                               foreach ($dbAnalysis->itemArray as $k => $v) {
-                                       // If language is set and differs from original record, this isn't a copy action but a localization of our parent/ancestor:
-                                       if ($language > 0 && BackendUtility::isTableLocalizable($table) && $language != $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]) {
-                                               // If children should be localized when the parent gets localized the first time, just do it:
-                                               if ($localizationMode != FALSE && isset($conf['behaviour']['localizeChildrenAtParentLocalization']) && $conf['behaviour']['localizeChildrenAtParentLocalization']) {
-                                                       $newId = $this->localize($v['table'], $v['id'], $language);
-                                               }
-                                       } else {
-                                               if (!MathUtility::canBeInterpretedAsInteger($realDestPid)) {
-                                                       $newId = $this->copyRecord($v['table'], $v['id'], -$v['id']);
-                                               // If the destination page id is a NEW string, keep it on the same page
-                                               } elseif ($this->BE_USER->workspace > 0 && BackendUtility::isTableWorkspaceEnabled($v['table'])) {
-                                                       // A filled $workspaceOptions indicated that this call
-                                                       // has it's origin in previous versionizeRecord() processing
-                                                       if (count($workspaceOptions)) {
-                                                               // Versions use live default id, thus the "new"
-                                                               // id is the original live default child record
-                                                               $newId = $v['id'];
-                                                               $this->versionizeRecord(
-                                                                       $v['table'], $v['id'],
-                                                                       (isset($workspaceOptions['label']) ? $workspaceOptions['label'] : 'Auto-created for WS #' . $this->BE_USER->workspace),
-                                                                       (isset($workspaceOptions['delete']) ? $workspaceOptions['delete'] : FALSE)
-                                                               );
-                                                       // Otherwise just use plain copyRecord() to create placeholders etc.
-                                                       } else {
-                                                               // If a record has been copied already during this request,
-                                                               // prevent superfluous duplication and use the existing copy
-                                                               if (isset($this->copyMappingArray[$v['table']][$v['id']])) {
-                                                                       $newId = $this->copyMappingArray[$v['table']][$v['id']];
-                                                               } else {
-                                                                       $newId = $this->copyRecord($v['table'], $v['id'], $realDestPid);
-                                                               }
-                                                       }
-                                               } else {
-                                                       // If a record has been copied already during this request,
-                                                       // prevent superfluous duplication and use the existing copy
-                                                       if (isset($this->copyMappingArray[$v['table']][$v['id']])) {
-                                                               $newId = $this->copyMappingArray[$v['table']][$v['id']];
-                                                       } else {
-                                                               $newId = $this->copyRecord_raw($v['table'], $v['id'], $realDestPid, array(), $workspaceOptions);
-                                                       }
-                                               }
-                                       }
-                                       // If the current field is set on a page record, update the pid of related child records:
-                                       if ($table == 'pages') {
-                                               $this->registerDBPids[$v['table']][$v['id']] = $uid;
-                                       } elseif (isset($this->registerDBPids[$table][$uid])) {
-                                               $this->registerDBPids[$v['table']][$v['id']] = $this->registerDBPids[$table][$uid];
-                                       }
-                                       $dbAnalysis->itemArray[$k]['id'] = $newId;
-                               }
-                               // Store the new values, we will set up the uids for the subtype later on (exception keep localization from original record):
-                               $value = implode(',', $dbAnalysis->getValueArray());
-                               $this->registerDBList[$table][$uid][$field] = $value;
-                       }
-               }
-               // For "flex" fieldtypes we need to traverse the structure for two reasons: If there are file references they have to be prepended with absolute paths and if there are database reference they MIGHT need to be remapped (still done in remapListedDBRecords())
-               if ($conf['type'] == 'flex') {
-                       // Get current value array:
-                       $dataStructArray = BackendUtility::getFlexFormDS($conf, $row, $table, $field);
-                       $currentValueArray = GeneralUtility::xml2array($value);
-                       // Traversing the XML structure, processing files:
-                       if (is_array($currentValueArray)) {
-                               $currentValueArray['data'] = $this->checkValue_flex_procInData($currentValueArray['data'], array(), array(), $dataStructArray, array($table, $uid, $field, $realDestPid), 'copyRecord_flexFormCallBack');
-                               // Setting value as an array! -> which means the input will be processed according to the 'flex' type when the new copy is created.
-                               $value = $currentValueArray;
-                       }
-               }
-               return $value;
-       }
-
-       /**
-        * Callback function for traversing the FlexForm structure in relation to creating copied files of file relations inside of flex form structures.
-        *
-        * @param array $pParams Array of parameters in num-indexes: table, uid, field
-        * @param array $dsConf TCA field configuration (from Data Structure XML)
-        * @param string $dataValue The value of the flexForm field
-        * @param string $dataValue_ext1 Not used.
-        * @param string $dataValue_ext2 Not used.
-        * @return array Result array with key "value" containing the value of the processing.
-        * @see copyRecord(), checkValue_flex_procInData_travDS()
-        */
-       public function copyRecord_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2) {
-               // Extract parameters:
-               list($table, $uid, $field, $realDestPid) = $pParams;
-               // Process references and files, currently that means only the files, prepending absolute paths:
-               $dataValue = $this->copyRecord_procFilesRefs($dsConf, $uid, $dataValue);
-               // If references are set for this field, set flag so they can be corrected later (in ->remapListedDBRecords())
-               if (($this->isReferenceField($dsConf) || $this->getInlineFieldType($dsConf) !== FALSE) && (string)$dataValue !== '') {
-                       $dataValue = $this->copyRecord_procBasedOnFieldType($table, $uid, $field, $dataValue, array(), $dsConf, $realDestPid);
-                       $this->registerDBList[$table][$uid][$field] = 'FlexForm_reference';
-               }
-               // Return
-               return array('value' => $dataValue);
-       }
-
-       /**
-        * Modifying a field value for any situation regarding files/references:
-        * For attached files: take current file names and prepend absolute paths so they get copied.
-        * For DB references: Nothing done.
-        *
-        * @param array $conf TCE field config
-        * @param int $uid Record UID
-        * @param string $value Field value (eg. list of files)
-        * @return string The (possibly modified) value
-        * @see copyRecord(), copyRecord_flexFormCallBack()
-        */
-       public function copyRecord_procFilesRefs($conf, $uid, $value) {
-               // Prepend absolute paths to files:
-               if ($conf['type'] == 'group' && ($conf['internal_type'] == 'file' || $conf['internal_type'] == 'file_reference')) {
-                       // Get an array with files as values:
-                       if ($conf['MM']) {
-                               $theFileValues = array();
-                               /** @var $dbAnalysis RelationHandler */
-                               $dbAnalysis = $this->createRelationHandlerInstance();
-                               $dbAnalysis->start('', 'files', $conf['MM'], $uid);
-                               foreach ($dbAnalysis->itemArray as $somekey => $someval) {
-                                       if ($someval['id']) {
-                                               $theFileValues[] = $someval['id'];
-                                       }
-                               }
-                       } else {
-                               $theFileValues = GeneralUtility::trimExplode(',', $value, TRUE);
-                       }
-                       // Traverse this array of files:
-                       $uploadFolder = $conf['internal_type'] == 'file' ? $conf['uploadfolder'] : '';
-                       $dest = $this->destPathFromUploadFolder($uploadFolder);
-                       $newValue = array();
-                       foreach ($theFileValues as $file) {
-                               if (trim($file)) {
-                                       $realFile = str_replace('//', '/', $dest . '/' . trim($file));
-                                       if (@is_file($realFile)) {
-                                               $newValue[] = $realFile;
-                                       }
-                               }
-                       }
-                       // Implode the new filelist into the new value (all files have absolute paths now which means they will get copied when entering TCEmain as new values...)
-                       $value = implode(',', $newValue);
-               }
-               // Return the new value:
-               return $value;
-       }
-
-       /**
-        * Copies any "RTEmagic" image files found in record with table/id to new names.
-        * Usage: After copying a record this function should be called to search for "RTEmagic"-images inside the record. If such are found they should be duplicated to new names so all records have a 1-1 relation to them.
-        * Reason for copying RTEmagic files: a) if you remove an RTEmagic image from a record it will remove the file - any other record using it will have a lost reference! b) RTEmagic images keeps an original and a copy. The copy always is re-calculated to have the correct physical measures as the HTML tag inserting it defines. This is calculated from the original. Two records using the same image could have difference HTML-width/heights for the image and the copy could only comply with one of them. If you don't want a 1-1 relation you should NOT use RTEmagic files but just insert it as a normal file reference to a file inside fileadmin/ folder
-        *
-        * @param string $table Table name
-        * @param int $theNewSQLID Record UID
-        * @return void
-        */
-       public function copyRecord_fixRTEmagicImages($table, $theNewSQLID) {
-               // Creating fileFunc object.
-               if (!$this->fileFunc) {
-                       $this->fileFunc = GeneralUtility::makeInstance(BasicFileUtility::class);
-                       $this->include_filefunctions = 1;
-               }
-               // Select all RTEmagic files in the reference table from the table/ID
-               $where = join(' AND ', array(
-                       'ref_table=' . $this->databaseConnection->fullQuoteStr('_FILE', 'sys_refindex'),
-                       'ref_string LIKE ' . $this->databaseConnection->fullQuoteStr('%/RTEmagic%', 'sys_refindex'),
-                       'softref_key=' . $this->databaseConnection->fullQuoteStr('images', 'sys_refindex'),
-                       'tablename=' . $this->databaseConnection->fullQuoteStr($table, 'sys_refindex'),
-                       'recuid=' . (int)$theNewSQLID,
-               ));
-               $rteFileRecords = $this->databaseConnection->exec_SELECTgetRows('*', 'sys_refindex', $where, '', 'sorting DESC');
-               // Traverse the files found and copy them:
-               if (is_array($rteFileRecords)) {
-                       foreach ($rteFileRecords as $rteFileRecord) {
-                               $filename = basename($rteFileRecord['ref_string']);
-                               $fileInfo = array();
-                               if (GeneralUtility::isFirstPartOfStr($filename, 'RTEmagicC_')) {
-                                       $fileInfo['exists'] = @is_file((PATH_site . $rteFileRecord['ref_string']));
-                                       $fileInfo['original'] = substr($rteFileRecord['ref_string'], 0, -strlen($filename)) . 'RTEmagicP_' . preg_replace('/\\.[[:alnum:]]+$/', '', substr($filename, 10));
-                                       $fileInfo['original_exists'] = @is_file((PATH_site . $fileInfo['original']));
-                                       // CODE from tx_impexp and class.rte_images.php adapted for use here:
-                                       if ($fileInfo['exists'] && $fileInfo['original_exists']) {
-                                               // Initialize; Get directory prefix for file and set the original name:
-                                               $dirPrefix = dirname($rteFileRecord['ref_string']) . '/';
-                                               $rteOrigName = basename($fileInfo['original']);
-                                               // If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file!
-                                               if ($rteOrigName && GeneralUtility::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir((PATH_site . $dirPrefix))) {
-                                                       // RTE:
-                                                       // From the "original" RTE filename, produce a new "original" destination filename which is unused.
-                                                       $origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
-                                                       // Create copy file name:
-                                                       $pI = pathinfo($rteFileRecord['ref_string']);
-                                                       $copyDestName = dirname($origDestName) . '/RTEmagicC_' . substr(basename($origDestName), 10) . '.' . $pI['extension'];
-                                                       if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === GeneralUtility::getFileAbsFileName($origDestName) && $copyDestName === GeneralUtility::getFileAbsFileName($copyDestName)) {
-                                                               // Making copies:
-                                                               GeneralUtility::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
-                                                               GeneralUtility::upload_copy_move(PATH_site . $rteFileRecord['ref_string'], $copyDestName);
-                                                               clearstatcache();
-                                                               // Register this:
-                                                               $this->RTEmagic_copyIndex[$rteFileRecord['tablename']][$rteFileRecord['recuid']][$rteFileRecord['field']][$rteFileRecord['ref_string']] = PathUtility::stripPathSitePrefix($copyDestName);
-                                                               // Check and update the record using \TYPO3\CMS\Core\Database\ReferenceIndex
-                                                               if (@is_file($copyDestName)) {
-                                                                       /** @var ReferenceIndex $sysRefObj */
-                                                                       $sysRefObj = GeneralUtility::makeInstance(ReferenceIndex::class);
-                                                                       $error = $sysRefObj->setReferenceValue($rteFileRecord['hash'], PathUtility::stripPathSitePrefix($copyDestName), FALSE, TRUE);
-                                                                       if ($this->enableLogging && $error) {
-                                                                               echo $this->newlog(ReferenceIndex::class . '::setReferenceValue(): ' . $error, 1);
-                                                                       }
-                                                               } elseif ($this->enableLogging) {
-                                                                       $this->newlog('File "' . $copyDestName . '" was not created!', 1);
-                                                               }
-                                                       } elseif ($this->enableLogging) {
-                                                               $this->newlog('Could not construct new unique names for file!', 1);
-                                                       }
-                                               } elseif ($this->enableLogging) {
-                                                       $this->newlog('Maybe directory of file was not within "uploads/"?', 1);
-                                               }
-                                       } elseif ($this->enableLogging) {
-                                               $this->newlog('Trying to copy RTEmagic files (' . $rteFileRecord['ref_string'] . ' / ' . $fileInfo['original'] . ') but one or both were missing', 1);
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Find l10n-overlay records and perform the requested copy action for these records.
-        *
-        * @param string $table Record Table
-        * @param string $uid Record UID
-        * @param string $destPid Position to copy to
-        * @param bool $first
-        * @param array $overrideValues
-        * @param string $excludeFields
-        * @return void
-        */
-       public function copyL10nOverlayRecords($table, $uid, $destPid, $first = FALSE, $overrideValues = array(), $excludeFields = '') {
-               // There's no need to perform this for page-records or for tables that are not localizable
-               if (!BackendUtility::isTableLocalizable($table) || !empty($GLOBALS['TCA'][$table]['ctrl']['transForeignTable']) || !empty($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])) {
-                       return;
-               }
-               $where = '';
-               if (isset($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-                       $where = ' AND t3ver_oid=0';
-               }
-               // If $destPid is < 0, get the pid of the record with uid equal to abs($destPid)
-               $tscPID = BackendUtility::getTSconfig_pidValue($table, $uid, $destPid);
-               // Get the localized records to be copied
-               $l10nRecords = BackendUtility::getRecordsByField($table, $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], $uid, $where);
-               if (is_array($l10nRecords)) {
-                       // If $destPid < 0, then it is the uid of the original language record we are inserting after
-                       if ($destPid < 0) {
-                               $localizedDestPids = array();
-                               // Get the localized records of the record we are inserting after
-                               $destL10nRecords = BackendUtility::getRecordsByField($table, $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], abs($destPid), $where);
-                               // Index the localized record uids by language
-                               if (is_array($destL10nRecords)) {
-                                       foreach ($destL10nRecords as $record) {
-                                               $localizedDestPids[$record[$GLOBALS['TCA'][$table]['ctrl']['languageField']]] = -$record['uid'];
-                                       }
-                               }
-                       }
-                       // Copy the localized records after the corresponding localizations of the destination record
-                       foreach ($l10nRecords as $record) {
-                               $localizedDestPid = (int)$localizedDestPids[$record[$GLOBALS['TCA'][$table]['ctrl']['languageField']]];
-                               if ($localizedDestPid < 0) {
-                                       $this->copyRecord($table, $record['uid'], $localizedDestPid, $first, $overrideValues, $excludeFields, $record[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
-                               } else {
-                                       $this->copyRecord($table, $record['uid'], $destPid < 0 ? $tscPID : $destPid, $first, $overrideValues, $excludeFields, $record[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
-                               }
-                       }
-               }
-       }
-
-       /*********************************************
-        *
-        * Cmd: Moving, Localizing
-        *
-        ********************************************/
-       /**
-        * Moving single records
-        *
-        * @param string $table Table name to move
-        * @param int $uid Record uid to move
-        * @param int $destPid Position to move to: $destPid: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
-        * @return void
-        */
-       public function moveRecord($table, $uid, $destPid) {
-               if ($GLOBALS['TCA'][$table]) {
-                       // In case the record to be moved turns out to be an offline version,
-                       // we have to find the live version and work on that one (this case
-                       // happens for pages with "branch" versioning type)
-                       // @deprecated note: as "branch" versioning is deprecated since TYPO3 4.2, this
-                       // functionality will be removed in TYPO3 4.7 (note by benni: a hook could replace this)
-                       if ($lookForLiveVersion = BackendUtility::getLiveVersionOfRecord($table, $uid, 'uid')) {
-                               $uid = $lookForLiveVersion['uid'];
-                       }
-                       // Initialize:
-                       $destPid = (int)$destPid;
-                       // Get this before we change the pid (for logging)
-                       $propArr = $this->getRecordProperties($table, $uid);
-                       $moveRec = $this->getRecordProperties($table, $uid, TRUE);
-                       // This is the actual pid of the moving to destination
-                       $resolvedPid = $this->resolvePid($table, $destPid);
-                       // Finding out, if the record may be moved from where it is. If the record is a non-page, then it depends on edit-permissions.
-                       // If the record is a page, then there are two options: If the page is moved within itself, (same pid) it's edit-perms of the pid. If moved to another place then its both delete-perms of the pid and new-page perms on the destination.
-                       if ($table != 'pages' || $resolvedPid == $moveRec['pid']) {
-                               // Edit rights for the record...
-                               $mayMoveAccess = $this->checkRecordUpdateAccess($table, $uid);
-                       } else {
-                               $mayMoveAccess = $this->doesRecordExist($table, $uid, 'delete');
-                       }
-                       // Finding out, if the record may be moved TO another place. Here we check insert-rights (non-pages = edit, pages = new), unless the pages are moved on the same pid, then edit-rights are checked
-                       if ($table != 'pages' || $resolvedPid != $moveRec['pid']) {
-                               // Insert rights for the record...
-                               $mayInsertAccess = $this->checkRecordInsertAccess($table, $resolvedPid, 4);
-                       } else {
-                               $mayInsertAccess = $this->checkRecordUpdateAccess($table, $uid);
-                       }
-                       // Checking if there is anything else disallowing moving the record by checking if editing is allowed
-                       $fullLanguageCheckNeeded = $table != 'pages';
-                       $mayEditAccess = $this->BE_USER->recordEditAccessInternals($table, $uid, FALSE, FALSE, $fullLanguageCheckNeeded);
-                       // If moving is allowed, begin the processing:
-                       if ($mayEditAccess) {
-                               if ($mayMoveAccess) {
-                                       if ($mayInsertAccess) {
-                                               $recordWasMoved = FALSE;
-                                               // Move the record via a hook, used e.g. for versioning
-                                               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'])) {
-                                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'] as $classRef) {
-                                                               $hookObj = GeneralUtility::getUserObj($classRef);
-                                                               if (method_exists($hookObj, 'moveRecord')) {
-                                                                       $hookObj->moveRecord($table, $uid, $destPid, $propArr, $moveRec, $resolvedPid, $recordWasMoved, $this);
-                                                               }
-                                                       }
-                                               }
-                                               // Move the record if a hook hasn't moved it yet
-                                               if (!$recordWasMoved) {
-                                                       $this->moveRecord_raw($table, $uid, $destPid);
-                                               }
-                                       } elseif ($this->enableLogging) {
-                                               $this->log($table, $uid, 4, 0, 1, 'Attempt to move record \'%s\' (%s) without having permissions to insert.', 14, array($propArr['header'], $table . ':' . $uid), $propArr['event_pid']);
-                                       }
-                               } elseif ($this->enableLogging) {
-                                       $this->log($table, $uid, 4, 0, 1, 'Attempt to move record \'%s\' (%s) without having permissions to do so.', 14, array($propArr['header'], $table . ':' . $uid), $propArr['event_pid']);
-                               }
-                       } elseif ($this->enableLogging) {
-                               $this->log($table, $uid, 4, 0, 1, 'Attempt to move record "%s" (%s) without having permissions to do so. [' . $this->BE_USER->errorMsg . ']', 14, array($propArr['header'], $table . ':' . $uid), $propArr['event_pid']);
-                       }
-               }
-       }
-
-       /**
-        * Moves a record without checking security of any sort.
-        * USE ONLY INTERNALLY
-        *
-        * @param string $table Table name to move
-        * @param int $uid Record uid to move
-        * @param int $destPid Position to move to: $destPid: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
-        * @return void
-        * @see moveRecord()
-        */
-       public function moveRecord_raw($table, $uid, $destPid) {
-               $sortRow = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
-               $origDestPid = $destPid;
-               // This is the actual pid of the moving to destination
-               $resolvedPid = $this->resolvePid($table, $destPid);
-               // Checking if the pid is negative, but no sorting row is defined. In that case, find the correct pid. Basically this check make the error message 4-13 meaning less... But you can always remove this check if you prefer the error instead of a no-good action (which is to move the record to its own page...)
-               // $destPid>=0 because we must correct pid in case of versioning "page" types.
-               if ($destPid < 0 && !$sortRow || $destPid >= 0) {
-                       $destPid = $resolvedPid;
-               }
-               // Get this before we change the pid (for logging)
-               $propArr = $this->getRecordProperties($table, $uid);
-               $moveRec = $this->getRecordProperties($table, $uid, TRUE);
-               // Prepare user defined objects (if any) for hooks which extend this function:
-               $hookObjectsArr = array();
-               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'])) {
-                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'] as $classRef) {
-                               $hookObjectsArr[] = GeneralUtility::getUserObj($classRef);
-                       }
-               }
-               // Timestamp field:
-               $updateFields = array();
-               if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
-                       $updateFields[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
-               }
-               // Insert as first element on page (where uid = $destPid)
-               if ($destPid >= 0) {
-                       if ($table != 'pages' || $this->destNotInsideSelf($destPid, $uid)) {
-                               // Clear cache before moving
-                               $this->registerRecordIdForPageCacheClearing($table, $uid);
-                               // Setting PID
-                               $updateFields['pid'] = $destPid;
-                               // Table is sorted by 'sortby'
-                               if ($sortRow) {
-                                       $sortNumber = $this->getSortNumber($table, $uid, $destPid);
-                                       $updateFields[$sortRow] = $sortNumber;
-                               }
-                               // Check for child records that have also to be moved
-                               $this->moveRecord_procFields($table, $uid, $destPid);
-                               // Create query for update:
-                               $this->databaseConnection->exec_UPDATEquery($table, 'uid=' . (int)$uid, $updateFields);
-                               // Check for the localizations of that element
-                               $this->moveL10nOverlayRecords($table, $uid, $destPid, $destPid);
-                               // Call post processing hooks:
-                               foreach ($hookObjectsArr as $hookObj) {
-                                       if (method_exists($hookObj, 'moveRecord_firstElementPostProcess')) {
-                                               $hookObj->moveRecord_firstElementPostProcess($table, $uid, $destPid, $moveRec, $updateFields, $this);
-                                       }
-                               }
-                               if ($this->enableLogging) {
-                                       // Logging...
-                                       $oldpagePropArr = $this->getRecordProperties('pages', $propArr['pid']);
-                                       if ($destPid != $propArr['pid']) {
-                                               // Logged to old page
-                                               $newPropArr = $this->getRecordProperties($table, $uid);
-                                               $newpagePropArr = $this->getRecordProperties('pages', $destPid);