From 09cbf63c5aa0bc9cf2a0cae959e13c1fedc180ec Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Fri, 4 Sep 2015 08:40:32 +0000 Subject: [PATCH] CSV import GUI: now matching more representations (object id and external fields that are external keys) SVN:trunk[3714] --- pages/ajax.csvimport.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pages/ajax.csvimport.php b/pages/ajax.csvimport.php index 124f9c44e..234c537e5 100644 --- a/pages/ajax.csvimport.php +++ b/pages/ajax.csvimport.php @@ -119,7 +119,7 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo // A star character at the end can be used to indicate a mandatory field $sFieldName = $aMatches[1].'->'.$aMatches[2]; } - if ($sFieldName == 'id') + if (($sFieldName == 'id') || ($sFieldName == Dict::S('UI:CSVImport:idField'))) { $sFieldCode = 'id'; } @@ -132,7 +132,7 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo $sStar = ''; if ($oAttDef->IsExternalKey()) { - if ( ($sFieldName == $oAttDef->GetLabel()) || ($sFieldName == $sAttCode)) + if (($sFieldName == $oAttDef->GetLabel()) || ($sFieldName == $sAttCode)) { $sFieldCode = $sAttCode; } @@ -152,19 +152,25 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode)) { $bExtKey = $oTargetAttDef->IsExternalKey(); - $sSuffix = ''; + $aSignatures = array(); + $aSignatures[] = $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel(); + $aSignatures[] = $sAttCode.'->'.$sTargetAttCode; if ($bExtKey) { - $sSuffix = '->id'; + $aSignatures[] = $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel().'->id'; + $aSignatures[] = $sAttCode.'->'.$sTargetAttCode.'->id'; } if ($bAdvancedMode || !$bExtKey) { // When not in advanced mode do not allow to use reconciliation keys (on external keys) if they are themselves external keys ! $aChoices[$sAttCode.'->'.$sTargetAttCode] = MetaModel::GetLabel($sClassName, $sAttCode.'->'.$sTargetAttCode, true); - if ((strcasecmp($sFieldName, $oAttDef->GetLabel().'->'.$oTargetAttDef->GetLabel().$sSuffix) == 0) || (strcasecmp($sFieldName, ($sAttCode.'->'.$sTargetAttCode.$sSuffix)) == 0) ) + foreach ($aSignatures as $sSignature) { - $sFieldCode = $sAttCode.'->'.$sTargetAttCode; + if (strcasecmp($sFieldName, $sSignature) == 0) + { + $sFieldCode = $sAttCode.'->'.$sTargetAttCode; + } } } }