$filename = "survey_" . $surveyid . "_R_syntax_file.R";
    $exportroutput .= "<input type='hidden' name='sid' value='{$surveyid}' />\n" . "<input type='hidden' name='action' value='exportr' /></li>\n" . "<li><label for='dlstructure'>" . $clang->gT("Step 1:") . "</label><input type='submit' name='dlstructure' id='dlstructure' value='" . $clang->gT("Export R syntax file") . "'/></li>\n" . "<li><label for='dldata'/>" . $clang->gT("Step 2:") . "</label><input type='submit' name='dldata' id='dldata' value='" . $clang->gT("Export .csv data file") . "'/></li></ul>\n" . "</form>\n" . "<p><div class='messagebox ui-corner-all'><div class='header ui-widget-header'>" . $clang->gT("Instructions for the impatient") . "</div>" . "<br/><ol style='margin:0 auto; font-size:8pt;'>" . "<li>" . $clang->gT("Download the data and the syntax file.") . "</li>" . "<li>" . $clang->gT("Save both of them on the R working directory (use getwd() and setwd() on the R command window to get and set it)") . ".</li>" . "<li>" . sprintf($clang->gT("digit:       source(\"%s\", encoding = \"UTF-8\")        on the R command window"), $filename) . "</li>" . "</ol><br />" . $clang->gT("Your data should be imported now, the data.frame is named \"data\", the variable.labels are attributes of data (\"attributes(data)\$variable.labels\"), like for foreign:read.spss.") . "</div>";
} else {
    // Get Base language:
    $language = GetBaseLanguageFromSurveyID($surveyid);
    $clang = new limesurvey_lang($language);
    require_once "export_data_functions.php";
}
if ($subaction == 'dldata') {
    header("Content-Disposition: attachment; filename=survey_" . $surveyid . "_R_data_file.csv");
    header("Content-type: text/comma-separated-values; charset=UTF-8");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    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
    exit;
}
if ($subaction == 'dlstructure') {
    header("Content-Disposition: attachment; filename=survey_" . $surveyid . "_R_syntax_file.R");
    header("Content-type: application/download; charset=UTF-8");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: public");
    echo $headerComment;
    echo "data <- read.table(\"survey_" . $surveyid . "_R_data_file.csv\", sep=\",\", quote = \"'\", " . "na.strings=c(\"\",\"\\\"\\\"\"), " . "stringsAsFactors=FALSE)\n\n";
    //  echo "names(data) <- paste(\"V\",1:dim(data)[2],sep=\"\")\n\n";
    // Build array that has to be returned
    $fields = spss_fieldmap("V");
    //Now get the query string with all fields to export
    $query = spss_getquery();
Example #2
0
} else {
    // Get Base language:
    $language = GetBaseLanguageFromSurveyID($surveyid);
    $clang = new limesurvey_lang($language);
    require_once "export_data_functions.php";
}
if ($subaction == 'dldata') {
    header("Content-Disposition: attachment; filename=survey_" . $surveyid . "_SPSS_data_file.dat");
    header("Content-type: text/comma-separated-values; charset=UTF-8");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: public");
    if ($spssver == 2) {
        echo "";
    }
    $na = "";
    spss_export_data($na);
    exit;
}
if ($subaction == 'dlstructure') {
    header("Content-Disposition: attachment; filename=survey_" . $surveyid . "_SPSS_syntax_file.sps");
    header("Content-type: application/download; charset=UTF-8");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: public");
    // Build array that has to be returned
    $fields = spss_fieldmap();
    //Now get the query string with all fields to export
    $query = spss_getquery();
    $result = db_execute_num($query) or safe_die("Couldn't get results<br />{$query}<br />" . $connect->ErrorMsg());
    //Checked
    $num_fields = $result->FieldCount();
    //Now we check if we need to adjust the size of the field or the type of the field
    // Get Base language:
    $language = GetBaseLanguageFromSurveyID($surveyid);
    $clang = new limesurvey_lang($language);
    require_once ("export_data_functions.php");
}


if  ($subaction=='dldata')
{
    header("Content-Disposition: attachment; filename=survey_".$surveyid."_data_file.csv");
    header("Content-type: text/comma-separated-values; charset=UTF-8");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    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

    exit;
}

if  ($subaction=='dlstructure')
{
    header("Content-Disposition: attachment; filename=Surveydata_syntax.R");
    header("Content-type: application/download; charset=UTF-8");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: public");

  echo $headerComment;
  echo "data <- read.table(\"survey_".$surveyid
      ."_data_file.csv\", sep=\",\", quote = \"'\", "
      ."na.strings=c(\"\",\"\\\"\\\"\"), "