function subscriptions_token_info in Subscriptions 2.0.x
Same name and namespace in other branches
- 7 subscriptions.tokens.inc \subscriptions_token_info()
Implements hook_token_info().
Return value
array
File
- ./
subscriptions.tokens.old.php, line 13 - Token callbacks for the subscriptions module.
Code
function subscriptions_token_info() {
$variables = array(
'%TYPE' => 'TYPE',
'!TYPE' => 'TYPE',
);
$info = array(
'types' => array(
'subs' => array(
'name' => t('Subscriptions information'),
'description' => t('Tokens related to the %Subscriptions module.', array(
'%Subscriptions' => 'Subscriptions',
)),
'needs-data' => 'subs',
),
'subs_item' => array(
'name' => t('Subscriptions item'),
'description' => t('Tokens related to the %Subscriptions module for building a digest.', array(
'%Subscriptions' => 'Subscriptions',
)),
'needs-data' => 'subs_item',
),
),
'tokens' => array(
'subs' => array(
'type' => array(
'name' => t('Type'),
'description' => t('The type of the subscription.'),
),
'manage-url' => array(
'name' => t('Manage URL'),
'description' => t("The URL of the user's @Subscriptions page (requires log-in).", array(
'@Subscriptions' => t('Subscriptions'),
)),
'type' => 'url',
),
'unsubscribe-url' => array(
'name' => t('Unsubscribe URL'),
'description' => t('The URL for immediate canceling of the subscription that caused this notification.'),
'type' => 'url',
),
'is-new' => array(
'name' => t('Is new'),
'description' => t('Whether the item is new.'),
),
'is-updated' => array(
'name' => t('Is updated'),
'description' => t('Whether the item is updated (or new and subsequently updated).'),
),
'is-old' => array(
'name' => t('Is old'),
'description' => t('Whether the item is not new nor updated.'),
),
'is-published' => array(
'name' => t('Is published'),
'description' => t('Whether the item is published.'),
),
'has-distinct-summary' => array(
'name' => t('Has distinct summary'),
'description' => t('Whether the item has a non-empty summary that is distinct from the body.'),
),
'forum' => array(
'name' => t('Forum'),
'description' => t('The forum (taxonomy term), if the item is in a forum.'),
'type' => 'term',
),
'comments' => array(
'name' => t('Comments'),
'description' => t('The array of formatted comments that have not been sent yet (for inclusion in a node).'),
'type' => 'array',
),
'items' => array(
'name' => t('Digest Items'),
'description' => t('The array of formatted items to send to one recipient (for building a digest).'),
'type' => 'subs_list<subs_item>',
),
'subs-module' => array(
'name' => t('Subscription module'),
'description' => t('The module of the item that triggered the notification.'),
),
'subs-field' => array(
'name' => t('Subscription field'),
'description' => t('The field (property) of the item that triggered the notification.'),
),
'subs-value' => array(
'name' => t('Subscription value'),
'description' => t('The value of the field of the item that triggered the notification.'),
),
// The following tokens need to be implemented for each entity type
// that can be subscribed to, if they are applicable.
'view' => array(
'name' => t('View'),
'description' => t('The item rendered using the %Subscriptions view mode.', array(
'%Subscriptions' => t('Subscriptions'),
)),
),
),
'subs_item' => array(
'as-TYPE' => array(
'name' => t('Cast to %TYPE', $variables),
'description' => t("Makes the !TYPE tokens available for use (e.g. '!example').", $variables + array(
'!example' => 'as-node:?',
)),
),
'is-TYPE' => array(
'name' => t('Is %TYPE', $variables),
'description' => t("Whether the item is of type !TYPE (e.g. '!example').", $variables + array(
'!example' => 'is-node',
)),
),
'formatted' => array(
'name' => t('Formatted'),
'description' => t("Formatted string representation of the item, processed by its own template in the !DIGEST context.", $variables + array(
'!DIGEST' => 'DIGEST',
)),
),
'subs' => array(
'name' => t('Item information'),
'description' => t('The Subscriptions information of the digest item.'),
'type' => 'subs',
),
),
),
);
if (module_exists('date')) {
$info['tokens']['subs']['dates'] = array(
'name' => t('Dates'),
'description' => t('The array of dates in the specified !Date field.', array(
'!Date' => t('Date'),
)),
'type' => 'subs_list<date>',
'dynamic' => TRUE,
);
}
if (module_exists('file')) {
$info['tokens']['subs']['files'] = array(
'name' => t('Files'),
'description' => t('The array of attached files in the specified !File field.', array(
'!File' => t('File'),
)),
'type' => 'subs_list<file>',
'dynamic' => TRUE,
);
}
if (module_exists('taxonomy')) {
$info['tokens']['subs']['terms'] = array(
'name' => t('Terms'),
'description' => t('The array of taxonomy terms in the specified !Term_reference field.', array(
'!Term_reference' => t('Term reference'),
)),
'type' => 'subs_list<term>',
'dynamic' => TRUE,
);
}
$info['tokens']['subs']['texts'] = array(
'name' => t('Texts'),
'description' => t('The single value or array of values in the specified field, represented as text.'),
'type' => 'array',
'dynamic' => TRUE,
);
$info['tokens']['subs']['users'] = array(
'name' => t('Users'),
'description' => t('The array of users in the specified !User_reference field.', array(
'!User_reference' => t('User reference'),
)),
'type' => 'subs_list<user>',
'dynamic' => TRUE,
);
return $info;
}