Index: Classes/Persistence/Mapper/DataMapper.php =================================================================== --- Classes/Persistence/Mapper/DataMapper.php (Revision 2075) +++ Classes/Persistence/Mapper/DataMapper.php (Arbeitskopie) @@ -187,10 +187,13 @@ $properties = $object->_getProperties(); $localizedUid = $row['_LOCALIZED_UID']; if ($localizedUid !== NULL) { - $object->_setProperty('uid', $localizedUid); - $object->_setProperty('_localizationParentUid', $row['uid']); + $object->_setProperty('uid', $row['uid']); + $object->_setProperty('_localizationUid', $localizedUid); + $object->_setProperty('_localizationLanguageUid', $row['_LOCALIZED_LANG']); } else { $object->_setProperty('uid', $row['uid']); + $object->_setProperty('_localizationUid', $row['uid']); + $object->_setProperty('_localizationLanguageUid', 0); } unset($properties['uid']); foreach ($properties as $propertyName => $propertyValue) { Index: Classes/Persistence/Mapper/DataMap.php =================================================================== --- Classes/Persistence/Mapper/DataMap.php (Revision 2075) +++ Classes/Persistence/Mapper/DataMap.php (Arbeitskopie) @@ -169,6 +169,12 @@ if ($this->hasHiddenColumn()) { $this->addColumn($this->getHiddenColumnName(), NULL, Tx_Extbase_Persistence_PropertyType::BOOLEAN); } + if($this->hasLanguageFieldColumn()) { + $this->addColumn($this->getLanguageFieldColumnName(), NULL, Tx_Extbase_Persistence_PropertyType::LONG); + } + if($this->hasLanguageOrigPointerColumn()) { + $this->addColumn($this->getLanguageOrigPointerColumnName(), NULL, Tx_Extbase_Persistence_PropertyType::LONG); + } } /** @@ -402,6 +408,51 @@ } /** + * Check wether record is translatable. + * + * @return boolean + */ + public function isTranslatable() { + return (isset($GLOBALS['TCA'][$this->tableName]['ctrl']['languageField']) && $GLOBALS['TCA'][$this->tableName]['ctrl']['languageField'] !== ''); + } + + /** + * Returns TRUE if the table has a column holding the language the record + * + * @return boolean The result + */ + public function hasLanguageFieldColumn() { + return !empty($GLOBALS['TCA'][$this->getTableName()]['ctrl']['languageField']); + } + + /** + * Returns the name of a column holding the language id of the record + * + * @return string The field name + */ + public function getLanguageFieldColumnName() { + return $GLOBALS['TCA'][$this->tableName]['ctrl']['languageField']; + } + + /** + * Returns TRUE if the table has a column holding the uid of the record which this record is a translation of + * + * @return boolean The result + */ + public function hasLanguageOrigPointerColumn() { + return !empty($GLOBALS['TCA'][$this->getTableName()]['ctrl']['transOrigPointerField']); + } + + /** + * Returns the name of a column holding the the uid of the record which this record is a translation of. + * + * @return string The field name + */ + public function getLanguageOrigPointerColumnName() { + return $GLOBALS['TCA'][$this->tableName]['ctrl']['transOrigPointerField']; + } + + /** * Returns TRUE if the table has a pid column holding the id of the page the record is virtually stored on. * Currently we don't support tables without a pid column. * Index: Classes/Persistence/Storage/Typo3DbBackend.php =================================================================== --- Classes/Persistence/Storage/Typo3DbBackend.php (Revision 2075) +++ Classes/Persistence/Storage/Typo3DbBackend.php (Arbeitskopie) @@ -890,6 +890,7 @@ if(isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField']) && $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] !== '') { if (in_array($row[$GLOBALS['TCA'][$tableName]['ctrl']['languageField']], array(-1,0))) { $row = $this->pageSelectObject->getRecordOverlay($tableName, $row, $languageUid); + $row['_LOCALIZED_LANG'] = $languageUid; } } $overlayedRows[] = $row; Index: Classes/Persistence/Backend.php =================================================================== --- Classes/Persistence/Backend.php (Revision 2075) +++ Classes/Persistence/Backend.php (Arbeitskopie) @@ -811,6 +811,23 @@ if ($object->_isNew() && $dataMap->hasPidColumn() && !isset($row['pid'])) { $row['pid'] = $this->determineStoragePageIdForNewRecord($object); } + if($dataMap->isTranslatable()) { + if($object->_isNew()) { + //TODO: Support creation of translated records + $row[$dataMap->getLanguageFieldColumnName()] = 0; + if($dataMap->hasLanguageOrigPointerColumn()) { + $row[$dataMap->getLanguageOrigPointerColumnName()] = 0; + } + } else { + // on update / insert wie need to access "the tranlated uid" + $uid = $row['uid']; + $row['uid'] = $row['_LOCALIZATION_UID']; + if($dataMap->hasLanguageOrigPointerColumn()) { + $row[$dataMap->getLanguageOrigPointerColumnName()] = $uid; + } + } + + } } /** Index: Classes/DomainObject/AbstractDomainObject.php =================================================================== --- Classes/DomainObject/AbstractDomainObject.php (Revision 2075) +++ Classes/DomainObject/AbstractDomainObject.php (Arbeitskopie) @@ -39,9 +39,9 @@ protected $uid; /** - * @var int The uid of the localization parent + * @var int The uid of the localization */ - protected $_localizationParentUid; + protected $_localizationUid; /** * TRUE if the object is a clone