From 52f68059d9a4b3e3f1fcccbe9004d100a7a13397 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 7 May 2012 21:19:16 +1200 Subject: [PATCH] ENHANCEMENT: show link to file download in CSV export. Fixes #32 --- code/formfields/SubmittedFormReportField.php | 2 +- code/model/submissions/SubmittedFileField.php | 9 +++++++++ code/model/submissions/SubmittedFormField.php | 12 +++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/code/formfields/SubmittedFormReportField.php b/code/formfields/SubmittedFormReportField.php index 7b24597..9016d9b 100755 --- a/code/formfields/SubmittedFormReportField.php +++ b/code/formfields/SubmittedFormReportField.php @@ -109,7 +109,7 @@ class SubmittedFormReportField extends FormField { $row = array(); foreach($fields as $field) { - $row[$field->Name] = $field->Value; + $row[$field->Name] = $field->getExportValue(); } $row['Submitted'] = $submission->Created; diff --git a/code/model/submissions/SubmittedFileField.php b/code/model/submissions/SubmittedFileField.php index c57a9b0..d2f4a75 100755 --- a/code/model/submissions/SubmittedFileField.php +++ b/code/model/submissions/SubmittedFileField.php @@ -28,6 +28,15 @@ class SubmittedFileField extends SubmittedFormField { return false; } + + /** + * Return the value for this field in the CSV export + * + * @return String + */ + public function getExportValue() { + return ($link = $this->getLink()) ? $link : ""; + } /** * Return the link for the file attached to this submitted form field diff --git a/code/model/submissions/SubmittedFormField.php b/code/model/submissions/SubmittedFormField.php index 4e4da48..04b3b1b 100755 --- a/code/model/submissions/SubmittedFormField.php +++ b/code/model/submissions/SubmittedFormField.php @@ -22,9 +22,19 @@ class SubmittedFormField extends DataObject { * Converts new lines (which are stored in the database text field) as * so they will output as newlines in the reports * - * @return String + * @return string */ public function getFormattedValue() { return nl2br($this->dbObject('Value')->ATT()); } + + /** + * Return the value of this submitted form field suitable for inclusion + * into the CSV + * + * @return Text + */ + public function getExportValue() { + return $this->Value; + } }