Projet

Général

Profil

Paste
Télécharger (6,01 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / locale.views.inc @ 7547bb19

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides views data and handlers for locale.module.
6
 *
7
 * @ingroup views_module_handlers
8
 */
9

    
10
/**
11
 * Implements hook_views_data().
12
 */
13
function locale_views_data() {
14
  // Basic table information.
15

    
16
  // Define the base group of this table.
17
  $data['locales_source']['table']['group']  = t('Locale source');
18

    
19
  // Advertise this table as a possible base table.
20
  $data['locales_source']['table']['base'] = array(
21
    'field' => 'lid',
22
    'title' => t('Locale source'),
23
    'help' => t('A source string for translation, in English or the default site language.'),
24
  );
25

    
26
  // lid
27
  $data['locales_source']['lid'] = array(
28
    'title' => t('LID'),
29
    'help' => t('The ID of the source string.'),
30
    'field' => array(
31
      'handler' => 'views_handler_field',
32
      'click sortable' => TRUE,
33
    ),
34
    'argument' => array(
35
      'handler' => 'views_handler_argument_numeric',
36
      'numeric' => TRUE,
37
      'validate type' => 'lid',
38
    ),
39
    'filter' => array(
40
      'handler' => 'views_handler_filter_numeric',
41
    ),
42
    'sort' => array(
43
      'handler' => 'views_handler_sort',
44
    ),
45
  );
46

    
47
  // location
48
  $data['locales_source']['location'] = array(
49
    'group' => t('Locale source'),
50
    'title' => t('Location'),
51
    'help' => t('A description of the location or context of the string.'),
52
    'field' => array(
53
      'handler' => 'views_handler_field',
54
      'click sortable' => TRUE,
55
     ),
56
    'sort' => array(
57
      'handler' => 'views_handler_sort',
58
    ),
59
    'filter' => array(
60
      'handler' => 'views_handler_filter_string',
61
    ),
62
    'argument' => array(
63
      'handler' => 'views_handler_argument_string',
64
    ),
65
  );
66

    
67
  // Group field
68
  $data['locales_source']['textgroup'] = array(
69
    'group' => t('Locale source'),
70
    'title' => t('Group'),
71
    'help' => t('The group the translation is in.'),
72
    'field' => array(
73
      'handler' => 'views_handler_field_locale_group',
74
      'click sortable' => TRUE,
75
    ),
76
    'filter' => array(
77
      'handler' => 'views_handler_filter_locale_group',
78
    ),
79
    'argument' => array(
80
      'handler' => 'views_handler_argument_locale_group',
81
    ),
82
  );
83

    
84
  // Source field
85
  $data['locales_source']['source'] = array(
86
    'group' => t('Locale source'),
87
    'title' => t('Source'),
88
    'help' => t('The full original string.'),
89
    'field' => array(
90
      'handler' => 'views_handler_field',
91
    ),
92
    'filter' => array(
93
      'handler' => 'views_handler_filter_string',
94
    ),
95
  );
96

    
97
  // Version field
98
  $data['locales_source']['version'] = array(
99
    'group' => t('Locale source'),
100
    'title' => t('Version'),
101
    'help' => t('The version of Drupal core that this string is for.'),
102
    'field' => array(
103
      'handler' => 'views_handler_field',
104
      'click sortable' => TRUE,
105
    ),
106
    'filter' => array(
107
      'handler' => 'views_handler_filter_locale_version',
108
    ),
109
    'argument' => array(
110
      'handler' => 'views_handler_argument_string',
111
    ),
112
  );
113

    
114
  $data['locales_source']['edit_lid'] = array(
115
    'group' => t('Locale source'),
116
    'field' => array(
117
      'title' => t('Edit link'),
118
      'help' => t('Provide a simple link to edit the translations.'),
119
      'handler' => 'views_handler_field_locale_link_edit',
120
    ),
121
  );
122

    
123
  // ----------------------------------------------------------------------
124
  // Locales target table
125

    
126
  // Define the base group of this table. Fields that don't
127
  // have a group defined will go into this field by default.
128
  $data['locales_target']['table']['group']  = t('Locale target');
129

    
130
  // Join information
131
  $data['locales_target']['table']['join'] = array(
132
    'locales_source' => array(
133
      'left_field' => 'lid',
134
      'field' => 'lid',
135
    ),
136
  );
137

    
138
  // Translation field
139
  $data['locales_target']['translation'] = array(
140
    'group' => t('Locale target'),
141
    'title' => t('Translation'),
142
    'help' => t('The full translation string.'),
143
    'field' => array(
144
      'handler' => 'views_handler_field',
145
    ),
146
    'filter' => array(
147
      'handler' => 'views_handler_filter_string',
148
    ),
149
  );
150

    
151
  // Language field
152
  $data['locales_target']['language'] = array(
153
    'group' => t('Locale target'),
154
    'title' => t('Language'),
155
    'help' => t('The language this translation is in.'),
156
    'field' => array(
157
      'handler' => 'views_handler_field_locale_language',
158
      'click sortable' => TRUE,
159
    ),
160
    'filter' => array(
161
      'handler' => 'views_handler_filter_locale_language',
162
    ),
163
    'argument' => array(
164
      'handler' => 'views_handler_argument_locale_language',
165
    ),
166
  );
167

    
168
  $data['locales_target']['plid'] = array(
169
    'group' => t('Locale target'),
170
    'title' => t('Singular LID'),
171
    'help' => t('The ID of the parent translation.'),
172
    'field' => array(
173
      'handler' => 'views_handler_field',
174
    ),
175
  );
176

    
177
  // Plural
178
  $data['locales_target']['plural'] = array(
179
    'group' => t('Locale target'),
180
    'title' => t('Plural'),
181
    'help' => t('Whether or not the translation is plural.'),
182
    'field' => array(
183
      'handler' => 'views_handler_field_boolean',
184
      'click sortable' => TRUE,
185
    ),
186
    'filter' => array(
187
      'handler' => 'views_handler_filter_boolean_operator',
188
      'label' => t('Plural'),
189
      'type' => 'yes-no',
190
    ),
191
    'sort' => array(
192
      'handler' => 'views_handler_sort',
193
    ),
194
  );
195

    
196
  return $data;
197
}
198

    
199
/**
200
 * Implements hook_views_data_alter().
201
 */
202
function locale_views_data_alter(&$data) {
203
  // Language field
204
  $data['node']['language'] = array(
205
    'title' => t('Language'),
206
    'help' => t('The language the content is in.'),
207
    'field' => array(
208
      'handler' => 'views_handler_field_node_language',
209
      'click sortable' => TRUE,
210
    ),
211
    'filter' => array(
212
      'handler' => 'views_handler_filter_node_language',
213
    ),
214
    'argument' => array(
215
      'handler' => 'views_handler_argument_node_language',
216
    ),
217
    'sort' => array(
218
      'handler' => 'views_handler_sort',
219
    ),
220
  );
221
  $data['node']['specific_language'] = array(
222
    'title' => t('Specific language'),
223
    'help' => t('Sort by a specific language that the content is in.'),
224
    'sort' => array(
225
      'handler' => 'views_handler_sort_node_language',
226
    ),
227
  );
228
}