You are here

function _webform_csv_headers_addressfield in Addressfield Tokens 7

Return the header for this component to be displayed in a CSV file.

The output of this function will be displayed under the "Results" tab then "Download".

Parameters

mixed $component: A Webform component array.

mixed $export_options: An array of options that may configure export of this field.

Return value

array An array of data to be displayed in the first three rows of a CSV file, not including either prefixed or trailing commas.

File

./addressfield_tokens.components.inc, line 402
Webform Component information for an address field type.

Code

function _webform_csv_headers_addressfield($component, $export_options) {
  $header = array();
  if (!empty($component['extra']['csv_separate']) && $component['extra']['csv_separate'] == 1) {
    $header[0] = array();
    $header[1] = array();
    $header[2] = array();
    $properties = addressfield_tokens_property_names();

    // Ugly alter to let others decide which columns to include.
    // @TODO this should be a config option.
    drupal_alter('addressfield_tokens_download', $properties);
    foreach ($properties as $key => $name) {
      $header[0][] = '';
      $header[1][] = empty($header[1]) ? $component['name'] : '';
      $header[2][] = $name;
    }
  }
  else {
    $header[0] = array(
      '',
    );
    $header[1] = array(
      '',
    );
    $header[2] = array(
      $component['name'],
    );
  }
  return $header;
}