Skip to content

Commit

Permalink
Convert the 2-char-string "\n" to true return or html BR when importi…
Browse files Browse the repository at this point in the history
…ng a survey from CSV

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2467 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Thibault Le Meur committed Mar 1, 2007
1 parent 115054b commit ced3484
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions admin/importsurvey.php
Expand Up @@ -527,7 +527,7 @@ function array_combine($a, $b) {

$values=array_values($surveyrowdata);
$values=array_map(array(&$connect, "qstr"),$values); // quote everything accordingly
$insert = "insert INTO {$dbprefix}surveys (".implode(',',array_keys($surveyrowdata)).") VALUES (".implode(',',$values).")"; //handle db prefix
$insert = "INSERT INTO {$dbprefix}surveys (".implode(',',array_keys($surveyrowdata)).") VALUES (".implode(',',$values).")"; //handle db prefix
$iresult = $connect->Execute($insert) or die("<br />".$clang->gT("Import of this survey file failed")."<br />\n<font size='1'>[$insert]</font><hr>$surveyarray[0]<br /><br />\n" . $connect->ErrorMsg());

$oldsid=$surveyid;
Expand All @@ -539,11 +539,15 @@ function array_combine($a, $b) {
unset($surveylsarray[0]);
foreach ($surveylsarray as $slsrow) {
$fieldcontents=convertCSVRowToArray($slsrow,',','"');
$surveylsrowdata=array_combine($fieldorders,$fieldcontents);
$surveylsrowdata=array_combine($fieldorders,$fieldcontents);
// convert back the '\'.'n' cahr from the CSV file to true return char "\n"
$surveylsrowdata=array_map('convertCsvreturn2return', $surveylsrowdata);
// Convert the \n return char from welcometext to <br />
$surveylsrowdata['surveyls_welcometext'] = str_replace("\n", "<br />", $surveylsrowdata['surveyls_welcometext']);
$surveylsrowdata['surveyls_survey_id']=$newsid;
$newvalues=array_values($surveylsrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lsainsert = "insert INTO {$dbprefix}surveys_languagesettings (".implode(',',array_keys($surveylsrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$lsainsert = "INSERT INTO {$dbprefix}surveys_languagesettings (".implode(',',array_keys($surveylsrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$lsiresult=$connect->Execute($lsainsert) or die("<br />".$clang->gT("Import of this survey file failed")."<br />\n<font size='1'>[$lsainsert]</font><hr><br />\n" . $connect->ErrorMsg() );
}

Expand Down Expand Up @@ -1033,4 +1037,9 @@ function convertToArray($stringtoconvert, $seperator, $start, $end)
return $resultarray;
}

function convertCsvreturn2return($string)
{
return str_replace('\n', "\n", $string);
}

?>

0 comments on commit ced3484

Please sign in to comment.