node.views.inc 17 KB
Newer Older
merlinofchaos's avatar
merlinofchaos committed
1
2
3
4
5
6
7
8
9
<?php

/**
 * @file
 * Provide views data and handlers for node.module.
 *
 * @ingroup views_module_handlers
 */

10
use Drupal\views\Analyzer;
11
use Drupal\views\ViewExecutable;
12

merlinofchaos's avatar
merlinofchaos committed
13
14
15
16
17
/**
 * Implements hook_views_data().
 */
function node_views_data() {

18
19
  // Define the base group of this table. Fields that don't have a group defined
  // will go into this field by default.
merlinofchaos's avatar
merlinofchaos committed
20
21
  $data['node']['table']['group'] = t('Content');

22
  // Advertise this table as a possible base table.
merlinofchaos's avatar
merlinofchaos committed
23
24
25
26
27
28
29
30
31
32
  $data['node']['table']['base'] = array(
    'field' => 'nid',
    'title' => t('Content'),
    'weight' => -10,
    'access query tag' => 'node_access',
    'defaults' => array(
      'field' => 'title',
    ),
  );
  $data['node']['table']['entity type'] = 'node';
33
  $data['node']['table']['wizard_id'] = 'node';
merlinofchaos's avatar
merlinofchaos committed
34

35
36
37
38
39
40
41
42
  $data['node_field_data']['table']['group'] = t('Content');
  $data['node_field_data']['table']['entity type'] = 'node';
  $data['node_field_data']['table']['join']['node'] = array(
    'type' => 'INNER',
    'left_field' => 'nid',
    'field' => 'nid',
  );

merlinofchaos's avatar
merlinofchaos committed
43
44
  $data['node']['nid'] = array(
    'title' => t('Nid'),
45
    'help' => t('The node ID.'),
merlinofchaos's avatar
merlinofchaos committed
46
    'field' => array(
aspilicious's avatar
aspilicious committed
47
      'id' => 'node',
merlinofchaos's avatar
merlinofchaos committed
48
49
    ),
    'argument' => array(
aspilicious's avatar
aspilicious committed
50
      'id' => 'node_nid',
51
      'name field' => 'title',
merlinofchaos's avatar
merlinofchaos committed
52
53
54
55
      'numeric' => TRUE,
      'validate type' => 'nid',
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
56
      'id' => 'numeric',
merlinofchaos's avatar
merlinofchaos committed
57
58
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
59
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
60
61
62
63
    ),
  );

  // This definition has more items in it than it needs to as an example.
64
  $data['node_field_data']['title'] = array(
65
66
    'title' => t('Title'),
    'help' => t('The content title.'),
merlinofchaos's avatar
merlinofchaos committed
67
    'field' => array(
68
69
70
71
      // This is the real field which could be left out since it is the same.
      'field' => 'title',
      // This is the UI group which could be left out since it is the same.
      'group' => t('Content'),
aspilicious's avatar
aspilicious committed
72
      'id' => 'node',
merlinofchaos's avatar
merlinofchaos committed
73
74
75
      'link_to_node default' => TRUE,
     ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
76
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
77
78
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
79
      'id' => 'string',
merlinofchaos's avatar
merlinofchaos committed
80
81
    ),
    'argument' => array(
aspilicious's avatar
aspilicious committed
82
      'id' => 'string',
merlinofchaos's avatar
merlinofchaos committed
83
84
85
    ),
  );

86
  $data['node_field_data']['created'] = array(
87
88
    'title' => t('Post date'),
    'help' => t('The date the content was posted.'),
merlinofchaos's avatar
merlinofchaos committed
89
    'field' => array(
aspilicious's avatar
aspilicious committed
90
      'id' => 'date',
merlinofchaos's avatar
merlinofchaos committed
91
92
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
93
      'id' => 'date'
merlinofchaos's avatar
merlinofchaos committed
94
95
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
96
      'id' => 'date',
merlinofchaos's avatar
merlinofchaos committed
97
98
99
    ),
  );

100
  $data['node_field_data']['changed'] = array(
101
102
    'title' => t('Updated date'),
    'help' => t('The date the content was last updated.'),
merlinofchaos's avatar
merlinofchaos committed
103
    'field' => array(
aspilicious's avatar
aspilicious committed
104
      'id' => 'date',
merlinofchaos's avatar
merlinofchaos committed
105
106
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
107
      'id' => 'date'
merlinofchaos's avatar
merlinofchaos committed
108
109
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
110
      'id' => 'date',
merlinofchaos's avatar
merlinofchaos committed
111
112
113
    ),
  );

114
  $data['node_field_data']['type'] = array(
115
116
    'title' => t('Type'),
    'help' => t('The content type (for example, "blog entry", "forum post", "story", etc).'),
merlinofchaos's avatar
merlinofchaos committed
117
    'field' => array(
aspilicious's avatar
aspilicious committed
118
      'id' => 'node_type',
merlinofchaos's avatar
merlinofchaos committed
119
120
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
121
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
122
123
    ),
    'filter' => array(
124
      'id' => 'bundle',
merlinofchaos's avatar
merlinofchaos committed
125
126
    ),
    'argument' => array(
aspilicious's avatar
aspilicious committed
127
      'id' => 'node_type',
merlinofchaos's avatar
merlinofchaos committed
128
129
130
    ),
  );

131
  $data['node_field_data']['status'] = array(
132
    'title' => t('Published status'),
merlinofchaos's avatar
merlinofchaos committed
133
134
    'help' => t('Whether or not the content is published.'),
    'field' => array(
aspilicious's avatar
aspilicious committed
135
      'id' => 'boolean',
merlinofchaos's avatar
merlinofchaos committed
136
137
138
139
140
      'output formats' => array(
        'published-notpublished' => array(t('Published'), t('Not published')),
      ),
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
141
      'id' => 'boolean',
142
      'label' => t('Published status'),
merlinofchaos's avatar
merlinofchaos committed
143
      'type' => 'yes-no',
144
145
      // Use status = 1 instead of status <> 0 in WHERE statement.
      'use_equal' => TRUE,
merlinofchaos's avatar
merlinofchaos committed
146
147
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
148
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
149
150
151
    ),
  );

152
  $data['node_field_data']['status_extra'] = array(
153
    'title' => t('Published status or admin user'),
merlinofchaos's avatar
merlinofchaos committed
154
155
156
    'help' => t('Filters out unpublished content if the current user cannot view it.'),
    'filter' => array(
      'field' => 'status',
aspilicious's avatar
aspilicious committed
157
      'id' => 'node_status',
158
      'label' => t('Published status or admin user'),
merlinofchaos's avatar
merlinofchaos committed
159
160
161
    ),
  );

162
  $data['node_field_data']['promote'] = array(
163
    'title' => t('Promoted to front page status'),
merlinofchaos's avatar
merlinofchaos committed
164
165
    'help' => t('Whether or not the content is promoted to the front page.'),
    'field' => array(
aspilicious's avatar
aspilicious committed
166
      'id' => 'boolean',
merlinofchaos's avatar
merlinofchaos committed
167
168
169
170
171
      'output formats' => array(
        'promoted-notpromoted' => array(t('Promoted'), t('Not promoted')),
      ),
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
172
      'id' => 'boolean',
173
      'label' => t('Promoted to front page status'),
merlinofchaos's avatar
merlinofchaos committed
174
175
176
      'type' => 'yes-no',
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
177
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
178
179
180
    ),
  );

181
  $data['node_field_data']['sticky'] = array(
182
    'title' => t('Sticky status'),
183
    'help' => t('Whether or not the content is sticky.'),
merlinofchaos's avatar
merlinofchaos committed
184
    'field' => array(
aspilicious's avatar
aspilicious committed
185
      'id' => 'boolean',
merlinofchaos's avatar
merlinofchaos committed
186
187
188
189
190
      'output formats' => array(
        'sticky' => array(t('Sticky'), t('Not sticky')),
      ),
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
191
      'id' => 'boolean',
192
      'label' => t('Sticky status'),
merlinofchaos's avatar
merlinofchaos committed
193
194
195
      'type' => 'yes-no',
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
196
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
197
198
199
200
      'help' => t('Whether or not the content is sticky. To list sticky content first, set this to descending.'),
    ),
  );

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
  if (module_exists('language')) {
    $data['node']['langcode'] = array(
      'title' => t('Language'),
      'help' => t('The language the content is in.'),
      'field' => array(
        'id' => 'node_language',
      ),
      'filter' => array(
        'id' => 'language',
      ),
      'argument' => array(
        'id' => 'language',
      ),
      'sort' => array(
        'id' => 'standard',
      ),
    );
  }

220
  if (Drupal::moduleHandler()->moduleExists('translation_entity')) {
221
222
223
224
225
226
227
228
229
    $data['node']['translation_link'] = array(
      'title' => t('Translation link'),
      'help' => t('Provide a link to the translations overview for nodes.'),
      'field' => array(
        'id' => 'translation_entity_link',
      ),
    );
  }

merlinofchaos's avatar
merlinofchaos committed
230
231
232
233
  // Define some fields based upon views_handler_field_entity in the entity
  // table so they can be re-used with other query backends.
  // @see views_handler_field_entity

234
235
  // Define the base group of this table. Fields that don't have a group defined
  // will go into this field by default.
236
237
  $data['views_entity_node']['table']['group'] = t('Content');

merlinofchaos's avatar
merlinofchaos committed
238
239
  $data['views_entity_node']['view_node'] = array(
    'field' => array(
240
      'title' => t('Link to content'),
merlinofchaos's avatar
merlinofchaos committed
241
      'help' => t('Provide a simple link to the content.'),
aspilicious's avatar
aspilicious committed
242
      'id' => 'node_link',
merlinofchaos's avatar
merlinofchaos committed
243
244
245
246
247
    ),
  );

  $data['views_entity_node']['edit_node'] = array(
    'field' => array(
248
      'title' => t('Link to edit content'),
merlinofchaos's avatar
merlinofchaos committed
249
      'help' => t('Provide a simple link to edit the content.'),
aspilicious's avatar
aspilicious committed
250
      'id' => 'node_link_edit',
merlinofchaos's avatar
merlinofchaos committed
251
252
253
254
255
    ),
  );

  $data['views_entity_node']['delete_node'] = array(
    'field' => array(
256
      'title' => t('Link to delete content'),
merlinofchaos's avatar
merlinofchaos committed
257
      'help' => t('Provide a simple link to delete the content.'),
aspilicious's avatar
aspilicious committed
258
      'id' => 'node_link_delete',
merlinofchaos's avatar
merlinofchaos committed
259
260
261
262
263
264
265
    ),
  );

  $data['node']['path'] = array(
    'field' => array(
      'title' => t('Path'),
      'help' => t('The aliased path to this content.'),
aspilicious's avatar
aspilicious committed
266
      'id' => 'node_path',
merlinofchaos's avatar
merlinofchaos committed
267
268
269
270
271
    ),
  );

  // Bogus fields for aliasing purposes.

272
  $data['node_field_data']['created_fulldate'] = array(
merlinofchaos's avatar
merlinofchaos committed
273
274
275
276
    'title' => t('Created date'),
    'help' => t('Date in the form of CCYYMMDD.'),
    'argument' => array(
      'field' => 'created',
277
      'id' => 'date_fulldate',
merlinofchaos's avatar
merlinofchaos committed
278
279
280
    ),
  );

281
  $data['node_field_data']['created_year_month'] = array(
merlinofchaos's avatar
merlinofchaos committed
282
283
284
285
    'title' => t('Created year + month'),
    'help' => t('Date in the form of YYYYMM.'),
    'argument' => array(
      'field' => 'created',
286
      'id' => 'date_year_month',
merlinofchaos's avatar
merlinofchaos committed
287
288
289
    ),
  );

290
  $data['node_field_data']['created_year'] = array(
merlinofchaos's avatar
merlinofchaos committed
291
292
293
294
    'title' => t('Created year'),
    'help' => t('Date in the form of YYYY.'),
    'argument' => array(
      'field' => 'created',
295
      'id' => 'date_year',
merlinofchaos's avatar
merlinofchaos committed
296
297
298
    ),
  );

299
  $data['node_field_data']['created_month'] = array(
merlinofchaos's avatar
merlinofchaos committed
300
301
302
303
    'title' => t('Created month'),
    'help' => t('Date in the form of MM (01 - 12).'),
    'argument' => array(
      'field' => 'created',
304
      'id' => 'date_month',
merlinofchaos's avatar
merlinofchaos committed
305
306
307
    ),
  );

308
  $data['node_field_data']['created_day'] = array(
merlinofchaos's avatar
merlinofchaos committed
309
310
311
312
    'title' => t('Created day'),
    'help' => t('Date in the form of DD (01 - 31).'),
    'argument' => array(
      'field' => 'created',
313
      'id' => 'date_day',
merlinofchaos's avatar
merlinofchaos committed
314
315
316
    ),
  );

317
  $data['node_field_data']['created_week'] = array(
merlinofchaos's avatar
merlinofchaos committed
318
319
320
321
    'title' => t('Created week'),
    'help' => t('Date in the form of WW (01 - 53).'),
    'argument' => array(
      'field' => 'created',
322
      'id' => 'date_week',
merlinofchaos's avatar
merlinofchaos committed
323
324
325
    ),
  );

326
  $data['node_field_data']['changed_fulldate'] = array(
merlinofchaos's avatar
merlinofchaos committed
327
328
329
330
    'title' => t('Updated date'),
    'help' => t('Date in the form of CCYYMMDD.'),
    'argument' => array(
      'field' => 'changed',
331
      'id' => 'date_fulldate',
merlinofchaos's avatar
merlinofchaos committed
332
333
334
    ),
  );

335
  $data['node_field_data']['changed_year_month'] = array(
merlinofchaos's avatar
merlinofchaos committed
336
337
338
339
    'title' => t('Updated year + month'),
    'help' => t('Date in the form of YYYYMM.'),
    'argument' => array(
      'field' => 'changed',
340
      'id' => 'date_year_month',
merlinofchaos's avatar
merlinofchaos committed
341
342
343
    ),
  );

344
  $data['node_field_data']['changed_year'] = array(
merlinofchaos's avatar
merlinofchaos committed
345
346
347
348
    'title' => t('Updated year'),
    'help' => t('Date in the form of YYYY.'),
    'argument' => array(
      'field' => 'changed',
349
      'id' => 'date_year',
merlinofchaos's avatar
merlinofchaos committed
350
351
352
    ),
  );

353
  $data['node_field_data']['changed_month'] = array(
merlinofchaos's avatar
merlinofchaos committed
354
355
356
357
    'title' => t('Updated month'),
    'help' => t('Date in the form of MM (01 - 12).'),
    'argument' => array(
      'field' => 'changed',
358
      'id' => 'date_month',
merlinofchaos's avatar
merlinofchaos committed
359
360
361
    ),
  );

362
  $data['node_field_data']['changed_day'] = array(
merlinofchaos's avatar
merlinofchaos committed
363
364
365
366
    'title' => t('Updated day'),
    'help' => t('Date in the form of DD (01 - 31).'),
    'argument' => array(
      'field' => 'changed',
367
      'id' => 'date_day',
merlinofchaos's avatar
merlinofchaos committed
368
369
370
    ),
  );

371
  $data['node_field_data']['changed_week'] = array(
merlinofchaos's avatar
merlinofchaos committed
372
373
374
375
    'title' => t('Updated week'),
    'help' => t('Date in the form of WW (01 - 53).'),
    'argument' => array(
      'field' => 'changed',
376
      'id' => 'date_week',
merlinofchaos's avatar
merlinofchaos committed
377
378
379
    ),
  );

380
  $data['node_field_data']['uid'] = array(
merlinofchaos's avatar
merlinofchaos committed
381
382
383
    'title' => t('Author uid'),
    'help' => t('The user authoring the content. If you need more fields than the uid add the content: author relationship'),
    'relationship' => array(
384
      'title' => t('Content author'),
merlinofchaos's avatar
merlinofchaos committed
385
      'help' => t('Relate content to the user who created it.'),
aspilicious's avatar
aspilicious committed
386
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
387
388
389
390
391
      'base' => 'users',
      'field' => 'uid',
      'label' => t('author'),
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
392
      'id' => 'user_name',
merlinofchaos's avatar
merlinofchaos committed
393
394
    ),
    'argument' => array(
aspilicious's avatar
aspilicious committed
395
      'id' => 'numeric',
merlinofchaos's avatar
merlinofchaos committed
396
397
    ),
    'field' => array(
aspilicious's avatar
aspilicious committed
398
      'id' => 'user',
merlinofchaos's avatar
merlinofchaos committed
399
400
401
    ),
  );

402
403
404
405
406
407
408
409
  $data['node']['node_listing_empty'] = array(
    'title' => t('Empty Node Frontpage behavior'),
    'help' => t('Provides a link to the node add overview page.'),
    'area' => array(
      'id' => 'node_listing_empty',
    ),
  );

410
  $data['node_field_data']['uid_revision'] = array(
merlinofchaos's avatar
merlinofchaos committed
411
412
413
414
    'title' => t('User has a revision'),
    'help' => t('All nodes where a certain user has a revision'),
    'real field' => 'nid',
    'filter' => array(
aspilicious's avatar
aspilicious committed
415
      'id' => 'node_uid_revision',
merlinofchaos's avatar
merlinofchaos committed
416
417
    ),
    'argument' => array(
aspilicious's avatar
aspilicious committed
418
      'id' => 'node_uid_revision',
merlinofchaos's avatar
merlinofchaos committed
419
420
421
    ),
  );

422
  $data['node_field_revision']['table']['entity type'] = 'node';
423
424
  // Define the base group of this table. Fields that don't have a group defined
  // will go into this field by default.
425
426
  $data['node_field_revision']['table']['group']  = t('Content revision');
  $data['node_field_revision']['table']['wizard_id'] = 'node_revision';
427

merlinofchaos's avatar
merlinofchaos committed
428

429
  // Advertise this table as a possible base table.
430
  $data['node_field_revision']['table']['base'] = array(
merlinofchaos's avatar
merlinofchaos committed
431
432
433
434
435
436
437
438
    'field' => 'vid',
    'title' => t('Content revision'),
    'help' => t('Content revision is a history of changes to content.'),
    'defaults' => array(
      'field' => 'title',
    ),
  );

439
  // For other base tables, explain how we join.
440
  $data['node_field_revision']['table']['join'] = array(
merlinofchaos's avatar
merlinofchaos committed
441
442
443
444
445
446
    'node' => array(
      'left_field' => 'vid',
      'field' => 'vid',
    ),
  );

447
  $data['node_field_revision']['revision_uid'] = array(
merlinofchaos's avatar
merlinofchaos committed
448
449
450
    'title' => t('User'),
    'help' => t('Relate a content revision to the user who created the revision.'),
    'relationship' => array(
aspilicious's avatar
aspilicious committed
451
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
452
453
454
455
456
457
      'base' => 'users',
      'base field' => 'uid',
      'label' => t('revision user'),
    ),
  );

458
  $data['node_field_revision']['nid'] = array(
459
460
461
    'title' => t('Nid'),
    'help' => t('The revision NID of the content revision.'),
    'field' => array(
462
      'id' => 'standard',
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
    ),
    'argument' => array(
      'id' => 'node_nid',
      'numeric' => TRUE,
    ),
    'filter' => array(
      'id' => 'numeric',
    ),
    'sort' => array(
      'id' => 'standard',
    ),
    'relationship' => array(
      'id' => 'standard',
      'base' => 'node',
      'base field' => 'nid',
      'title' => t('Content'),
      'label' => t('Get the actual content from a content revision.'),
    ),
  );

483
  $data['node_field_revision']['vid'] = array(
merlinofchaos's avatar
merlinofchaos committed
484
    'title' => t('Vid'),
485
    'help' => t('The revision ID of the content revision.'),
merlinofchaos's avatar
merlinofchaos committed
486
    'field' => array(
487
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
488
489
    ),
    'argument' => array(
aspilicious's avatar
aspilicious committed
490
      'id' => 'node_vid',
merlinofchaos's avatar
merlinofchaos committed
491
492
493
      'numeric' => TRUE,
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
494
      'id' => 'numeric',
merlinofchaos's avatar
merlinofchaos committed
495
496
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
497
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
498
499
    ),
    'relationship' => array(
aspilicious's avatar
aspilicious committed
500
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
501
502
503
504
505
506
507
      'base' => 'node',
      'base field' => 'vid',
      'title' => t('Content'),
      'label' => t('Get the actual content from a content revision.'),
    ),
  );

508
  $data['node_field_revision']['status'] = array(
509
510
511
512
513
514
515
516
517
518
519
520
    'title' => t('Published'),
    'help' => t('Whether or not the content is published.'),
    'field' => array(
      'id' => 'boolean',
      'output formats' => array(
        'published-notpublished' => array(t('Published'), t('Not published')),
      ),
    ),
    'filter' => array(
      'id' => 'boolean',
      'label' => t('Published'),
      'type' => 'yes-no',
521
522
      // Use status = 1 instead of status <> 0 in WHERE statement.
      'use_equal' => TRUE,
523
524
525
526
527
528
    ),
    'sort' => array(
      'id' => 'standard',
    ),
  );

529
  $data['node_field_revision']['title'] = array(
530
531
    'title' => t('Title'),
    'help' => t('The content title.'),
merlinofchaos's avatar
merlinofchaos committed
532
    'field' => array(
533
      'field' => 'title',
aspilicious's avatar
aspilicious committed
534
      'id' => 'node_revision',
merlinofchaos's avatar
merlinofchaos committed
535
536
     ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
537
      'id' => 'standard',
merlinofchaos's avatar
merlinofchaos committed
538
539
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
540
      'id' => 'string',
merlinofchaos's avatar
merlinofchaos committed
541
542
    ),
    'argument' => array(
aspilicious's avatar
aspilicious committed
543
      'id' => 'string',
merlinofchaos's avatar
merlinofchaos committed
544
545
546
    ),
  );

547
  $data['node_field_revision']['log'] = array(
548
549
    'title' => t('Log message'),
    'help' => t('The log message entered when the revision was created.'),
merlinofchaos's avatar
merlinofchaos committed
550
    'field' => array(
aspilicious's avatar
aspilicious committed
551
      'id' => 'xss',
merlinofchaos's avatar
merlinofchaos committed
552
553
     ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
554
      'id' => 'string',
merlinofchaos's avatar
merlinofchaos committed
555
556
557
    ),
  );

558
  $data['node_field_revision']['changed'] = array(
559
560
    'title' => t('Updated date'),
    'help' => t('The date the node was last updated.'),
merlinofchaos's avatar
merlinofchaos committed
561
    'field' => array(
aspilicious's avatar
aspilicious committed
562
      'id' => 'date',
merlinofchaos's avatar
merlinofchaos committed
563
564
    ),
    'sort' => array(
aspilicious's avatar
aspilicious committed
565
      'id' => 'date'
merlinofchaos's avatar
merlinofchaos committed
566
567
    ),
    'filter' => array(
aspilicious's avatar
aspilicious committed
568
      'id' => 'date',
merlinofchaos's avatar
merlinofchaos committed
569
570
571
    ),
  );

572
  $data['node_field_revision']['link_to_revision'] = array(
merlinofchaos's avatar
merlinofchaos committed
573
    'field' => array(
574
      'title' => t('Link to revision'),
merlinofchaos's avatar
merlinofchaos committed
575
      'help' => t('Provide a simple link to the revision.'),
aspilicious's avatar
aspilicious committed
576
      'id' => 'node_revision_link',
577
      'click sortable' => FALSE,
merlinofchaos's avatar
merlinofchaos committed
578
579
580
    ),
  );

581
  $data['node_field_revision']['revert_revision'] = array(
merlinofchaos's avatar
merlinofchaos committed
582
    'field' => array(
583
      'title' => t('Link to revert revision'),
merlinofchaos's avatar
merlinofchaos committed
584
      'help' => t('Provide a simple link to revert to the revision.'),
aspilicious's avatar
aspilicious committed
585
      'id' => 'node_revision_link_revert',
586
      'click sortable' => FALSE,
merlinofchaos's avatar
merlinofchaos committed
587
588
589
    ),
  );

590
  $data['node_field_revision']['delete_revision'] = array(
merlinofchaos's avatar
merlinofchaos committed
591
    'field' => array(
592
      'title' => t('Link to delete revision'),
merlinofchaos's avatar
merlinofchaos committed
593
      'help' => t('Provide a simple link to delete the content revision.'),
aspilicious's avatar
aspilicious committed
594
      'id' => 'node_revision_link_delete',
595
      'click sortable' => FALSE,
merlinofchaos's avatar
merlinofchaos committed
596
597
598
    ),
  );

599
600
  // Define the base group of this table. Fields that don't have a group defined
  // will go into this field by default.
merlinofchaos's avatar
merlinofchaos committed
601
602
  $data['node_access']['table']['group']  = t('Content access');

603
  // For other base tables, explain how we join.
merlinofchaos's avatar
merlinofchaos committed
604
605
606
607
608
609
610
611
612
613
  $data['node_access']['table']['join'] = array(
    'node' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );
  $data['node_access']['nid'] = array(
    'title' => t('Access'),
    'help' => t('Filter by access.'),
    'filter' => array(
aspilicious's avatar
aspilicious committed
614
      'id' => 'node_access',
merlinofchaos's avatar
merlinofchaos committed
615
616
617
618
619
620
621
622
623
624
625
626
      'help' => t('Filter for content by view access. <strong>Not necessary if you are using node as your base table.</strong>'),
    ),
  );

  return $data;
}

/**
 * Implements hook_preprocess_node().
 */
function node_row_node_view_preprocess_node(&$vars) {
  $node = $vars['node'];
627
  $options = $vars['view']->rowPlugin->options;
merlinofchaos's avatar
merlinofchaos committed
628
629

  // Prevent the comment form from showing up if this is not a page display.
630
  if ($vars['view_mode'] == 'full' && !$vars['view']->display_handler->hasPath()) {
merlinofchaos's avatar
merlinofchaos committed
631
632
633
634
635
636
637
638
639
640
641
642
    $node->comment = FALSE;
  }

  if (!$options['links']) {
    unset($vars['content']['links']);
  }

  if (!empty($options['comments']) && user_access('access comments') && $node->comment) {
    $vars['content']['comments'] = comment_node_page_additions($node);
  }
}

643
644
645
646
/**
 * Implements hook_views_wizard().
 */
function node_views_wizard() {
647
  // @todo: figure this piece out.
648
649
650
651
652
  if (module_exists('statistics')) {
    $plugins['node']['available_sorts']['node_counter-totalcount:DESC'] = t('Number of hits');
  }

}