Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / modules / locale.views.inc @ 5d12d676

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
  // Define the base group of this table.
16
  $data['locales_source']['table']['group']  = t('Locale source');
17

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

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

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

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

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

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

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

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

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

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

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

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

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

    
194
  return $data;
195
}
196

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