You are here

function _webform_csv_headers_select in Webform 7.4

Same name and namespace in other branches
  1. 5.2 components/select.inc \_webform_csv_headers_select()
  2. 5 components/select.inc \_webform_csv_headers_select()
  3. 6.3 components/select.inc \_webform_csv_headers_select()
  4. 6.2 components/select.inc \_webform_csv_headers_select()
  5. 7.3 components/select.inc \_webform_csv_headers_select()

Implements _webform_csv_headers_component().

File

components/select.inc, line 779
Webform module multiple select component.

Code

function _webform_csv_headers_select($component, $export_options) {
  $headers = array(
    0 => array(),
    1 => array(),
    2 => array(),
  );
  if ($component['extra']['multiple'] && $export_options['select_format'] == 'separate') {
    $headers[0][] = '';
    $headers[1][] = $export_options['header_keys'] ? $component['form_key'] : $component['name'];
    $items = _webform_select_options($component, TRUE);
    if ($component['extra']['other_option']) {
      if ($export_options['header_keys']) {
        $other_label = $component['form_key'] . '_other';
      }
      else {
        $other_label = !empty($component['extra']['other_text']) ? check_plain($component['extra']['other_text']) : t('Other...');
      }
      $items[$other_label] = $other_label;
    }
    $count = 0;
    foreach ($items as $key => $item) {

      // Empty column per sub-field in main header.
      if ($count != 0) {
        $headers[0][] = '';
        $headers[1][] = '';
      }
      if ($export_options['select_keys']) {
        $headers[2][] = $key;
      }
      else {
        $headers[2][] = $item;
      }
      $count++;
    }
  }
  else {
    $headers[0][] = '';
    $headers[1][] = '';
    $headers[2][] = $export_options['header_keys'] ? $component['form_key'] : $component['name'];
  }
  return $headers;
}