1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Provide views data and handlers for node.module.
|
6
|
*
|
7
|
* @ingroup views_module_handlers
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Implements hook_views_data().
|
12
|
*/
|
13
|
function node_views_data() {
|
14
|
// ----------------------------------------------------------------
|
15
|
// 'node' table -- basic table information.
|
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['node']['table']['group'] = t('Content');
|
19
|
|
20
|
// Advertise this table as a possible base table.
|
21
|
$data['node']['table']['base'] = array(
|
22
|
'field' => 'nid',
|
23
|
'title' => t('Content'),
|
24
|
'weight' => -10,
|
25
|
'access query tag' => 'node_access',
|
26
|
'defaults' => array(
|
27
|
'field' => 'title',
|
28
|
),
|
29
|
);
|
30
|
$data['node']['table']['entity type'] = 'node';
|
31
|
|
32
|
$data['node']['table']['default_relationship'] = array(
|
33
|
'node_revision' => array(
|
34
|
'table' => 'node_revision',
|
35
|
'field' => 'vid',
|
36
|
),
|
37
|
);
|
38
|
|
39
|
// ----------------------------------------------------------------
|
40
|
// 'node' table -- fields.
|
41
|
// Node ID / 'nid'.
|
42
|
$data['node']['nid'] = array(
|
43
|
// The item it appears as on the UI,
|
44
|
'title' => t('Nid'),
|
45
|
// The help that appears on the UI,
|
46
|
'help' => t('The node ID.'),
|
47
|
// Information for displaying the nid.
|
48
|
'field' => array(
|
49
|
'handler' => 'views_handler_field_node',
|
50
|
'click sortable' => TRUE,
|
51
|
),
|
52
|
// Information for accepting a nid as an argument.
|
53
|
'argument' => array(
|
54
|
'handler' => 'views_handler_argument_node_nid',
|
55
|
'name field' => 'title',
|
56
|
// The field to display in the summary.
|
57
|
'numeric' => TRUE,
|
58
|
'validate type' => 'nid',
|
59
|
),
|
60
|
// Information for accepting a nid as a filter.
|
61
|
'filter' => array(
|
62
|
'handler' => 'views_handler_filter_numeric',
|
63
|
),
|
64
|
// Information for sorting on a nid.
|
65
|
'sort' => array(
|
66
|
'handler' => 'views_handler_sort',
|
67
|
),
|
68
|
);
|
69
|
|
70
|
// Title.
|
71
|
// This definition has more items in it than it needs to as an example.
|
72
|
$data['node']['title'] = array(
|
73
|
// The item it appears as on the UI,
|
74
|
'title' => t('Title'),
|
75
|
// The help that appears on the UI,
|
76
|
'help' => t('The content title.'),
|
77
|
// Information for displaying a title as a field.
|
78
|
'field' => array(
|
79
|
'field' => 'title',
|
80
|
// The real field. This could be left out since it is the same.
|
81
|
'group' => t('Content'),
|
82
|
// The group it appears in on the UI. Could be left out.
|
83
|
'handler' => 'views_handler_field_node',
|
84
|
'click sortable' => TRUE,
|
85
|
'link_to_node default' => TRUE,
|
86
|
),
|
87
|
'sort' => array(
|
88
|
'handler' => 'views_handler_sort',
|
89
|
),
|
90
|
// Information for accepting a title as a filter.
|
91
|
'filter' => array(
|
92
|
'handler' => 'views_handler_filter_string',
|
93
|
),
|
94
|
'argument' => array(
|
95
|
'handler' => 'views_handler_argument_string',
|
96
|
),
|
97
|
);
|
98
|
|
99
|
// Created field.
|
100
|
$data['node']['created'] = array(
|
101
|
// The item it appears as on the UI,
|
102
|
'title' => t('Post date'),
|
103
|
// The help that appears on the UI,
|
104
|
'help' => t('The date the content was posted.'),
|
105
|
'field' => array(
|
106
|
'handler' => 'views_handler_field_date',
|
107
|
'click sortable' => TRUE,
|
108
|
),
|
109
|
'sort' => array(
|
110
|
'handler' => 'views_handler_sort_date',
|
111
|
),
|
112
|
'filter' => array(
|
113
|
'handler' => 'views_handler_filter_date',
|
114
|
),
|
115
|
);
|
116
|
|
117
|
// Changed field.
|
118
|
$data['node']['changed'] = array(
|
119
|
// The item it appears as on the UI,
|
120
|
'title' => t('Updated date'),
|
121
|
// The help that appears on the UI,
|
122
|
'help' => t('The date the content was last updated.'),
|
123
|
'field' => array(
|
124
|
'handler' => 'views_handler_field_date',
|
125
|
'click sortable' => TRUE,
|
126
|
),
|
127
|
'sort' => array(
|
128
|
'handler' => 'views_handler_sort_date',
|
129
|
),
|
130
|
'filter' => array(
|
131
|
'handler' => 'views_handler_filter_date',
|
132
|
),
|
133
|
);
|
134
|
|
135
|
// Content type.
|
136
|
$data['node']['type'] = array(
|
137
|
// The item it appears as on the UI,
|
138
|
'title' => t('Type'),
|
139
|
// The help that appears on the UI,
|
140
|
'help' => t('The content type (for example, "blog entry", "forum post", "story", etc).'),
|
141
|
'field' => array(
|
142
|
'handler' => 'views_handler_field_node_type',
|
143
|
'click sortable' => TRUE,
|
144
|
),
|
145
|
'sort' => array(
|
146
|
'handler' => 'views_handler_sort',
|
147
|
),
|
148
|
'filter' => array(
|
149
|
'handler' => 'views_handler_filter_node_type',
|
150
|
),
|
151
|
'argument' => array(
|
152
|
'handler' => 'views_handler_argument_node_type',
|
153
|
),
|
154
|
);
|
155
|
|
156
|
// Published status.
|
157
|
$data['node']['status'] = array(
|
158
|
'title' => t('Published'),
|
159
|
'help' => t('Whether or not the content is published.'),
|
160
|
'field' => array(
|
161
|
'handler' => 'views_handler_field_boolean',
|
162
|
'click sortable' => TRUE,
|
163
|
'output formats' => array(
|
164
|
'published-notpublished' => array(t('Published'), t('Not published')),
|
165
|
),
|
166
|
),
|
167
|
'filter' => array(
|
168
|
'handler' => 'views_handler_filter_boolean_operator',
|
169
|
'label' => t('Published'),
|
170
|
'type' => 'yes-no',
|
171
|
'use equal' => TRUE,
|
172
|
// Use status = 1 instead of status <> 0 in WHERE statment.
|
173
|
),
|
174
|
'sort' => array(
|
175
|
'handler' => 'views_handler_sort',
|
176
|
),
|
177
|
);
|
178
|
|
179
|
// Published status + extra.
|
180
|
$data['node']['status_extra'] = array(
|
181
|
'title' => t('Published or admin'),
|
182
|
'help' => t('Filters out unpublished content if the current user cannot view it.'),
|
183
|
'filter' => array(
|
184
|
'field' => 'status',
|
185
|
'handler' => 'views_handler_filter_node_status',
|
186
|
'label' => t('Published or admin'),
|
187
|
),
|
188
|
);
|
189
|
|
190
|
// Promote status.
|
191
|
$data['node']['promote'] = array(
|
192
|
'title' => t('Promoted to front page'),
|
193
|
'help' => t('Whether or not the content is promoted to the front page.'),
|
194
|
'field' => array(
|
195
|
'handler' => 'views_handler_field_boolean',
|
196
|
'click sortable' => TRUE,
|
197
|
'output formats' => array(
|
198
|
'promoted-notpromoted' => array(t('Promoted'), t('Not promoted')),
|
199
|
),
|
200
|
),
|
201
|
'filter' => array(
|
202
|
'handler' => 'views_handler_filter_boolean_operator',
|
203
|
'label' => t('Promoted to front page'),
|
204
|
'type' => 'yes-no',
|
205
|
),
|
206
|
'sort' => array(
|
207
|
'handler' => 'views_handler_sort',
|
208
|
),
|
209
|
);
|
210
|
|
211
|
// Sticky.
|
212
|
$data['node']['sticky'] = array(
|
213
|
// The item it appears as on the UI,
|
214
|
'title' => t('Sticky'),
|
215
|
// The help that appears on the UI,
|
216
|
'help' => t('Whether or not the content is sticky.'),
|
217
|
// Information for displaying a title as a field.
|
218
|
'field' => array(
|
219
|
'handler' => 'views_handler_field_boolean',
|
220
|
'click sortable' => TRUE,
|
221
|
'output formats' => array(
|
222
|
'sticky' => array(t('Sticky'), t('Not sticky')),
|
223
|
),
|
224
|
),
|
225
|
'filter' => array(
|
226
|
'handler' => 'views_handler_filter_boolean_operator',
|
227
|
'label' => t('Sticky'),
|
228
|
'type' => 'yes-no',
|
229
|
),
|
230
|
'sort' => array(
|
231
|
'handler' => 'views_handler_sort',
|
232
|
'help' => t('Whether or not the content is sticky. To list sticky content first, set this to descending.'),
|
233
|
),
|
234
|
);
|
235
|
|
236
|
// Define some fields based upon views_handler_field_entity in the entity
|
237
|
// table so they can be re-used with other query backends.
|
238
|
// @see views_handler_field_entity()
|
239
|
$data['views_entity_node']['table']['group'] = t('Content');
|
240
|
|
241
|
$data['node']['view_node']['moved to'] = array('views_entity_node', 'view_node');
|
242
|
$data['views_entity_node']['view_node'] = array(
|
243
|
'field' => array(
|
244
|
'title' => t('Link'),
|
245
|
'help' => t('Provide a simple link to the content.'),
|
246
|
'handler' => 'views_handler_field_node_link',
|
247
|
),
|
248
|
);
|
249
|
|
250
|
$data['node']['edit_node']['moved to'] = array('views_entity_node', 'edit_node');
|
251
|
$data['views_entity_node']['edit_node'] = array(
|
252
|
'field' => array(
|
253
|
'title' => t('Edit link'),
|
254
|
'help' => t('Provide a simple link to edit the content.'),
|
255
|
'handler' => 'views_handler_field_node_link_edit',
|
256
|
),
|
257
|
);
|
258
|
|
259
|
$data['node']['delete_node']['moved to'] = array('views_entity_node', 'delete_node');
|
260
|
$data['views_entity_node']['delete_node'] = array(
|
261
|
'field' => array(
|
262
|
'title' => t('Delete link'),
|
263
|
'help' => t('Provide a simple link to delete the content.'),
|
264
|
'handler' => 'views_handler_field_node_link_delete',
|
265
|
),
|
266
|
);
|
267
|
|
268
|
$data['node']['path'] = array(
|
269
|
'field' => array(
|
270
|
'title' => t('Path'),
|
271
|
'help' => t('The aliased path to this content.'),
|
272
|
'handler' => 'views_handler_field_node_path',
|
273
|
),
|
274
|
);
|
275
|
|
276
|
// Bogus fields for aliasing purposes.
|
277
|
$data['node']['created_fulldate'] = array(
|
278
|
'title' => t('Created date'),
|
279
|
'help' => t('Date in the form of CCYYMMDD.'),
|
280
|
'argument' => array(
|
281
|
'field' => 'created',
|
282
|
'handler' => 'views_handler_argument_node_created_fulldate',
|
283
|
),
|
284
|
);
|
285
|
|
286
|
$data['node']['created_year_month'] = array(
|
287
|
'title' => t('Created year + month'),
|
288
|
'help' => t('Date in the form of YYYYMM.'),
|
289
|
'argument' => array(
|
290
|
'field' => 'created',
|
291
|
'handler' => 'views_handler_argument_node_created_year_month',
|
292
|
),
|
293
|
);
|
294
|
|
295
|
$data['node']['created_year'] = array(
|
296
|
'title' => t('Created year'),
|
297
|
'help' => t('Date in the form of YYYY.'),
|
298
|
'argument' => array(
|
299
|
'field' => 'created',
|
300
|
'handler' => 'views_handler_argument_node_created_year',
|
301
|
),
|
302
|
);
|
303
|
|
304
|
$data['node']['created_month'] = array(
|
305
|
'title' => t('Created month'),
|
306
|
'help' => t('Date in the form of MM (01 - 12).'),
|
307
|
'argument' => array(
|
308
|
'field' => 'created',
|
309
|
'handler' => 'views_handler_argument_node_created_month',
|
310
|
),
|
311
|
);
|
312
|
|
313
|
$data['node']['created_day'] = array(
|
314
|
'title' => t('Created day'),
|
315
|
'help' => t('Date in the form of DD (01 - 31).'),
|
316
|
'argument' => array(
|
317
|
'field' => 'created',
|
318
|
'handler' => 'views_handler_argument_node_created_day',
|
319
|
),
|
320
|
);
|
321
|
|
322
|
$data['node']['created_week'] = array(
|
323
|
'title' => t('Created week'),
|
324
|
'help' => t('Date in the form of WW (01 - 53).'),
|
325
|
'argument' => array(
|
326
|
'field' => 'created',
|
327
|
'handler' => 'views_handler_argument_node_created_week',
|
328
|
),
|
329
|
);
|
330
|
|
331
|
$data['node']['changed_fulldate'] = array(
|
332
|
'title' => t('Updated date'),
|
333
|
'help' => t('Date in the form of CCYYMMDD.'),
|
334
|
'argument' => array(
|
335
|
'field' => 'changed',
|
336
|
'handler' => 'views_handler_argument_node_created_fulldate',
|
337
|
),
|
338
|
);
|
339
|
|
340
|
$data['node']['changed_year_month'] = array(
|
341
|
'title' => t('Updated year + month'),
|
342
|
'help' => t('Date in the form of YYYYMM.'),
|
343
|
'argument' => array(
|
344
|
'field' => 'changed',
|
345
|
'handler' => 'views_handler_argument_node_created_year_month',
|
346
|
),
|
347
|
);
|
348
|
|
349
|
$data['node']['changed_year'] = array(
|
350
|
'title' => t('Updated year'),
|
351
|
'help' => t('Date in the form of YYYY.'),
|
352
|
'argument' => array(
|
353
|
'field' => 'changed',
|
354
|
'handler' => 'views_handler_argument_node_created_year',
|
355
|
),
|
356
|
);
|
357
|
|
358
|
$data['node']['changed_month'] = array(
|
359
|
'title' => t('Updated month'),
|
360
|
'help' => t('Date in the form of MM (01 - 12).'),
|
361
|
'argument' => array(
|
362
|
'field' => 'changed',
|
363
|
'handler' => 'views_handler_argument_node_created_month',
|
364
|
),
|
365
|
);
|
366
|
|
367
|
$data['node']['changed_day'] = array(
|
368
|
'title' => t('Updated day'),
|
369
|
'help' => t('Date in the form of DD (01 - 31).'),
|
370
|
'argument' => array(
|
371
|
'field' => 'changed',
|
372
|
'handler' => 'views_handler_argument_node_created_day',
|
373
|
),
|
374
|
);
|
375
|
|
376
|
$data['node']['changed_week'] = array(
|
377
|
'title' => t('Updated week'),
|
378
|
'help' => t('Date in the form of WW (01 - 53).'),
|
379
|
'argument' => array(
|
380
|
'field' => 'changed',
|
381
|
'handler' => 'views_handler_argument_node_created_week',
|
382
|
),
|
383
|
);
|
384
|
|
385
|
// User ID / 'uid' field.
|
386
|
$data['node']['uid'] = array(
|
387
|
'title' => t('Author uid'),
|
388
|
'help' => t('The user authoring the content. If you need more fields than the uid add the content: author relationship'),
|
389
|
'relationship' => array(
|
390
|
'title' => t('Author'),
|
391
|
'help' => t('Relate content to the user who created it.'),
|
392
|
'handler' => 'views_handler_relationship',
|
393
|
'base' => 'users',
|
394
|
'field' => 'uid',
|
395
|
'label' => t('author'),
|
396
|
),
|
397
|
'filter' => array(
|
398
|
'handler' => 'views_handler_filter_user_name',
|
399
|
),
|
400
|
'argument' => array(
|
401
|
'handler' => 'views_handler_argument_numeric',
|
402
|
),
|
403
|
'field' => array(
|
404
|
'handler' => 'views_handler_field_user',
|
405
|
),
|
406
|
);
|
407
|
|
408
|
$data['node']['uid_revision'] = array(
|
409
|
'title' => t('User has a revision'),
|
410
|
'help' => t('All nodes where a certain user has a revision'),
|
411
|
'real field' => 'nid',
|
412
|
'filter' => array(
|
413
|
'handler' => 'views_handler_filter_node_uid_revision',
|
414
|
),
|
415
|
'argument' => array(
|
416
|
'handler' => 'views_handler_argument_node_uid_revision',
|
417
|
),
|
418
|
);
|
419
|
|
420
|
$data['node']['version_count'] = array(
|
421
|
'title' => t('Version Count'),
|
422
|
'help' => t('The total count of versions/revisions of a certain node.'),
|
423
|
'field' => array(
|
424
|
'handler' => 'views_handler_field_node_version_count',
|
425
|
'field' => 'nid',
|
426
|
'click sortable' => TRUE,
|
427
|
),
|
428
|
'filter' => array(
|
429
|
'handler' => 'views_handler_filter_node_version_count',
|
430
|
'allow empty' => FALSE,
|
431
|
),
|
432
|
'sort' => array(
|
433
|
'handler' => 'views_handler_sort_node_version_count',
|
434
|
),
|
435
|
);
|
436
|
|
437
|
// ----------------------------------------------------------------------
|
438
|
// Content revision table.
|
439
|
// Define the base group of this table. Fields that don't have a group
|
440
|
// defined will go into this field by default.
|
441
|
$data['node_revisions']['moved to'] = 'node_revision';
|
442
|
$data['node_revision']['table']['entity type'] = 'node';
|
443
|
$data['node_revision']['table']['revision'] = TRUE;
|
444
|
$data['node_revision']['table']['group'] = t('Content revision');
|
445
|
// Support the conversion of the field body.
|
446
|
$data['node_revisions']['body']['moved to'] = array('field_revision_data', 'body-revision_id');
|
447
|
|
448
|
// Advertise this table as a possible base table.
|
449
|
$data['node_revision']['table']['base'] = array(
|
450
|
'field' => 'vid',
|
451
|
'title' => t('Content revision'),
|
452
|
'help' => t('Content revision is a history of changes to content.'),
|
453
|
'defaults' => array(
|
454
|
'field' => 'title',
|
455
|
),
|
456
|
);
|
457
|
|
458
|
// For other base tables, explain how we join.
|
459
|
$data['node_revision']['table']['join'] = array(
|
460
|
// Directly links to node table.
|
461
|
'node' => array(
|
462
|
'left_field' => 'vid',
|
463
|
'field' => 'vid',
|
464
|
),
|
465
|
);
|
466
|
|
467
|
$data['node_revision']['table']['default_relationship'] = array(
|
468
|
'node' => array(
|
469
|
'table' => 'node',
|
470
|
'field' => 'nid',
|
471
|
),
|
472
|
);
|
473
|
|
474
|
// User ID / 'uid' field for node revision.
|
475
|
$data['node_revision']['uid'] = array(
|
476
|
'title' => t('User'),
|
477
|
'help' => t('Relate a content revision to the user who created the revision.'),
|
478
|
'relationship' => array(
|
479
|
'handler' => 'views_handler_relationship',
|
480
|
'base' => 'users',
|
481
|
'base field' => 'uid',
|
482
|
'label' => t('revision user'),
|
483
|
),
|
484
|
);
|
485
|
|
486
|
// Node ID / 'nid'.
|
487
|
$data['node_revision']['nid'] = array(
|
488
|
'title' => t('Nid'),
|
489
|
// The help that appears on the UI.
|
490
|
'help' => t('The revision NID of the content revision.'),
|
491
|
// Information for displaying the nid.
|
492
|
'field' => array(
|
493
|
'click sortable' => TRUE,
|
494
|
),
|
495
|
// Information for accepting a nid as an argument.
|
496
|
'argument' => array(
|
497
|
'handler' => 'views_handler_argument_node_nid',
|
498
|
'click sortable' => TRUE,
|
499
|
'numeric' => TRUE,
|
500
|
),
|
501
|
// Information for accepting a nid as a filter.
|
502
|
'filter' => array(
|
503
|
'handler' => 'views_handler_filter_numeric',
|
504
|
),
|
505
|
// Information for sorting on a nid.
|
506
|
'sort' => array(
|
507
|
'handler' => 'views_handler_sort',
|
508
|
),
|
509
|
'relationship' => array(
|
510
|
'handler' => 'views_handler_relationship',
|
511
|
'base' => 'node',
|
512
|
'base field' => 'nid',
|
513
|
'title' => t('Content'),
|
514
|
'label' => t('Get the actual content from a content revision.'),
|
515
|
),
|
516
|
);
|
517
|
|
518
|
// Revision ID / 'vid'.
|
519
|
$data['node_revision']['vid'] = array(
|
520
|
'title' => t('Vid'),
|
521
|
// The help that appears on the UI.
|
522
|
'help' => t('The revision ID of the content revision.'),
|
523
|
// Information for displaying the vid.
|
524
|
'field' => array(
|
525
|
'click sortable' => TRUE,
|
526
|
),
|
527
|
// Information for accepting a vid as an argument.
|
528
|
'argument' => array(
|
529
|
'handler' => 'views_handler_argument_node_vid',
|
530
|
'click sortable' => TRUE,
|
531
|
'numeric' => TRUE,
|
532
|
),
|
533
|
// Information for accepting a vid as a filter.
|
534
|
'filter' => array(
|
535
|
'handler' => 'views_handler_filter_numeric',
|
536
|
),
|
537
|
// Information for sorting on a vid.
|
538
|
'sort' => array(
|
539
|
'handler' => 'views_handler_sort',
|
540
|
),
|
541
|
'relationship' => array(
|
542
|
'handler' => 'views_handler_relationship',
|
543
|
'base' => 'node',
|
544
|
'base field' => 'vid',
|
545
|
'title' => t('Content'),
|
546
|
'label' => t('Get the actual content from a content revision.'),
|
547
|
),
|
548
|
);
|
549
|
|
550
|
// Title.
|
551
|
$data['node_revision']['title'] = array(
|
552
|
// The item it appears as on the UI,
|
553
|
'title' => t('Title'),
|
554
|
// The help that appears on the UI,
|
555
|
'help' => t('The content title.'),
|
556
|
// Information for displaying a title as a field.
|
557
|
'field' => array(
|
558
|
'field' => 'title',
|
559
|
// The real field.
|
560
|
'handler' => 'views_handler_field_node_revision',
|
561
|
'click sortable' => TRUE,
|
562
|
),
|
563
|
'sort' => array(
|
564
|
'handler' => 'views_handler_sort',
|
565
|
),
|
566
|
'filter' => array(
|
567
|
'handler' => 'views_handler_filter_string',
|
568
|
),
|
569
|
'argument' => array(
|
570
|
'handler' => 'views_handler_argument_string',
|
571
|
),
|
572
|
);
|
573
|
|
574
|
// Log field.
|
575
|
$data['node_revision']['log'] = array(
|
576
|
// The item it appears as on the UI,
|
577
|
'title' => t('Log message'),
|
578
|
// The help that appears on the UI,
|
579
|
'help' => t('The log message entered when the revision was created.'),
|
580
|
// Information for displaying a title as a field.
|
581
|
'field' => array(
|
582
|
'handler' => 'views_handler_field_xss',
|
583
|
),
|
584
|
'filter' => array(
|
585
|
'handler' => 'views_handler_filter_string',
|
586
|
),
|
587
|
);
|
588
|
|
589
|
// Revision timestamp / 'changed' field.
|
590
|
$data['node_revision']['timestamp'] = array(
|
591
|
// The item it appears as on the UI,
|
592
|
'title' => t('Updated date'),
|
593
|
// The help that appears on the UI,
|
594
|
'help' => t('The date the node was last updated.'),
|
595
|
'field' => array(
|
596
|
'handler' => 'views_handler_field_date',
|
597
|
'click sortable' => TRUE,
|
598
|
),
|
599
|
'sort' => array(
|
600
|
'handler' => 'views_handler_sort_date',
|
601
|
),
|
602
|
'filter' => array(
|
603
|
'handler' => 'views_handler_filter_date',
|
604
|
),
|
605
|
);
|
606
|
|
607
|
$data['node_revision']['link_to_revision'] = array(
|
608
|
'field' => array(
|
609
|
'title' => t('Link'),
|
610
|
'help' => t('Provide a simple link to the revision.'),
|
611
|
'handler' => 'views_handler_field_node_revision_link',
|
612
|
),
|
613
|
);
|
614
|
|
615
|
$data['node_revision']['revert_revision'] = array(
|
616
|
'field' => array(
|
617
|
'title' => t('Revert link'),
|
618
|
'help' => t('Provide a simple link to revert to the revision.'),
|
619
|
'handler' => 'views_handler_field_node_revision_link_revert',
|
620
|
),
|
621
|
);
|
622
|
|
623
|
$data['node_revision']['delete_revision'] = array(
|
624
|
'field' => array(
|
625
|
'title' => t('Delete link'),
|
626
|
'help' => t('Provide a simple link to delete the content revision.'),
|
627
|
'handler' => 'views_handler_field_node_revision_link_delete',
|
628
|
),
|
629
|
);
|
630
|
|
631
|
// ----------------------------------------------------------------------
|
632
|
// Node access table.
|
633
|
// Define the base group of this table. Fields that don't have a group
|
634
|
// defined will go into this field by default.
|
635
|
$data['node_access']['table']['group'] = t('Content access');
|
636
|
|
637
|
// For other base tables, explain how we join.
|
638
|
$data['node_access']['table']['join'] = array(
|
639
|
// Directly links to node table.
|
640
|
'node' => array(
|
641
|
'left_field' => 'nid',
|
642
|
'field' => 'nid',
|
643
|
),
|
644
|
);
|
645
|
// Node ID / 'nid' field.
|
646
|
$data['node_access']['nid'] = array(
|
647
|
'title' => t('Access'),
|
648
|
'help' => t('Filter by access.'),
|
649
|
'filter' => array(
|
650
|
'handler' => 'views_handler_filter_node_access',
|
651
|
'help' => t('Filter for content by view access. <strong>Not necessary if you are using node as your base table.</strong>'),
|
652
|
),
|
653
|
);
|
654
|
|
655
|
// ----------------------------------------------------------------------
|
656
|
// History table.
|
657
|
// We're actually defining a specific instance of the table, so let's alias
|
658
|
// it so that we can later add the real table for other purposes if we need
|
659
|
// it.
|
660
|
$data['history_user']['moved to'] = 'history';
|
661
|
$data['history']['table']['group'] = t('Content');
|
662
|
|
663
|
// Explain how this table joins to others.
|
664
|
$data['history']['table']['join'] = array(
|
665
|
// Directly links to node table.
|
666
|
'node' => array(
|
667
|
'table' => 'history',
|
668
|
'left_field' => 'nid',
|
669
|
'field' => 'nid',
|
670
|
'extra' => array(
|
671
|
array('field' => 'uid', 'value' => '***CURRENT_USER***', 'numeric' => TRUE),
|
672
|
),
|
673
|
),
|
674
|
);
|
675
|
|
676
|
$data['history']['timestamp'] = array(
|
677
|
'title' => t('Has new content'),
|
678
|
'field' => array(
|
679
|
'handler' => 'views_handler_field_history_user_timestamp',
|
680
|
'help' => t('Show a marker if the content is new or updated.'),
|
681
|
),
|
682
|
'filter' => array(
|
683
|
'help' => t('Show only content that is new or updated.'),
|
684
|
'handler' => 'views_handler_filter_history_user_timestamp',
|
685
|
),
|
686
|
);
|
687
|
return $data;
|
688
|
}
|
689
|
|
690
|
/**
|
691
|
* Implements hook_views_plugins().
|
692
|
*/
|
693
|
function node_views_plugins() {
|
694
|
return array(
|
695
|
'module' => 'views',
|
696
|
// This just tells our themes are elsewhere.
|
697
|
'row' => array(
|
698
|
'node' => array(
|
699
|
'title' => t('Content'),
|
700
|
'help' => t('Display the content with standard node view.'),
|
701
|
'handler' => 'views_plugin_row_node_view',
|
702
|
'path' => drupal_get_path('module', 'views') . '/modules/node',
|
703
|
// Not necessary for most modules.
|
704
|
'base' => array('node'),
|
705
|
// Only works with 'node' as base.
|
706
|
'uses options' => TRUE,
|
707
|
'type' => 'normal',
|
708
|
'help topic' => 'style-node',
|
709
|
),
|
710
|
'node_rss' => array(
|
711
|
'title' => t('Content'),
|
712
|
'help' => t('Display the content with standard node view.'),
|
713
|
'handler' => 'views_plugin_row_node_rss',
|
714
|
'path' => drupal_get_path('module', 'views') . '/modules/node',
|
715
|
// Not necessary for most modules.
|
716
|
'theme' => 'views_view_row_rss',
|
717
|
'base' => array('node'),
|
718
|
// Only works with 'node' as base.
|
719
|
'uses options' => TRUE,
|
720
|
'type' => 'feed',
|
721
|
'help topic' => 'style-node-rss',
|
722
|
),
|
723
|
),
|
724
|
'argument validator' => array(
|
725
|
'node' => array(
|
726
|
'title' => t('Content'),
|
727
|
'handler' => 'views_plugin_argument_validate_node',
|
728
|
),
|
729
|
),
|
730
|
'argument default' => array(
|
731
|
'node' => array(
|
732
|
'title' => t('Content ID from URL'),
|
733
|
'handler' => 'views_plugin_argument_default_node',
|
734
|
),
|
735
|
),
|
736
|
);
|
737
|
}
|
738
|
|
739
|
/**
|
740
|
* Implements hook_preprocess_node().
|
741
|
*/
|
742
|
function node_row_node_view_preprocess_node(&$vars) {
|
743
|
$node = $vars['node'];
|
744
|
$options = $vars['view']->style_plugin->row_plugin->options;
|
745
|
|
746
|
// Prevent the comment form from showing up if this is not a page display.
|
747
|
if ($vars['view_mode'] == 'full' && !$vars['view']->display_handler->has_path()) {
|
748
|
$node->comment = FALSE;
|
749
|
}
|
750
|
|
751
|
if (!$options['links']) {
|
752
|
unset($vars['content']['links']);
|
753
|
}
|
754
|
|
755
|
if (module_exists('comment') && !empty($options['comments']) && user_access('access comments') && $node->comment) {
|
756
|
$vars['content']['comments'] = comment_node_page_additions($node);
|
757
|
}
|
758
|
}
|
759
|
|
760
|
/**
|
761
|
* Implements hook_views_query_substitutions().
|
762
|
*/
|
763
|
function node_views_query_substitutions() {
|
764
|
return array(
|
765
|
'***ADMINISTER_NODES***' => intval(user_access('administer nodes')),
|
766
|
'***VIEW_OWN_UNPUBLISHED_NODES***' => intval(user_access('view own unpublished content')),
|
767
|
'***BYPASS_NODE_ACCESS***' => intval(user_access('bypass node access')),
|
768
|
);
|
769
|
}
|
770
|
|
771
|
/**
|
772
|
* Implements hook_views_analyze().
|
773
|
*/
|
774
|
function node_views_analyze($view) {
|
775
|
$ret = array();
|
776
|
// Check for something other than the default display.
|
777
|
if ($view->base_table == 'node') {
|
778
|
foreach ($view->display as $id => $display) {
|
779
|
if (empty($display->handler)) {
|
780
|
continue;
|
781
|
}
|
782
|
if (!$display->handler->is_defaulted('access') || !$display->handler->is_defaulted('filters')) {
|
783
|
// Check for no access control.
|
784
|
$access = $display->handler->get_option('access');
|
785
|
if (empty($access['type']) || $access['type'] == 'none') {
|
786
|
$select = db_select('role', 'r');
|
787
|
$select->innerJoin('role_permission', 'p', 'r.rid = p.rid');
|
788
|
$result = $select->fields('r', array('name'))
|
789
|
->fields('p', array('permission'))
|
790
|
->condition('r.name', array('anonymous user', 'authenticated user'), 'IN')
|
791
|
->condition('p.permission', 'access content')
|
792
|
->execute();
|
793
|
|
794
|
foreach ($result as $role) {
|
795
|
$role->safe = TRUE;
|
796
|
$roles[$role->name] = $role;
|
797
|
}
|
798
|
if (!($roles['anonymous user']->safe && $roles['authenticated user']->safe)) {
|
799
|
$ret[] = views_ui_analysis(t('Some roles lack permission to access content, but display %display has no access control.', array('%display' => $display->display_title)), 'warning');
|
800
|
}
|
801
|
$filters = $display->handler->get_option('filters');
|
802
|
foreach ($filters as $filter) {
|
803
|
if ($filter['table'] == 'node' && ($filter['field'] == 'status' || $filter['field'] == 'status_extra')) {
|
804
|
continue 2;
|
805
|
}
|
806
|
}
|
807
|
$ret[] = views_ui_analysis(t('Display %display has no access control but does not contain a filter for published nodes.', array('%display' => $display->display_title)), 'warning');
|
808
|
}
|
809
|
}
|
810
|
}
|
811
|
}
|
812
|
foreach ($view->display as $id => $display) {
|
813
|
if ($display->display_plugin == 'page') {
|
814
|
if ($display->handler->get_option('path') == 'node/%') {
|
815
|
$ret[] = views_ui_analysis(t('Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use panels.', array('%display' => $display->display_title)), 'warning');
|
816
|
}
|
817
|
}
|
818
|
}
|
819
|
|
820
|
return $ret;
|
821
|
}
|