| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: token_comment.inc,v 1.3.4.11 2010/07/08 00:41:19 davereid Exp $ 3 4 /** 5 * @file 6 * Implementations of token module hooks for the core comment module. 7 * 8 * The token module requires specific hooks to be added to modules 9 * so that those modules can return data about their objects to the 10 * token API. Until and unless token becomes a part of core, the 11 * implementations of the token hooks for core modules are provided 12 * in the token module itself. 13 * @ingroup token 14 */ 15 16 /** 17 * Implementation of hook_token_values(). 18 */ 19 function comment_token_values($type, $object = NULL, $options = array()) { 20 $values = array(); 21 switch ($type) { 22 case 'comment': 23 24 // Cast to an object just in case fussy Drupal gave us an array 25 $comment = (object)$object; 26 27 $values['comment-cid'] = $comment->cid; 28 $values['comment-nid'] = $comment->nid; 29 $values['comment-title'] = check_plain($comment->subject); 30 $values['comment-body'] = check_markup($comment->comment, $comment->format, FALSE); 31 $values['comment-author-name'] = check_plain($comment->name); 32 $values['comment-author-uid'] = $comment->uid; 33 $values['comment-author-homepage'] = check_url($comment->homepage); 34 35 // Raw counterparts of user supplied data. 36 $values['comment-title-raw'] = $comment->subject; 37 $values['comment-body-raw'] = $comment->comment; 38 $values['comment-author-name-raw'] = $comment->name; 39 40 if (!empty($comment->mail)) { 41 $account_mail = $comment->mail; 42 } 43 elseif (!empty($comment->uid)) { 44 $account_mail = db_result(db_query("SELECT mail FROM {users} WHERE uid = %d", $comment->uid)); 45 } 46 else { 47 $account_mail = ''; 48 } 49 $values['comment-author-mail'] = check_plain($account_mail); 50 $values['comment-author-mail-raw'] = $account_mail; 51 52 // Included in case a consuming module wants to format the body 53 $values['comment-body-format'] = $comment->format; 54 55 $values += token_get_date_token_values($comment->timestamp, 'comment-'); 56 57 $values['comment-node-title-raw'] = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $comment->nid)); 58 $values['comment-node-title'] = check_plain($values['comment-node-title-raw']); 59 break; 60 } 61 62 return $values; 63 } 64 65 /** 66 * Implementation of hook_token_list(). 67 */ 68 function comment_token_list($type = 'all') { 69 if ($type == 'comment' || $type == 'all') { 70 $tokens['comment']['comment-cid'] = t('The unique ID of the comment.'); 71 $tokens['comment']['comment-nid'] = t('The unique ID of the node the comment was posted to.'); 72 $tokens['comment']['comment-title'] = t('The title of the comment.'); 73 $tokens['comment']['comment-title-raw'] = t('The title of the comment.'); 74 $tokens['comment']['comment-body'] = t('The formatted content of the comment itself.'); 75 $tokens['comment']['comment-body-raw'] = t('The formatted content of the comment itself.'); 76 77 $tokens['comment']['comment-author-uid'] = t('The unique ID of the author of the comment.'); 78 $tokens['comment']['comment-author-name'] = t('The name left by the comment author.'); 79 $tokens['comment']['comment-author-name-raw'] = t('The name left by the comment author.'); 80 $tokens['comment']['comment-author-homepage'] = t('The home page URL left by the comment author.'); 81 82 $tokens['comment']['comment-author-mail'] = t('The email address left by the comment author.'); 83 $tokens['comment']['comment-author-mail-raw'] = t('The email address left by the comment author.'); 84 85 $tokens['comment'] += token_get_date_token_info(t('Comment creation'), 'comment-'); 86 87 $tokens['comment']['comment-node-title'] = t('The title of the node the comment was posted to.'); 88 $tokens['comment']['comment-node-title-raw'] = t('The title of the node the comment was posted to.'); 89 90 return $tokens; 91 } 92 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |