summaryrefslogtreecommitdiff
path: root/modules/comment/comment.tokens.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-04-20 09:48:06 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-04-20 09:48:06 +0000
commit7bb6753e9fc8d89472ecc2b6d5ab670dde27b935 (patch)
tree79eae1caf8b93351560fa36202d46913ac06e1ef /modules/comment/comment.tokens.inc
parent8e94b5d6d400d33c0f840a7ae97ff8a715272a79 (diff)
downloadbrdo-7bb6753e9fc8d89472ecc2b6d5ab670dde27b935.tar.gz
brdo-7bb6753e9fc8d89472ecc2b6d5ab670dde27b935.tar.bz2
#701818 by mcarbone: Test coverage of every core token, and bug fixes to make them work. AWESOME! :D
Diffstat (limited to 'modules/comment/comment.tokens.inc')
-rw-r--r--modules/comment/comment.tokens.inc22
1 files changed, 17 insertions, 5 deletions
diff --git a/modules/comment/comment.tokens.inc b/modules/comment/comment.tokens.inc
index d16eabda6..cf26d74c9 100644
--- a/modules/comment/comment.tokens.inc
+++ b/modules/comment/comment.tokens.inc
@@ -82,6 +82,11 @@ function comment_token_info() {
'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."),
@@ -133,6 +138,10 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
$replacements[$original] = $comment->cid;
break;
+ case 'pid':
+ $replacements[$original] = $comment->pid;
+ break;
+
case 'nid':
$replacements[$original] = $comment->nid;
break;
@@ -141,10 +150,6 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
$replacements[$original] = $comment->uid;
break;
- case 'pid':
- $replacements[$original] = $comment->pid;
- break;
-
// Poster identity information for comments
case 'hostname':
$replacements[$original] = $sanitize ? check_plain($comment->hostname) : $comment->hostname;
@@ -175,7 +180,9 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'body':
- $replacements[$original] = $sanitize ? check_markup($comment->comment, $comment->format, '', TRUE) : $comment->comment;
+ $item = $comment->comment_body[LANGUAGE_NONE][0];
+ $instance = field_info_instance('comment', 'body', 'comment_body');
+ $replacements[$original] = $sanitize ? _text_sanitize($instance, LANGUAGE_NONE, $item, 'value') : $item['value'];
break;
// Comment related URLs.
@@ -185,6 +192,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'edit-url':
+ $url_options['fragment'] = NULL;
$replacements[$original] = url('comment/' . $comment->cid . '/edit', $url_options);
break;
@@ -226,6 +234,10 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
$replacements += token_generate('date', $date_tokens, array('date' => $comment->created), $options);
}
+ if ($date_tokens = token_find_with_prefix($tokens, 'changed')) {
+ $replacements += token_generate('date', $date_tokens, array('date' => $comment->changed), $options);
+ }
+
if (($parent_tokens = token_find_with_prefix($tokens, 'parent')) && $parent = comment_load($comment->pid)) {
$replacements += token_generate('comment', $parent_tokens, array('comment' => $parent), $options);
}