function comment_views_tables in Views (for Drupal 7) 5
This include file implements views functionality on behalf of comment.module
File
- modules/
views_comment.inc, line 7
Code
function comment_views_tables() {
$tables['comments'] = array(
'name' => 'comments',
'provider' => 'internal',
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'nid',
),
'right' => array(
'field' => 'nid',
),
),
'fields' => array(
'subject' => array(
'name' => t('Comment: Subject'),
'handler' => array(
'views_handler_field_commentlink' => t('Normal'),
'views_handler_field_commentlink_with_mark' => t('With updated mark'),
),
'option' => array(
'#type' => 'select',
'#options' => array(
'link' => 'As link',
'nolink' => 'Without link',
),
),
'addlfields' => array(
'cid',
),
'sortable' => TRUE,
),
'comment' => array(
'name' => t('Comment: Comment'),
'handler' => 'views_handler_field_comment',
'addlfields' => array(
'format',
),
'help' => t('Display the content of a comment.'),
),
'cid' => array(
'name' => t('Comment: Comment ID'),
'sortable' => TRUE,
'help' => t('Display the CID of a comment.'),
),
'timestamp' => array(
'name' => t('Comment: Created Time'),
'sortable' => TRUE,
'handler' => views_handler_field_dates(),
'option' => 'string',
'help' => t('Display the post time of the comment.'),
),
'name' => array(
'name' => t('Comment: Author Name'),
'handler' => 'views_handler_field_username',
'sortable' => TRUE,
'uid' => 'uid',
'addlfields' => array(
'uid',
),
'help' => t('This will display the author of the node.'),
),
'add' => array(
'name' => t('Comment: Add link'),
'handler' => 'views_handler_comment_add',
'notafield' => TRUE,
'option' => 'string',
'help' => t('Display a link to add a comment to the node. Enter the text of this link into the option field; if blank the default "Comment" will be used.'),
),
),
'filters' => array(
'status' => array(
'name' => t('Comment: Pending approval'),
'operator' => array(
'=' => t('Equals'),
),
'list' => 'views_handler_operator_yesno',
'list-type' => 'select',
),
),
'sorts' => array(
'timestamp' => array(
'name' => t('Comment: Created Time'),
'handler' => 'views_handler_sort_date',
'option' => views_handler_sort_date_options(),
'help' => t('Sort by the created time of comments.'),
),
),
);
$tables['node_comment_statistics'] = array(
'name' => 'node_comment_statistics',
'provider' => 'internal',
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'nid',
),
'right' => array(
'field' => 'nid',
),
),
'fields' => array(
'last_comment_timestamp' => array(
'name' => t('Comment: Last Comment Time'),
'sortable' => true,
'handler' => views_handler_field_dates(),
'option' => 'string',
'help' => t('This will display the last comment time.'),
),
'last_comment_name' => array(
'name' => t('Comment: Last Comment Author'),
'query_handler' => 'views_query_handler_field_last_comment_name',
'handler' => 'views_handler_field_last_comment_name',
'sortable' => true,
'uid' => 'last_comment_uid',
'addlfields' => array(
'last_comment_name',
'last_comment_uid',
),
'help' => t('This will display the name of the last user to comment on the post.'),
),
'comment_count' => array(
'name' => t('Comment: Count'),
'sortable' => true,
'handler' => array(
'views_handler_field_int' => t('Normal'),
'views_handler_comments_with_new' => t('With New Count'),
),
'help' => t('This will display the comment count.'),
),
'last_changed' => array(
'name' => t('Comment: Last Changed Time'),
'query_handler' => 'views_query_handler_field_last_changed',
'sortable' => TRUE,
'handler' => views_handler_field_dates(),
'option' => 'string',
'notafield' => TRUE,
'help' => t('This will display the time of the last comment or node edit.'),
),
),
'filters' => array(
'comment_count' => array(
'name' => t('Comment: Comment Count'),
'operator' => 'views_handler_operator_gtlt',
'option' => 'integer',
'help' => t('This filter allows you to filter by the amount of comments.'),
),
'last_comment_timestamp' => array(
'name' => t('Comment: Last Comment Time'),
'operator' => 'views_handler_operator_gtlt',
'value' => views_handler_filter_date_value_form(),
'handler' => 'views_handler_filter_timestamp',
'option' => 'string',
'help' => t('This filter allows nodes to be filtered by the timestamp for the last comment or node edit.') . ' ' . views_t_strings('filter date'),
),
'last_changed' => array(
'name' => t('Comment: Last Changed Time'),
'operator' => 'views_handler_operator_gtlt',
'value' => views_handler_filter_date_value_form(),
'handler' => 'views_handler_filter_last_changed',
'option' => 'string',
'help' => t('This filter allows nodes to be filtered by the timestamp for the last comment or node edit.') . ' ' . views_t_strings('filter date'),
),
),
'sorts' => array(
'last_comment_timestamp' => array(
'name' => t('Comment: Last Comment Date'),
'handler' => 'views_handler_sort_date',
'option' => views_handler_sort_date_options(),
'help' => t('This will allow you to sort by the date of the most recent comment on a node.'),
),
'comment_count' => array(
'name' => t('Comment: Comment Count'),
'help' => t('This filter allows you to sort by the number of comments.'),
),
'last_changed' => array(
'name' => t('Comment: Last Changed'),
'handler' => 'views_handler_sort_last_changed',
'option' => views_handler_sort_date_options(),
'help' => t('Sort based on the most recent comment or edit for the node.'),
),
),
);
return $tables;
}