You are here

function ViewsDataExportExporterDelimited::bof in Views data export 7.4

Generate the BOF.

Overrides ViewsDataExportExporter::bof

File

exporters/views_data_export_exporter_delimited.inc, line 223

Class

ViewsDataExportExporterDelimited
Webform exporter for creating CSV/TSV delimited files.

Code

function bof(&$file_handle) {
  $first_field = true;
  foreach ($this->options['field_labels'] as $field) {
    if (!$first_field) {
      fwrite($file_handle, ",");
    }
    else {
      $first_field = false;
    }

    // Strip html tags.
    if (!isset($this->options['keep_html']) || !$this->options['keep_html']) {
      $field = strip_tags($field);
    }

    // Escape inner quotes and wrap all contents in new quotes.
    $field = '"' . str_replace('"', '""', $field) . '"';

    // Write the field.
    fwrite($file_handle, $field);
  }
  fwrite($file_handle, PHP_EOL);
}