You are here

function webform_webform_exporters in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform_export.inc \webform_webform_exporters()
  2. 6.3 includes/webform.export.inc \webform_webform_exporters()
  3. 6.2 webform_export.inc \webform_webform_exporters()
  4. 7.3 includes/webform.export.inc \webform_webform_exporters()

Implements hook_webform_exporters().

File

includes/webform.export.inc, line 11
Provides several different handlers for exporting webform results.

Code

function webform_webform_exporters() {
  $exporters = array(
    'delimited' => array(
      'title' => t('Delimited text'),
      'description' => t('A plain text file delimited by commas, tabs, or other characters.'),
      'handler' => 'webform_exporter_delimited',
      'file' => drupal_get_path('module', 'webform') . '/includes/exporters/webform_exporter_delimited.inc',
      'weight' => 10,
    ),
    'excel' => array(
      'title' => t('Microsoft Excel'),
      'description' => t('A file readable by Microsoft Excel.'),
      'handler' => 'webform_exporter_excel_xlsx',
      'file' => drupal_get_path('module', 'webform') . '/includes/exporters/webform_exporter_excel_xlsx.inc',
      'weight' => -1,
      // Tells the options to use consistent dates instead of user-defined
      // formats.
      'options' => array(
        'iso8601_time' => TRUE,
        'iso8601_date' => TRUE,
      ),
    ),
    'excel_legacy' => array(
      'title' => t('Microsoft Excel (older versions)'),
      'description' => t('A file readable by older versions of Microsoft Excel.'),
      'handler' => 'webform_exporter_excel_delimited',
      'file' => drupal_get_path('module', 'webform') . '/includes/exporters/webform_exporter_excel_delimited.inc',
      'weight' => 0,
    ),
  );

  // The new Excel exporter is only available if ZipArchive is available.
  if (!class_exists('ZipArchive')) {
    drupal_set_message(t('@format downloads are not available because this install of PHP lacks Zip archive support.', array(
      '@format' => $exporters['excel']['title'],
    )), 'warning');
    unset($exporters['excel']);
  }

  // By default the legacy Excel exporter is disabled.
  if (!webform_variable_get('webform_excel_legacy_exporter')) {
    unset($exporters['excel_legacy']);
  }
  return $exporters;
}