Author: spadkins
Date: Wed Jun 14 11:28:53 2006
New Revision: 6503
Modified:
p5ee/trunk/App-Widget/lib/App/Widget.pm
Log:
Added the ablity to usr a differnt filename in set_alternative_content
Modified: p5ee/trunk/App-Widget/lib/App/Widget.pm
==============================================================================
--- p5ee/trunk/App-Widget/lib/App/Widget.pm (original)
+++ p5ee/trunk/App-Widget/lib/App/Widget.pm Wed Jun 14 11:28:53 2006
@@ -269,9 +269,10 @@
sub set_alternative_content {
&App::sub_entry if ($App::trace);
- my ($self, $content, $extension) = @_;
+ my ($self, $content, $extension, $filename) = @_;
$self->{content} = $content;
$self->{extension} = $extension;
+ $self->{filename} = $filename;
&App::sub_exit() if ($App::trace);
}
@@ -293,19 +294,21 @@
=cut
-my %content_type = (
- html => "text/html",
- txt => "text/plain",
- pdf => "application/pdf\nContent-disposition: attachment; filename=\"data.pdf\"",
- xls => "application/vnd.ms-excel\nContent-disposition: attachment; filename=\"data.xls\"",
- xml => "application/xml",
- csv => "application/octet-stream\nContent-disposition: attachment; filename=\"data.csv\"",
- bin => "application/octet-stream\nContent-disposition: attachment; filename=\"data.bin\"",
-);
-
sub content_type {
&App::sub_entry if ($App::trace);
my ($self) = @_;
+
+ my $filename = $self->{filename} || "data";
+ my %content_type = (
+ html => "text/html",
+ txt => "text/plain",
+ pdf => "application/pdf\nContent-disposition: attachment; filename=\"$filename.pdf\"",
+ xls => "application/vnd.ms-excel\nContent-disposition: attachment; filename=\"$filename.xls\"",
+ xml => "application/xml",
+ csv => "application/octet-stream\nContent-disposition: attachment; filename=\"$filename.csv\"",
+ bin => "application/octet-stream\nContent-disposition: attachment; filename=\"$filename.bin\"",
+ );
+
my $extension = $self->{extension} || "html";
delete $self->{extension} if (!defined $self->{content});
my $content_type = $content_type{$extension};
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.