[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1646] trunk/LedgerSMB/Template.pm



Revision: 1646
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1646&view=rev
Author:   tetragon
Date:     2007-09-22 10:48:38 -0700 (Sat, 22 Sep 2007)

Log Message:
-----------
Adding Content-Disposition for items with output filenames

Modified Paths:
--------------
    trunk/LedgerSMB/Template.pm

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2007-09-22 15:59:00 UTC (rev 1645)
+++ trunk/LedgerSMB/Template.pm	2007-09-22 17:48:38 UTC (rev 1646)
@@ -217,12 +217,18 @@
 	my $self = shift;
 	my $data = shift;
 	$data ||= $self->{output};
-	my $FH;
+	my $format = "LedgerSMB::Template::$self->{format}";
+	my $disposition = "\n";
+	my $name = $format->can('postprocess')->($self);
 
+	if ($name) {
+		$name =~ s#^.*/##;
+		$disposition .= qq|Content-Disposition: attachment; filename="$name"|;
+	}
 	if ($self->{mimetype} =~ /^text/) {
-		print "Content-Type: $self->{mimetype}; charset=utf-8\n\n";
+		print "Content-Type: $self->{mimetype}; charset=utf-8$disposition\n\n";
 	} else {
-		print "Content-Type: $self->{mimetype}\n\n";
+		print "Content-Type: $self->{mimetype}$disposition\n\n";
 	}
 	binmode STDOUT, ':bytes';
 	print $data;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.