Skip to content
This repository was archived by the owner on Jan 1, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions system/modules/tabimporter/Tabimporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ public function runStep($intStep, $line=false)
elseif(in_array('missing',$arrTableimport['deleteOnStart']) && is_array($arrTableimport['existentKeysSource']) && is_array($arrTableimport['existentKeysTarget']))
{
$arrToDelete=array_diff($arrTableimport['existentKeysTarget'],$arrTableimport['existentKeysSource']);
if(count($arrToDelete>0))
if(count($arrToDelete)>0)
{
$arrCheck = $this->performSQL("DELETE FROM ".$arrTableimport['targetTable']."_tabimport WHERE ".$arrTableimport['deleteKeyField']." IN ('".implode('\',\'',$arrToDelete)."')",array(),false);
$arrCheck = $this->performSQL("DELETE FROM ".$arrTableimport['targetTable']."_tabimport WHERE ".$arrTableimport['uniqueTarget']." IN ('".implode('\',\'',$arrToDelete)."')",array(),false);
$this->updateStatus($arrCheck['result'], $objSteps->abortOnError,
$objSteps->title,
sprintf($GLOBALS['TL_LANG']['tl_tabimporter']['missing_ok'],$arrTableimport['targetTable']),
Expand Down Expand Up @@ -470,9 +470,9 @@ public function runStep($intStep, $line=false)
{
$arrNotExistent=array_diff($arrTableimport['existentKeysSource'],$arrTableimport['existentKeysTarget']);
$arrToDelete=array_diff($arrTableimport['existentKeysTarget'],$arrNotExistent);
if(count($arrToDelete>0))
if(count($arrToDelete)>0)
{
$arrCheck = $this->performSQL("DELETE FROM ".$arrTableimport['targetTable']."_tabimport WHERE ".$arrTableimport['deleteKeyField']." IN ('".implode('\',\'',$arrToDelete)."')",array(),false);
$arrCheck = $this->performSQL("DELETE FROM ".$arrTableimport['targetTable']."_tabimport WHERE ".$arrTableimport['uniqueTarget']." IN ('".implode('\',\'',$arrToDelete)."')",array(),false);
$this->updateStatus($arrCheck['result'], $objSteps->abortOnError,
$objSteps->title,
sprintf($GLOBALS['TL_LANG']['tl_tabimporter']['existent_ok'],$arrTableimport['targetTable']),
Expand Down Expand Up @@ -955,7 +955,7 @@ public function getExistentKeysTarget($arrTableimport)
}
else
{
$objKeys = $this->Database->prepare("SELECT ".$arrTableimport['uniqueTarget']." FROM ".$arrTableimport['targetTable']." WHERE ".$arrTableimport['uniqueTarget']." IN ('".implode('\',\'',$arrTableimport['existentKeysSource'])."')")
$objKeys = $this->Database->prepare("SELECT ".$arrTableimport['uniqueTarget']." FROM ".$arrTableimport['targetTable']." ")
->executeUncached();

$arrKeys = $objKeys->fetchEach($arrTableimport['uniqueTarget']);
Expand Down
29 changes: 17 additions & 12 deletions system/modules/tabimporter/TabimporterSource_csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,24 @@ public function getAllData($arrTableimport)
for($i=0;$i < sizeof($arrContent); $i++)
{
$arrContent[$i] = $this->String->splitCsv($arrContent[$i], $strDelimiter);

// get field names ba first line
if($arrTableimport['hasFieldnames'])
$arrNewContent = array();

//skip first row with field names
if ($i == 0 && $arrTableimport['hasFieldnames']) continue;

// get field names of first line or set key to field_x
for($ii=0;$ii<sizeof($arrContent[$i]);$ii++)
{
for($ii=0;$ii<sizeof($arrContent[$i]);$ii++)

if($arrTableimport['hasFieldnames'])
{
$arrContent[$i][$arrContent[0][$ii]] = $arrContent[$i][$ii];
if($i>0)
{
unset($arrContent[$i][$ii]);
}
}
}
$arrNewContent[$arrContent[0][$ii]] = $arrContent[$i][$ii];
}else{
$arrNewContent['field_'.$ii] = $arrContent[$i][$ii];
}
}
$arrContent[$i] = $arrNewContent;

}

Expand Down Expand Up @@ -126,7 +131,7 @@ public function getExistentKeysSource($arrTableimport)
$arrKeys[] =
$arrData[($arrTableimport['hasFieldnames'] ?
$arrTableimport['uniqueSource'] :
str_replace('field_','',$arrTableimport['uniqueSource']))];
$arrTableimport['uniqueSource'])];
}

if(!$arrKeys || count($arrKeys)<1)
Expand Down