function notifications_feed_token_values in Notifications 5
Same name and namespace in other branches
- 6 notifications_feed/notifications_feed.module \notifications_feed_token_values()
Implementation of hook_token_values()
File
- notifications_feed/
notifications_feed.module, line 233 - Subscriptions to FeedAPI feeds
Code
function notifications_feed_token_values($type, $object = NULL, $options = array()) {
switch ($type) {
case 'feed':
if ($feed = $object) {
$values['feed-name'] = check_plain($feed->title);
$values['feed-teaser'] = $feed->teaser ? check_markup($feed->teaser, $feed->format, FALSE) : '';
// We may need to use a different link here
$values['feed-url'] = url('node/' . $feed->nid, NULL, NULL, TRUE);
// Item lists
$updated = array_map('check_plain', $feed->items_updated);
$new = array_map('check_plain', $feed->items_new);
$refreshed = array();
foreach ($new as $item) {
$refreshed[] = t('New: !title', array(
'!title' => $item,
));
}
foreach ($updated as $item) {
$refreshed[] = t('Updated: !title', array(
'!title' => $item,
));
}
$values['feed-items-updated'] = $updated ? implode("\n- ", $updated) : t('no updated items');
$values['feed-items-new'] = $new ? '- ' . implode("\n- ", $new) : t('no new items');
$values['feed-items-refresh'] = implode("\n", $refreshed);
return $values;
}
break;
}
}