1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Provide views data and handlers for comment.module.
|
6
|
*
|
7
|
* @ingroup views_module_handlers
|
8
|
*/
|
9
|
|
10
|
/**
|
11
|
* Implements hook_views_data().
|
12
|
*/
|
13
|
|
14
|
function comment_views_data() {
|
15
|
$data['comments']['moved to'] = 'comment';
|
16
|
$data['comment']['comment']['moved to'] = array('field_data_comment_body', 'comment_body');
|
17
|
$data['comment']['comment']['field']['moved to'] = array('field_data_comment_body', 'comment_body');
|
18
|
// Define the base group of this table. Fields that don't
|
19
|
// have a group defined will go into this field by default.
|
20
|
$data['comment']['table']['group'] = t('Comment');
|
21
|
|
22
|
$data['comment']['table']['base'] = array(
|
23
|
'field' => 'cid',
|
24
|
'title' => t('Comment'),
|
25
|
'help' => t("Comments are responses to node content."),
|
26
|
'access query tag' => 'comment_access',
|
27
|
);
|
28
|
$data['comment']['table']['entity type'] = 'comment';
|
29
|
|
30
|
// Provide a "default relationship" to keep older views from choking.
|
31
|
$data['comment']['table']['default_relationship'] = array(
|
32
|
'node' => array(
|
33
|
'table' => 'node',
|
34
|
'field' => 'cid',
|
35
|
),
|
36
|
);
|
37
|
|
38
|
// ----------------------------------------------------------------
|
39
|
// Fields
|
40
|
|
41
|
// subject
|
42
|
$data['comment']['subject'] = array(
|
43
|
'title' => t('Title'),
|
44
|
'help' => t('The title of the comment.'),
|
45
|
'field' => array(
|
46
|
'handler' => 'views_handler_field_comment',
|
47
|
'click sortable' => TRUE,
|
48
|
),
|
49
|
'filter' => array(
|
50
|
'handler' => 'views_handler_filter_string',
|
51
|
),
|
52
|
'sort' => array(
|
53
|
'handler' => 'views_handler_sort',
|
54
|
),
|
55
|
'argument' => array(
|
56
|
'handler' => 'views_handler_argument_string',
|
57
|
),
|
58
|
);
|
59
|
|
60
|
// cid
|
61
|
$data['comment']['cid'] = array(
|
62
|
'title' => t('ID'),
|
63
|
'help' => t('The comment ID of the field'),
|
64
|
'field' => array(
|
65
|
'handler' => 'views_handler_field_comment',
|
66
|
'click sortable' => TRUE,
|
67
|
),
|
68
|
'filter' => array(
|
69
|
'handler' => 'views_handler_filter_numeric',
|
70
|
),
|
71
|
'sort' => array(
|
72
|
'handler' => 'views_handler_sort',
|
73
|
),
|
74
|
'argument' => array(
|
75
|
'handler' => 'views_handler_argument_numeric',
|
76
|
),
|
77
|
);
|
78
|
|
79
|
// name (of comment author)
|
80
|
$data['comment']['name'] = array(
|
81
|
'title' => t('Author'),
|
82
|
'help' => t("The name of the comment's author. Can be rendered as a link to the author's homepage."),
|
83
|
'field' => array(
|
84
|
'handler' => 'views_handler_field_comment_username',
|
85
|
'click sortable' => TRUE,
|
86
|
),
|
87
|
'filter' => array(
|
88
|
'handler' => 'views_handler_filter_string',
|
89
|
),
|
90
|
'sort' => array(
|
91
|
'handler' => 'views_handler_sort',
|
92
|
),
|
93
|
'argument' => array(
|
94
|
'handler' => 'views_handler_argument_string',
|
95
|
),
|
96
|
);
|
97
|
|
98
|
// homepage
|
99
|
$data['comment']['homepage'] = array(
|
100
|
'title' => t("Author's website"),
|
101
|
'help' => t("The website address of the comment's author. Can be rendered as a link. Will be empty if the author is a registered user."),
|
102
|
'field' => array(
|
103
|
'handler' => 'views_handler_field_url',
|
104
|
'click sortable' => TRUE,
|
105
|
),
|
106
|
'filter' => array(
|
107
|
'handler' => 'views_handler_filter_string',
|
108
|
),
|
109
|
'sort' => array(
|
110
|
'handler' => 'views_handler_sort',
|
111
|
),
|
112
|
'argument' => array(
|
113
|
'handler' => 'views_handler_argument_string',
|
114
|
),
|
115
|
);
|
116
|
|
117
|
// hostname
|
118
|
$data['comment']['hostname'] = array(
|
119
|
'title' => t('Hostname'),
|
120
|
'help' => t('Hostname of user that posted the comment.'),
|
121
|
'field' => array(
|
122
|
'handler' => 'views_handler_field',
|
123
|
'click sortable' => TRUE,
|
124
|
),
|
125
|
'filter' => array(
|
126
|
'handler' => 'views_handler_filter_string',
|
127
|
),
|
128
|
'sort' => array(
|
129
|
'handler' => 'views_handler_sort',
|
130
|
),
|
131
|
'argument' => array(
|
132
|
'handler' => 'views_handler_argument_string',
|
133
|
),
|
134
|
);
|
135
|
|
136
|
// mail
|
137
|
$data['comment']['mail'] = array(
|
138
|
'title' => t('Mail'),
|
139
|
'help' => t('Email of user that posted the comment. Will be empty if the author is a registered user.'),
|
140
|
'field' => array(
|
141
|
'handler' => 'views_handler_field',
|
142
|
'click sortable' => TRUE,
|
143
|
),
|
144
|
'filter' => array(
|
145
|
'handler' => 'views_handler_filter_string',
|
146
|
),
|
147
|
'sort' => array(
|
148
|
'handler' => 'views_handler_sort',
|
149
|
),
|
150
|
'argument' => array(
|
151
|
'handler' => 'views_handler_argument_string',
|
152
|
),
|
153
|
);
|
154
|
|
155
|
// created (when comment was posted)
|
156
|
$data['comment']['created'] = array(
|
157
|
'title' => t('Post date'),
|
158
|
'help' => t('Date and time of when the comment was created.'),
|
159
|
'field' => array(
|
160
|
'handler' => 'views_handler_field_date',
|
161
|
'click sortable' => TRUE,
|
162
|
),
|
163
|
'sort' => array(
|
164
|
'handler' => 'views_handler_sort_date',
|
165
|
),
|
166
|
'filter' => array(
|
167
|
'handler' => 'views_handler_filter_date',
|
168
|
),
|
169
|
);
|
170
|
|
171
|
$data['comment']['created_fulldata'] = array(
|
172
|
'title' => t('Created date'),
|
173
|
'help' => t('Date in the form of CCYYMMDD.'),
|
174
|
'argument' => array(
|
175
|
'field' => 'created',
|
176
|
'handler' => 'views_handler_argument_node_created_fulldate',
|
177
|
),
|
178
|
);
|
179
|
|
180
|
$data['comment']['created_year_month'] = array(
|
181
|
'title' => t('Created year + month'),
|
182
|
'help' => t('Date in the form of YYYYMM.'),
|
183
|
'argument' => array(
|
184
|
'field' => 'created',
|
185
|
'handler' => 'views_handler_argument_node_created_year_month',
|
186
|
),
|
187
|
);
|
188
|
|
189
|
$data['comment']['created_year'] = array(
|
190
|
'title' => t('Created year'),
|
191
|
'help' => t('Date in the form of YYYY.'),
|
192
|
'argument' => array(
|
193
|
'field' => 'created',
|
194
|
'handler' => 'views_handler_argument_node_created_year',
|
195
|
),
|
196
|
);
|
197
|
|
198
|
$data['comment']['created_month'] = array(
|
199
|
'title' => t('Created month'),
|
200
|
'help' => t('Date in the form of MM (01 - 12).'),
|
201
|
'argument' => array(
|
202
|
'field' => 'created',
|
203
|
'handler' => 'views_handler_argument_node_created_month',
|
204
|
),
|
205
|
);
|
206
|
|
207
|
$data['comment']['created_day'] = array(
|
208
|
'title' => t('Created day'),
|
209
|
'help' => t('Date in the form of DD (01 - 31).'),
|
210
|
'argument' => array(
|
211
|
'field' => 'created',
|
212
|
'handler' => 'views_handler_argument_node_created_day',
|
213
|
),
|
214
|
);
|
215
|
|
216
|
$data['comment']['created_week'] = array(
|
217
|
'title' => t('Created week'),
|
218
|
'help' => t('Date in the form of WW (01 - 53).'),
|
219
|
'argument' => array(
|
220
|
'field' => 'created',
|
221
|
'handler' => 'views_handler_argument_node_created_week',
|
222
|
),
|
223
|
);
|
224
|
|
225
|
// Language field
|
226
|
if (module_exists('locale')) {
|
227
|
$data['comment']['language'] = array(
|
228
|
'title' => t('Language'),
|
229
|
'help' => t('The language the comment is in.'),
|
230
|
'field' => array(
|
231
|
'handler' => 'views_handler_field_locale_language',
|
232
|
'click sortable' => TRUE,
|
233
|
),
|
234
|
'filter' => array(
|
235
|
'handler' => 'views_handler_filter_locale_language',
|
236
|
),
|
237
|
'argument' => array(
|
238
|
'handler' => 'views_handler_argument_locale_language',
|
239
|
),
|
240
|
'sort' => array(
|
241
|
'handler' => 'views_handler_sort',
|
242
|
),
|
243
|
);
|
244
|
}
|
245
|
|
246
|
$data['comments']['timestamp']['moved to'] = array('comment', 'changed');
|
247
|
// changed (when comment was last updated)
|
248
|
$data['comment']['changed'] = array(
|
249
|
'title' => t('Updated date'),
|
250
|
'help' => t('Date and time of when the comment was last updated.'),
|
251
|
'field' => array(
|
252
|
'handler' => 'views_handler_field_date',
|
253
|
'click sortable' => TRUE,
|
254
|
),
|
255
|
'sort' => array(
|
256
|
'handler' => 'views_handler_sort_date',
|
257
|
),
|
258
|
'filter' => array(
|
259
|
'handler' => 'views_handler_filter_date',
|
260
|
),
|
261
|
);
|
262
|
|
263
|
$data['comments']['timestamp_fulldate']['moved to'] = array('comment', 'changed_fulldata');
|
264
|
$data['comment']['changed_fulldata'] = array(
|
265
|
'title' => t('Changed date'),
|
266
|
'help' => t('Date in the form of CCYYMMDD.'),
|
267
|
'argument' => array(
|
268
|
'field' => 'changed',
|
269
|
'handler' => 'views_handler_argument_node_created_fulldate',
|
270
|
),
|
271
|
);
|
272
|
|
273
|
$data['comments']['timestamp_year_month']['moved to'] = array('comment', 'changed_year_month');
|
274
|
$data['comment']['changed_year_month'] = array(
|
275
|
'title' => t('Changed year + month'),
|
276
|
'help' => t('Date in the form of YYYYMM.'),
|
277
|
'argument' => array(
|
278
|
'field' => 'changed',
|
279
|
'handler' => 'views_handler_argument_node_created_year_month',
|
280
|
),
|
281
|
);
|
282
|
|
283
|
$data['comments']['timestamp_year']['moved to'] = array('comment', 'changed_year');
|
284
|
$data['comment']['changed_year'] = array(
|
285
|
'title' => t('Changed year'),
|
286
|
'help' => t('Date in the form of YYYY.'),
|
287
|
'argument' => array(
|
288
|
'field' => 'changed',
|
289
|
'handler' => 'views_handler_argument_node_created_year',
|
290
|
),
|
291
|
);
|
292
|
|
293
|
$data['comments']['timestamp_month']['moved to'] = array('comment', 'changed_month');
|
294
|
$data['comment']['changed_month'] = array(
|
295
|
'title' => t('Changed month'),
|
296
|
'help' => t('Date in the form of MM (01 - 12).'),
|
297
|
'argument' => array(
|
298
|
'field' => 'changed',
|
299
|
'handler' => 'views_handler_argument_node_created_month',
|
300
|
),
|
301
|
);
|
302
|
|
303
|
$data['comments']['timestamp_day']['moved to'] = array('comment', 'changed_day');
|
304
|
$data['comment']['changed_day'] = array(
|
305
|
'title' => t('Changed day'),
|
306
|
'help' => t('Date in the form of DD (01 - 31).'),
|
307
|
'argument' => array(
|
308
|
'field' => 'changed',
|
309
|
'handler' => 'views_handler_argument_node_created_day',
|
310
|
),
|
311
|
);
|
312
|
|
313
|
$data['comments']['timestamp_week']['moved to'] = array('comment', 'changed_week');
|
314
|
$data['comment']['changed_week'] = array(
|
315
|
'title' => t('Changed week'),
|
316
|
'help' => t('Date in the form of WW (01 - 53).'),
|
317
|
'argument' => array(
|
318
|
'field' => 'changed',
|
319
|
'handler' => 'views_handler_argument_node_created_week',
|
320
|
),
|
321
|
);
|
322
|
|
323
|
// status (approved or not)
|
324
|
$data['comment']['status'] = array(
|
325
|
'title' => t('Approved'),
|
326
|
'help' => t('Whether the comment is approved (or still in the moderation queue).'),
|
327
|
'field' => array(
|
328
|
'handler' => 'views_handler_field_boolean',
|
329
|
'click sortable' => TRUE,
|
330
|
'output formats' => array(
|
331
|
'approved-not-approved' => array(t('Approved'), t('Not Approved')),
|
332
|
),
|
333
|
),
|
334
|
'filter' => array(
|
335
|
'handler' => 'views_handler_filter_boolean_operator',
|
336
|
'label' => t('Approved comment'),
|
337
|
'type' => 'yes-no',
|
338
|
),
|
339
|
'sort' => array(
|
340
|
'handler' => 'views_handler_sort',
|
341
|
),
|
342
|
);
|
343
|
|
344
|
// link to view comment
|
345
|
$data['comment']['view_comment'] = array(
|
346
|
'field' => array(
|
347
|
'title' => t('View link'),
|
348
|
'help' => t('Provide a simple link to view the comment.'),
|
349
|
'handler' => 'views_handler_field_comment_link',
|
350
|
),
|
351
|
);
|
352
|
|
353
|
// link to edit comment
|
354
|
$data['comment']['edit_comment'] = array(
|
355
|
'field' => array(
|
356
|
'title' => t('Edit link'),
|
357
|
'help' => t('Provide a simple link to edit the comment.'),
|
358
|
'handler' => 'views_handler_field_comment_link_edit',
|
359
|
),
|
360
|
);
|
361
|
|
362
|
// link to delete comment
|
363
|
$data['comment']['delete_comment'] = array(
|
364
|
'field' => array(
|
365
|
'title' => t('Delete link'),
|
366
|
'help' => t('Provide a simple link to delete the comment.'),
|
367
|
'handler' => 'views_handler_field_comment_link_delete',
|
368
|
),
|
369
|
);
|
370
|
|
371
|
|
372
|
// link to approve comment
|
373
|
$data['comment']['approve_comment'] = array(
|
374
|
'field' => array(
|
375
|
'title' => t('Approve link'),
|
376
|
'help' => t('Provide a simple link to approve the comment.'),
|
377
|
'handler' => 'views_handler_field_comment_link_approve',
|
378
|
),
|
379
|
);
|
380
|
|
381
|
// link to reply to comment
|
382
|
$data['comment']['replyto_comment'] = array(
|
383
|
'field' => array(
|
384
|
'title' => t('Reply-to link'),
|
385
|
'help' => t('Provide a simple link to reply to the comment.'),
|
386
|
'handler' => 'views_handler_field_comment_link_reply',
|
387
|
),
|
388
|
);
|
389
|
|
390
|
$data['comment']['thread'] = array(
|
391
|
'field' => array(
|
392
|
'title' => t('Depth'),
|
393
|
'help' => t('Display the depth of the comment if it is threaded.'),
|
394
|
'handler' => 'views_handler_field_comment_depth',
|
395
|
),
|
396
|
'sort' => array(
|
397
|
'title' => t('Thread'),
|
398
|
'help' => t('Sort by the threaded order. This will keep child comments together with their parents.'),
|
399
|
'handler' => 'views_handler_sort_comment_thread',
|
400
|
),
|
401
|
);
|
402
|
|
403
|
$data['comment']['nid'] = array(
|
404
|
'title' => t('Nid'),
|
405
|
'help' => t('The node ID to which the comment is a reply to.'),
|
406
|
'relationship' => array(
|
407
|
'title' => t('Content'),
|
408
|
'help' => t('The content to which the comment is a reply to.'),
|
409
|
'base' => 'node',
|
410
|
'base field' => 'nid',
|
411
|
'handler' => 'views_handler_relationship',
|
412
|
'label' => t('Content'),
|
413
|
),
|
414
|
'filter' => array(
|
415
|
'handler' => 'views_handler_filter_numeric',
|
416
|
),
|
417
|
'argument' => array(
|
418
|
'handler' => 'views_handler_argument_numeric',
|
419
|
),
|
420
|
'field' => array(
|
421
|
'handler' => 'views_handler_field_numeric',
|
422
|
),
|
423
|
);
|
424
|
|
425
|
$data['comment']['uid'] = array(
|
426
|
'title' => t('Author uid'),
|
427
|
'help' => t('If you need more fields than the uid add the comment: author relationship'),
|
428
|
'relationship' => array(
|
429
|
'title' => t('Author'),
|
430
|
'help' => t("The User ID of the comment's author."),
|
431
|
'base' => 'users',
|
432
|
'base field' => 'uid',
|
433
|
'handler' => 'views_handler_relationship',
|
434
|
'label' => t('author'),
|
435
|
),
|
436
|
'filter' => array(
|
437
|
'handler' => 'views_handler_filter_numeric',
|
438
|
),
|
439
|
'argument' => array(
|
440
|
'handler' => 'views_handler_argument_numeric',
|
441
|
),
|
442
|
'field' => array(
|
443
|
'handler' => 'views_handler_field_user',
|
444
|
),
|
445
|
);
|
446
|
|
447
|
$data['comment']['pid'] = array(
|
448
|
'title' => t('Parent CID'),
|
449
|
'help' => t('The Comment ID of the parent comment.'),
|
450
|
'field' => array(
|
451
|
'handler' => 'views_handler_field',
|
452
|
),
|
453
|
'relationship' => array(
|
454
|
'title' => t('Parent comment'),
|
455
|
'help' => t('The parent comment.'),
|
456
|
'base' => 'comment',
|
457
|
'base field' => 'cid',
|
458
|
'handler' => 'views_handler_relationship',
|
459
|
'label' => t('Parent comment'),
|
460
|
),
|
461
|
);
|
462
|
|
463
|
// ----------------------------------------------------------------------
|
464
|
// node_comment_statistics table
|
465
|
|
466
|
// define the group
|
467
|
$data['node_comment_statistics']['table']['group'] = t('Content');
|
468
|
|
469
|
// joins
|
470
|
$data['node_comment_statistics']['table']['join'] = array(
|
471
|
//...to the node table
|
472
|
'node' => array(
|
473
|
'type' => 'INNER',
|
474
|
'left_field' => 'nid',
|
475
|
'field' => 'nid',
|
476
|
),
|
477
|
);
|
478
|
|
479
|
// last_comment_timestamp
|
480
|
$data['node_comment_statistics']['last_comment_timestamp'] = array(
|
481
|
'title' => t('Last comment time'),
|
482
|
'help' => t('Date and time of when the last comment was posted.'),
|
483
|
'field' => array(
|
484
|
'handler' => 'views_handler_field_last_comment_timestamp',
|
485
|
'click sortable' => TRUE,
|
486
|
),
|
487
|
'sort' => array(
|
488
|
'handler' => 'views_handler_sort_date',
|
489
|
),
|
490
|
'filter' => array(
|
491
|
'handler' => 'views_handler_filter_date',
|
492
|
),
|
493
|
);
|
494
|
|
495
|
// last_comment_name (author's name)
|
496
|
$data['node_comment_statistics']['last_comment_name'] = array(
|
497
|
'title' => t("Last comment author"),
|
498
|
'help' => t('The name of the author of the last posted comment.'),
|
499
|
'field' => array(
|
500
|
'handler' => 'views_handler_field_ncs_last_comment_name',
|
501
|
'click sortable' => TRUE,
|
502
|
'no group by' => TRUE,
|
503
|
),
|
504
|
'sort' => array(
|
505
|
'handler' => 'views_handler_sort_ncs_last_comment_name',
|
506
|
'no group by' => TRUE,
|
507
|
),
|
508
|
);
|
509
|
|
510
|
// comment_count
|
511
|
$data['node_comment_statistics']['comment_count'] = array(
|
512
|
'title' => t('Comment count'),
|
513
|
'help' => t('The number of comments a node has.'),
|
514
|
'field' => array(
|
515
|
'handler' => 'views_handler_field_numeric',
|
516
|
'click sortable' => TRUE,
|
517
|
),
|
518
|
'filter' => array(
|
519
|
'handler' => 'views_handler_filter_numeric',
|
520
|
),
|
521
|
'sort' => array(
|
522
|
'handler' => 'views_handler_sort',
|
523
|
),
|
524
|
'argument' => array(
|
525
|
'handler' => 'views_handler_argument',
|
526
|
),
|
527
|
);
|
528
|
|
529
|
// last_comment_timestamp
|
530
|
$data['node_comment_statistics']['last_updated'] = array(
|
531
|
'title' => t('Updated/commented date'),
|
532
|
'help' => t('The most recent of last comment posted or node updated time.'),
|
533
|
'field' => array(
|
534
|
'handler' => 'views_handler_field_ncs_last_updated',
|
535
|
'click sortable' => TRUE,
|
536
|
'no group by' => TRUE,
|
537
|
),
|
538
|
'sort' => array(
|
539
|
'handler' => 'views_handler_sort_ncs_last_updated',
|
540
|
'no group by' => TRUE,
|
541
|
),
|
542
|
'filter' => array(
|
543
|
'handler' => 'views_handler_filter_ncs_last_updated',
|
544
|
),
|
545
|
);
|
546
|
|
547
|
$data['node_comment_statistics']['cid'] = array(
|
548
|
'title' => t('Last comment CID'),
|
549
|
'help' => t('Display the last comment of a node'),
|
550
|
'relationship' => array(
|
551
|
'title' => t('Last Comment'),
|
552
|
'help' => t('The last comment of a node.'),
|
553
|
'group' => t('Comment'),
|
554
|
'base' => 'comment',
|
555
|
'base field' => 'cid',
|
556
|
'handler' => 'views_handler_relationship',
|
557
|
'label' => t('Last Comment'),
|
558
|
),
|
559
|
);
|
560
|
|
561
|
// last_comment_uid
|
562
|
$data['node_comment_statistics']['last_comment_uid'] = array(
|
563
|
'title' => t('Last comment uid'),
|
564
|
'help' => t('The User ID of the author of the last comment of a node.'),
|
565
|
'relationship' => array(
|
566
|
'title' => t('Last comment author'),
|
567
|
'base' => 'users',
|
568
|
'base field' => 'uid',
|
569
|
'handler' => 'views_handler_relationship',
|
570
|
'label' => t('Last comment author'),
|
571
|
),
|
572
|
'filter' => array(
|
573
|
'handler' => 'views_handler_filter_numeric',
|
574
|
),
|
575
|
'argument' => array(
|
576
|
'handler' => 'views_handler_argument_numeric',
|
577
|
),
|
578
|
'field' => array(
|
579
|
'handler' => 'views_handler_field_numeric',
|
580
|
),
|
581
|
);
|
582
|
|
583
|
return $data;
|
584
|
}
|
585
|
|
586
|
/**
|
587
|
* Use views_data_alter to add items to the node table that are
|
588
|
* relevant to comments.
|
589
|
*/
|
590
|
function comment_views_data_alter(&$data) {
|
591
|
// new comments
|
592
|
$data['node']['new_comments'] = array(
|
593
|
'title' => t('New comments'),
|
594
|
'help' => t('The number of new comments on the node.'),
|
595
|
'field' => array(
|
596
|
'handler' => 'views_handler_field_node_new_comments',
|
597
|
'no group by' => TRUE,
|
598
|
),
|
599
|
);
|
600
|
|
601
|
$data['node']['comments_link'] = array(
|
602
|
'field' => array(
|
603
|
'title' => t('Add comment link'),
|
604
|
'help' => t('Display the standard add comment link used on regular nodes, which will only display if the viewing user has access to add a comment.'),
|
605
|
'handler' => 'views_handler_field_comment_node_link',
|
606
|
),
|
607
|
);
|
608
|
|
609
|
// Comment status of the node
|
610
|
$data['node']['comment'] = array(
|
611
|
'title' => t('Comment status'),
|
612
|
'help' => t('Whether comments are enabled or disabled on the node.'),
|
613
|
'field' => array(
|
614
|
'handler' => 'views_handler_field_node_comment',
|
615
|
'click sortable' => TRUE,
|
616
|
),
|
617
|
'sort' => array(
|
618
|
'handler' => 'views_handler_sort',
|
619
|
),
|
620
|
'filter' => array(
|
621
|
'handler' => 'views_handler_filter_node_comment',
|
622
|
),
|
623
|
);
|
624
|
|
625
|
$data['node']['uid_touch'] = array(
|
626
|
'title' => t('User posted or commented'),
|
627
|
'help' => t('Display nodes only if a user posted the node or commented on the node.'),
|
628
|
'argument' => array(
|
629
|
'field' => 'uid',
|
630
|
'name table' => 'users',
|
631
|
'name field' => 'name',
|
632
|
'handler' => 'views_handler_argument_comment_user_uid',
|
633
|
'no group by' => TRUE,
|
634
|
),
|
635
|
'filter' => array(
|
636
|
'field' => 'uid',
|
637
|
'name table' => 'users',
|
638
|
'name field' => 'name',
|
639
|
'handler' => 'views_handler_filter_comment_user_uid'
|
640
|
),
|
641
|
);
|
642
|
|
643
|
$data['node']['cid'] = array(
|
644
|
'title' => t('Comments of the node'),
|
645
|
'help' => t('Relate all comments on the node. This will create 1 duplicate record for every comment. Usually if you need this it is better to create a comment view.'),
|
646
|
'relationship' => array(
|
647
|
'group' => t('Comment'),
|
648
|
'label' => t('Comments'),
|
649
|
'base' => 'comment',
|
650
|
'base field' => 'nid',
|
651
|
'relationship field' => 'nid',
|
652
|
'handler' => 'views_handler_relationship',
|
653
|
),
|
654
|
);
|
655
|
|
656
|
}
|
657
|
|
658
|
/**
|
659
|
* Implements hook_views_plugins().
|
660
|
*/
|
661
|
function comment_views_plugins() {
|
662
|
return array(
|
663
|
'module' => 'views',
|
664
|
'row' => array(
|
665
|
'comment' => array(
|
666
|
'title' => t('Comment'),
|
667
|
'help' => t('Display the comment with standard comment view.'),
|
668
|
'handler' => 'views_plugin_row_comment_view',
|
669
|
'theme' => 'views_view_row_comment',
|
670
|
'path' => drupal_get_path('module', 'views') . '/modules/comment', // not necessary for most modules
|
671
|
'base' => array('comment'), // only works with 'comment' as base.
|
672
|
'uses options' => TRUE,
|
673
|
'type' => 'normal',
|
674
|
'help topic' => 'style-comment',
|
675
|
),
|
676
|
'comment_rss' => array(
|
677
|
'title' => t('Comment'),
|
678
|
'help' => t('Display the comment as RSS.'),
|
679
|
'handler' => 'views_plugin_row_comment_rss',
|
680
|
'theme' => 'views_view_row_rss',
|
681
|
'path' => drupal_get_path('module', 'views') . '/modules/comment', // not necessary for most modules
|
682
|
'base' => array('comment'), // only works with 'comment' as base.
|
683
|
'uses options' => TRUE,
|
684
|
'type' => 'feed',
|
685
|
'help topic' => 'style-comment-rss',
|
686
|
),
|
687
|
),
|
688
|
);
|
689
|
}
|
690
|
|
691
|
/**
|
692
|
* Template helper for theme_views_view_row_comment
|
693
|
*/
|
694
|
function template_preprocess_views_view_row_comment(&$vars) {
|
695
|
$options = $vars['options'];
|
696
|
$view = &$vars['view'];
|
697
|
$plugin = &$view->style_plugin->row_plugin;
|
698
|
$comment = $plugin->comments[$vars['row']->{$vars['field_alias']}];
|
699
|
$node = $plugin->nodes[$comment->nid];
|
700
|
// Put the view on the node so we can retrieve it in the preprocess.
|
701
|
$node->view = &$view;
|
702
|
|
703
|
$build = comment_view_multiple(array($comment->cid => $comment), $node, $plugin->options['view_mode']);
|
704
|
// If we're displaying the comments without links, remove them from the
|
705
|
// renderable array. There is no way to avoid building them in the first
|
706
|
// place (see comment_build_content()).
|
707
|
if (empty($options['links'])) {
|
708
|
foreach ($build as $cid => &$comment_build) {
|
709
|
if (isset($comment_build['links'])) {
|
710
|
unset($comment_build['links']);
|
711
|
}
|
712
|
}
|
713
|
}
|
714
|
$vars['comment'] = drupal_render($build);
|
715
|
}
|