Chris@0: t('Comments are responses to content.'); Chris@0: $data['comment_field_data']['table']['base']['access query tag'] = 'comment_access'; Chris@0: Chris@0: $data['comment_field_data']['table']['wizard_id'] = 'comment'; Chris@0: Chris@0: $data['comment_field_data']['subject']['title'] = $this->t('Title'); Chris@0: $data['comment_field_data']['subject']['help'] = $this->t('The title of the comment.'); Chris@0: $data['comment_field_data']['subject']['field']['default_formatter'] = 'comment_permalink'; Chris@0: Chris@0: $data['comment_field_data']['name']['title'] = $this->t('Author'); Chris@0: $data['comment_field_data']['name']['help'] = $this->t("The name of the comment's author. Can be rendered as a link to the author's homepage."); Chris@0: $data['comment_field_data']['name']['field']['default_formatter'] = 'comment_username'; Chris@0: Chris@0: $data['comment_field_data']['homepage']['title'] = $this->t("Author's website"); Chris@0: $data['comment_field_data']['homepage']['help'] = $this->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."); Chris@0: Chris@0: $data['comment_field_data']['mail']['help'] = $this->t('Email of user that posted the comment. Will be empty if the author is a registered user.'); Chris@0: Chris@0: $data['comment_field_data']['created']['title'] = $this->t('Post date'); Chris@0: $data['comment_field_data']['created']['help'] = $this->t('Date and time of when the comment was created.'); Chris@0: Chris@0: $data['comment_field_data']['created_fulldata'] = [ Chris@0: 'title' => $this->t('Created date'), Chris@0: 'help' => $this->t('Date in the form of CCYYMMDD.'), Chris@0: 'argument' => [ Chris@0: 'field' => 'created', Chris@0: 'id' => 'date_fulldate', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['created_year_month'] = [ Chris@0: 'title' => $this->t('Created year + month'), Chris@0: 'help' => $this->t('Date in the form of YYYYMM.'), Chris@0: 'argument' => [ Chris@0: 'field' => 'created', Chris@0: 'id' => 'date_year_month', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['created_year'] = [ Chris@0: 'title' => $this->t('Created year'), Chris@0: 'help' => $this->t('Date in the form of YYYY.'), Chris@0: 'argument' => [ Chris@0: 'field' => 'created', Chris@0: 'id' => 'date_year', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['created_month'] = [ Chris@0: 'title' => $this->t('Created month'), Chris@0: 'help' => $this->t('Date in the form of MM (01 - 12).'), Chris@0: 'argument' => [ Chris@0: 'field' => 'created', Chris@0: 'id' => 'date_month', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['created_day'] = [ Chris@0: 'title' => $this->t('Created day'), Chris@0: 'help' => $this->t('Date in the form of DD (01 - 31).'), Chris@0: 'argument' => [ Chris@0: 'field' => 'created', Chris@0: 'id' => 'date_day', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['created_week'] = [ Chris@0: 'title' => $this->t('Created week'), Chris@0: 'help' => $this->t('Date in the form of WW (01 - 53).'), Chris@0: 'argument' => [ Chris@0: 'field' => 'created', Chris@0: 'id' => 'date_week', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['changed']['title'] = $this->t('Updated date'); Chris@0: $data['comment_field_data']['changed']['help'] = $this->t('Date and time of when the comment was last updated.'); Chris@0: Chris@0: $data['comment_field_data']['changed_fulldata'] = [ Chris@0: 'title' => $this->t('Changed date'), Chris@0: 'help' => $this->t('Date in the form of CCYYMMDD.'), Chris@0: 'argument' => [ Chris@0: 'field' => 'changed', Chris@0: 'id' => 'date_fulldate', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['changed_year_month'] = [ Chris@0: 'title' => $this->t('Changed year + month'), Chris@0: 'help' => $this->t('Date in the form of YYYYMM.'), Chris@0: 'argument' => [ Chris@0: 'field' => 'changed', Chris@0: 'id' => 'date_year_month', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['changed_year'] = [ Chris@0: 'title' => $this->t('Changed year'), Chris@0: 'help' => $this->t('Date in the form of YYYY.'), Chris@0: 'argument' => [ Chris@0: 'field' => 'changed', Chris@0: 'id' => 'date_year', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['changed_month'] = [ Chris@0: 'title' => $this->t('Changed month'), Chris@0: 'help' => $this->t('Date in the form of MM (01 - 12).'), Chris@0: 'argument' => [ Chris@0: 'field' => 'changed', Chris@0: 'id' => 'date_month', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['changed_day'] = [ Chris@0: 'title' => $this->t('Changed day'), Chris@0: 'help' => $this->t('Date in the form of DD (01 - 31).'), Chris@0: 'argument' => [ Chris@0: 'field' => 'changed', Chris@0: 'id' => 'date_day', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['changed_week'] = [ Chris@0: 'title' => $this->t('Changed week'), Chris@0: 'help' => $this->t('Date in the form of WW (01 - 53).'), Chris@0: 'argument' => [ Chris@0: 'field' => 'changed', Chris@0: 'id' => 'date_week', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['status']['title'] = $this->t('Approved status'); Chris@0: $data['comment_field_data']['status']['help'] = $this->t('Whether the comment is approved (or still in the moderation queue).'); Chris@0: $data['comment_field_data']['status']['filter']['label'] = $this->t('Approved comment status'); Chris@0: $data['comment_field_data']['status']['filter']['type'] = 'yes-no'; Chris@0: Chris@0: $data['comment']['approve_comment'] = [ Chris@0: 'field' => [ Chris@0: 'title' => $this->t('Link to approve comment'), Chris@0: 'help' => $this->t('Provide a simple link to approve the comment.'), Chris@0: 'id' => 'comment_link_approve', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment']['replyto_comment'] = [ Chris@0: 'field' => [ Chris@0: 'title' => $this->t('Link to reply-to comment'), Chris@0: 'help' => $this->t('Provide a simple link to reply to the comment.'), Chris@0: 'id' => 'comment_link_reply', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['entity_id']['field']['id'] = 'commented_entity'; Chris@0: unset($data['comment_field_data']['entity_id']['relationship']); Chris@0: Chris@0: $data['comment']['comment_bulk_form'] = [ Chris@0: 'title' => $this->t('Comment operations bulk form'), Chris@0: 'help' => $this->t('Add a form element that lets you run operations on multiple comments.'), Chris@0: 'field' => [ Chris@0: 'id' => 'comment_bulk_form', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_field_data']['thread']['field'] = [ Chris@0: 'title' => $this->t('Depth'), Chris@0: 'help' => $this->t('Display the depth of the comment if it is threaded.'), Chris@0: 'id' => 'comment_depth', Chris@0: ]; Chris@0: $data['comment_field_data']['thread']['sort'] = [ Chris@0: 'title' => $this->t('Thread'), Chris@0: 'help' => $this->t('Sort by the threaded order. This will keep child comments together with their parents.'), Chris@0: 'id' => 'comment_thread', Chris@0: ]; Chris@0: unset($data['comment_field_data']['thread']['filter']); Chris@0: unset($data['comment_field_data']['thread']['argument']); Chris@0: Chris@0: $entities_types = \Drupal::entityManager()->getDefinitions(); Chris@0: Chris@0: // Provide a relationship for each entity type except comment. Chris@0: foreach ($entities_types as $type => $entity_type) { Chris@0: if ($type == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) { Chris@0: continue; Chris@0: } Chris@0: if ($fields = \Drupal::service('comment.manager')->getFields($type)) { Chris@0: $data['comment_field_data'][$type] = [ Chris@0: 'relationship' => [ Chris@0: 'title' => $entity_type->getLabel(), Chris@0: 'help' => $this->t('The @entity_type to which the comment is a reply to.', ['@entity_type' => $entity_type->getLabel()]), Chris@0: 'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(), Chris@0: 'base field' => $entity_type->getKey('id'), Chris@0: 'relationship field' => 'entity_id', Chris@0: 'id' => 'standard', Chris@0: 'label' => $entity_type->getLabel(), Chris@0: 'extra' => [ Chris@0: [ Chris@0: 'field' => 'entity_type', Chris@0: 'value' => $type, Chris@17: 'table' => 'comment_field_data', Chris@0: ], Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: } Chris@0: Chris@0: $data['comment_field_data']['uid']['title'] = $this->t('Author uid'); Chris@0: $data['comment_field_data']['uid']['help'] = $this->t('If you need more fields than the uid add the comment: author relationship'); Chris@0: $data['comment_field_data']['uid']['relationship']['title'] = $this->t('Author'); Chris@0: $data['comment_field_data']['uid']['relationship']['help'] = $this->t("The User ID of the comment's author."); Chris@0: $data['comment_field_data']['uid']['relationship']['label'] = $this->t('author'); Chris@0: Chris@0: $data['comment_field_data']['pid']['title'] = $this->t('Parent CID'); Chris@0: $data['comment_field_data']['pid']['relationship']['title'] = $this->t('Parent comment'); Chris@0: $data['comment_field_data']['pid']['relationship']['help'] = $this->t('The parent comment'); Chris@0: $data['comment_field_data']['pid']['relationship']['label'] = $this->t('parent'); Chris@0: Chris@0: // Define the base group of this table. Fields that don't have a group defined Chris@0: // will go into this field by default. Chris@17: $data['comment_entity_statistics']['table']['group'] = $this->t('Comment Statistics'); Chris@0: Chris@0: // Provide a relationship for each entity type except comment. Chris@0: foreach ($entities_types as $type => $entity_type) { Chris@0: if ($type == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) { Chris@0: continue; Chris@0: } Chris@0: // This relationship does not use the 'field id' column, if the entity has Chris@0: // multiple comment-fields, then this might introduce duplicates, in which Chris@0: // case the site-builder should enable aggregation and SUM the comment_count Chris@0: // field. We cannot create a relationship from the base table to Chris@0: // {comment_entity_statistics} for each field as multiple joins between Chris@0: // the same two tables is not supported. Chris@0: if (\Drupal::service('comment.manager')->getFields($type)) { Chris@0: $data['comment_entity_statistics']['table']['join'][$entity_type->getDataTable() ?: $entity_type->getBaseTable()] = [ Chris@0: 'type' => 'INNER', Chris@0: 'left_field' => $entity_type->getKey('id'), Chris@0: 'field' => 'entity_id', Chris@0: 'extra' => [ Chris@0: [ Chris@0: 'field' => 'entity_type', Chris@0: 'value' => $type, Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: } Chris@0: Chris@0: $data['comment_entity_statistics']['last_comment_timestamp'] = [ Chris@0: 'title' => $this->t('Last comment time'), Chris@0: 'help' => $this->t('Date and time of when the last comment was posted.'), Chris@0: 'field' => [ Chris@0: 'id' => 'comment_last_timestamp', Chris@0: ], Chris@0: 'sort' => [ Chris@0: 'id' => 'date', Chris@0: ], Chris@0: 'filter' => [ Chris@0: 'id' => 'date', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_entity_statistics']['last_comment_name'] = [ Chris@0: 'title' => $this->t("Last comment author"), Chris@0: 'help' => $this->t('The name of the author of the last posted comment.'), Chris@0: 'field' => [ Chris@0: 'id' => 'comment_ces_last_comment_name', Chris@0: 'no group by' => TRUE, Chris@0: ], Chris@0: 'sort' => [ Chris@0: 'id' => 'comment_ces_last_comment_name', Chris@0: 'no group by' => TRUE, Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_entity_statistics']['comment_count'] = [ Chris@0: 'title' => $this->t('Comment count'), Chris@0: 'help' => $this->t('The number of comments an entity has.'), Chris@0: 'field' => [ Chris@0: 'id' => 'numeric', Chris@0: ], Chris@0: 'filter' => [ Chris@0: 'id' => 'numeric', Chris@0: ], Chris@0: 'sort' => [ Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: 'argument' => [ Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_entity_statistics']['last_updated'] = [ Chris@0: 'title' => $this->t('Updated/commented date'), Chris@0: 'help' => $this->t('The most recent of last comment posted or entity updated time.'), Chris@0: 'field' => [ Chris@0: 'id' => 'comment_ces_last_updated', Chris@0: 'no group by' => TRUE, Chris@0: ], Chris@0: 'sort' => [ Chris@0: 'id' => 'comment_ces_last_updated', Chris@0: 'no group by' => TRUE, Chris@0: ], Chris@0: 'filter' => [ Chris@0: 'id' => 'comment_ces_last_updated', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_entity_statistics']['cid'] = [ Chris@0: 'title' => $this->t('Last comment CID'), Chris@0: 'help' => $this->t('Display the last comment of an entity'), Chris@0: 'relationship' => [ Chris@0: 'title' => $this->t('Last comment'), Chris@0: 'help' => $this->t('The last comment of an entity.'), Chris@0: 'group' => $this->t('Comment'), Chris@0: 'base' => 'comment', Chris@0: 'base field' => 'cid', Chris@0: 'id' => 'standard', Chris@0: 'label' => $this->t('Last Comment'), Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_entity_statistics']['last_comment_uid'] = [ Chris@0: 'title' => $this->t('Last comment uid'), Chris@0: 'help' => $this->t('The User ID of the author of the last comment of an entity.'), Chris@0: 'relationship' => [ Chris@0: 'title' => $this->t('Last comment author'), Chris@0: 'base' => 'users', Chris@0: 'base field' => 'uid', Chris@0: 'id' => 'standard', Chris@0: 'label' => $this->t('Last comment author'), Chris@0: ], Chris@0: 'filter' => [ Chris@0: 'id' => 'numeric', Chris@0: ], Chris@0: 'argument' => [ Chris@0: 'id' => 'numeric', Chris@0: ], Chris@0: 'field' => [ Chris@0: 'id' => 'numeric', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: $data['comment_entity_statistics']['entity_type'] = [ Chris@0: 'title' => $this->t('Entity type'), Chris@0: 'help' => $this->t('The entity type to which the comment is a reply to.'), Chris@0: 'field' => [ Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: 'filter' => [ Chris@0: 'id' => 'string', Chris@0: ], Chris@0: 'argument' => [ Chris@0: 'id' => 'string', Chris@0: ], Chris@0: 'sort' => [ Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: ]; Chris@0: $data['comment_entity_statistics']['field_name'] = [ Chris@0: 'title' => $this->t('Comment field name'), Chris@0: 'help' => $this->t('The field name from which the comment originated.'), Chris@0: 'field' => [ Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: 'filter' => [ Chris@0: 'id' => 'string', Chris@0: ], Chris@0: 'argument' => [ Chris@0: 'id' => 'string', Chris@0: ], Chris@0: 'sort' => [ Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: return $data; Chris@0: } Chris@0: Chris@0: }