You are here

function comment_token_info in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/comment.tokens.inc \comment_token_info()

Implements hook_token_info().

File

core/modules/comment/comment.tokens.inc, line 15
Builds placeholder replacement tokens for comment-related data.

Code

function comment_token_info() {
  $type = array(
    'name' => t('Comments'),
    'description' => t('Tokens for comments posted on the site.'),
    'needs-data' => 'comment',
  );

  // @todo Make this work per field. See https://www.drupal.org/node/2031903.
  $entity['comment-count'] = array(
    'name' => t("Comment count"),
    'description' => t("The number of comments posted on an entity."),
  );
  $entity['comment-count-new'] = array(
    'name' => t("New comment count"),
    'description' => t("The number of comments posted on an entity since the reader last viewed it."),
  );

  // Core comment tokens
  $comment['cid'] = array(
    'name' => t("Comment ID"),
    'description' => t("The unique ID of the comment."),
  );
  $comment['hostname'] = array(
    'name' => t("IP Address"),
    'description' => t("The IP address of the computer the comment was posted from."),
  );
  $comment['mail'] = array(
    'name' => t("Email address"),
    'description' => t("The email address left by the comment author."),
  );
  $comment['homepage'] = array(
    'name' => t("Home page"),
    'description' => t("The home page URL left by the comment author."),
  );
  $comment['title'] = array(
    'name' => t("Title"),
    'description' => t("The title of the comment."),
  );
  $comment['body'] = array(
    'name' => t("Content"),
    'description' => t("The formatted content of the comment itself."),
  );
  $comment['langcode'] = array(
    'name' => t('Language code'),
    'description' => t('The language code of the language the comment is written in.'),
  );
  $comment['url'] = array(
    'name' => t("URL"),
    'description' => t("The URL of the comment."),
  );
  $comment['edit-url'] = array(
    'name' => t("Edit URL"),
    'description' => t("The URL of the comment's edit page."),
  );

  // Chained tokens for comments
  $comment['created'] = array(
    'name' => t("Date created"),
    'description' => t("The date the comment was posted."),
    'type' => 'date',
  );
  $comment['changed'] = array(
    'name' => t("Date changed"),
    'description' => t("The date the comment was most recently updated."),
    'type' => 'date',
  );
  $comment['parent'] = array(
    'name' => t("Parent"),
    'description' => t("The comment's parent, if comment threading is active."),
    'type' => 'comment',
  );
  $comment['entity'] = array(
    'name' => t("Entity"),
    'description' => t("The entity the comment was posted to."),
    'type' => 'entity',
  );
  $comment['author'] = array(
    'name' => t("Author"),
    'description' => t("The author name of the comment."),
    'type' => 'user',
  );
  return array(
    'types' => array(
      'comment' => $type,
    ),
    'tokens' => array(
      'entity' => $entity,
      'comment' => $comment,
    ),
  );
}