Projet

Général

Profil

Paste
Télécharger (4,05 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views_data_export / plugins / views_data_export_plugin_style_export_csv.inc @ f0456308

1
<?php
2
/**
3
 * @file
4
 * Plugin include file for export style plugin.
5
 */
6

    
7
/**
8
 * Generalized style plugin for export plugins.
9
 *
10
 * @ingroup views_style_plugins
11
 */
12
class views_data_export_plugin_style_export_csv extends views_data_export_plugin_style_export {
13

    
14
  /**
15
   * Set options fields and default values.
16
   *
17
   * @return
18
   * An array of options information.
19
   */
20
  function option_definition() {
21
    $options = parent::option_definition();
22

    
23
    $options['separator'] = array(
24
      'default' => ',',
25
      'translatable' => TRUE,
26
    );
27
    $options['quote'] = array(
28
      'default' => TRUE,
29
      'translatable' => TRUE,
30
    );
31
    $options['trim'] = array(
32
      'default' => FALSE,
33
      'translatable' => FALSE,
34
    );
35
    $options['replace_newlines'] = array(
36
      'default' => FALSE,
37
      'translatable' => FALSE,
38
    );
39
    $options['newline_replacement'] = array(
40
      'default' => ', ',
41
      'translatable' => FALSE,
42
    );
43
    $options['header'] = array(
44
      'default' => TRUE,
45
      'translatable' => FALSE,
46
    );
47
    $options['keep_html'] = array(
48
      'default' => FALSE,
49
      'translatable' => FALSE,
50
    );
51
    $options['encoding'] = array(
52
      'default' => '',
53
      'translatable' => FALSE,
54
    );
55

    
56
    return $options;
57
  }
58

    
59
  /**
60
   * Options form mini callback.
61
   *
62
   * @param $form
63
   * Form array to add additional fields to.
64
   * @param $form_state
65
   * State of the form.
66
   * @return
67
   * None.
68
   */
69
  function options_form(&$form, &$form_state) {
70
    parent::options_form($form, $form_state);
71

    
72
    $form['separator'] = array(
73
      '#type' => 'textfield',
74
      '#title' => t('Separator'),
75
      '#default_value' => !empty($this->options['separator']) ? $this->options['separator'] : ',',
76
      '#description' => t('This is the separator that is used to separate fields. CSV implies comma separated fields so this should not be changed unless you have specific requirements'),
77
    );
78
    $form['quote'] = array(
79
      '#type' => 'checkbox',
80
      '#default_value' => !empty($this->options['quote']),
81
      '#title' => t('Quote values. Useful for output that might contain your separator as part of one of the values.'),
82
    );
83
    $form['trim'] = array(
84
      '#type' => 'checkbox',
85
      '#default_value' => !empty($this->options['trim']),
86
      '#title' => t('Trim whitespace from rendered fields. Can be useful for some themes where output results in extra newlines.'),
87
    );
88
    $form['replace_newlines'] = array(
89
      '#type' => 'checkbox',
90
      '#default_value' => !empty($this->options['replace_newlines']),
91
      '#title' => t('Replace newlines in rendered fields.'),
92
    );
93
    $form['newline_replacement'] = array(
94
      '#prefix' => '<div><div id="edit-options-newline-replacement">',
95
      '#suffix' => '</div></div>',
96
      '#type' => 'textfield',
97
      '#title' => t('Replacement'),
98
      '#default_value' => $this->options['newline_replacement'],
99
      '#process' => array('ctools_dependent_process'),
100
      '#dependency' => array('edit-style-options-replace-newlines' => array(TRUE)),
101
    );
102
    $form['header'] = array(
103
      '#type' => 'checkbox',
104
      '#title' => t('Make first row a list of column headers.'),
105
      '#default_value' => !empty($this->options['header']),
106
    );
107
    $form['keep_html'] = array(
108
      '#type' => 'checkbox',
109
      '#default_value' => !empty($this->options['keep_html']),
110
      '#title' => t('Keep HTML tags.'),
111
    );
112
    $form['encoding'] = array(
113
      '#type' => 'textfield',
114
      '#default_value' => !empty($this->options['encoding']) ? $this->options['encoding'] : '',
115
      '#title' => t('Character encoding conversion'),
116
      '#description' => t('Optionally specify a character conversion that some CSV file readers need. Use "utf8_decode" for ISO-8859-1 via <a href="@utf8_decode">utf8_decode PHP function</a>, other values will be passed <a href="@iconv">iconv</a> (this requires the iconv PHP extension), empty or illegal values will leave the output as UTF-8.',
117
        array('@iconv' => 'http://www.php.net/manual/en/function.iconv.php', '@utf8_decode' => 'http://www.php.net/manual/en/function.utf8-decode.php')),
118
    );
119
  }
120
}