TPac: One prefers to download CSV, not to display it
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 12 Oct 2011 18:04:01 +0000 (14:04 -0400)
committerDan Scott <dscott@laurentian.ca>
Thu, 13 Oct 2011 03:21:18 +0000 (23:21 -0400)
For the "Download CSV" operation in the TPac "My Lists" interface,
provoke the user's browser to download the file, rather than displaying
the file in a new tab/window.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/templates/opac/myopac/lists.tt2

index b63f89a..9952c8c 100644 (file)
@@ -1626,6 +1626,15 @@ sub load_myopac_bookbag_print {
         );
     }
 
+    # Create a reasonable filename and set the content disposition to
+    # provoke browser download dialogs.
+    (my $filename = $bbag->id . $bbag->name) =~ s/[^a-z0-9_ -]//gi;
+
+    $self->apache->headers_out->add(
+        "Content-Disposition",
+        "attachment;filename=$filename.csv"
+    );
+
     return Apache2::Const::OK;
 }
 
index 863bb1a..5615fa9 100644 (file)
@@ -99,7 +99,7 @@
                         <input type="submit" value="[% l('Delete List') %]" />
                     </div>
                 </form>
-                <form action="[% ctx.opac_root %]/myopac/list/print" method="POST" target="_blank">
+                <form action="[% ctx.opac_root %]/myopac/list/print" method="POST">
                     <div class="bookbag-controls">
                         <input type="hidden" name="list" value="[% bbag.id %]" />
                         <input type="hidden" name="sort" value="[% CGI.param('sort') | html %]" />