Révision feca1e4a
Ajouté par Assos Assos il y a presque 7 ans
drupal7/sites/all/modules/webform/includes/exporters/webform_exporter_delimited.inc | ||
---|---|---|
4 | 4 |
* @file |
5 | 5 |
* Webform exporter for creating CSV/TSV delimited files. |
6 | 6 |
*/ |
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
*/ |
|
7 | 11 |
class webform_exporter_delimited extends webform_exporter { |
8 | 12 |
public $line_ending; |
9 | 13 |
public $delimiter; |
10 | 14 |
|
11 |
function __construct($options) { |
|
15 |
/** |
|
16 |
* |
|
17 |
*/ |
|
18 |
public function __construct($options) { |
|
12 | 19 |
$this->line_ending = webform_variable_get('webform_csv_line_ending'); |
13 | 20 |
$this->delimiter = isset($options['delimiter']) ? $options['delimiter'] : ','; |
14 | 21 |
// Convert tabs. |
... | ... | |
19 | 26 |
parent::__construct($options); |
20 | 27 |
} |
21 | 28 |
|
22 |
function add_row(&$file_handle, $data, $row_count) { |
|
29 |
/** |
|
30 |
* |
|
31 |
*/ |
|
32 |
public function add_row(&$file_handle, $data, $row_count) { |
|
23 | 33 |
foreach ($data as $key => $value) { |
24 | 34 |
// Escape inner quotes and wrap all contents in new quotes. |
25 | 35 |
$data[$key] = '"' . str_replace('"', '""', $data[$key]) . '"'; |
... | ... | |
32 | 42 |
@fwrite($file_handle, $row); |
33 | 43 |
} |
34 | 44 |
|
35 |
function set_headers($filename) { |
|
45 |
/** |
|
46 |
* |
|
47 |
*/ |
|
48 |
public function set_headers($filename) { |
|
36 | 49 |
parent::set_headers($filename); |
37 | 50 |
|
38 | 51 |
// Convert tabs. |
... | ... | |
48 | 61 |
drupal_add_http_header('Content-Type', $content_type); |
49 | 62 |
drupal_add_http_header('Content-Disposition', "attachment; filename=$filename.$extension"); |
50 | 63 |
} |
64 |
|
|
51 | 65 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules