From f7a6f396b2b5976963749f04eb4a0c480b59a06e Mon Sep 17 00:00:00 2001 From: Dries <dries@buytaert.net> Date: Wed, 27 Feb 2013 17:57:18 -0500 Subject: [PATCH] Issue #1912946 by mitron: Clean up comments in comment.views.inc node.views.inc user.views.inc. --- core/modules/comment/comment.views.inc | 40 ++------- core/modules/node/node.views.inc | 118 ++++++++----------------- core/modules/user/user.views.inc | 63 +++++-------- 3 files changed, 69 insertions(+), 152 deletions(-) diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index 9886c674860f..e74c97c91eca 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -11,8 +11,9 @@ * Implements hook_views_data(). */ function comment_views_data() { - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['comment']['table']['group'] = t('Comment'); $data['comment']['table']['base'] = array( @@ -24,9 +25,6 @@ function comment_views_data() { $data['comment']['table']['entity type'] = 'comment'; $data['comment']['table']['wizard_id'] = 'comment'; - // Fields - - // subject $data['comment']['subject'] = array( 'title' => t('Title'), 'help' => t('The title of the comment.'), @@ -44,7 +42,6 @@ function comment_views_data() { ), ); - // cid $data['comment']['cid'] = array( 'title' => t('ID'), 'help' => t('The comment ID of the field'), @@ -62,7 +59,6 @@ function comment_views_data() { ), ); - // name (of comment author) $data['comment']['name'] = array( 'title' => t('Author'), 'help' => t("The name of the comment's author. Can be rendered as a link to the author's homepage."), @@ -80,7 +76,6 @@ function comment_views_data() { ), ); - // homepage $data['comment']['homepage'] = array( 'title' => t("Author's website"), '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."), @@ -98,7 +93,6 @@ function comment_views_data() { ), ); - // hostname $data['comment']['hostname'] = array( 'title' => t('Hostname'), 'help' => t('Hostname of user that posted the comment.'), @@ -116,7 +110,6 @@ function comment_views_data() { ), ); - // mail $data['comment']['mail'] = array( 'title' => t('E-mail'), 'help' => t('E-mail of user that posted the comment. Will be empty if the author is a registered user.'), @@ -134,7 +127,6 @@ function comment_views_data() { ), ); - // created (when comment was posted) $data['comment']['created'] = array( 'title' => t('Post date'), 'help' => t('Date and time of when the comment was created.'), @@ -149,7 +141,6 @@ function comment_views_data() { ), ); - // Langcode field if (module_exists('language')) { $data['comment']['langcode'] = array( 'title' => t('Language'), @@ -169,7 +160,6 @@ function comment_views_data() { ); } - // changed (when comment was last updated) $data['comment']['changed'] = array( 'title' => t('Updated date'), 'help' => t('Date and time of when the comment was last updated.'), @@ -238,7 +228,6 @@ function comment_views_data() { ), ); - // status (approved or not) $data['comment']['status'] = array( 'title' => t('Approved status'), 'help' => t('Whether the comment is approved (or still in the moderation queue).'), @@ -258,7 +247,6 @@ function comment_views_data() { ), ); - // Link to view comment. $data['comment']['view_comment'] = array( 'field' => array( 'title' => t('Link to comment'), @@ -267,7 +255,6 @@ function comment_views_data() { ), ); - // Link to edit comment. $data['comment']['edit_comment'] = array( 'field' => array( 'title' => t('Link to edit comment'), @@ -276,7 +263,6 @@ function comment_views_data() { ), ); - // Link to delete comment. $data['comment']['delete_comment'] = array( 'field' => array( 'title' => t('Link to delete comment'), @@ -285,7 +271,6 @@ function comment_views_data() { ), ); - // Link to approve comment. $data['comment']['approve_comment'] = array( 'field' => array( 'title' => t('Link to approve comment'), @@ -294,7 +279,6 @@ function comment_views_data() { ), ); - // Link to reply to comment. $data['comment']['replyto_comment'] = array( 'field' => array( 'title' => t('Link to reply-to comment'), @@ -376,7 +360,6 @@ function comment_views_data() { ), ); - // Entity translation field. if (drupal_container()->get('module_handler')->moduleExists('translation_entity')) { $data['comment']['translation_link'] = array( 'title' => t('Translation link'), @@ -387,14 +370,12 @@ function comment_views_data() { ); } - // node_comment_statistics table - - // define the group + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['node_comment_statistics']['table']['group'] = t('Content'); - // joins + // Explain how this table joins to others. $data['node_comment_statistics']['table']['join'] = array( - //...to the node table 'node' => array( 'type' => 'INNER', 'left_field' => 'nid', @@ -402,7 +383,6 @@ function comment_views_data() { ), ); - // last_comment_timestamp $data['node_comment_statistics']['last_comment_timestamp'] = array( 'title' => t('Last comment time'), 'help' => t('Date and time of when the last comment was posted.'), @@ -417,7 +397,6 @@ function comment_views_data() { ), ); - // last_comment_name (author's name) $data['node_comment_statistics']['last_comment_name'] = array( 'title' => t("Last comment author"), 'help' => t('The name of the author of the last posted comment.'), @@ -431,7 +410,6 @@ function comment_views_data() { ), ); - // comment_count $data['node_comment_statistics']['comment_count'] = array( 'title' => t('Comment count'), 'help' => t('The number of comments a node has.'), @@ -449,7 +427,6 @@ function comment_views_data() { ), ); - // last_comment_timestamp $data['node_comment_statistics']['last_updated'] = array( 'title' => t('Updated/commented date'), 'help' => t('The most recent of last comment posted or node updated time.'), @@ -480,7 +457,6 @@ function comment_views_data() { ), ); - // last_comment_uid $data['node_comment_statistics']['last_comment_uid'] = array( 'title' => t('Last comment uid'), 'help' => t('The User ID of the author of the last comment of a node.'), @@ -506,8 +482,7 @@ function comment_views_data() { } /** - * Use views_data_alter to add items to the node table that are - * relevant to comments. + * Implements hook_views_data_alter(). */ function comment_views_data_alter(&$data) { // new comments @@ -528,7 +503,6 @@ function comment_views_data_alter(&$data) { ), ); - // Comment status of the node $data['node']['comment'] = array( 'title' => t('Comment status'), 'help' => t('Whether comments are enabled or disabled on the node.'), diff --git a/core/modules/node/node.views.inc b/core/modules/node/node.views.inc index cd6575ef8bda..7794c98b6118 100644 --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -14,13 +14,12 @@ * Implements hook_views_data(). */ function node_views_data() { - // node table -- basic table information. - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['node']['table']['group'] = t('Content'); - // Advertise this table as a possible base table + // Advertise this table as a possible base table. $data['node']['table']['base'] = array( 'field' => 'nid', 'title' => t('Content'), @@ -33,49 +32,41 @@ function node_views_data() { $data['node']['table']['entity type'] = 'node'; $data['node']['table']['wizard_id'] = 'node'; - // node table -- fields - - // nid $data['node']['nid'] = array( 'title' => t('Nid'), - 'help' => t('The node ID.'), // The help that appears on the UI, - // Information for displaying the nid + 'help' => t('The node ID.'), 'field' => array( 'id' => 'node', ), - // Information for accepting a nid as an argument 'argument' => array( 'id' => 'node_nid', - 'name field' => 'title', // the field to display in the summary. + 'name field' => 'title', 'numeric' => TRUE, 'validate type' => 'nid', ), - // Information for accepting a nid as a filter 'filter' => array( 'id' => 'numeric', ), - // Information for sorting on a nid. 'sort' => array( 'id' => 'standard', ), ); - // title // This definition has more items in it than it needs to as an example. $data['node']['title'] = array( - 'title' => t('Title'), // The item it appears as on the UI, - 'help' => t('The content title.'), // The help that appears on the UI, - // Information for displaying a title as a field + 'title' => t('Title'), + 'help' => t('The content title.'), 'field' => array( - 'field' => 'title', // the real field. This could be left out since it is the same. - 'group' => t('Content'), // The group it appears in on the UI. Could be left out. + // 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'), 'id' => 'node', 'link_to_node default' => TRUE, ), 'sort' => array( 'id' => 'standard', ), - // Information for accepting a title as a filter 'filter' => array( 'id' => 'string', ), @@ -84,10 +75,9 @@ function node_views_data() { ), ); - // created field $data['node']['created'] = array( - 'title' => t('Post date'), // The item it appears as on the UI, - 'help' => t('The date the content was posted.'), // The help that appears on the UI, + 'title' => t('Post date'), + 'help' => t('The date the content was posted.'), 'field' => array( 'id' => 'date', ), @@ -99,10 +89,9 @@ function node_views_data() { ), ); - // changed field $data['node']['changed'] = array( - 'title' => t('Updated date'), // The item it appears as on the UI, - 'help' => t('The date the content was last updated.'), // The help that appears on the UI, + 'title' => t('Updated date'), + 'help' => t('The date the content was last updated.'), 'field' => array( 'id' => 'date', ), @@ -114,10 +103,9 @@ function node_views_data() { ), ); - // Content type $data['node']['type'] = array( - 'title' => t('Type'), // The item it appears as on the UI, - 'help' => t('The content type (for example, "blog entry", "forum post", "story", etc).'), // The help that appears on the UI, + 'title' => t('Type'), + 'help' => t('The content type (for example, "blog entry", "forum post", "story", etc).'), 'field' => array( 'id' => 'node_type', ), @@ -132,7 +120,6 @@ function node_views_data() { ), ); - // published status $data['node']['status'] = array( 'title' => t('Published status'), 'help' => t('Whether or not the content is published.'), @@ -146,14 +133,14 @@ function node_views_data() { 'id' => 'boolean', 'label' => t('Published status'), 'type' => 'yes-no', - 'use_equal' => TRUE, // Use status = 1 instead of status <> 0 in WHERE statment + // Use status = 1 instead of status <> 0 in WHERE statement. + 'use_equal' => TRUE, ), 'sort' => array( 'id' => 'standard', ), ); - // published status + extra $data['node']['status_extra'] = array( 'title' => t('Published status or admin user'), 'help' => t('Filters out unpublished content if the current user cannot view it.'), @@ -164,7 +151,6 @@ function node_views_data() { ), ); - // promote status $data['node']['promote'] = array( 'title' => t('Promoted to front page status'), 'help' => t('Whether or not the content is promoted to the front page.'), @@ -184,11 +170,9 @@ function node_views_data() { ), ); - // sticky $data['node']['sticky'] = array( 'title' => t('Sticky status'), - 'help' => t('Whether or not the content is sticky.'), // The help that appears on the UI, - // Information for displaying a title as a field + 'help' => t('Whether or not the content is sticky.'), 'field' => array( 'id' => 'boolean', 'output formats' => array( @@ -206,7 +190,6 @@ function node_views_data() { ), ); - // Language field if (module_exists('language')) { $data['node']['langcode'] = array( 'title' => t('Language'), @@ -226,7 +209,6 @@ function node_views_data() { ); } - // Entity translation field. if (drupal_container()->get('module_handler')->moduleExists('translation_entity')) { $data['node']['translation_link'] = array( 'title' => t('Translation link'), @@ -241,6 +223,8 @@ function node_views_data() { // table so they can be re-used with other query backends. // @see views_handler_field_entity + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['views_entity_node']['table']['group'] = t('Content'); $data['views_entity_node']['view_node'] = array( @@ -385,7 +369,6 @@ function node_views_data() { ), ); - // uid field $data['node']['uid'] = array( 'title' => t('Author uid'), 'help' => t('The user authoring the content. If you need more fields than the uid add the content: author relationship'), @@ -420,16 +403,14 @@ function node_views_data() { ), ); - // Content revision table - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. $data['node_revision']['table']['entity type'] = 'node'; + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['node_revision']['table']['group'] = t('Content revision'); $data['node_revision']['table']['wizard_id'] = 'node_revision'; - // Advertise this table as a possible base table + // Advertise this table as a possible base table. $data['node_revision']['table']['base'] = array( 'field' => 'vid', 'title' => t('Content revision'), @@ -439,16 +420,14 @@ function node_views_data() { ), ); - // For other base tables, explain how we join + // For other base tables, explain how we join. $data['node_revision']['table']['join'] = array( - // Directly links to node table. 'node' => array( 'left_field' => 'vid', 'field' => 'vid', ), ); - // UID field for node revision. $data['node_revision']['uid'] = array( 'title' => t('User'), 'help' => t('Relate a content revision to the user who created the revision.'), @@ -460,25 +439,19 @@ function node_views_data() { ), ); - // nid $data['node_revision']['nid'] = array( 'title' => t('Nid'), - // The help that appears on the UI. 'help' => t('The revision NID of the content revision.'), - // Information for displaying the nid. 'field' => array( 'id' => 'standard', ), - // Information for accepting a nid as an argument. 'argument' => array( 'id' => 'node_nid', 'numeric' => TRUE, ), - // Information for accepting a nid as a filter. 'filter' => array( 'id' => 'numeric', ), - // Information for sorting on a nid. 'sort' => array( 'id' => 'standard', ), @@ -491,24 +464,19 @@ function node_views_data() { ), ); - // vid $data['node_revision']['vid'] = array( 'title' => t('Vid'), 'help' => t('The revision ID of the content revision.'), - // Information for displaying the vid 'field' => array( 'id' => 'standard', ), - // Information for accepting a vid as an argument 'argument' => array( 'id' => 'node_vid', 'numeric' => TRUE, ), - // Information for accepting a vid as a filter 'filter' => array( 'id' => 'numeric', ), - // Information for sorting on a vid. 'sort' => array( 'id' => 'standard', ), @@ -521,7 +489,6 @@ function node_views_data() { ), ); - // published status $data['node_revision']['status'] = array( 'title' => t('Published'), 'help' => t('Whether or not the content is published.'), @@ -535,20 +502,19 @@ function node_views_data() { 'id' => 'boolean', 'label' => t('Published'), 'type' => 'yes-no', - 'use_equal' => TRUE, // Use status = 1 instead of status <> 0 in WHERE statment + // Use status = 1 instead of status <> 0 in WHERE statement. + 'use_equal' => TRUE, ), 'sort' => array( 'id' => 'standard', ), ); - // title $data['node_revision']['title'] = array( - 'title' => t('Title'), // The item it appears as on the UI, - 'help' => t('The content title.'), // The help that appears on the UI, - // Information for displaying a title as a field + 'title' => t('Title'), + 'help' => t('The content title.'), 'field' => array( - 'field' => 'title', // the real field + 'field' => 'title', 'id' => 'node_revision', ), 'sort' => array( @@ -562,11 +528,9 @@ function node_views_data() { ), ); - // log field $data['node_revision']['log'] = array( - 'title' => t('Log message'), // The item it appears as on the UI, - 'help' => t('The log message entered when the revision was created.'), // The help that appears on the UI, - // Information for displaying a title as a field + 'title' => t('Log message'), + 'help' => t('The log message entered when the revision was created.'), 'field' => array( 'id' => 'xss', ), @@ -575,11 +539,9 @@ function node_views_data() { ), ); - // revision timestamp - // changed field $data['node_revision']['timestamp'] = array( - 'title' => t('Updated date'), // The item it appears as on the UI, - 'help' => t('The date the node was last updated.'), // The help that appears on the UI, + 'title' => t('Updated date'), + 'help' => t('The date the node was last updated.'), 'field' => array( 'id' => 'date', ), @@ -618,21 +580,17 @@ function node_views_data() { ), ); - // Node access table - - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['node_access']['table']['group'] = t('Content access'); - // For other base tables, explain how we join + // For other base tables, explain how we join. $data['node_access']['table']['join'] = array( - // Directly links to node table. 'node' => array( 'left_field' => 'nid', 'field' => 'nid', ), ); - // nid field $data['node_access']['nid'] = array( 'title' => t('Access'), 'help' => t('Filter by access.'), diff --git a/core/modules/user/user.views.inc b/core/modules/user/user.views.inc index 0dbe8707aad1..13b1690e04ed 100644 --- a/core/modules/user/user.views.inc +++ b/core/modules/user/user.views.inc @@ -11,10 +11,9 @@ * Implements hook_views_data(). */ function user_views_data() { - // users table - // Define the base group of this table. Fields that don't - // have a group defined will go into this field by default. + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['users']['table']['group'] = t('User'); $data['users']['table']['base'] = array( @@ -26,16 +25,15 @@ function user_views_data() { $data['users']['table']['entity type'] = 'user'; $data['users']['table']['wizard_id'] = 'user'; - // uid $data['users']['uid'] = array( 'title' => t('Uid'), - 'help' => t('The user ID'), // The help that appears on the UI, + 'help' => t('The user ID'), 'field' => array( 'id' => 'user', ), 'argument' => array( 'id' => 'user_uid', - 'name field' => 'name', // display this field in the summary + 'name field' => 'name', ), 'filter' => array( 'title' => t('Name'), @@ -55,7 +53,6 @@ function user_views_data() { ), ); - // uid_raw $data['users']['uid_raw'] = array( 'help' => t('The raw numeric user ID.'), 'real field' => 'uid', @@ -65,7 +62,6 @@ function user_views_data() { ), ); - // uid $data['users']['uid_representative'] = array( 'relationship' => array( 'title' => t('Representative node'), @@ -82,7 +78,6 @@ function user_views_data() { ), ); - // uid $data['users']['uid_current'] = array( 'real field' => 'uid', 'title' => t('Current'), @@ -93,10 +88,9 @@ function user_views_data() { ), ); - // name $data['users']['name'] = array( - 'title' => t('Name'), // The item it appears as on the UI, - 'help' => t('The user or author name.'), // The help that appears on the UI, + 'title' => t('Name'), + 'help' => t('The user or author name.'), 'field' => array( 'id' => 'user_name', ), @@ -113,7 +107,6 @@ function user_views_data() { ), ); - // mail // Note that this field implements field level access control. $data['users']['mail'] = array( 'title' => t('E-mail'), @@ -132,9 +125,8 @@ function user_views_data() { ), ); - // language $data['users']['langcode'] = array( - 'title' => t('Language'), // The item it appears as on the UI, + 'title' => t('Language'), 'help' => t('Language of the user'), 'field' => array( 'id' => 'user_language', @@ -150,7 +142,6 @@ function user_views_data() { ), ); - // link $data['users']['view_user'] = array( 'field' => array( 'title' => t('Link to user'), @@ -160,10 +151,9 @@ function user_views_data() { ), ); - // created field $data['users']['created'] = array( - 'title' => t('Created date'), // The item it appears as on the UI, - 'help' => t('The date the user was created.'), // The help that appears on the UI, + 'title' => t('Created date'), + 'help' => t('The date the user was created.'), 'field' => array( 'id' => 'date', ), @@ -229,10 +219,9 @@ function user_views_data() { ), ); - // access field $data['users']['access'] = array( - 'title' => t('Last access'), // The item it appears as on the UI, - 'help' => t("The user's last access date."), // The help that appears on the UI, + 'title' => t('Last access'), + 'help' => t("The user's last access date."), 'field' => array( 'id' => 'date', ), @@ -244,10 +233,9 @@ function user_views_data() { ), ); - // login field $data['users']['login'] = array( - 'title' => t('Last login'), // The item it appears as on the UI, - 'help' => t("The user's last login date."), // The help that appears on the UI, + 'title' => t('Last login'), + 'help' => t("The user's last login date."), 'field' => array( 'id' => 'date', ), @@ -259,11 +247,9 @@ function user_views_data() { ), ); - // active status $data['users']['status'] = array( 'title' => t('Active status'), - 'help' => t('Whether a user is active or blocked.'), // The help that appears on the UI, - // Information for displaying a title as a field + 'help' => t('Whether a user is active or blocked.'), 'field' => array( 'id' => 'boolean', 'output formats' => array( @@ -280,11 +266,9 @@ function user_views_data() { ), ); - // log field $data['users']['signature'] = array( - 'title' => t('Signature'), // The item it appears as on the UI, - 'help' => t("The user's signature."), // The help that appears on the UI, - // Information for displaying a title as a field + 'title' => t('Signature'), + 'help' => t("The user's signature."), 'field' => array( 'id' => 'markup', 'format' => filter_fallback_format(), @@ -295,7 +279,6 @@ function user_views_data() { ), ); - // Entity translation field. if (drupal_container()->get('module_handler')->moduleExists('translation_entity')) { $data['users']['translation_link'] = array( 'title' => t('Translation link'), @@ -333,13 +316,12 @@ function user_views_data() { ), ); - // users_roles table - + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['users_roles']['table']['group'] = t('User'); // Explain how this table joins to others. $data['users_roles']['table']['join'] = array( - // Directly links to users table. 'users' => array( 'left_field' => 'uid', 'field' => 'uid', @@ -367,10 +349,11 @@ function user_views_data() { ), ); - // permission table + // Define the base group of this table. Fields that don't have a group defined + // will go into this field by default. $data['role_permission']['table']['group'] = t('User'); + // Explain how this table joins to others. $data['role_permission']['table']['join'] = array( - // Directly links to users table. 'users' => array( 'left_table' => 'users_roles', 'left_field' => 'rid', @@ -394,7 +377,9 @@ function user_views_data() { } /** - * Allow replacement of current userid so we can cache these queries + * Implements hook_views_query_substitutions(). + * + * Allow replacement of current userid so we can cache these queries. */ function user_views_query_substitutions($view) { global $user; -- GitLab