fix filename on CSV too

This commit is contained in:
james 2005-04-22 19:35:39 +00:00
parent 795ea89ae0
commit 424274b52c

View File

@ -27,6 +27,7 @@ class lcsv
var $csvdata; var $csvdata;
var $str_separator; var $str_separator;
var $str_newline; var $str_newline;
var $page_subheader;
function separator() function separator()
{ {
@ -121,17 +122,19 @@ class lcsv
{ {
if($this->csvdata) if($this->csvdata)
{ {
$filename=strtolower($this->page_subheader);
$filename=ereg_replace("[^a-z0-9]","_",$filename);
//header("Content-type: application/csv"); //header("Content-type: application/csv");
header("Content-type: text/x-csv"); header("Content-type: text/x-csv");
header("Content-disposition: inline; filename=sfiab_".$this->page_subtitle.".csv"); header("Content-disposition: inline; filename=sfiab_".$filename.".csv");
header("Content-length: ".strlen($this->csvdata)); header("Content-length: ".strlen($this->csvdata));
echo $this->csvdata; echo $this->csvdata;
} }
} }
function lcsv($subtitle,$sep=",",$nl="\r\n") function lcsv($subheader,$sep=",",$nl="\r\n")
{ {
$this->page_subtitle=$subtitle; $this->page_subheader=$subheader;
$this->setSeparator($sep); $this->setSeparator($sep);
$this->setNewline($nl); $this->setNewline($nl);