Skip to content

Commit

Permalink
Patches views_data_export for csv issues
Browse files Browse the repository at this point in the history
  • Loading branch information
a-fro committed Jul 10, 2015
1 parent 27f53c2 commit f7879f4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Expand Up @@ -236,6 +236,14 @@ class views_data_export_plugin_style_export extends views_plugin_style {
$rows = array();
$title = '';
$output = '';

if ($this instanceof views_data_export_plugin_style_export_csv) {
$encoding = $this->options['encoding'];
if (empty($encoding) || ($encoding != 'ASCII')) {
$output = chr(0xEF).chr(0xBB).chr(0xBF);
}
}

$output .= theme($this->theme_functions($this->definition['additional themes base'] . '_header'), array('view' => $this->view, 'options' => $this->options, 'rows' => $rows, 'title' => $title));
return $output;
}
Expand Down
5 changes: 5 additions & 0 deletions patches/readme.md
Expand Up @@ -79,3 +79,8 @@ Example:
* Fixes issues with youtube api v3
* https://www.drupal.org/node/2410027
* https://www.drupal.org/files/issues/media_youtube_apiv3_v4.patch

* views_data_export
* Fixes UTF-8 file settings when opening CSV downloads on Excel for Windows
* https://www.drupal.org/node/1701018
* https://www.drupal.org/files/issues/views_data_export-set_utf8_bom-1701018-13.patch
19 changes: 19 additions & 0 deletions patches/views_data_export-set_utf8_bom-1701018-13.patch
@@ -0,0 +1,19 @@
diff --git a/plugins/views_data_export_plugin_style_export.inc b/plugins/views_data_export_plugin_style_export.inc
index 3e6227b..53974bc 100644
--- a/plugins/views_data_export_plugin_style_export.inc
+++ b/plugins/views_data_export_plugin_style_export.inc
@@ -235,6 +235,14 @@ class views_data_export_plugin_style_export extends views_plugin_style {
$rows = array();
$title = '';
$output = '';
+
+ if ($this instanceof views_data_export_plugin_style_export_csv) {
+ $encoding = $this->options['encoding'];
+ if (empty($encoding) || ($encoding != 'ASCII')) {
+ $output = chr(0xEF).chr(0xBB).chr(0xBF);
+ }
+ }
+
$output .= theme($this->theme_functions($this->definition['additional themes base'] . '_header'), array('view' => $this->view, 'options' => $this->options, 'rows' => $rows, 'title' => $title));
return $output;
}

0 comments on commit f7879f4

Please sign in to comment.