Skip to content

Commit

Permalink
MOD: Export as "Word Document" now exports a more sensibly styled tex…
Browse files Browse the repository at this point in the history
…t output - each record starts with "NEW RECORD" and then presents the question on one line, the answer indented on the next line, and then two lines until the next question/answer. Useful for producing "paper" style exports of survey results.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@1178 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Sep 12, 2004
1 parent 829babd commit 7e35f5e
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions admin/export.php
Expand Up @@ -257,7 +257,7 @@
{
header("Content-Disposition: attachment; filename=survey.doc");
header("Content-type: application/vnd.ms-word");
$s="\t";
$s="\n\n";
}
elseif ($type == "xls")
{
Expand Down Expand Up @@ -522,7 +522,22 @@
}
$firstline = trim($firstline);
$firstline .= "\n";
echo $firstline; //Sending the header row

if ($type == "doc")
{
$flarray=explode($s, $firstline);
$fli=0;
foreach ($flarray as $fl)
{
$fieldmap[$fli]['title']=$fl;
$fli++;
}
//print_r($fieldmap);
}
else
{
echo $firstline; //Sending the header row
}


//Now dump the data
Expand Down Expand Up @@ -586,6 +601,10 @@
$fieldcount = mysql_num_fields($dresult);
while ($drow = mysql_fetch_array($dresult))
{
if ($type == "doc")
{
echo "\n\n\nNEW RECORD\n";
}
if (!ini_get('safe_mode'))
{
set_time_limit(3); //Give each record 3 seconds
Expand All @@ -602,6 +621,10 @@
$fsid=$fielddata['sid'];
$fgid=$fielddata['gid'];
$faid=$fielddata['aid'];
if ($type == "doc")
{
$ftitle=$fielddata['title'];
}
$qq = "SELECT lid, other FROM {$dbprefix}questions WHERE qid=$fqid";
$qr = mysql_query($qq) or die("Error selecting type and lid from questions table.<br />".$qq."<br />".mysql_error());
while ($qrow = mysql_fetch_array($qr, MYSQL_ASSOC))
Expand All @@ -610,13 +633,19 @@
else
{
$fsid=""; $fgid=""; $fqid="";
if ($type == "doc")
{
$fielddata=arraySearchByKey($fieldinfo, $fieldmap, "fieldname", 1);
$ftitle=$fielddata['title'].":";
}
}
if (!$fqid) {$fqid = "0";}
if ($fqid == 0)
{
$ftype = "-";
}
if ($type == "csv") {echo "\"";}
if ($type == "doc") {echo "\n$ftitle\n\t";}
switch ($ftype)
{
case "-": //JASONS SPECIAL TYPE
Expand Down

0 comments on commit 7e35f5e

Please sign in to comment.