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