Skip to content

Commit

Permalink
Dev Reverting to Spreadsheet Excel Writer because phpExcel uses too m…
Browse files Browse the repository at this point in the history
…uch memory

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@10243 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Jun 9, 2011
1 parent 8dcad7f commit 7e121c1
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions admin/exportresults.php
Expand Up @@ -17,8 +17,7 @@
//Ensure script is not run directly, avoid path disclosure
include_once("login_check.php");


if (!isset($imagefiles)) {$imagefiles="./images";}
if (!isset($imageurl)) {$imageurl="./images";}
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($exportstyle)) {$exportstyle=returnglobal('exportstyle');}
if (!isset($answers)) {$answers=returnglobal('answers');}
Expand All @@ -27,12 +26,11 @@
if (!isset($convertnto2)) {$convertnto2=returnglobal('convertnto2');}
if (!isset($convertspacetous)) {$convertspacetous=returnglobal('convertspacetous');}

if (!bHasRight($surveyid, 'export'))
if (!bHasSurveyPermission($surveyid, 'responses','export'))
{
exit;
}

include_once("login_check.php");
include_once(dirname(__FILE__)."/classes/pear/Spreadsheet/Excel/Writer.php");
include_once(dirname(__FILE__)."/classes/tcpdf/extensiontcpdf.php");

Expand All @@ -56,8 +54,8 @@


$afieldcount = count($excesscols);
$exportoutput .= browsemenubar($clang->gT("Export Results"));
$exportoutput .= "<div class='header'>".$clang->gT("Export results").'</div>'
$exportoutput .= browsemenubar($clang->gT("Export results"));
$exportoutput .= "<div class='header ui-widget-header'>".$clang->gT("Export results").'</div>'
."<div class='wrap2columns'>\n"
."<form id='resultexport' action='$scriptname?action=exportresults' method='post'><div class='left'>\n";

Expand Down Expand Up @@ -190,13 +188,13 @@

if ($afieldcount > 255)
{
$exportoutput .= "\t<img src='$imagefiles/help.gif' alt='".$clang->gT("Help")."' onclick='javascript:alert(\""
$exportoutput .= "\t<img src='$imageurl/help.gif' alt='".$clang->gT("Help")."' onclick='javascript:alert(\""
.$clang->gT("Your survey contains more than 255 columns of responses. Spreadsheet applications such as Excel are limited to loading no more than 255. Select the columns you wish to export in the list below.","js")
."\")' />";
}
else
{
$exportoutput .= "\t<img src='$imagefiles/help.gif' alt='".$clang->gT("Help")."' onclick='javascript:alert(\""
$exportoutput .= "\t<img src='$imageurl/help.gif' alt='".$clang->gT("Help")."' onclick='javascript:alert(\""
.$clang->gT("Choose the columns you wish to export.","js")
."\")' />";
}
Expand All @@ -223,9 +221,9 @@
$exportoutput .= "<br />&nbsp;</fieldset>\n";
//OPTIONAL EXTRAS (FROM TOKENS TABLE)
// Find out if survey results are anonymous
if ($thissurvey['private'] == "N" && tableExists("tokens_$surveyid"))
if ($thissurvey['anonymized'] == "N" && tableExists("tokens_$surveyid"))
{
$exportoutput .= "<fieldset><legend>".$clang->gT("Token Control")."</legend>\n"
$exportoutput .= "<fieldset><legend>".$clang->gT("Token control")."</legend>\n"
.$clang->gT("Choose token fields").":"
."<img src='$imageurl/help.gif' alt='".$clang->gT("Help")."' onclick='javascript:alert(\""
.$clang->gT("Your survey can export associated token data with each response. Select any additional fields you would like to export.","js")
Expand Down Expand Up @@ -266,7 +264,7 @@
$attributeFields=array_keys($attributeFieldAndNames);
}

switch ( $_POST["type"] ) { // this is a step to register_globals = false ;c)
switch ( $_POST["type"] ) {
case "doc":
header("Content-Disposition: attachment; filename=results-survey".$surveyid.".doc");
header("Content-type: application/vnd.ms-word");
Expand Down Expand Up @@ -426,18 +424,18 @@

if ($fieldinfo == "lastname")
{
if ($type == "csv") {$firstline .= "\"".$elang->gT("Last Name")."\"$separator";}
else {$firstline .= $elang->gT("Last Name")."$separator";}
if ($type == "csv") {$firstline .= "\"".$elang->gT("Last name")."\"$separator";}
else {$firstline .= $elang->gT("Last name")."$separator";}
}
elseif ($fieldinfo == "firstname")
{
if ($type == "csv") {$firstline .= "\"".$elang->gT("First Name")."\"$separator";}
else {$firstline .= $elang->gT("First Name")."$separator";}
if ($type == "csv") {$firstline .= "\"".$elang->gT("First name")."\"$separator";}
else {$firstline .= $elang->gT("First name")."$separator";}
}
elseif ($fieldinfo == "email")
{
if ($type == "csv") {$firstline .= "\"".$elang->gT("Email Address")."\"$separator";}
else {$firstline .= $elang->gT("Email Address")."$separator";}
if ($type == "csv") {$firstline .= "\"".$elang->gT("Email address")."\"$separator";}
else {$firstline .= $elang->gT("Email address")."$separator";}
}
elseif ($fieldinfo == "token")
{
Expand Down Expand Up @@ -471,13 +469,13 @@
}
elseif ($fieldinfo == "ipaddr")
{
if ($type == "csv") {$firstline .= "\"".$elang->gT("IP-Address")."\"$separator";}
else {$firstline .= $elang->gT("IP-Address")."$separator";}
if ($type == "csv") {$firstline .= "\"".$elang->gT("IP address")."\"$separator";}
else {$firstline .= $elang->gT("IP address")."$separator";}
}
elseif ($fieldinfo == "refurl")
{
if ($type == "csv") {$firstline .= "\"".$elang->gT("Referring URL")."\"$separator";}
else {$firstline .= $elang->gT("Referring URL")."$separator";}
if ($type == "csv") {$firstline .= "\"".$elang->gT("Referrer URL")."\"$separator";}
else {$firstline .= $elang->gT("Referrer URL")."$separator";}
}
elseif ($fieldinfo == "lastpage")
{
Expand Down Expand Up @@ -754,19 +752,19 @@
$ftitle=$elang->gT("Date Started").":";
break;
case "ipaddr":
$ftitle=$elang->gT("IP Address").":";
$ftitle=$elang->gT("IP address").":";
break;
case "completed":
$ftitle=$elang->gT("Completed").":";
break;
case "refurl":
$ftitle=$elang->gT("Referring URL").":";
$ftitle=$elang->gT("Referrer URL").":";
break;
case "firstname":
$ftitle=$elang->gT("First Name").":";
$ftitle=$elang->gT("First name").":";
break;
case "lastname":
$ftitle=$elang->gT("Last Name").":";
$ftitle=$elang->gT("Last name").":";
break;
case "email":
$ftitle=$elang->gT("Email").":";
Expand Down Expand Up @@ -798,7 +796,7 @@
}
if ($fqid == 0)
{
$ftype = "-"; // This is set if it not a normal answer field, but something like tokenID, First Name etc
$ftype = "-"; // This is set if it not a normal answer field, but something like tokenID, First name etc
}
if ($type == "csv") {$exportoutput .= "\"";}
if ($type == "doc") {$exportoutput .= "<td>$ftitle</td><td>";}
Expand Down Expand Up @@ -1099,8 +1097,8 @@
}
if ($type=='xls')
{
// echo memory_get_peak_usage(true); die();
$workbook->close();
// echo memory_get_peak_usage(true); die();
}
else if($type=='pdf')
{
Expand Down

0 comments on commit 7e121c1

Please sign in to comment.