Projet

Général

Profil

Paste
Télécharger (9,67 ko) Statistiques
| Branche: | Révision:

root / htmltest / sites / all / modules / feeds / views / feeds.views.inc @ a5572547

1
<?php
2

    
3
/**
4
 * @file
5
 * Views integration for Feeds tables.
6
 *
7
 * @see http://drupal.org/project/views
8
 */
9

    
10
/**
11
 * Implements hook_views_data().
12
 */
13
function feeds_views_data() {
14
  $data = array();
15

    
16
  /**
17
   * Expose feeds_source table to views.
18
   */
19
  $data['feeds_source']['table'] = array(
20
    'group' => 'Feeds source',
21
    'base' => array(
22
      'field' => array('feed_nid', 'id'),
23
      'title' => 'Feeds source',
24
      'help' => 'The source information for a feed, for example its URL',
25
    ),
26
  );
27
  $data['feeds_source']['feed_nid'] = array(
28
    'title' => 'Feed node id',
29
    'help' => 'Contains the node id of a feed node if the feed\'s configuration is attached to a content type, otherwise contains 0.',
30
    'field' => array(
31
      'handler' => 'views_handler_field_numeric',
32
      'click sortable' => TRUE,
33
    ),
34
    'filter' => array(
35
      'handler' => 'views_handler_filter_numeric',
36
      'allow empty' => TRUE,
37
      'help' => 'Filter on a Feeds Source\'s feed_nid field.',
38
    ),
39
    'argument' => array(
40
      'handler' => 'views_handler_argument_numeric',
41
      'numeric' => TRUE,
42
      'validate type' => 'nid',
43
      'help' => 'Argument on a Feeds Source\'s feed_nid field.',
44
    ),
45
    'sort' => array(
46
      'handler' => 'views_handler_sort',
47
      'help' => 'Sort Feeds Source\'s feed_nid field.',
48
    ),
49
  );
50
  $data['feeds_source']['config'] = array(
51
    'title' => 'Source',
52
    'help' => 'The resource identifier for this feed. For instance a URL.',
53
    'field' => array(
54
      'handler' => 'feeds_views_handler_field_source',
55
      'click sortable' => FALSE,
56
    ),
57
  );
58
  $data['feeds_source']['table']['join'] = array(
59
    'node' => array(
60
      'left_field' => 'nid',
61
      'field' => 'feed_nid',
62
      'type' => 'LEFT',
63
    ),
64
  );
65

    
66
  /**
67
   * Expose feeds_node_item table to views.
68
   */
69
  $data['feeds_item']['table'] = array(
70
    'group' => 'Feeds item',
71
  );
72
  $data['feeds_item']['feed_nid'] = array(
73
    'title' => t('Owner feed nid'),
74
    'help' => t('The node id of the owner feed node if available.'),
75
    'field' => array(
76
      'handler' => 'views_handler_field_numeric',
77
      'click sortable' => TRUE,
78
    ),
79
    'filter' => array(
80
      'handler' => 'views_handler_filter_numeric',
81
      'allow empty' => TRUE,
82
      'help' => t('Filter on Feed Items by the Feed they were generated from using the Node Id of the Feed Node.'),
83
    ),
84
    'argument' => array(
85
      'handler' => 'views_handler_argument_numeric',
86
      'numeric' => TRUE,
87
      'validate type' => 'nid',
88
      'help' => t('Argument on Feed Items by the Feed they were generated from using the Node Id of the Feed Node.'),
89
    ),
90
    'sort' => array(
91
      'help' => t('Sort Feed Items by the Feed they were generated from using the Node Id of the Feed Node.'),
92
    ),
93
    'relationship' => array(
94
      'title' => t('Owner feed'),
95
      'help' => t('Relate a feed item to its owner feed node if available.'),
96
      'label' => t('Owner feed'),
97
      'base' => 'node',
98
      'base field' => 'nid',
99
    ),
100
  );
101
  $data['feeds_item']['url'] = array(
102
    'title' => t('Item URL'),
103
    'help' => t('Contains the URL of the feed item.'),
104
    'field' => array(
105
      'handler' => 'views_handler_field_url',
106
      'click sortable' => TRUE,
107
    ),
108
    'filter' => array(
109
      'handler' => 'views_handler_filter_string',
110
      'allow empty' => TRUE,
111
      'help' => t('Filter on a Feeds Item\'s URL field.'),
112
    ),
113
    'argument' => array(
114
      'handler' => 'views_handler_argument_string',
115
      'numeric' => TRUE,
116
      'validate type' => 'nid',
117
      'help' => t('Argument on a Feeds Item\'s URL field.'),
118
    ),
119
    'sort' => array(
120
      'help' => t('Sort on a Feeds Item\'s URL field.'),
121
    ),
122
  );
123
  $data['feeds_item']['guid'] = array(
124
    'title' => t('Item GUID'),
125
    'help' => t('Contains the GUID of the feed item.'),
126
    'field' => array(
127
      'click sortable' => TRUE,
128
    ),
129
    'filter' => array(
130
      'handler' => 'views_handler_filter_string',
131
      'allow empty' => TRUE,
132
      'help' => t('Filter on a Feeds Item\'s GUID field.'),
133
    ),
134
    'argument' => array(
135
      'handler' => 'views_handler_argument_string',
136
      'numeric' => TRUE,
137
      'validate type' => 'nid',
138
      'help' => t('Argument on a Feeds Item\'s GUID field.'),
139
    ),
140
    'sort' => array(
141
      'help' => t('Sort on a Feeds Item\'s GUID field.'),
142
    ),
143
  );
144
  $data['feeds_item']['imported'] = array(
145
    'title' => t('Import date'),
146
    'help' => t('Contains the import date of the feed item.'),
147
    'field' => array(
148
      'handler' => 'views_handler_field_date',
149
      'click sortable' => TRUE,
150
    ),
151
    'sort' => array(
152
      'handler' => 'views_handler_sort_date',
153
      'help' => t('Sort on a Feeds Item\'s import date field.'),
154
    ),
155
    'filter' => array(
156
      'handler' => 'views_handler_filter_date',
157
      'help' => t('Filter on a Feeds Item\'s import date field.'),
158
    ),
159
    'argument' => array(
160
      'handler' => 'views_handler_argument_date',
161
      'numeric' => TRUE,
162
      'validate type' => 'nid',
163
      'help' => t('Argument on a Feeds Item\'s import date field.'),
164
    ),
165
  );
166

    
167
  // Add a relationship for each entity type relating the entity's base table
168
  // to the feeds_item table whre feeds_item.entity_type = 'entity_type'.
169
  foreach (array('node', 'taxonomy_term', 'user') as $entity_type) {
170
    $info = entity_get_info($entity_type);
171
    $data['feeds_item']['table']['join'][$info['base table']] = array(
172
      'left_field' => $info['entity keys']['id'],
173
      'field' => 'entity_id',
174
      'type' => 'LEFT',
175
      'extra' => array(
176
        array(
177
          'table' => 'feeds_item',
178
          'field' => 'entity_type',
179
          'value' => $entity_type,
180
          'operator' => '=',
181
        ),
182
      ),
183
    );
184
  }
185

    
186
  /**
187
   * Expose feeds_log table to views.
188
   */
189
  $data['feeds_log']['table'] = array(
190
    'group' => 'Feeds log',
191
    'base' => array(
192
      'field' => array('flid'),
193
      'title' => 'Feeds log',
194
      'help' => 'Logs events during importing, clearing, expiry.',
195
    ),
196
  );
197
  $data['feeds_log']['id'] = array(
198
    'title' => 'Importer id',
199
    'help' => 'The id of an importer.',
200
    'field' => array(
201
      'handler' => 'views_handler_field',
202
      'click sortable' => TRUE,
203
    ),
204
    'filter' => array(
205
      'handler' => 'views_handler_filter_string',
206
      'allow empty' => TRUE,
207
      'help' => 'Filter on an importer id.',
208
    ),
209
    'argument' => array(
210
      'handler' => 'feeds_views_handler_argument_importer_id',
211
      'help' => 'Filter on an importer id.',
212
    ),
213
    'sort' => array(
214
      'handler' => 'views_handler_sort',
215
      'help' => 'Sort by importer id.',
216
    ),
217
    'relationship' => array(
218
      'title' => t('Importer'),
219
      'help' => t('Relate a log entry to its importer if available.'),
220
      'label' => t('Importer'),
221
      'base' => 'feeds_importer',
222
      'base field' => 'id',
223
    ),
224
  );
225
  $data['feeds_log']['importer_name'] = array(
226
    'real field' => 'id',
227
    'title' => 'Importer name',
228
    'help' => 'The human readable name of an importer.',
229
    'field' => array(
230
      'handler' => 'feeds_views_handler_field_importer_name',
231
    ),
232
  );
233
  $data['feeds_log']['feed_nid'] = array(
234
    'title' => 'Feed node id',
235
    'help' => 'Contains the node id of a feed node if the feed\'s configuration is attached to a content type, otherwise contains 0.',
236
    'field' => array(
237
      'handler' => 'views_handler_field_numeric',
238
      'click sortable' => TRUE,
239
    ),
240
    'filter' => array(
241
      'handler' => 'views_handler_filter_numeric',
242
      'allow empty' => TRUE,
243
      'help' => 'Filter on a Feeds Source\'s feed_nid field.',
244
    ),
245
    'argument' => array(
246
      'handler' => 'views_handler_argument_numeric',
247
      'numeric' => TRUE,
248
      'validate type' => 'nid',
249
      'help' => 'Argument on a Feeds Source\'s feed_nid field.',
250
    ),
251
    'sort' => array(
252
      'handler' => 'views_handler_sort',
253
      'help' => 'Sort Feeds Source\'s feed_nid field.',
254
    ),
255
    'relationship' => array(
256
      'title' => t('Feed node'),
257
      'help' => t('Relate a log entry to its feed node if available.'),
258
      'label' => t('Feed node'),
259
      'base' => 'node',
260
      'base field' => 'nid',
261
    ),
262
  );
263
  $data['feeds_log']['log_time'] = array(
264
    'title' => t('Log time'),
265
    'help' => t('The time of the event.'),
266
    'field' => array(
267
      'handler' => 'views_handler_field_date',
268
      'click sortable' => TRUE,
269
    ),
270
    'sort' => array(
271
      'handler' => 'views_handler_sort_date',
272
    ),
273
    'filter' => array(
274
      'handler' => 'views_handler_filter_date',
275
    ),
276
  );
277
  $data['feeds_log']['request_time'] = array(
278
    'title' => t('Request time'),
279
    'help' => t('The time of the page request of an event.'),
280
    'field' => array(
281
      'handler' => 'views_handler_field_date',
282
      'click sortable' => TRUE,
283
    ),
284
    'sort' => array(
285
      'handler' => 'views_handler_sort_date',
286
    ),
287
    'filter' => array(
288
      'handler' => 'views_handler_filter_date',
289
    ),
290
  );
291
  $data['feeds_log']['message'] = array(
292
    'title' => 'Log message',
293
    'help' => 'The message logged by the event.',
294
    'field' => array(
295
      'handler' => 'feeds_views_handler_field_log_message',
296
      'click sortable' => FALSE,
297
      'additional fields' => array(
298
        'variables',
299
      ),
300
    ),
301
  );
302
  $data['feeds_log']['severity'] = array(
303
    'title' => 'Severity',
304
    'help' => 'The severity of the event logged.',
305
    'field' => array(
306
      'handler' => 'feeds_views_handler_field_severity',
307
      'click sortable' => FALSE,
308
    ),
309
    'filter' => array(
310
      'handler' => 'feeds_views_handler_filter_severity',
311
      'allow empty' => TRUE,
312
      'help' => 'Filter on the severity of a log message.',
313
    ),
314
  );
315
  $data['feeds_log']['table']['join'] = array(
316
    'node' => array(
317
      'left_field' => 'nid',
318
      'field' => 'feed_nid',
319
      'type' => 'LEFT',
320
    ),
321
  );
322

    
323
  return $data;
324
}