You are here

function views_data_export_plugin_style_export::add_http_headers in Views data export 7

Same name and namespace in other branches
  1. 6.3 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::add_http_headers()
  2. 6 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::add_http_headers()
  3. 6.2 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::add_http_headers()
  4. 7.4 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::add_http_headers()
  5. 7.3 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::add_http_headers()

Add any HTTP headers that this style plugin wants to.

File

plugins/views_data_export_plugin_style_export.inc, line 232
Plugin include file for export style plugin.

Class

views_data_export_plugin_style_export
Generalized style plugin for export plugins.

Code

function add_http_headers() {
  drupal_add_http_header('Cache-Control', 'max-age=60, must-revalidate');
  if (!empty($this->definition['export headers'])) {
    foreach ($this->definition['export headers'] as $name => $value) {
      drupal_add_http_header($name, $value);
    }
  }
  if (isset($this->options['filename']) && !empty($this->options['provide_file'])) {
    $filename = strtr($this->options['filename'], array(
      '%view' => check_plain($this->view->name),
    ));
    if ($filename) {
      drupal_add_http_header('Content-Disposition', 'attachment; filename="' . $filename . '"');
    }
  }
}