You are here

function views_data_export_plugin_style_export::render_header in Views data export 7.4

Same name and namespace in other branches
  1. 6.3 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::render_header()
  2. 6 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::render_header()
  3. 6.2 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::render_header()
  4. 7 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::render_header()
  5. 7.3 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::render_header()
1 call to views_data_export_plugin_style_export::render_header()
views_data_export_plugin_style_export::render in plugins/views_data_export_plugin_style_export.inc
Render the display in this style.

File

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

Class

views_data_export_plugin_style_export
Generalized style plugin for export plugins.

Code

function render_header($file = null) {

  // Return a value if we haven't been given a file to write to.
  $return_a_value = is_null($file);
  if ($return_a_value) {
    $file = fopen('php://memory', 'w+');
  }

  // Get the field titles/labels.
  $field_labels = $this->display->handler
    ->get_field_labels();

  // Get the BOF.
  $this
    ->get_exporter(array(
    'field_labels' => $field_labels,
  ))
    ->bof($file);

  // Return a value if we haven't been given a file to write to.
  if ($return_a_value) {

    // Read from file and verify contents.
    fseek($file, 0);
    $contents = '';
    while (!feof($file)) {
      $contents .= fread($file, 8192);
    }

    // Close up the file stream.
    fclose($file);
    return $contents;
  }
}