You are here

function template_preprocess_views_data_export_csv_header in Views data export 7.4

Same name and namespace in other branches
  1. 6.3 theme/views_data_export.theme.inc \template_preprocess_views_data_export_csv_header()
  2. 6 theme/views_data_export.theme.inc \template_preprocess_views_data_export_csv_header()
  3. 6.2 theme/views_data_export.theme.inc \template_preprocess_views_data_export_csv_header()
  4. 7 theme/views_data_export.theme.inc \template_preprocess_views_data_export_csv_header()
  5. 7.3 theme/views_data_export.theme.inc \template_preprocess_views_data_export_csv_header()

File

theme/views_data_export.theme.inc, line 85
Theme related functions for processing our output style plugins.

Code

function template_preprocess_views_data_export_csv_header(&$vars) {
  _views_data_export_header_shared_preprocess($vars);

  // Make sure we catch saved options that are misspelled. LEGACY
  if (isset($vars['options']['seperator'])) {
    $vars['options']['separator'] = $vars['options']['seperator'];
  }

  // Support old misspelled templates. LEGACY
  $vars['seperator'] = $vars['separator'] = $vars['options']['separator'];

  // Special handling when quoted values are involved.
  if ($vars['options']['quote']) {
    $wrap = '"';
    $replace_value = '""';
  }
  else {
    $wrap = '';
    $replace_value = '';
  }

  // Format header values.
  foreach ($vars['header'] as $key => $value) {
    $output = decode_entities($value);
    $output = empty($vars['options']['keep_html']) ? strip_tags($output) : $output;
    if (!empty($vars['options']['trim'])) {
      $output = trim($output);
    }
    if (!empty($vars['options']['encoding']) && function_exists('iconv')) {
      switch ($vars['options']['encoding']) {
        case 'utf8_decode':
          $converted = utf8_decode($output);
          break;
        default:
          $converted = iconv("UTF-8", $vars['options']['encoding'], $output);
          break;
      }
      if ($converted !== FALSE) {
        $output = $converted;
      }
    }
    $vars['header'][$key] = $wrap . str_replace('"', $replace_value, $output) . $wrap;
  }
}