Skip to content

Commit

Permalink
Fixed issue #5126: CSV export - no new lines
Browse files Browse the repository at this point in the history
Dev This time for real

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@11222 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Oct 20, 2011
1 parent c58cb7f commit 0d2a37e
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 222 deletions.
38 changes: 5 additions & 33 deletions admin/export_data_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,13 @@
* @param $string
* @return $string
*/
function strip_tags_full($string, $is_csv=false ) {
function strip_tags_full($string) {
$string=html_entity_decode($string, ENT_QUOTES, "UTF-8");
//combining these into one mb_ereg_replace call ought to speed things up
//$string = str_replace(array("\r\n","\r","\n",'-oth-'), '', $string);
//The backslashes must be escaped twice, once for php, and again for the regexp
//$string = str_replace("'|\\\\'", "'", $string);
if($is_csv==true)
return FlattenText($string,true);
else
return FlattenText($string);
}

/**
* Strips html tags
*
* @param $string
* @return $string
*/
function strip_tags_full_save_newline($string) {
$string=html_entity_decode($string, ENT_QUOTES, "UTF-8");
//combining these into one mb_ereg_replace call ought to speed things up
//$string = str_replace(array("\r\n","\r","\n",'-oth-'), '', $string);
//The backslashes must be escaped twice, once for php, and again for the regexp
//$string = str_replace("'|\\\\'", "'", $string);
return FlattenTextWithNewline($string);
return FlattenText($string);
}

/**
Expand All @@ -64,7 +46,7 @@ function my_is_numeric($value) {
return ($eng_or_world);
}

function spss_export_data ($na = null, $is_csv = false) {
function spss_export_data ($na = null) {
global $length_data;

// Build array that has to be returned
Expand Down Expand Up @@ -156,19 +138,9 @@ function spss_export_data ($na = null, $is_csv = false) {
echo("'0'");
}
} elseif (!$field['hide']) {
if($is_csv == true) {
$strTmp=mb_substr(strip_tags_full($row[$fieldno],true), 0, $length_data);
}
else {
$strTmp=mb_substr(strip_tags_full($row[$fieldno]), 0, $length_data);
}
$strTmp=mb_substr(strip_tags_full($row[$fieldno]), 0, $length_data);
if (trim($strTmp) != ''){
if($is_csv == true) {
$strTemp=str_replace(array("'"),array("''"),trim($strTmp));
}
else {
$strTemp=str_replace(array("'","\n","\r"),array("''",' ',' '),trim($strTmp));
}
$strTemp=str_replace(array("'","\n","\r"),array("''",' ',' '),trim($strTmp));
/*
* Temp quick fix for replacing decimal dots with comma's
if (my_is_numeric($strTemp)) {
Expand Down
2 changes: 1 addition & 1 deletion admin/export_data_r.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
header("Pragma: public");

$na=""; //change to empty string instead of two double quotes to fix warnings on NA
spss_export_data($na, true); // this true indicates that the format is .csv
spss_export_data($na);

exit;
}
Expand Down

0 comments on commit 0d2a37e

Please sign in to comment.