Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/comment.views.inc | ||
---|---|---|
10 | 10 |
/** |
11 | 11 |
* Implements hook_views_data(). |
12 | 12 |
*/ |
13 |
|
|
14 | 13 |
function comment_views_data() { |
15 | 14 |
$data['comments']['moved to'] = 'comment'; |
16 | 15 |
$data['comment']['comment']['moved to'] = array('field_data_comment_body', 'comment_body'); |
17 | 16 |
$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.
|
|
17 |
// Define the base group of this table. Fields that don't have a group
|
|
18 |
// defined will go into this field by default. |
|
20 | 19 |
$data['comment']['table']['group'] = t('Comment'); |
21 | 20 |
|
22 | 21 |
$data['comment']['table']['base'] = array( |
... | ... | |
36 | 35 |
); |
37 | 36 |
|
38 | 37 |
// ---------------------------------------------------------------- |
39 |
// Fields |
|
40 |
|
|
41 |
// subject |
|
38 |
// Fields. |
|
39 |
// Subject. |
|
42 | 40 |
$data['comment']['subject'] = array( |
43 | 41 |
'title' => t('Title'), |
44 | 42 |
'help' => t('The title of the comment.'), |
... | ... | |
57 | 55 |
), |
58 | 56 |
); |
59 | 57 |
|
60 |
// cid
|
|
58 |
// Comment ID / 'cid'.
|
|
61 | 59 |
$data['comment']['cid'] = array( |
62 | 60 |
'title' => t('ID'), |
63 | 61 |
'help' => t('The comment ID of the field'), |
... | ... | |
76 | 74 |
), |
77 | 75 |
); |
78 | 76 |
|
79 |
// name (of comment author)
|
|
77 |
// Username of the comment author.
|
|
80 | 78 |
$data['comment']['name'] = array( |
81 | 79 |
'title' => t('Author'), |
82 | 80 |
'help' => t("The name of the comment's author. Can be rendered as a link to the author's homepage."), |
... | ... | |
95 | 93 |
), |
96 | 94 |
); |
97 | 95 |
|
98 |
// homepage
|
|
96 |
// Homepage.
|
|
99 | 97 |
$data['comment']['homepage'] = array( |
100 | 98 |
'title' => t("Author's website"), |
101 | 99 |
'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."), |
... | ... | |
114 | 112 |
), |
115 | 113 |
); |
116 | 114 |
|
117 |
// hostname |
|
115 |
// hostname.
|
|
118 | 116 |
$data['comment']['hostname'] = array( |
119 | 117 |
'title' => t('Hostname'), |
120 | 118 |
'help' => t('Hostname of user that posted the comment.'), |
121 | 119 |
'field' => array( |
122 | 120 |
'handler' => 'views_handler_field', |
123 | 121 |
'click sortable' => TRUE, |
124 |
),
|
|
122 |
), |
|
125 | 123 |
'filter' => array( |
126 | 124 |
'handler' => 'views_handler_filter_string', |
127 | 125 |
), |
... | ... | |
133 | 131 |
), |
134 | 132 |
); |
135 | 133 |
|
136 |
// mail
|
|
134 |
// Email address.
|
|
137 | 135 |
$data['comment']['mail'] = array( |
138 | 136 |
'title' => t('Mail'), |
139 | 137 |
'help' => t('Email of user that posted the comment. Will be empty if the author is a registered user.'), |
140 | 138 |
'field' => array( |
141 | 139 |
'handler' => 'views_handler_field', |
142 | 140 |
'click sortable' => TRUE, |
143 |
),
|
|
141 |
), |
|
144 | 142 |
'filter' => array( |
145 | 143 |
'handler' => 'views_handler_filter_string', |
146 | 144 |
), |
... | ... | |
152 | 150 |
), |
153 | 151 |
); |
154 | 152 |
|
155 |
// created (when comment was posted)
|
|
153 |
// Created - when comment was posted.
|
|
156 | 154 |
$data['comment']['created'] = array( |
157 | 155 |
'title' => t('Post date'), |
158 | 156 |
'help' => t('Date and time of when the comment was created.'), |
... | ... | |
222 | 220 |
), |
223 | 221 |
); |
224 | 222 |
|
225 |
// Language field |
|
223 |
// Language field.
|
|
226 | 224 |
if (module_exists('locale')) { |
227 | 225 |
$data['comment']['language'] = array( |
228 | 226 |
'title' => t('Language'), |
... | ... | |
244 | 242 |
} |
245 | 243 |
|
246 | 244 |
$data['comments']['timestamp']['moved to'] = array('comment', 'changed'); |
247 |
// changed (when comment was last updated)
|
|
245 |
// Changed (when comment was last updated).
|
|
248 | 246 |
$data['comment']['changed'] = array( |
249 | 247 |
'title' => t('Updated date'), |
250 | 248 |
'help' => t('Date and time of when the comment was last updated.'), |
... | ... | |
320 | 318 |
), |
321 | 319 |
); |
322 | 320 |
|
323 |
// status (approved or not)
|
|
321 |
// Status (approved or not).
|
|
324 | 322 |
$data['comment']['status'] = array( |
325 | 323 |
'title' => t('Approved'), |
326 | 324 |
'help' => t('Whether the comment is approved (or still in the moderation queue).'), |
... | ... | |
341 | 339 |
), |
342 | 340 |
); |
343 | 341 |
|
344 |
// link to view comment
|
|
342 |
// Link to view comment.
|
|
345 | 343 |
$data['comment']['view_comment'] = array( |
346 | 344 |
'field' => array( |
347 | 345 |
'title' => t('View link'), |
... | ... | |
350 | 348 |
), |
351 | 349 |
); |
352 | 350 |
|
353 |
// link to edit comment
|
|
351 |
// Link to edit comment.
|
|
354 | 352 |
$data['comment']['edit_comment'] = array( |
355 | 353 |
'field' => array( |
356 | 354 |
'title' => t('Edit link'), |
... | ... | |
359 | 357 |
), |
360 | 358 |
); |
361 | 359 |
|
362 |
// link to delete comment
|
|
360 |
// Link to delete comment.
|
|
363 | 361 |
$data['comment']['delete_comment'] = array( |
364 | 362 |
'field' => array( |
365 | 363 |
'title' => t('Delete link'), |
... | ... | |
368 | 366 |
), |
369 | 367 |
); |
370 | 368 |
|
371 |
|
|
372 |
// link to approve comment |
|
369 |
// Link to approve comment. |
|
373 | 370 |
$data['comment']['approve_comment'] = array( |
374 | 371 |
'field' => array( |
375 | 372 |
'title' => t('Approve link'), |
... | ... | |
378 | 375 |
), |
379 | 376 |
); |
380 | 377 |
|
381 |
// link to reply to comment
|
|
378 |
// Link to reply to comment.
|
|
382 | 379 |
$data['comment']['replyto_comment'] = array( |
383 | 380 |
'field' => array( |
384 | 381 |
'title' => t('Reply-to link'), |
... | ... | |
461 | 458 |
); |
462 | 459 |
|
463 | 460 |
// ---------------------------------------------------------------------- |
464 |
// node_comment_statistics table |
|
465 |
|
|
466 |
// define the group |
|
461 |
// 'node_comment_statistics' table. |
|
462 |
// Define the group. |
|
467 | 463 |
$data['node_comment_statistics']['table']['group'] = t('Content'); |
468 | 464 |
|
469 |
// joins
|
|
465 |
// Joins.
|
|
470 | 466 |
$data['node_comment_statistics']['table']['join'] = array( |
471 |
//...to the node table
|
|
467 |
// ...to the node table.
|
|
472 | 468 |
'node' => array( |
473 | 469 |
'type' => 'INNER', |
474 | 470 |
'left_field' => 'nid', |
475 | 471 |
'field' => 'nid', |
476 |
),
|
|
472 |
), |
|
477 | 473 |
); |
478 | 474 |
|
479 |
// last_comment_timestamp
|
|
475 |
// Timestamp of the last comment.
|
|
480 | 476 |
$data['node_comment_statistics']['last_comment_timestamp'] = array( |
481 | 477 |
'title' => t('Last comment time'), |
482 | 478 |
'help' => t('Date and time of when the last comment was posted.'), |
... | ... | |
492 | 488 |
), |
493 | 489 |
); |
494 | 490 |
|
495 |
// last_comment_name (author's name)
|
|
491 |
// Last comment author's username.
|
|
496 | 492 |
$data['node_comment_statistics']['last_comment_name'] = array( |
497 | 493 |
'title' => t("Last comment author"), |
498 | 494 |
'help' => t('The name of the author of the last posted comment.'), |
... | ... | |
507 | 503 |
), |
508 | 504 |
); |
509 | 505 |
|
510 |
// comment_count
|
|
506 |
// Comment count.
|
|
511 | 507 |
$data['node_comment_statistics']['comment_count'] = array( |
512 | 508 |
'title' => t('Comment count'), |
513 | 509 |
'help' => t('The number of comments a node has.'), |
... | ... | |
526 | 522 |
), |
527 | 523 |
); |
528 | 524 |
|
529 |
// last_comment_timestamp
|
|
525 |
// Timestamp of when the last comment update happened.
|
|
530 | 526 |
$data['node_comment_statistics']['last_updated'] = array( |
531 | 527 |
'title' => t('Updated/commented date'), |
532 | 528 |
'help' => t('The most recent of last comment posted or node updated time.'), |
... | ... | |
558 | 554 |
), |
559 | 555 |
); |
560 | 556 |
|
561 |
// last_comment_uid
|
|
557 |
// The user ID / 'uid' of the user who last posted a comment.
|
|
562 | 558 |
$data['node_comment_statistics']['last_comment_uid'] = array( |
563 | 559 |
'title' => t('Last comment uid'), |
564 | 560 |
'help' => t('The User ID of the author of the last comment of a node.'), |
... | ... | |
584 | 580 |
} |
585 | 581 |
|
586 | 582 |
/** |
587 |
* Use views_data_alter to add items to the node table that are |
|
588 |
* relevant to comments. |
|
583 |
* Implements hook_views_data_alter() on behalf of comment.module. |
|
584 |
* |
|
585 |
* Add items to the node table that are relevant to comments. |
|
589 | 586 |
*/ |
590 | 587 |
function comment_views_data_alter(&$data) { |
591 |
// new comments
|
|
588 |
// New comments.
|
|
592 | 589 |
$data['node']['new_comments'] = array( |
593 | 590 |
'title' => t('New comments'), |
594 | 591 |
'help' => t('The number of new comments on the node.'), |
... | ... | |
606 | 603 |
), |
607 | 604 |
); |
608 | 605 |
|
609 |
// Comment status of the node |
|
606 |
// Comment status of the node.
|
|
610 | 607 |
$data['node']['comment'] = array( |
611 | 608 |
'title' => t('Comment status'), |
612 | 609 |
'help' => t('Whether comments are enabled or disabled on the node.'), |
... | ... | |
636 | 633 |
'field' => 'uid', |
637 | 634 |
'name table' => 'users', |
638 | 635 |
'name field' => 'name', |
639 |
'handler' => 'views_handler_filter_comment_user_uid' |
|
636 |
'handler' => 'views_handler_filter_comment_user_uid',
|
|
640 | 637 |
), |
641 | 638 |
); |
642 | 639 |
|
... | ... | |
652 | 649 |
'handler' => 'views_handler_relationship', |
653 | 650 |
), |
654 | 651 |
); |
655 |
|
|
656 | 652 |
} |
657 | 653 |
|
658 | 654 |
/** |
... | ... | |
667 | 663 |
'help' => t('Display the comment with standard comment view.'), |
668 | 664 |
'handler' => 'views_plugin_row_comment_view', |
669 | 665 |
'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. |
|
666 |
'path' => drupal_get_path('module', 'views') . '/modules/comment', |
|
667 |
// Not necessary for most modules. |
|
668 |
'base' => array('comment'), |
|
669 |
// Only works with 'comment' as base. |
|
672 | 670 |
'uses options' => TRUE, |
673 | 671 |
'type' => 'normal', |
674 | 672 |
'help topic' => 'style-comment', |
... | ... | |
678 | 676 |
'help' => t('Display the comment as RSS.'), |
679 | 677 |
'handler' => 'views_plugin_row_comment_rss', |
680 | 678 |
'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. |
|
679 |
'path' => drupal_get_path('module', 'views') . '/modules/comment', |
|
680 |
// Not necessary for most modules. |
|
681 |
'base' => array('comment'), |
|
682 |
// Only works with 'comment' as base. |
|
683 | 683 |
'uses options' => TRUE, |
684 | 684 |
'type' => 'feed', |
685 | 685 |
'help topic' => 'style-comment-rss', |
... | ... | |
689 | 689 |
} |
690 | 690 |
|
691 | 691 |
/** |
692 |
* Template helper for theme_views_view_row_comment |
|
692 |
* Template helper for theme_views_view_row_comment.
|
|
693 | 693 |
*/ |
694 | 694 |
function template_preprocess_views_view_row_comment(&$vars) { |
695 | 695 |
$options = $vars['options']; |
... | ... | |
701 | 701 |
$node->view = &$view; |
702 | 702 |
|
703 | 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()).
|
|
704 |
// If displaying the comments without links, remove them from the renderable
|
|
705 |
// array; there is no way to avoid building them in the first place.
|
|
706 |
// @see comment_build_content()
|
|
707 | 707 |
if (empty($options['links'])) { |
708 | 708 |
foreach ($build as $cid => &$comment_build) { |
709 | 709 |
if (isset($comment_build['links'])) { |
Formats disponibles : Unified diff
Weekly update of contrib modules