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']['imported'] = array(
|
59
|
'title' => t('Imported date'),
|
60
|
'help' => t('The date the source was imported last.'),
|
61
|
'field' => array(
|
62
|
'handler' => 'views_handler_field_date',
|
63
|
'click sortable' => TRUE,
|
64
|
),
|
65
|
'filter' => array(
|
66
|
'handler' => 'views_handler_filter_date',
|
67
|
),
|
68
|
'argument' => array(
|
69
|
'handler' => 'views_handler_argument_date',
|
70
|
),
|
71
|
'sort' => array(
|
72
|
'handler' => 'views_handler_sort_date',
|
73
|
),
|
74
|
);
|
75
|
$data['feeds_source']['table']['join'] = array(
|
76
|
'node' => array(
|
77
|
'left_field' => 'nid',
|
78
|
'field' => 'feed_nid',
|
79
|
'type' => 'LEFT',
|
80
|
),
|
81
|
);
|
82
|
|
83
|
/**
|
84
|
* Expose feeds_node_item table to views.
|
85
|
*/
|
86
|
$data['feeds_item']['table'] = array(
|
87
|
'group' => 'Feeds item',
|
88
|
);
|
89
|
$data['feeds_item']['feed_nid'] = array(
|
90
|
'title' => t('Owner feed nid'),
|
91
|
'help' => t('The node id of the owner feed node if available.'),
|
92
|
'field' => array(
|
93
|
'handler' => 'views_handler_field_numeric',
|
94
|
'click sortable' => TRUE,
|
95
|
),
|
96
|
'filter' => array(
|
97
|
'handler' => 'views_handler_filter_numeric',
|
98
|
'allow empty' => TRUE,
|
99
|
'help' => t('Filter on Feed Items by the Feed they were generated from using the Node Id of the Feed Node.'),
|
100
|
),
|
101
|
'argument' => array(
|
102
|
'handler' => 'views_handler_argument_numeric',
|
103
|
'numeric' => TRUE,
|
104
|
'validate type' => 'nid',
|
105
|
'help' => t('Argument on Feed Items by the Feed they were generated from using the Node Id of the Feed Node.'),
|
106
|
),
|
107
|
'sort' => array(
|
108
|
'help' => t('Sort Feed Items by the Feed they were generated from using the Node Id of the Feed Node.'),
|
109
|
),
|
110
|
'relationship' => array(
|
111
|
'title' => t('Owner feed'),
|
112
|
'help' => t('Relate a feed item to its owner feed node if available.'),
|
113
|
'label' => t('Owner feed'),
|
114
|
'base' => 'node',
|
115
|
'base field' => 'nid',
|
116
|
),
|
117
|
);
|
118
|
$data['feeds_item']['url'] = array(
|
119
|
'title' => t('Item URL'),
|
120
|
'help' => t('Contains the URL of the feed item.'),
|
121
|
'field' => array(
|
122
|
'handler' => 'views_handler_field_url',
|
123
|
'click sortable' => TRUE,
|
124
|
),
|
125
|
'filter' => array(
|
126
|
'handler' => 'views_handler_filter_string',
|
127
|
'allow empty' => TRUE,
|
128
|
'help' => t('Filter on a Feeds Item\'s URL field.'),
|
129
|
),
|
130
|
'argument' => array(
|
131
|
'handler' => 'views_handler_argument_string',
|
132
|
'numeric' => TRUE,
|
133
|
'validate type' => 'nid',
|
134
|
'help' => t('Argument on a Feeds Item\'s URL field.'),
|
135
|
),
|
136
|
'sort' => array(
|
137
|
'help' => t('Sort on a Feeds Item\'s URL field.'),
|
138
|
),
|
139
|
);
|
140
|
$data['feeds_item']['guid'] = array(
|
141
|
'title' => t('Item GUID'),
|
142
|
'help' => t('Contains the GUID of the feed item.'),
|
143
|
'field' => array(
|
144
|
'click sortable' => TRUE,
|
145
|
),
|
146
|
'filter' => array(
|
147
|
'handler' => 'views_handler_filter_string',
|
148
|
'allow empty' => TRUE,
|
149
|
'help' => t('Filter on a Feeds Item\'s GUID field.'),
|
150
|
),
|
151
|
'argument' => array(
|
152
|
'handler' => 'views_handler_argument_string',
|
153
|
'numeric' => TRUE,
|
154
|
'validate type' => 'nid',
|
155
|
'help' => t('Argument on a Feeds Item\'s GUID field.'),
|
156
|
),
|
157
|
'sort' => array(
|
158
|
'help' => t('Sort on a Feeds Item\'s GUID field.'),
|
159
|
),
|
160
|
);
|
161
|
$data['feeds_item']['imported'] = array(
|
162
|
'title' => t('Import date'),
|
163
|
'help' => t('Contains the import date of the feed item.'),
|
164
|
'field' => array(
|
165
|
'handler' => 'views_handler_field_date',
|
166
|
'click sortable' => TRUE,
|
167
|
),
|
168
|
'sort' => array(
|
169
|
'handler' => 'views_handler_sort_date',
|
170
|
'help' => t('Sort on a Feeds Item\'s import date field.'),
|
171
|
),
|
172
|
'filter' => array(
|
173
|
'handler' => 'views_handler_filter_date',
|
174
|
'help' => t('Filter on a Feeds Item\'s import date field.'),
|
175
|
),
|
176
|
'argument' => array(
|
177
|
'handler' => 'views_handler_argument_date',
|
178
|
'numeric' => TRUE,
|
179
|
'validate type' => 'nid',
|
180
|
'help' => t('Argument on a Feeds Item\'s import date field.'),
|
181
|
),
|
182
|
);
|
183
|
|
184
|
// Add a relationship for each entity type relating the entity's base table
|
185
|
// to the feeds_item table whre feeds_item.entity_type = 'entity_type'.
|
186
|
foreach (entity_get_info() as $entity_type => $info) {
|
187
|
if (!empty($info['base table'])) {
|
188
|
$data['feeds_item']['table']['join'][$info['base table']] = array(
|
189
|
'left_field' => $info['entity keys']['id'],
|
190
|
'field' => 'entity_id',
|
191
|
'type' => 'LEFT',
|
192
|
'extra' => array(
|
193
|
array(
|
194
|
'field' => 'entity_type',
|
195
|
'value' => $entity_type,
|
196
|
),
|
197
|
),
|
198
|
);
|
199
|
}
|
200
|
}
|
201
|
|
202
|
/**
|
203
|
* Expose feeds_log table to views.
|
204
|
*/
|
205
|
$data['feeds_log']['table'] = array(
|
206
|
'group' => 'Feeds log',
|
207
|
'base' => array(
|
208
|
'field' => array('flid'),
|
209
|
'title' => t('Feeds log'),
|
210
|
'help' => t('Logs events during importing, clearing, expiry.'),
|
211
|
),
|
212
|
);
|
213
|
$data['feeds_log']['flid'] = array(
|
214
|
'title' => t('Log id'),
|
215
|
'help' => t('The id of the log message.'),
|
216
|
'field' => array(
|
217
|
'handler' => 'views_handler_field',
|
218
|
'click sortable' => TRUE,
|
219
|
),
|
220
|
'filter' => array(
|
221
|
'handler' => 'views_handler_filter_numeric',
|
222
|
),
|
223
|
'argument' => array(
|
224
|
'handler' => 'views_handler_argument_numeric',
|
225
|
'numeric' => TRUE,
|
226
|
),
|
227
|
'sort' => array(
|
228
|
'handler' => 'views_handler_sort',
|
229
|
),
|
230
|
);
|
231
|
$data['feeds_log']['id'] = array(
|
232
|
'title' => t('Importer id'),
|
233
|
'help' => t('The id of an importer.'),
|
234
|
'field' => array(
|
235
|
'handler' => 'views_handler_field',
|
236
|
'click sortable' => TRUE,
|
237
|
),
|
238
|
'filter' => array(
|
239
|
'handler' => 'views_handler_filter_string',
|
240
|
'allow empty' => TRUE,
|
241
|
'help' => t('Filter on an importer id.'),
|
242
|
),
|
243
|
'argument' => array(
|
244
|
'handler' => 'feeds_views_handler_argument_importer_id',
|
245
|
'help' => t('Filter on an importer id.'),
|
246
|
),
|
247
|
'sort' => array(
|
248
|
'handler' => 'views_handler_sort',
|
249
|
'help' => t('Sort by importer id.'),
|
250
|
),
|
251
|
'relationship' => array(
|
252
|
'title' => t('Importer'),
|
253
|
'help' => t('Relate a log entry to its importer if available.'),
|
254
|
'label' => t('Importer'),
|
255
|
'base' => 'feeds_importer',
|
256
|
'base field' => 'id',
|
257
|
),
|
258
|
);
|
259
|
$data['feeds_log']['importer_name'] = array(
|
260
|
'real field' => 'id',
|
261
|
'title' => t('Importer name'),
|
262
|
'help' => t('The human readable name of an importer.'),
|
263
|
'field' => array(
|
264
|
'handler' => 'feeds_views_handler_field_importer_name',
|
265
|
),
|
266
|
);
|
267
|
$data['feeds_log']['feed_nid'] = array(
|
268
|
'title' => t('Feed node id'),
|
269
|
'help' => t('Contains the node id of a feed node if the feed\'s configuration is attached to a content type, otherwise contains 0.'),
|
270
|
'field' => array(
|
271
|
'handler' => 'views_handler_field_numeric',
|
272
|
'click sortable' => TRUE,
|
273
|
),
|
274
|
'filter' => array(
|
275
|
'handler' => 'views_handler_filter_numeric',
|
276
|
'allow empty' => TRUE,
|
277
|
'help' => t('Filter on a Feeds Source\'s feed_nid field.'),
|
278
|
),
|
279
|
'argument' => array(
|
280
|
'handler' => 'views_handler_argument_numeric',
|
281
|
'numeric' => TRUE,
|
282
|
'validate type' => 'nid',
|
283
|
'help' => t('Argument on a Feeds Source\'s feed_nid field.'),
|
284
|
),
|
285
|
'sort' => array(
|
286
|
'handler' => 'views_handler_sort',
|
287
|
'help' => t('Sort Feeds Source\'s feed_nid field.'),
|
288
|
),
|
289
|
'relationship' => array(
|
290
|
'title' => t('Feed node'),
|
291
|
'help' => t('Relate a log entry to its feed node if available.'),
|
292
|
'label' => t('Feed node'),
|
293
|
'base' => 'node',
|
294
|
'base field' => 'nid',
|
295
|
),
|
296
|
);
|
297
|
$data['feeds_log']['log_time'] = array(
|
298
|
'title' => t('Log time'),
|
299
|
'help' => t('The time of the event.'),
|
300
|
'field' => array(
|
301
|
'handler' => 'views_handler_field_date',
|
302
|
'click sortable' => TRUE,
|
303
|
),
|
304
|
'sort' => array(
|
305
|
'handler' => 'views_handler_sort_date',
|
306
|
),
|
307
|
'filter' => array(
|
308
|
'handler' => 'views_handler_filter_date',
|
309
|
),
|
310
|
'argument' => array(
|
311
|
'handler' => 'views_handler_argument_numeric',
|
312
|
),
|
313
|
'sort' => array(
|
314
|
'handler' => 'views_handler_sort',
|
315
|
),
|
316
|
);
|
317
|
$data['feeds_log']['request_time'] = array(
|
318
|
'title' => t('Request time'),
|
319
|
'help' => t('The time of the page request of an event.'),
|
320
|
'field' => array(
|
321
|
'handler' => 'views_handler_field_date',
|
322
|
'click sortable' => TRUE,
|
323
|
),
|
324
|
'sort' => array(
|
325
|
'handler' => 'views_handler_sort_date',
|
326
|
),
|
327
|
'filter' => array(
|
328
|
'handler' => 'views_handler_filter_date',
|
329
|
),
|
330
|
'argument' => array(
|
331
|
'handler' => 'views_handler_argument_numeric',
|
332
|
),
|
333
|
'sort' => array(
|
334
|
'handler' => 'views_handler_sort',
|
335
|
),
|
336
|
);
|
337
|
$data['feeds_log']['type'] = array(
|
338
|
'title' => t('Type'),
|
339
|
'help' => t('Type of log message.'),
|
340
|
'field' => array(
|
341
|
'handler' => 'views_handler_field',
|
342
|
'click sortable' => TRUE,
|
343
|
),
|
344
|
'filter' => array(
|
345
|
'handler' => 'views_handler_filter_string',
|
346
|
),
|
347
|
'argument' => array(
|
348
|
'handler' => 'views_handler_argument_string',
|
349
|
),
|
350
|
'sort' => array(
|
351
|
'handler' => 'views_handler_sort',
|
352
|
),
|
353
|
);
|
354
|
$data['feeds_log']['message'] = array(
|
355
|
'title' => t('Log message'),
|
356
|
'help' => t('The message logged by the event.'),
|
357
|
'field' => array(
|
358
|
'handler' => 'feeds_views_handler_field_log_message',
|
359
|
'click sortable' => FALSE,
|
360
|
'additional fields' => array(
|
361
|
'variables',
|
362
|
),
|
363
|
),
|
364
|
'filter' => array(
|
365
|
'handler' => 'views_handler_filter_string',
|
366
|
),
|
367
|
'sort' => array(
|
368
|
'handler' => 'views_handler_sort',
|
369
|
),
|
370
|
);
|
371
|
$data['feeds_log']['severity'] = array(
|
372
|
'title' => t('Severity'),
|
373
|
'help' => t('The severity of the event logged.'),
|
374
|
'field' => array(
|
375
|
'handler' => 'feeds_views_handler_field_severity',
|
376
|
'click sortable' => FALSE,
|
377
|
),
|
378
|
'filter' => array(
|
379
|
'handler' => 'feeds_views_handler_filter_severity',
|
380
|
'allow empty' => TRUE,
|
381
|
'help' => t('Filter on the severity of a log message.'),
|
382
|
),
|
383
|
'argument' => array(
|
384
|
'handler' => 'views_handler_argument_numeric',
|
385
|
),
|
386
|
'sort' => array(
|
387
|
'handler' => 'views_handler_sort',
|
388
|
),
|
389
|
);
|
390
|
$data['feeds_log']['table']['join'] = array(
|
391
|
'node' => array(
|
392
|
'left_field' => 'nid',
|
393
|
'field' => 'feed_nid',
|
394
|
'type' => 'LEFT',
|
395
|
),
|
396
|
);
|
397
|
|
398
|
return $data;
|
399
|
}
|
400
|
|
401
|
/**
|
402
|
* Implements hook_views_plugins().
|
403
|
*/
|
404
|
function feeds_views_plugins() {
|
405
|
return array(
|
406
|
'argument validator' => array(
|
407
|
'feed_nid' => array(
|
408
|
'title' => t('Feed node id'),
|
409
|
'handler' => 'feeds_views_plugin_argument_validate_feed_nid',
|
410
|
),
|
411
|
),
|
412
|
);
|
413
|
}
|