function webform_results_download_headers in Webform 7.4
Print the header rows for the downloadable webform data.
Parameters
$node: The webform node on which to generate the analysis.
array $options: A list of options that define the output format. These are generally passed through from the GUI interface.
2 calls to webform_results_download_headers()
- webform_results_batch_headers in includes/
webform.report.inc - Batch API callback; Write the headers of the export to the export file.
- webform_results_export in includes/
webform.report.inc - Generate a Excel-readable CSV file containing all submissions for a Webform.
File
- includes/
webform.report.inc, line 1051 - This file includes helper functions for creating reports for webform.module.
Code
function webform_results_download_headers($node, array $options) {
module_load_include('inc', 'webform', 'includes/webform.components');
$submission_information = webform_results_download_submission_information($node, $options);
// Fill in the header for the submission information (if any).
$header[2] = $header[1] = $header[0] = count($submission_information) ? array_fill(0, count($submission_information), '') : array();
if (count($submission_information)) {
$header[0][0] = $node->title;
if ($options['header_keys']) {
$header[1][0] = t('submission_details');
$submission_information_headers = array_keys($submission_information);
}
else {
$header[1][0] = t('Submission Details');
$submission_information_headers = array_values($submission_information);
}
foreach ($submission_information_headers as $column => $label) {
$header[2][$column] = $label;
}
}
// Compile header information for components.
foreach ($options['components'] as $cid) {
if (isset($node->webform['components'][$cid])) {
$component = $node->webform['components'][$cid];
// Let each component determine its headers.
if (webform_component_feature($component['type'], 'csv')) {
$component_header = (array) webform_component_invoke($component['type'], 'csv_headers', $component, $options);
// Allow modules to modify the component CSV header.
drupal_alter('webform_csv_header', $component_header, $component);
// Merge component CSV header to overall CSV header.
$header[0] = array_merge($header[0], (array) $component_header[0]);
$header[1] = array_merge($header[1], (array) $component_header[1]);
$header[2] = array_merge($header[2], (array) $component_header[2]);
}
}
}
return $header;
}