Projet

Général

Profil

Paste
Télécharger (11,8 ko) Statistiques
| Branche: | Révision:

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

1
<?php
2

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

    
10
/**
11
 * Implements hook_views_data().
12
 */
13
function aggregator_views_data() {
14
  // ----------------------------------------------------------------------
15
  // Main Aggregator Item base table.
16
  // Define the base group of this table. Fields that don't have a group
17
  // defined will go into this field by default.
18
  $data['aggregator_item']['table']['group']  = t('Aggregator');
19

    
20
  // Advertise this table as a possible base table.
21
  $data['aggregator_item']['table']['base'] = array(
22
    'field' => 'iid',
23
    'title' => t('Aggregator item'),
24
    'help' => t("Aggregator items are imported from external RSS and Atom news feeds."),
25
  );
26

    
27
  // ----------------------------------------------------------------
28
  // Fields
29
  // Item ID / 'iid'.
30
  $data['aggregator_item']['iid'] = array(
31
    // The item it appears as on the UI,
32
    'title' => t('Item ID'),
33
    // The help that appears on the UI,
34
    'help' => t('The unique ID of the aggregator item.'),
35
    // Information for displaying the iid.
36
    'field' => array(
37
      'handler' => 'views_handler_field_numeric',
38
      'click sortable' => TRUE,
39
    ),
40
    // Information for accepting a iid as an argument.
41
    'argument' => array(
42
      'handler' => 'views_handler_argument_aggregator_iid',
43
      'name field' => 'title',
44
      // The field to display in the summary.
45
      'numeric' => TRUE,
46
    ),
47
    // Information for accepting a nid as a filter.
48
    'filter' => array(
49
      'handler' => 'views_handler_filter_numeric',
50
    ),
51
    // Information for sorting on a nid.
52
    'sort' => array(
53
      'handler' => 'views_handler_sort',
54
    ),
55
  );
56

    
57
  // Title.
58
  $data['aggregator_item']['title'] = array(
59
    // The item it appears as on the UI,
60
    'title' => t('Title'),
61
    'help' => t('The title of the aggregator item.'),
62
    // Information for displaying a title as a field.
63
    'field' => array(
64
      'handler' => 'views_handler_field_aggregator_title_link',
65
      'extra' => array('link'),
66
      'click sortable' => TRUE,
67
    ),
68
    'sort' => array(
69
      'handler' => 'views_handler_sort',
70
    ),
71
    // Information for accepting a title as a filter.
72
    'filter' => array(
73
      'handler' => 'views_handler_filter_string',
74
    ),
75
  );
76

    
77
  // Link.
78
  $data['aggregator_item']['link'] = array(
79
    // The item it appears as on the UI,
80
    'title' => t('Link'),
81
    'help' => t('The link to the original source URL of the item.'),
82
    'field' => array(
83
      'handler' => 'views_handler_field_url',
84
      'click sortable' => TRUE,
85
    ),
86
    'sort' => array(
87
      'handler' => 'views_handler_sort',
88
    ),
89
    // Information for accepting a title as a filter.
90
    'filter' => array(
91
      'handler' => 'views_handler_filter_string',
92
    ),
93
  );
94

    
95
  // Author.
96
  $data['aggregator_item']['author'] = array(
97
    // The item it appears as on the UI,
98
    'title' => t('Author'),
99
    'help' => t('The author of the original imported item.'),
100
    // Information for displaying a title as a field.
101
    'field' => array(
102
      'handler' => 'views_handler_field_aggregator_xss',
103
      'click sortable' => TRUE,
104
    ),
105
    'sort' => array(
106
      'handler' => 'views_handler_sort',
107
    ),
108
    // Information for accepting a title as a filter.
109
    'filter' => array(
110
      'handler' => 'views_handler_filter_string',
111
    ),
112
    'argument' => array(
113
      'handler' => 'views_handler_argument_string',
114
    ),
115
  );
116

    
117
  // 'guid'.
118
  $data['aggregator_item']['guid'] = array(
119
    // The item it appears as on the UI,
120
    'title' => t('GUID'),
121
    'help' => t('The guid of the original imported item.'),
122
    // Information for displaying a title as a field.
123
    'field' => array(
124
      'handler' => 'views_handler_field_xss',
125
      'click sortable' => TRUE,
126
    ),
127
    'sort' => array(
128
      'handler' => 'views_handler_sort',
129
    ),
130
    // Information for accepting a title as a filter.
131
    'filter' => array(
132
      'handler' => 'views_handler_filter_string',
133
    ),
134
    'argument' => array(
135
      'handler' => 'views_handler_argument_string',
136
    ),
137
  );
138

    
139
  // Feed body.
140
  $data['aggregator_item']['description'] = array(
141
    // The item it appears as on the UI,
142
    'title' => t('Body'),
143
    'help' => t('The actual content of the imported item.'),
144
    // Information for displaying a title as a field.
145
    'field' => array(
146
      'handler' => 'views_handler_field_aggregator_xss',
147
      'click sortable' => FALSE,
148
    ),
149
    // Information for accepting a title as a filter.
150
    'filter' => array(
151
      'handler' => 'views_handler_filter_string',
152
    ),
153
  );
154

    
155
  // Item timestamp.
156
  $data['aggregator_item']['timestamp'] = array(
157
    // The item it appears as on the UI,
158
    'title' => t('Timestamp'),
159
    'help' => t('The date the original feed item was posted. (With some feeds, this will be the date it was imported.)'),
160
    // Information for displaying a title as a field.
161
    'field' => array(
162
      'handler' => 'views_handler_field_date',
163
      'click sortable' => TRUE,
164
    ),
165
    'sort' => array(
166
      'handler' => 'views_handler_sort_date',
167
    ),
168
    // Information for accepting a title as a filter.
169
    'filter' => array(
170
      'handler' => 'views_handler_filter_date',
171
    ),
172
    'argument' => array(
173
      'handler' => 'views_handler_argument_date',
174
    ),
175
  );
176

    
177
  // ----------------------------------------------------------------------
178
  // Aggregator feed table.
179
  $data['aggregator_feed']['table']['group']  = t('Aggregator feed');
180

    
181
  // Explain how this table joins to others.
182
  $data['aggregator_feed']['table']['join'] = array(
183
    'aggregator_item' => array(
184
      'left_field' => 'fid',
185
      'field' => 'fid',
186
    ),
187
  );
188

    
189
  // Feed ID / 'fid'.
190
  $data['aggregator_feed']['fid'] = array(
191
    // The item it appears as on the UI,
192
    'title' => t('Feed ID'),
193
    // The help that appears on the UI,
194
    'help' => t('The unique ID of the aggregator feed.'),
195
    // Information for displaying the fid.
196
    'field' => array(
197
      'handler' => 'views_handler_field_numeric',
198
      'click sortable' => TRUE,
199
    ),
200
    // Information for accepting a fid as an argument.
201
    'argument' => array(
202
      'handler' => 'views_handler_argument_aggregator_fid',
203
      'name field' => 'title',
204
      // The field to display in the summary.
205
      'numeric' => TRUE,
206
    ),
207
    // Information for accepting a nid as a filter.
208
    'filter' => array(
209
      'handler' => 'views_handler_filter_numeric',
210
    ),
211
    // Information for sorting on a fid.
212
    'sort' => array(
213
      'handler' => 'views_handler_sort',
214
    ),
215
  );
216

    
217
  // Title.
218
  $data['aggregator_feed']['title'] = array(
219
    // The item it appears as on the UI,
220
    'title' => t('Title'),
221
    // The help that appears on the UI,
222
    'help' => t('The title of the aggregator feed.'),
223
    // Information for displaying a title as a field.
224
    'field' => array(
225
      'handler' => 'views_handler_field_aggregator_title_link',
226
      'extra' => array('link'),
227
      'click sortable' => TRUE,
228
    ),
229
    'sort' => array(
230
      'handler' => 'views_handler_sort',
231
    ),
232
    // Information for accepting a title as a filter.
233
    'filter' => array(
234
      'handler' => 'views_handler_filter_string',
235
    ),
236
    'argument' => array(
237
      'handler' => 'views_handler_argument_string',
238
    ),
239
  );
240

    
241
  // Link.
242
  $data['aggregator_feed']['link'] = array(
243
    // The item it appears as on the UI,
244
    'title' => t('Link'),
245
    'help' => t('The link to the source URL of the feed.'),
246
    // Information for displaying a title as a field.
247
    'field' => array(
248
      'handler' => 'views_handler_field_url',
249
      'click sortable' => TRUE,
250
    ),
251
    'sort' => array(
252
      'handler' => 'views_handler_sort',
253
    ),
254
    'filter' => array(
255
      'handler' => 'views_handler_filter_string',
256
    ),
257
  );
258

    
259
  // Feed last updated.
260
  $data['aggregator_feed']['checked'] = array(
261
    // The item it appears as on the UI,
262
    'title' => t('Last checked'),
263
    'help' => t('The date the feed was last checked for new content.'),
264
    // Information for displaying a title as a field.
265
    'field' => array(
266
      'handler' => 'views_handler_field_date',
267
      'click sortable' => TRUE,
268
    ),
269
    'sort' => array(
270
      'handler' => 'views_handler_sort_date',
271
    ),
272
    'filter' => array(
273
      'handler' => 'views_handler_filter_date',
274
    ),
275
    'argument' => array(
276
      'handler' => 'views_handler_argument_date',
277
    ),
278
  );
279

    
280
  // Feed description.
281
  $data['aggregator_feed']['description'] = array(
282
    // The item it appears as on the UI,
283
    'title' => t('Description'),
284
    'help' => t('The description of the aggregator feed.'),
285
    // Information for displaying a title as a field.
286
    'field' => array(
287
      'handler' => 'views_handler_field_xss',
288
      'click sortable' => FALSE,
289
    ),
290
    'filter' => array(
291
      'handler' => 'views_handler_filter_string',
292
    ),
293
  );
294

    
295
  // Feed last updated.
296
  $data['aggregator_feed']['modified'] = array(
297
    // The item it appears as on the UI,
298
    'title' => t('Last modified'),
299
    'help' => t('The date of the most recent new content on the feed.'),
300
    // Information for displaying a title as a field.
301
    'field' => array(
302
      'handler' => 'views_handler_field_date',
303
      'click sortable' => TRUE,
304
    ),
305
    'sort' => array(
306
      'handler' => 'views_handler_sort_date',
307
    ),
308
    // Information for accepting a title as a filter.
309
    'filter' => array(
310
      'handler' => 'views_handler_filter_date',
311
    ),
312
    'argument' => array(
313
      'handler' => 'views_handler_argument_date',
314
    ),
315
  );
316

    
317
  // ----------------------------------------------------------------------
318
  // Aggregator category feed table.
319
  $data['aggregator_category_feed']['table']['join'] = array(
320
    'aggregator_item' => array(
321
      'left_field' => 'fid',
322
      'field' => 'fid',
323
    ),
324
  );
325

    
326
  // ----------------------------------------------------------------------
327
  // Aggregator category table.
328
  $data['aggregator_category']['table']['group'] = t('Aggregator category');
329

    
330
  $data['aggregator_category']['table']['join'] = array(
331
    'aggregator_item' => array(
332
      'left_table' => 'aggregator_category_feed',
333
      'left_field' => 'cid',
334
      'field' => 'cid',
335
    ),
336
  );
337

    
338
  // Category ID / 'cid'.
339
  $data['aggregator_category']['cid'] = array(
340
    'title' => t('Category ID'),
341
    'help' => t('The unique ID of the aggregator category.'),
342
    'field' => array(
343
      'handler' => 'views_handler_field_numeric',
344
      'click sortable' => TRUE,
345
    ),
346
    'argument' => array(
347
      'handler' => 'views_handler_argument_aggregator_category_cid',
348
      'name field' => 'title',
349
      'numeric' => TRUE,
350
    ),
351
    'filter' => array(
352
      'handler' => 'views_handler_filter_aggregator_category_cid',
353
    ),
354
    'sort' => array(
355
      'handler' => 'views_handler_sort',
356
    ),
357
  );
358

    
359
  // Title.
360
  $data['aggregator_category']['title'] = array(
361
    'title' => t('Category'),
362
    'help' => t('The title of the aggregator category.'),
363
    'field' => array(
364
      'handler' => 'views_handler_field_aggregator_category',
365
      'click sortable' => TRUE,
366
    ),
367
    'sort' => array(
368
      'handler' => 'views_handler_sort',
369
    ),
370
    'filter' => array(
371
      'handler' => 'views_handler_filter_string',
372
    ),
373
  );
374

    
375
  return $data;
376
}
377

    
378
/**
379
 * Implements hook_views_plugins().
380
 */
381
function aggregator_views_plugins() {
382
  return array(
383
    'module' => 'views',
384
    // This just tells our themes are elsewhere.
385
    'row' => array(
386
      'aggregator_rss' => array(
387
        'title' => t('Aggregator item'),
388
        'help' => t('Display the aggregator item using the data from the original source.'),
389
        'handler' => 'views_plugin_row_aggregator_rss',
390
        'path' => drupal_get_path('module', 'views') . '/modules/node',
391
        // Not necessary for most modules.
392
        'theme' => 'views_view_row_rss',
393
        'base' => array('aggregator_item'),
394
        // Only works with 'node' as base.
395
        'uses options' => TRUE,
396
        'type' => 'feed',
397
        'help topic' => 'style-aggregator-rss',
398
      ),
399
    ),
400
  );
401
}