function timeago_tokens in Timeago 7.2
Implements hook_tokens().
File
- ./
timeago.module, line 375 - Adds support for the Timeago jQuery library.
Code
function timeago_tokens($type, $tokens, array $data = array(), array $options = array()) {
$replacements = array();
if ($type == 'node' && !empty($data['node']) && isset($tokens['timeago'])) {
$node = (object) $data['node'];
$replacements[$tokens['timeago']] = timeago_format_date($node->created);
}
if ($type == 'comment' && !empty($data['comment'])) {
$comment = (object) $data['comment'];
if (isset($tokens['created-timeago'])) {
$replacements[$tokens['created-timeago']] = timeago_format_date($comment->created);
}
if (isset($tokens['changed-timeago'])) {
$replacements[$tokens['changed-timeago']] = timeago_format_date($comment->changed);
}
}
return $replacements;
}