function webform_results_batch_headers in Webform 7.4
Batch API callback; Write the headers of the export to the export file.
1 string reference to 'webform_results_batch_headers'
- webform_results_export_batch in includes/
webform.report.inc - Return a Batch API array of commands that will generate an export.
File
- includes/
webform.report.inc, line 1466 - This file includes helper functions for creating reports for webform.module.
Code
function webform_results_batch_headers($node, $format = 'delimited', $options = array(), &$context = NULL) {
module_load_include('inc', 'webform', 'includes/webform.export');
$exporter = webform_export_create_handler($format, $options);
$handle = fopen($options['file_name'], 'a');
if (!$handle) {
return;
}
$headers = webform_results_download_headers($node, $options);
$row_count = 0;
$col_count = 0;
foreach ($headers as $row) {
// Output header if header_keys is non-negative. -1 means no headers.
if ($options['header_keys'] >= 0) {
$exporter
->add_row($handle, $row, $row_count);
$row_count++;
}
$col_count = count($row) > $col_count ? count($row) : $col_count;
}
$context['results']['row_count'] = $row_count;
$context['results']['col_count'] = $col_count;
@fclose($handle);
}