You are here

public function webform_exporter_delimited::set_headers in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform_export.inc \webform_exporter_delimited::set_headers()
  2. 6.3 includes/webform.export.inc \webform_exporter_delimited::set_headers()
  3. 6.2 webform_export.inc \webform_exporter_delimited::set_headers()
  4. 7.3 includes/webform.export.inc \webform_exporter_delimited::set_headers()

Provide headers to the page when an export file is being downloaded.

Parameters

string $filename: The name of the file being downloaded, for example, export.xls.

Overrides webform_exporter::set_headers

1 method overrides webform_exporter_delimited::set_headers()
webform_exporter_excel_delimited::set_headers in includes/exporters/webform_exporter_excel_delimited.inc
Provide headers to the page when an export file is being downloaded.

File

includes/exporters/webform_exporter_delimited.inc, line 43

Class

webform_exporter_delimited
Webform exporter for creating CSV/TSV delimited files.

Code

public function set_headers($filename) {
  parent::set_headers($filename);

  // Convert tabs.
  if ($this->delimiter == "\t") {
    $content_type = 'text/tab-separated-values';
  }
  else {
    $content_type = 'text/csv';
  }
  drupal_add_http_header('Content-Type', $content_type);
  drupal_add_http_header('Content-Disposition', 'attachment; filename=' . $this
    ->get_filename($filename));
}